diff --git a/tool/src/org/antlr/v4/Tool.java b/tool/src/org/antlr/v4/Tool.java index bdd892ded..700ffd28c 100644 --- a/tool/src/org/antlr/v4/Tool.java +++ b/tool/src/org/antlr/v4/Tool.java @@ -42,6 +42,9 @@ import org.antlr.v4.parse.GrammarASTAdaptor; import org.antlr.v4.parse.ToolANTLRParser; import org.antlr.v4.semantics.SemanticPipeline; import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.GrammarASTErrorNode; +import org.antlr.v4.tool.ast.GrammarRootAST; import org.stringtemplate.v4.STGroup; import java.io.*; @@ -215,7 +218,7 @@ public class Tool { public void processGrammarsOnCommandLine() { for (String fileName : grammarFiles) { GrammarAST t = loadGrammar(fileName); - if ( t==null || t instanceof GrammarASTErrorNode ) return; // came back as error node + if ( t==null || t instanceof GrammarASTErrorNode) return; // came back as error node if ( ((GrammarRootAST)t).hasErrors ) return; GrammarRootAST ast = (GrammarRootAST)t; @@ -348,7 +351,7 @@ public class Tool { p.setTreeAdaptor(adaptor); ParserRuleReturnScope r = p.grammarSpec(); GrammarRootAST root = (GrammarRootAST)r.getTree(); - if ( root instanceof GrammarRootAST ) { + if ( root instanceof GrammarRootAST) { root.hasErrors = p.getNumberOfSyntaxErrors()>0; root.tokens = tokens; } diff --git a/tool/src/org/antlr/v4/automata/ATNFactory.java b/tool/src/org/antlr/v4/automata/ATNFactory.java index 96921db39..0c6e5d460 100644 --- a/tool/src/org/antlr/v4/automata/ATNFactory.java +++ b/tool/src/org/antlr/v4/automata/ATNFactory.java @@ -29,8 +29,9 @@ package org.antlr.v4.automata; -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.tool.*; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNState; +import org.antlr.v4.tool.ast.*; import java.util.List; diff --git a/tool/src/org/antlr/v4/automata/LexerATNFactory.java b/tool/src/org/antlr/v4/automata/LexerATNFactory.java index 8908f05ad..b7abf837a 100644 --- a/tool/src/org/antlr/v4/automata/LexerATNFactory.java +++ b/tool/src/org/antlr/v4/automata/LexerATNFactory.java @@ -34,7 +34,11 @@ import org.antlr.v4.misc.CharSupport; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.LexerGrammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TerminalAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/automata/ParserATNFactory.java b/tool/src/org/antlr/v4/automata/ParserATNFactory.java index c8a965006..31e20c579 100644 --- a/tool/src/org/antlr/v4/automata/ParserATNFactory.java +++ b/tool/src/org/antlr/v4/automata/ParserATNFactory.java @@ -41,7 +41,11 @@ import org.antlr.v4.parse.GrammarASTAdaptor; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.semantics.UseDefAnalyzer; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ErrorManager; +import org.antlr.v4.tool.ErrorType; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.*; import java.lang.reflect.Constructor; import java.util.Collection; diff --git a/tool/src/org/antlr/v4/automata/TreeParserATNFactory.java b/tool/src/org/antlr/v4/automata/TreeParserATNFactory.java index 3a3637ad2..86835b5ca 100644 --- a/tool/src/org/antlr/v4/automata/TreeParserATNFactory.java +++ b/tool/src/org/antlr/v4/automata/TreeParserATNFactory.java @@ -29,12 +29,16 @@ package org.antlr.v4.automata; -import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.RuleContext; +import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TreePatternAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** Build ATNs for tree grammars */ public class TreeParserATNFactory extends ParserATNFactory { diff --git a/tool/src/org/antlr/v4/codegen/ActionTranslator.java b/tool/src/org/antlr/v4/codegen/ActionTranslator.java index c9769cea7..a909565cb 100644 --- a/tool/src/org/antlr/v4/codegen/ActionTranslator.java +++ b/tool/src/org/antlr/v4/codegen/ActionTranslator.java @@ -35,7 +35,11 @@ import org.antlr.v4.codegen.model.RuleFunction; import org.antlr.v4.codegen.model.actions.*; import org.antlr.v4.parse.ActionSplitter; import org.antlr.v4.parse.ActionSplitterListener; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Attribute; +import org.antlr.v4.tool.ErrorType; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; import java.lang.reflect.Constructor; import java.util.ArrayList; diff --git a/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java b/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java index 7c295c7bc..f8d4d9eb1 100644 --- a/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java +++ b/tool/src/org/antlr/v4/codegen/BlankOutputModelFactory.java @@ -32,7 +32,12 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.ast.*; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.BlockAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.PredAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java index b0abece61..45e007b99 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java +++ b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.ast.*; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java b/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java index 4a791b18f..032cf300d 100644 --- a/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java +++ b/tool/src/org/antlr/v4/codegen/DefaultOutputModelFactory.java @@ -30,10 +30,14 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.*; -import org.antlr.v4.codegen.model.decl.*; -import org.antlr.v4.tool.*; +import org.antlr.v4.codegen.model.decl.CodeBlock; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** Create output objects for elements *within* rule functions except * buildOutputModel() which builds outer/root model object and any diff --git a/tool/src/org/antlr/v4/codegen/OutputModelController.java b/tool/src/org/antlr/v4/codegen/OutputModelController.java index 0cc509ec7..fd26a008f 100644 --- a/tool/src/org/antlr/v4/codegen/OutputModelController.java +++ b/tool/src/org/antlr/v4/codegen/OutputModelController.java @@ -33,10 +33,19 @@ import org.antlr.runtime.tree.CommonTreeNodeStream; import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.ast.*; import org.antlr.v4.codegen.model.decl.CodeBlock; -import org.antlr.v4.parse.*; -import org.antlr.v4.tool.*; +import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.parse.GrammarASTAdaptor; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.BlockAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.PredAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; /** This receives events from SourceGenTriggers.g and asks factory to do work. * Then runs extensions in order on resulting SrcOps to get final list. diff --git a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java index 0ac120d2d..573565e4e 100644 --- a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java +++ b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java @@ -33,7 +33,13 @@ import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.ast.*; import org.antlr.v4.codegen.model.decl.CodeBlock; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.BlockAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.PredAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/ParserASTExtension.java b/tool/src/org/antlr/v4/codegen/ParserASTExtension.java index 8e5fc7976..e855e009e 100644 --- a/tool/src/org/antlr/v4/codegen/ParserASTExtension.java +++ b/tool/src/org/antlr/v4/codegen/ParserASTExtension.java @@ -31,11 +31,11 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.ast.*; -import org.antlr.v4.codegen.model.ast.RuleAST; import org.antlr.v4.codegen.model.decl.*; import org.antlr.v4.misc.Utils; import org.antlr.v4.parse.ANTLRParser; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/ParserFactory.java b/tool/src/org/antlr/v4/codegen/ParserFactory.java index 46ba61ecf..f2699ecd7 100644 --- a/tool/src/org/antlr/v4/codegen/ParserFactory.java +++ b/tool/src/org/antlr/v4/codegen/ParserFactory.java @@ -39,7 +39,9 @@ import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.runtime.atn.StarLoopEntryState; import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.semantics.UseDefAnalyzer; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.*; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java index 676d43f2e..374b6d5ed 100644 --- a/tool/src/org/antlr/v4/codegen/Target.java +++ b/tool/src/org/antlr/v4/codegen/Target.java @@ -34,8 +34,8 @@ import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.Token; import org.antlr.v4.tool.Grammar; -import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.GrammarAST; import org.stringtemplate.v4.ST; /** */ diff --git a/tool/src/org/antlr/v4/codegen/TreeParserFactory.java b/tool/src/org/antlr/v4/codegen/TreeParserFactory.java index 07841a773..8dea27379 100644 --- a/tool/src/org/antlr/v4/codegen/TreeParserFactory.java +++ b/tool/src/org/antlr/v4/codegen/TreeParserFactory.java @@ -36,7 +36,7 @@ import org.antlr.v4.codegen.model.decl.Decl; import org.antlr.v4.codegen.model.decl.NodeDecl; import org.antlr.v4.codegen.model.decl.NodeListDecl; import org.antlr.v4.codegen.model.decl.TokenListDecl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/Wildcard.java b/tool/src/org/antlr/v4/codegen/Wildcard.java index 0d489e540..a937794b5 100644 --- a/tool/src/org/antlr/v4/codegen/Wildcard.java +++ b/tool/src/org/antlr/v4/codegen/Wildcard.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.MatchToken; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class Wildcard extends MatchToken { public Wildcard(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/Action.java b/tool/src/org/antlr/v4/codegen/model/Action.java index 18f44aa1e..fe37ff7c4 100644 --- a/tool/src/org/antlr/v4/codegen/model/Action.java +++ b/tool/src/org/antlr/v4/codegen/model/Action.java @@ -29,9 +29,11 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.*; +import org.antlr.v4.codegen.ActionTranslator; +import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.actions.ActionChunk; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/AltBlock.java b/tool/src/org/antlr/v4/codegen/model/AltBlock.java index 6cfeadd64..94e93841d 100644 --- a/tool/src/org/antlr/v4/codegen/model/AltBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/AltBlock.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.BlockStartState; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/ArgAction.java b/tool/src/org/antlr/v4/codegen/model/ArgAction.java index 172867a0c..e8fffef61 100644 --- a/tool/src/org/antlr/v4/codegen/model/ArgAction.java +++ b/tool/src/org/antlr/v4/codegen/model/ArgAction.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class ArgAction extends Action { /** Context type of invoked rule */ diff --git a/tool/src/org/antlr/v4/codegen/model/Choice.java b/tool/src/org/antlr/v4/codegen/model/Choice.java index f30b3282a..39651d3be 100644 --- a/tool/src/org/antlr/v4/codegen/model/Choice.java +++ b/tool/src/org/antlr/v4/codegen/model/Choice.java @@ -30,12 +30,14 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.codegen.model.decl.*; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.codegen.model.decl.TokenTypeDecl; import org.antlr.v4.misc.Utils; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** The class hierarchy underneath SrcOp is pretty deep but makes sense that, * for example LL1StarBlock is a kind of LL1Loop which is a kind of Choice. diff --git a/tool/src/org/antlr/v4/codegen/model/ForcedAction.java b/tool/src/org/antlr/v4/codegen/model/ForcedAction.java index b21cc0bd7..1e60014dd 100644 --- a/tool/src/org/antlr/v4/codegen/model/ForcedAction.java +++ b/tool/src/org/antlr/v4/codegen/model/ForcedAction.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class ForcedAction extends Action { public ForcedAction(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java index ffc91430d..c4b622bdb 100644 --- a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java +++ b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java @@ -29,13 +29,19 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.*; +import org.antlr.v4.codegen.ActionTranslator; +import org.antlr.v4.codegen.CodeGenerator; +import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.actions.ActionChunk; -import org.antlr.v4.codegen.model.decl.*; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.codegen.model.decl.RuleContextDecl; +import org.antlr.v4.codegen.model.decl.RuleContextListDecl; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.runtime.atn.RuleTransition; import org.antlr.v4.runtime.misc.OrderedHashSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java index 26aa8fd26..4c12444c7 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.DecisionState; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java index 76be95ea2..a4cc8aa46 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java index e62c56ec3..581d291f1 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.ArrayList; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java index 71bc98493..ad28795cc 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java index 3d2705e2d..06703dcb0 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.DecisionState; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java index c746e9333..e837b60ac 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java @@ -34,7 +34,7 @@ import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.tool.Grammar; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java index 19ff25d0b..c50995601 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java index b7cb313ad..5fcd22612 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.StarLoopEntryState; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java index a1ad68743..861888763 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.StarLoopEntryState; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/LexerFile.java b/tool/src/org/antlr/v4/codegen/model/LexerFile.java index cdd8e6151..afa4fb43c 100644 --- a/tool/src/org/antlr/v4/codegen/model/LexerFile.java +++ b/tool/src/org/antlr/v4/codegen/model/LexerFile.java @@ -30,9 +30,11 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public class LexerFile extends OutputModelObject { public String fileName; @@ -50,4 +52,4 @@ public class LexerFile extends OutputModelObject { namedActions.put(name, new Action(factory, ast)); } } -} \ No newline at end of file +} diff --git a/tool/src/org/antlr/v4/codegen/model/ListenerFile.java b/tool/src/org/antlr/v4/codegen/model/ListenerFile.java index bcbe20bc7..88703135a 100644 --- a/tool/src/org/antlr/v4/codegen/model/ListenerFile.java +++ b/tool/src/org/antlr/v4/codegen/model/ListenerFile.java @@ -1,9 +1,12 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** A model object representing a parse tree listener file. * These are the rules specific events triggered by a parse tree visitor. diff --git a/tool/src/org/antlr/v4/codegen/model/Loop.java b/tool/src/org/antlr/v4/codegen/model/Loop.java index 9e3766643..a24138028 100644 --- a/tool/src/org/antlr/v4/codegen/model/Loop.java +++ b/tool/src/org/antlr/v4/codegen/model/Loop.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/MatchDOWN.java b/tool/src/org/antlr/v4/codegen/model/MatchDOWN.java index 58dda3ad4..defffb3e7 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchDOWN.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchDOWN.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class MatchDOWN extends RuleElement { public MatchDOWN(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java b/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java index a99677d29..9e8433b39 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchNotSet.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class MatchNotSet extends MatchSet { public MatchNotSet(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/MatchSet.java b/tool/src/org/antlr/v4/codegen/model/MatchSet.java index 79a571c70..e177a54fc 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchSet.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchSet.java @@ -30,9 +30,10 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.codegen.model.decl.*; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.codegen.model.decl.TokenTypeDecl; import org.antlr.v4.runtime.atn.SetTransition; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class MatchSet extends MatchToken { @ModelElement public TestSetInline expr; diff --git a/tool/src/org/antlr/v4/codegen/model/MatchToken.java b/tool/src/org/antlr/v4/codegen/model/MatchToken.java index 80ab012d3..76b51cfa7 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchToken.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchToken.java @@ -29,11 +29,15 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.*; +import org.antlr.v4.codegen.CodeGenerator; +import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TerminalAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** */ public class MatchToken extends RuleElement implements LabeledOp { diff --git a/tool/src/org/antlr/v4/codegen/model/MatchTree.java b/tool/src/org/antlr/v4/codegen/model/MatchTree.java index 8865b1006..8ae6e02c2 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchTree.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchTree.java @@ -31,10 +31,13 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.misc.Utils; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.RuleContext; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.atn.ATNState; +import org.antlr.v4.runtime.atn.LL1Analyzer; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TreePatternAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/MatchUP.java b/tool/src/org/antlr/v4/codegen/model/MatchUP.java index 316104506..cd3435103 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchUP.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchUP.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class MatchUP extends RuleElement { public MatchUP(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java index 8f6be301d..1cea7ba98 100644 --- a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java index bd492dfb4..370169a8b 100644 --- a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java +++ b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public abstract class OutputModelObject { diff --git a/tool/src/org/antlr/v4/codegen/model/ParserFile.java b/tool/src/org/antlr/v4/codegen/model/ParserFile.java index 23d9ad063..c787bbe63 100644 --- a/tool/src/org/antlr/v4/codegen/model/ParserFile.java +++ b/tool/src/org/antlr/v4/codegen/model/ParserFile.java @@ -30,9 +30,11 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.HashMap; +import java.util.Map; /** */ public class ParserFile extends OutputModelObject { diff --git a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java index 2e9bd4ef4..44e1bfba2 100644 --- a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.runtime.atn.PlusLoopbackState; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/RuleElement.java b/tool/src/org/antlr/v4/codegen/model/RuleElement.java index 5c4ceb404..303731374 100644 --- a/tool/src/org/antlr/v4/codegen/model/RuleElement.java +++ b/tool/src/org/antlr/v4/codegen/model/RuleElement.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RuleElement extends SrcOp { /** Associated ATN state for this rule elements (action, token, ruleref, ...) */ diff --git a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java index e495dfb0c..f2582922f 100644 --- a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java +++ b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java @@ -38,8 +38,8 @@ import org.antlr.v4.misc.Utils; import org.antlr.v4.runtime.atn.ATNState; import org.antlr.v4.runtime.misc.OrderedHashSet; import org.antlr.v4.tool.Attribute; -import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.*; diff --git a/tool/src/org/antlr/v4/codegen/model/SemPred.java b/tool/src/org/antlr/v4/codegen/model/SemPred.java index 5a1debc5c..a50e0bbb3 100644 --- a/tool/src/org/antlr/v4/codegen/model/SemPred.java +++ b/tool/src/org/antlr/v4/codegen/model/SemPred.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class SemPred extends Action { diff --git a/tool/src/org/antlr/v4/codegen/model/SrcOp.java b/tool/src/org/antlr/v4/codegen/model/SrcOp.java index 284d6fb3c..19c775590 100644 --- a/tool/src/org/antlr/v4/codegen/model/SrcOp.java +++ b/tool/src/org/antlr/v4/codegen/model/SrcOp.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public abstract class SrcOp extends OutputModelObject { diff --git a/tool/src/org/antlr/v4/codegen/model/StarBlock.java b/tool/src/org/antlr/v4/codegen/model/StarBlock.java index efaf077d9..c6cadb9bb 100644 --- a/tool/src/org/antlr/v4/codegen/model/StarBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/StarBlock.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.atn.StarLoopEntryState; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/Sync.java b/tool/src/org/antlr/v4/codegen/model/Sync.java index dd15e480e..8cf5732fe 100644 --- a/tool/src/org/antlr/v4/codegen/model/Sync.java +++ b/tool/src/org/antlr/v4/codegen/model/Sync.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class Sync extends SrcOp { diff --git a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java index 6b7c23ed2..5785c5f36 100644 --- a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java +++ b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class TestSetInline extends SrcOp { diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java index 289b5e3de..f85fd7958 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class ThrowEarlyExitException extends ThrowRecognitionException { diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java index 5b957cd23..0a17d21aa 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class ThrowNoViableAlt extends ThrowRecognitionException { diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java index fa78609dd..d16ca7fcf 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.runtime.misc.IntervalSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class ThrowRecognitionException extends SrcOp { diff --git a/tool/src/org/antlr/v4/codegen/model/ast/ClearElementList.java b/tool/src/org/antlr/v4/codegen/model/ast/ClearElementList.java index d3bed9005..5318d4352 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/ClearElementList.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/ClearElementList.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class ClearElementList extends SrcOp { public String name; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/ElementASTOp.java b/tool/src/org/antlr/v4/codegen/model/ast/ElementASTOp.java index 9c2da7c52..8f736dcb7 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/ElementASTOp.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/ElementASTOp.java @@ -32,7 +32,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class ElementASTOp extends SrcOp { public Decl label; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteAction.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteAction.java index 85986edf6..9d3fb5787 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteAction.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteAction.java @@ -29,10 +29,12 @@ package org.antlr.v4.codegen.model.ast; -import org.antlr.v4.codegen.*; -import org.antlr.v4.codegen.model.*; +import org.antlr.v4.codegen.ActionTranslator; +import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.model.ModelElement; +import org.antlr.v4.codegen.model.SrcOp; import org.antlr.v4.codegen.model.actions.ActionChunk; -import org.antlr.v4.tool.ActionAST; +import org.antlr.v4.tool.ast.ActionAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteImagTokenRef.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteImagTokenRef.java index dff9386af..5bae6da72 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteImagTokenRef.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteImagTokenRef.java @@ -29,10 +29,13 @@ package org.antlr.v4.codegen.model.ast; -import org.antlr.v4.codegen.*; -import org.antlr.v4.codegen.model.*; +import org.antlr.v4.codegen.ActionTranslator; +import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.model.ModelElement; +import org.antlr.v4.codegen.model.SrcOp; import org.antlr.v4.codegen.model.actions.ActionChunk; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteLabelRef.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteLabelRef.java index 024c11036..744f344b6 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteLabelRef.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteLabelRef.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RewriteLabelRef extends SrcOp { public String iterName; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteRuleRef.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteRuleRef.java index 6a4503620..ba6cb8239 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteRuleRef.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteRuleRef.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RewriteRuleRef extends SrcOp { public String iterName; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteSelfRuleLabelRef.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteSelfRuleLabelRef.java index 4f68d537e..042391eba 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteSelfRuleLabelRef.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteSelfRuleLabelRef.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RewriteSelfRuleLabelRef extends SrcOp { public RewriteSelfRuleLabelRef(OutputModelFactory factory, GrammarAST ast) { diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTokenRef.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTokenRef.java index b7c54a072..8ba987f88 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTokenRef.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTokenRef.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RewriteTokenRef extends SrcOp { public String iterName; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeClosure.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeClosure.java index bc8252186..e250d692a 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeClosure.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeClosure.java @@ -30,10 +30,12 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.codegen.model.decl.*; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.codegen.model.decl.CodeBlock; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class RewriteTreeClosure extends CodeBlock { public List iteratorDecls = new ArrayList(); diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeOptional.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeOptional.java index 466784e96..78cad7e29 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeOptional.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeOptional.java @@ -30,10 +30,12 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.codegen.model.decl.*; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.codegen.model.decl.CodeBlock; +import org.antlr.v4.codegen.model.decl.Decl; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class RewriteTreeOptional extends CodeBlock { public List conditionalDecls = new ArrayList(); diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeStructure.java b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeStructure.java index 4b9337b32..0d67dbacf 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeStructure.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RewriteTreeStructure.java @@ -30,10 +30,11 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.codegen.model.*; +import org.antlr.v4.codegen.model.ModelElement; +import org.antlr.v4.codegen.model.SrcOp; import org.antlr.v4.codegen.model.decl.Decl; import org.antlr.v4.runtime.misc.OrderedHashSet; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/RuleAST.java b/tool/src/org/antlr/v4/codegen/model/ast/RuleAST.java index 259f772ab..247762c9b 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/RuleAST.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/RuleAST.java @@ -31,10 +31,10 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RuleAST extends ElementASTOp { public RuleAST(OutputModelFactory factory, GrammarAST ast, Decl label) { super(factory, ast, label); } -} \ No newline at end of file +} diff --git a/tool/src/org/antlr/v4/codegen/model/ast/TokenAST.java b/tool/src/org/antlr/v4/codegen/model/ast/TokenAST.java index 9a4161661..1053e3c7b 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/TokenAST.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/TokenAST.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; /** */ public class TokenAST extends ElementASTOp { diff --git a/tool/src/org/antlr/v4/codegen/model/ast/TrackRuleElement.java b/tool/src/org/antlr/v4/codegen/model/ast/TrackRuleElement.java index be6b4a355..f5ada7ba1 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/TrackRuleElement.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/TrackRuleElement.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class TrackRuleElement extends ElementASTOp { public String name; diff --git a/tool/src/org/antlr/v4/codegen/model/ast/TrackTokenElement.java b/tool/src/org/antlr/v4/codegen/model/ast/TrackTokenElement.java index 59bbe022c..b7a5dc0b6 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/TrackTokenElement.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/TrackTokenElement.java @@ -31,7 +31,7 @@ package org.antlr.v4.codegen.model.ast; import org.antlr.v4.codegen.OutputModelFactory; import org.antlr.v4.codegen.model.decl.Decl; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class TrackTokenElement extends ElementASTOp { public String name; diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RewriteIteratorDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RewriteIteratorDecl.java index 1a831536a..42096c8e8 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/RewriteIteratorDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/RewriteIteratorDecl.java @@ -30,7 +30,7 @@ package org.antlr.v4.codegen.model.decl; import org.antlr.v4.codegen.OutputModelFactory; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; public class RewriteIteratorDecl extends Decl { public String listName; diff --git a/tool/src/org/antlr/v4/misc/Utils.java b/tool/src/org/antlr/v4/misc/Utils.java index c99857a93..f714fc5e7 100644 --- a/tool/src/org/antlr/v4/misc/Utils.java +++ b/tool/src/org/antlr/v4/misc/Utils.java @@ -29,10 +29,13 @@ package org.antlr.v4.misc; -import org.antlr.v4.tool.GrammarAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; /** */ public class Utils { diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.g b/tool/src/org/antlr/v4/parse/ANTLRParser.g index 7fd01989b..a93291ca7 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.g +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.g @@ -131,6 +131,7 @@ tokens { package org.antlr.v4.parse; import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.*; } @members { diff --git a/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java b/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java index 957220adf..733063ca9 100644 --- a/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java +++ b/tool/src/org/antlr/v4/parse/GrammarASTAdaptor.java @@ -29,9 +29,13 @@ package org.antlr.v4.parse; -import org.antlr.runtime.*; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; import org.antlr.runtime.tree.CommonTreeAdaptor; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.GrammarASTErrorNode; +import org.antlr.v4.tool.ast.GrammarASTWithOptions; +import org.antlr.v4.tool.ast.TerminalAST; public class GrammarASTAdaptor extends CommonTreeAdaptor { org.antlr.runtime.CharStream input; // where we can find chars ref'd by tokens in tree diff --git a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleAnalyzer.java b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleAnalyzer.java index fd20ca279..ff53d8637 100644 --- a/tool/src/org/antlr/v4/parse/LeftRecursiveRuleAnalyzer.java +++ b/tool/src/org/antlr/v4/parse/LeftRecursiveRuleAnalyzer.java @@ -29,12 +29,18 @@ package org.antlr.v4.parse; -import org.antlr.runtime.*; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.TokenStream; import org.antlr.runtime.tree.CommonTreeNodeStream; import org.antlr.v4.Tool; import org.antlr.v4.codegen.CodeGenerator; -import org.antlr.v4.tool.*; -import org.stringtemplate.v4.*; +import org.antlr.v4.tool.AttributeDict; +import org.antlr.v4.tool.ErrorType; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.GrammarASTWithOptions; +import org.stringtemplate.v4.ST; +import org.stringtemplate.v4.STGroup; +import org.stringtemplate.v4.STGroupFile; import java.util.*; diff --git a/tool/src/org/antlr/v4/semantics/ActionSniffer.java b/tool/src/org/antlr/v4/semantics/ActionSniffer.java index 833be7fbf..fe2171993 100644 --- a/tool/src/org/antlr/v4/semantics/ActionSniffer.java +++ b/tool/src/org/antlr/v4/semantics/ActionSniffer.java @@ -29,9 +29,16 @@ package org.antlr.v4.semantics; -import org.antlr.runtime.*; +import org.antlr.runtime.ANTLRStringStream; +import org.antlr.runtime.Token; import org.antlr.v4.parse.ActionSplitter; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Alternative; +import org.antlr.v4.tool.ErrorManager; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TerminalAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/semantics/AttributeChecks.java b/tool/src/org/antlr/v4/semantics/AttributeChecks.java index 21fa567ca..d300a3ccf 100644 --- a/tool/src/org/antlr/v4/semantics/AttributeChecks.java +++ b/tool/src/org/antlr/v4/semantics/AttributeChecks.java @@ -34,6 +34,7 @@ import org.antlr.runtime.Token; import org.antlr.v4.parse.ActionSplitter; import org.antlr.v4.parse.ActionSplitterListener; import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.ActionAST; import java.util.List; diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java index a3080c4e6..d5a73b74c 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java @@ -31,8 +31,12 @@ package org.antlr.v4.semantics; import org.antlr.runtime.Token; import org.antlr.v4.misc.Utils; -import org.antlr.v4.parse.*; -import org.antlr.v4.tool.*; +import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.parse.GrammarTreeVisitor; +import org.antlr.v4.tool.ErrorManager; +import org.antlr.v4.tool.ErrorType; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.ast.*; import org.stringtemplate.v4.misc.MultiMap; import java.io.File; diff --git a/tool/src/org/antlr/v4/semantics/RewriteRefs.java b/tool/src/org/antlr/v4/semantics/RewriteRefs.java index 1279188ef..bd3e6a75f 100644 --- a/tool/src/org/antlr/v4/semantics/RewriteRefs.java +++ b/tool/src/org/antlr/v4/semantics/RewriteRefs.java @@ -30,9 +30,12 @@ package org.antlr.v4.semantics; import org.antlr.v4.parse.GrammarTreeVisitor; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TerminalAST; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class RewriteRefs extends GrammarTreeVisitor { List shallow = new ArrayList(); diff --git a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java index 1dd9c4d7a..6d48af078 100644 --- a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java +++ b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java @@ -30,9 +30,13 @@ package org.antlr.v4.semantics; import org.antlr.v4.parse.ANTLRParser; -import org.antlr.v4.tool.*; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.GrammarAST; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Set; /** Do as much semantic checking as we can and fill in grammar * with rules, actions, and token definitions. diff --git a/tool/src/org/antlr/v4/semantics/SymbolChecks.java b/tool/src/org/antlr/v4/semantics/SymbolChecks.java index 2950d7884..75591eb4f 100644 --- a/tool/src/org/antlr/v4/semantics/SymbolChecks.java +++ b/tool/src/org/antlr/v4/semantics/SymbolChecks.java @@ -32,6 +32,7 @@ package org.antlr.v4.semantics; import org.antlr.runtime.Token; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.*; diff --git a/tool/src/org/antlr/v4/semantics/SymbolCollector.java b/tool/src/org/antlr/v4/semantics/SymbolCollector.java index 8224807b8..d759508a2 100644 --- a/tool/src/org/antlr/v4/semantics/SymbolCollector.java +++ b/tool/src/org/antlr/v4/semantics/SymbolCollector.java @@ -29,10 +29,18 @@ package org.antlr.v4.semantics; -import org.antlr.v4.parse.*; -import org.antlr.v4.tool.*; +import org.antlr.v4.parse.GrammarTreeVisitor; +import org.antlr.v4.parse.ScopeParser; +import org.antlr.v4.tool.AttributeDict; +import org.antlr.v4.tool.Grammar; +import org.antlr.v4.tool.LabelElementPair; +import org.antlr.v4.tool.Rule; +import org.antlr.v4.tool.ast.*; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** Collects (create) rules, terminals, strings, actions, scopes etc... from AST * side-effects: sets resolver field of asts for actions and diff --git a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java index 20d07e7ba..ca70e8618 100644 --- a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java +++ b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java @@ -29,9 +29,14 @@ package org.antlr.v4.semantics; -import org.antlr.runtime.*; -import org.antlr.v4.parse.*; +import org.antlr.runtime.ANTLRStringStream; +import org.antlr.runtime.Token; +import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.parse.ActionSplitter; +import org.antlr.v4.parse.ActionSplitterListener; import org.antlr.v4.tool.*; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; import java.util.*; diff --git a/tool/src/org/antlr/v4/tool/Alternative.java b/tool/src/org/antlr/v4/tool/Alternative.java index a228b6d61..4db43a63b 100644 --- a/tool/src/org/antlr/v4/tool/Alternative.java +++ b/tool/src/org/antlr/v4/tool/Alternative.java @@ -31,6 +31,10 @@ package org.antlr.v4.tool; import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.AltAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.TerminalAST; import org.stringtemplate.v4.misc.MultiMap; import java.util.ArrayList; diff --git a/tool/src/org/antlr/v4/tool/AttributeDict.java b/tool/src/org/antlr/v4/tool/AttributeDict.java index 4621f6322..b2a1891ab 100644 --- a/tool/src/org/antlr/v4/tool/AttributeDict.java +++ b/tool/src/org/antlr/v4/tool/AttributeDict.java @@ -29,7 +29,12 @@ package org.antlr.v4.tool; -import java.util.*; +import org.antlr.v4.tool.ast.GrammarAST; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Set; /** Track the attributes within retval, arg lists etc... * diff --git a/tool/src/org/antlr/v4/tool/AttributeResolver.java b/tool/src/org/antlr/v4/tool/AttributeResolver.java index aae69500d..746a972d5 100644 --- a/tool/src/org/antlr/v4/tool/AttributeResolver.java +++ b/tool/src/org/antlr/v4/tool/AttributeResolver.java @@ -29,6 +29,8 @@ package org.antlr.v4.tool; +import org.antlr.v4.tool.ast.ActionAST; + /** Grammars, rules, and alternatives all have symbols visible to * actions. To evaluate attr exprs, ask action for its resolver * then ask resolver to look up various symbols. Depending on the context, diff --git a/tool/src/org/antlr/v4/tool/Grammar.java b/tool/src/org/antlr/v4/tool/Grammar.java index c7ac4411a..396eeee14 100644 --- a/tool/src/org/antlr/v4/tool/Grammar.java +++ b/tool/src/org/antlr/v4/tool/Grammar.java @@ -29,16 +29,26 @@ package org.antlr.v4.tool; -import org.antlr.runtime.tree.*; +import org.antlr.runtime.tree.TreeVisitor; +import org.antlr.runtime.tree.TreeVisitorAction; +import org.antlr.runtime.tree.TreeWizard; import org.antlr.v4.Tool; -import org.antlr.v4.misc.*; -import org.antlr.v4.parse.*; -import org.antlr.v4.runtime.*; +import org.antlr.v4.misc.CharSupport; +import org.antlr.v4.misc.OrderedHashMap; +import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.parse.GrammarASTAdaptor; +import org.antlr.v4.parse.GrammarTreeVisitor; +import org.antlr.v4.parse.TokenVocabParser; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.atn.ATN; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.misc.IntSet; +import org.antlr.v4.runtime.misc.IntervalSet; +import org.antlr.v4.tool.ast.*; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.util.*; public class Grammar implements AttributeResolver { @@ -233,7 +243,7 @@ public class Grammar implements AttributeResolver { continue; } // did it come back as error node or missing? - if ( grammarAST==null || grammarAST instanceof GrammarASTErrorNode ) return; + if ( grammarAST==null || grammarAST instanceof GrammarASTErrorNode) return; GrammarRootAST ast = (GrammarRootAST)grammarAST; Grammar g = tool.createGrammar(ast); File f = tool.getImportedGrammarFile(this, importedGrammarName+".g"); @@ -665,14 +675,10 @@ public class Grammar implements AttributeResolver { } } - public String getOption(String key) { - if ( ast.options==null ) return null; - return ast.options.get(key); - } + public String getOption(String key) { return ast.getOption(key); } public String getOption(String key, String defaultValue) { - if ( ast.options==null ) return defaultValue; - String v = ast.options.get(key); + String v = ast.getOption(key); if ( v!=null ) return v; return defaultValue; } diff --git a/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java b/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java index 1669773cd..83d567cfa 100644 --- a/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java +++ b/tool/src/org/antlr/v4/tool/GrammarTransformPipeline.java @@ -31,9 +31,12 @@ package org.antlr.v4.tool; import org.antlr.runtime.*; import org.antlr.runtime.misc.DoubleKeyMap; -import org.antlr.runtime.tree.*; +import org.antlr.runtime.tree.Tree; +import org.antlr.runtime.tree.TreeVisitor; +import org.antlr.runtime.tree.TreeVisitorAction; import org.antlr.v4.Tool; import org.antlr.v4.parse.*; +import org.antlr.v4.tool.ast.*; import java.util.*; diff --git a/tool/src/org/antlr/v4/tool/LabelElementPair.java b/tool/src/org/antlr/v4/tool/LabelElementPair.java index d20f42f27..0260faa17 100644 --- a/tool/src/org/antlr/v4/tool/LabelElementPair.java +++ b/tool/src/org/antlr/v4/tool/LabelElementPair.java @@ -31,6 +31,7 @@ package org.antlr.v4.tool; import org.antlr.runtime.BitSet; import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.tool.ast.GrammarAST; public class LabelElementPair { public static final BitSet tokenTypeForTokens = new BitSet(); diff --git a/tool/src/org/antlr/v4/tool/LexerGrammar.java b/tool/src/org/antlr/v4/tool/LexerGrammar.java index cbcef8b1c..45cfcd0d0 100644 --- a/tool/src/org/antlr/v4/tool/LexerGrammar.java +++ b/tool/src/org/antlr/v4/tool/LexerGrammar.java @@ -31,6 +31,7 @@ package org.antlr.v4.tool; import org.antlr.runtime.RecognitionException; import org.antlr.v4.Tool; +import org.antlr.v4.tool.ast.GrammarRootAST; import org.stringtemplate.v4.misc.MultiMap; /** */ diff --git a/tool/src/org/antlr/v4/tool/Rule.java b/tool/src/org/antlr/v4/tool/Rule.java index 7437ab6c2..984edc378 100644 --- a/tool/src/org/antlr/v4/tool/Rule.java +++ b/tool/src/org/antlr/v4/tool/Rule.java @@ -29,6 +29,10 @@ package org.antlr.v4.tool; +import org.antlr.v4.tool.ast.ActionAST; +import org.antlr.v4.tool.ast.GrammarAST; +import org.antlr.v4.tool.ast.PredAST; +import org.antlr.v4.tool.ast.RuleAST; import org.stringtemplate.v4.misc.MultiMap; import java.util.*; diff --git a/tool/src/org/antlr/v4/tool/ActionAST.java b/tool/src/org/antlr/v4/tool/ast/ActionAST.java similarity index 96% rename from tool/src/org/antlr/v4/tool/ActionAST.java rename to tool/src/org/antlr/v4/tool/ast/ActionAST.java index 98fd55b91..58c322e6d 100644 --- a/tool/src/org/antlr/v4/tool/ActionAST.java +++ b/tool/src/org/antlr/v4/tool/ast/ActionAST.java @@ -27,10 +27,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.runtime.tree.Tree; +import org.antlr.v4.tool.AttributeResolver; import java.util.List; diff --git a/tool/src/org/antlr/v4/tool/AltAST.java b/tool/src/org/antlr/v4/tool/ast/AltAST.java similarity index 97% rename from tool/src/org/antlr/v4/tool/AltAST.java rename to tool/src/org/antlr/v4/tool/ast/AltAST.java index 6940c4a9f..f3a6ddbad 100644 --- a/tool/src/org/antlr/v4/tool/AltAST.java +++ b/tool/src/org/antlr/v4/tool/ast/AltAST.java @@ -27,11 +27,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.runtime.tree.Tree; import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.tool.Alternative; /** Any ALT (which can be child of ALT_REWRITE node) */ public class AltAST extends GrammarAST { diff --git a/tool/src/org/antlr/v4/tool/BlockAST.java b/tool/src/org/antlr/v4/tool/ast/BlockAST.java similarity index 96% rename from tool/src/org/antlr/v4/tool/BlockAST.java rename to tool/src/org/antlr/v4/tool/ast/BlockAST.java index 46e78249e..d3020a439 100644 --- a/tool/src/org/antlr/v4/tool/BlockAST.java +++ b/tool/src/org/antlr/v4/tool/ast/BlockAST.java @@ -27,12 +27,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.runtime.tree.Tree; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public class BlockAST extends GrammarASTWithOptions { // TODO: maybe I need a Subrule object like Rule so these options mov to that? diff --git a/tool/src/org/antlr/v4/tool/DownAST.java b/tool/src/org/antlr/v4/tool/ast/DownAST.java similarity index 98% rename from tool/src/org/antlr/v4/tool/DownAST.java rename to tool/src/org/antlr/v4/tool/ast/DownAST.java index 926edf652..c1c228134 100644 --- a/tool/src/org/antlr/v4/tool/DownAST.java +++ b/tool/src/org/antlr/v4/tool/ast/DownAST.java @@ -27,7 +27,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; diff --git a/tool/src/org/antlr/v4/tool/GrammarAST.java b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java similarity index 93% rename from tool/src/org/antlr/v4/tool/GrammarAST.java rename to tool/src/org/antlr/v4/tool/ast/GrammarAST.java index 872453326..5d36afcf9 100644 --- a/tool/src/org/antlr/v4/tool/GrammarAST.java +++ b/tool/src/org/antlr/v4/tool/ast/GrammarAST.java @@ -27,15 +27,23 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; -import org.antlr.runtime.*; -import org.antlr.runtime.tree.*; -import org.antlr.v4.parse.*; +import org.antlr.runtime.CharStream; +import org.antlr.runtime.CommonToken; +import org.antlr.runtime.Token; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeNodeStream; +import org.antlr.runtime.tree.Tree; +import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.parse.GrammarASTAdaptor; import org.antlr.v4.runtime.atn.ATNState; import org.antlr.v4.runtime.misc.IntervalSet; +import org.antlr.v4.tool.Grammar; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; public class GrammarAST extends CommonTree { /** For error msgs, nice to know which grammar this AST lives in */ diff --git a/tool/src/org/antlr/v4/tool/GrammarASTErrorNode.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java similarity index 95% rename from tool/src/org/antlr/v4/tool/GrammarASTErrorNode.java rename to tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java index 3e0b95984..434d3a2fb 100644 --- a/tool/src/org/antlr/v4/tool/GrammarASTErrorNode.java +++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTErrorNode.java @@ -27,9 +27,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; -import org.antlr.runtime.*; +import org.antlr.runtime.Token; +import org.antlr.runtime.TokenStream; import org.antlr.runtime.tree.CommonErrorNode; /** A node representing erroneous token range in token stream */ diff --git a/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java new file mode 100644 index 000000000..a363c61f6 --- /dev/null +++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTVisitor.java @@ -0,0 +1,11 @@ +package org.antlr.v4.tool.ast; + +/* +GrammarAST t = ...; +SynDiagVisitor v = new ...; +t.visit(v); +*/ +public interface GrammarASTVisitor { + Object visit(RuleAST node); + Object visit(AltAST node); +} diff --git a/tool/src/org/antlr/v4/tool/GrammarASTWithOptions.java b/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java similarity index 93% rename from tool/src/org/antlr/v4/tool/GrammarASTWithOptions.java rename to tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java index 5627883fc..623146416 100644 --- a/tool/src/org/antlr/v4/tool/GrammarASTWithOptions.java +++ b/tool/src/org/antlr/v4/tool/ast/GrammarASTWithOptions.java @@ -27,11 +27,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public class GrammarASTWithOptions extends GrammarAST { protected Map options; @@ -56,5 +57,9 @@ public class GrammarASTWithOptions extends GrammarAST { return options.get(key); } + public int getNumberOfOptions() { + return options==null ? 0 : options.size(); + } + public Map getOptions() { return options; } } diff --git a/tool/src/org/antlr/v4/tool/GrammarRootAST.java b/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java similarity index 94% rename from tool/src/org/antlr/v4/tool/GrammarRootAST.java rename to tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java index c36367823..94a1799fb 100644 --- a/tool/src/org/antlr/v4/tool/GrammarRootAST.java +++ b/tool/src/org/antlr/v4/tool/ast/GrammarRootAST.java @@ -27,12 +27,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; -import org.antlr.runtime.*; +import org.antlr.runtime.Token; +import org.antlr.runtime.TokenStream; import org.antlr.runtime.tree.Tree; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public class GrammarRootAST extends GrammarASTWithOptions { public static final Map defaultOptions = diff --git a/tool/src/org/antlr/v4/tool/PredAST.java b/tool/src/org/antlr/v4/tool/ast/PredAST.java similarity index 98% rename from tool/src/org/antlr/v4/tool/PredAST.java rename to tool/src/org/antlr/v4/tool/ast/PredAST.java index 80761b669..672e7e3be 100644 --- a/tool/src/org/antlr/v4/tool/PredAST.java +++ b/tool/src/org/antlr/v4/tool/ast/PredAST.java @@ -27,7 +27,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; diff --git a/tool/src/org/antlr/v4/tool/RuleAST.java b/tool/src/org/antlr/v4/tool/ast/RuleAST.java similarity index 95% rename from tool/src/org/antlr/v4/tool/RuleAST.java rename to tool/src/org/antlr/v4/tool/ast/RuleAST.java index fc18c9448..86e9607c6 100644 --- a/tool/src/org/antlr/v4/tool/RuleAST.java +++ b/tool/src/org/antlr/v4/tool/ast/RuleAST.java @@ -27,13 +27,15 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.runtime.tree.Tree; import org.antlr.v4.parse.ANTLRParser; public class RuleAST extends GrammarASTWithOptions { + + public RuleAST(GrammarAST node) { super(node); } @@ -55,4 +57,6 @@ public class RuleAST extends GrammarASTWithOptions { } return null; } + + public Object visit(GrammarASTVisitor v) { return v.visit(this); } } diff --git a/tool/src/org/antlr/v4/tool/TerminalAST.java b/tool/src/org/antlr/v4/tool/ast/TerminalAST.java similarity index 98% rename from tool/src/org/antlr/v4/tool/TerminalAST.java rename to tool/src/org/antlr/v4/tool/ast/TerminalAST.java index dbe0879c2..0c382ed86 100644 --- a/tool/src/org/antlr/v4/tool/TerminalAST.java +++ b/tool/src/org/antlr/v4/tool/ast/TerminalAST.java @@ -27,7 +27,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.runtime.tree.Tree; diff --git a/tool/src/org/antlr/v4/tool/TreePatternAST.java b/tool/src/org/antlr/v4/tool/ast/TreePatternAST.java similarity index 98% rename from tool/src/org/antlr/v4/tool/TreePatternAST.java rename to tool/src/org/antlr/v4/tool/ast/TreePatternAST.java index 9a7e3fd28..e256cab31 100644 --- a/tool/src/org/antlr/v4/tool/TreePatternAST.java +++ b/tool/src/org/antlr/v4/tool/ast/TreePatternAST.java @@ -27,7 +27,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token; import org.antlr.v4.runtime.atn.ATNState; diff --git a/tool/src/org/antlr/v4/tool/UpAST.java b/tool/src/org/antlr/v4/tool/ast/UpAST.java similarity index 98% rename from tool/src/org/antlr/v4/tool/UpAST.java rename to tool/src/org/antlr/v4/tool/ast/UpAST.java index 9d1be30e1..286f90024 100644 --- a/tool/src/org/antlr/v4/tool/UpAST.java +++ b/tool/src/org/antlr/v4/tool/ast/UpAST.java @@ -27,7 +27,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.antlr.v4.tool; +package org.antlr.v4.tool.ast; import org.antlr.runtime.Token;