diff --git a/tool/playground/T.g b/tool/playground/T.g index 1c1f3dd8d..6e44e2b8a 100644 --- a/tool/playground/T.g +++ b/tool/playground/T.g @@ -1,6 +1,6 @@ parser grammar T; options {output=AST;} -a : A ; +a : A^ ; /* r[int a] returns [int b] scope {int qq;} diff --git a/tool/src/org/antlr/v4/codegen/ActionTranslator.java b/tool/src/org/antlr/v4/codegen/ActionTranslator.java index 216005889..1e9fa564c 100644 --- a/tool/src/org/antlr/v4/codegen/ActionTranslator.java +++ b/tool/src/org/antlr/v4/codegen/ActionTranslator.java @@ -33,14 +33,14 @@ public class ActionTranslator implements ActionSplitterListener { ActionAST node; RuleFunction rf; List chunks = new ArrayList(); - OutputModelFactory factory; + CoreOutputModelFactory factory; - public ActionTranslator(OutputModelFactory factory, ActionAST node) { + public ActionTranslator(CoreOutputModelFactory factory, ActionAST node) { this.factory = factory; this.node = node; } - public static List translateAction(OutputModelFactory factory, + public static List translateAction(CoreOutputModelFactory factory, RuleFunction rf, Token tokenWithinAction, ActionAST node) @@ -54,7 +54,7 @@ public class ActionTranslator implements ActionSplitterListener { return translateActionChunk(factory, rf, action, node); } - public static List translateActionChunk(OutputModelFactory factory, + public static List translateActionChunk(CoreOutputModelFactory factory, RuleFunction rf, String action, ActionAST node) diff --git a/tool/src/org/antlr/v4/codegen/CodeGenerator.java b/tool/src/org/antlr/v4/codegen/CodeGenerator.java index 887bd0d19..ac72070fb 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGenerator.java +++ b/tool/src/org/antlr/v4/codegen/CodeGenerator.java @@ -76,7 +76,7 @@ public class CodeGenerator { } public ST generate() { - OutputModelFactory factory; + CoreOutputModelFactory factory; if ( g.isParser() || g.isCombined() || g.isTreeGrammar() ) { factory = new ParserFactory(this); } diff --git a/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java new file mode 100644 index 000000000..a0ae24737 --- /dev/null +++ b/tool/src/org/antlr/v4/codegen/CodeGeneratorExtension.java @@ -0,0 +1,67 @@ +package org.antlr.v4.codegen; + + +import org.antlr.v4.codegen.model.*; + +import java.util.List; + +/** Filter list of SrcOps and return; default is pass-through filter */ +public class CodeGeneratorExtension { + public CoreOutputModelFactory factory; + + public CodeGeneratorExtension(CoreOutputModelFactory factory) { + this.factory = factory; + } + + public OutputModelObject buildOutputModel(OutputModelObject root) { + return null; + } + + public List alternative(List ops) { return ops; } + + public List ruleRef(List ops) { return ops; } + + public List tokenRef(List ops) { return ops; } + + public List stringRef(List ops) { return ops; } + + public List epsilon(List ops) { return ops; } + + // ACTIONS + + public List action(List ops) { return ops; } + + public List forcedAction(List ops) { return ops; } + + public List sempred(List ops) { return ops; } + + // AST OPS + + public List rootToken(List ops) { return ops; } + + public List rootRule(List ops) { return ops; } + + // BLOCKS + + public List getChoiceBlock(List ops) { return ops; } + + public List getEBNFBlock(List ops) { return ops; } + + public List getLL1ChoiceBlock(List ops) { return ops; } + + public List getLLStarChoiceBlock(List ops) { return ops; } + + public List getLL1EBNFBlock(List ops) { return ops; } + + public List getLLStarEBNFBlock(List ops) { return ops; } + + public List getLL1Test(List ops) { return ops; } + + /** Find exact object type in list */ + public static SrcOp find(List ops, Class cl) { + for (SrcOp op : ops) { + if ( op.getClass() == cl ) return op; + } + return null; + } +} diff --git a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java b/tool/src/org/antlr/v4/codegen/CoreOutputModelFactory.java similarity index 51% rename from tool/src/org/antlr/v4/codegen/OutputModelFactory.java rename to tool/src/org/antlr/v4/codegen/CoreOutputModelFactory.java index 369a3ea9e..ae7d24af2 100644 --- a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java +++ b/tool/src/org/antlr/v4/codegen/CoreOutputModelFactory.java @@ -11,16 +11,20 @@ import java.util.*; * objects such as RuleFunction that surround elements in rule * functions. */ -public abstract class OutputModelFactory { +public abstract class CoreOutputModelFactory implements OutputModelFactory { + // Interface to outside world public Grammar g; public CodeGenerator gen; + // Post-processing + List extensions = new ArrayList(); + // Context ptrs - public OutputModelObject file; // root + public OutputModelObject root; // normally ParserFile, LexerFile, ... public Stack currentRule = new Stack(); public Alternative currentAlt; - protected OutputModelFactory(CodeGenerator gen) { + protected CoreOutputModelFactory(CodeGenerator gen) { this.gen = gen; this.g = gen.g; } @@ -31,39 +35,23 @@ public abstract class OutputModelFactory { // ALTERNATIVES / ELEMENTS - public CodeBlock alternative(List elems) { - return null; - } + public CodeBlock alternative(List elems) { return null; } - public List ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { - return null; - } + public List ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; } - public List tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { - return null; - } + public List tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { return null; } - public List stringRef(GrammarAST ID, GrammarAST label) { - return null; - } + public List stringRef(GrammarAST ID, GrammarAST label) { return null; } - public CodeBlock epsilon() { - return null; - } + public CodeBlock epsilon() { return null; } // ACTIONS - public SrcOp action(GrammarAST ast) { - return null; - } + public List action(GrammarAST ast) { return null; } - public SrcOp forcedAction(GrammarAST ast) { - return null; - } + public List forcedAction(GrammarAST ast) { return null; } - public SrcOp sempred(GrammarAST ast) { - return null; - } + public List sempred(GrammarAST ast) { return null; } // AST OPS @@ -73,32 +61,31 @@ public abstract class OutputModelFactory { // BLOCKS - public Choice getChoiceBlock(BlockAST blkAST, List alts) { - return null; - } + public Choice getChoiceBlock(BlockAST blkAST, List alts) { return null; } - public Choice getEBNFBlock(GrammarAST ebnfRoot, List alts) { - return null; - } + public Choice getEBNFBlock(GrammarAST ebnfRoot, List alts) { return null; } - public Choice getLL1ChoiceBlock(BlockAST blkAST, List alts) { - return null; - } + public Choice getLL1ChoiceBlock(BlockAST blkAST, List alts) { return null; } - public Choice getLLStarChoiceBlock(BlockAST blkAST, List alts) { - return null; - } + public Choice getLLStarChoiceBlock(BlockAST blkAST, List alts) { return null; } - public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List alts) { - return null; - } + public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List alts) { return null; } - public Choice getLLStarEBNFBlock(GrammarAST ebnfRoot, List alts) { - return null; - } + public Choice getLLStarEBNFBlock(GrammarAST ebnfRoot, List alts) { return null; } - public SrcOp getLL1Test(IntervalSet look, GrammarAST blkAST) { - return null; + public SrcOp getLL1Test(IntervalSet look, GrammarAST blkAST) { return null; } + + public List list(Object... values) { + List x = new ArrayList(values.length); + for (Object v : values) { + if ( v!=null ) { + if ( v instanceof SrcOp ) x.add((SrcOp)v); + else if ( v instanceof List ) x.addAll((List)v); + else g.tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, + "add type " + v.getClass() + " to list"); + } + } + return x; } } diff --git a/tool/src/org/antlr/v4/codegen/LexerFactory.java b/tool/src/org/antlr/v4/codegen/LexerFactory.java index 60d46deb4..236de9550 100644 --- a/tool/src/org/antlr/v4/codegen/LexerFactory.java +++ b/tool/src/org/antlr/v4/codegen/LexerFactory.java @@ -3,7 +3,7 @@ package org.antlr.v4.codegen; import org.antlr.v4.codegen.model.*; /** */ -public class LexerFactory extends OutputModelFactory { +public class LexerFactory extends CoreOutputModelFactory { public LexerFactory(CodeGenerator gen) { super(gen); } public OutputModelObject buildOutputModel() { diff --git a/tool/src/org/antlr/v4/codegen/ParserASTExtension.java b/tool/src/org/antlr/v4/codegen/ParserASTExtension.java new file mode 100644 index 000000000..b9754c665 --- /dev/null +++ b/tool/src/org/antlr/v4/codegen/ParserASTExtension.java @@ -0,0 +1,19 @@ +package org.antlr.v4.codegen; + +import org.antlr.v4.codegen.model.*; +import org.antlr.v4.codegen.model.ast.AddLeaf; + +import java.util.List; + +public class ParserASTExtension extends CodeGeneratorExtension { + public ParserASTExtension(CoreOutputModelFactory factory) { + super(factory); + } + + @Override + public List tokenRef(List ops) { + MatchToken matchOp = (MatchToken)find(ops, MatchToken.class); + SrcOp treeOp = new AddLeaf(factory, matchOp.ast, matchOp); + return factory.list(ops, treeOp); + } +} diff --git a/tool/src/org/antlr/v4/codegen/ParserFactory.java b/tool/src/org/antlr/v4/codegen/ParserFactory.java index 792bc6d19..eeffbe47d 100644 --- a/tool/src/org/antlr/v4/codegen/ParserFactory.java +++ b/tool/src/org/antlr/v4/codegen/ParserFactory.java @@ -2,8 +2,7 @@ package org.antlr.v4.codegen; import org.antlr.v4.analysis.AnalysisPipeline; import org.antlr.v4.codegen.model.*; -import org.antlr.v4.codegen.model.ast.AddLeaf; -import org.antlr.v4.misc.*; +import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.tool.*; @@ -11,7 +10,7 @@ import org.antlr.v4.tool.*; import java.util.List; /** */ -public class ParserFactory extends OutputModelFactory { +public class ParserFactory extends CoreOutputModelFactory { public ParserFactory(CodeGenerator gen) { super(gen); } public OutputModelObject buildOutputModel() { @@ -22,11 +21,11 @@ public class ParserFactory extends OutputModelFactory { public CodeBlock alternative(List elems) { return new CodeBlock(this, elems); } - public SrcOp action(GrammarAST ast) { return new Action(this, ast); } + public List action(GrammarAST ast) { return list(new Action(this, ast)); } - public SrcOp forcedAction(GrammarAST ast) { return new ForcedAction(this, ast); } + public List forcedAction(GrammarAST ast) { return list(new ForcedAction(this, ast)); } - public SrcOp sempred(GrammarAST ast) { return new SemPred(this, ast); } + public List sempred(GrammarAST ast) { return list(new SemPred(this, ast)); } public List ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { InvokeRule r = new InvokeRule(this, ID, label); @@ -34,7 +33,7 @@ public class ParserFactory extends OutputModelFactory { if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { a = new AddToLabelList(this, gen.target.getListLabel(label.getText()), r); } - return Utils.list(r, a); + return list(r, a); } public List tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { @@ -44,11 +43,14 @@ public class ParserFactory extends OutputModelFactory { String listLabel = gen.target.getListLabel(label.getText()); labelOp = new AddToLabelList(this, listLabel, matchOp); } + /* SrcOp treeOp = null; if ( g.hasASTOption() ) { treeOp = new AddLeaf(this, ID, matchOp); } - return Utils.list(matchOp, labelOp, treeOp); + return list(matchOp, labelOp, treeOp); + */ + return list(matchOp, labelOp); } public List stringRef(GrammarAST ID, GrammarAST label) { diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g index 7f4143237..6ec85975e 100644 --- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g +++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g @@ -56,19 +56,19 @@ alternative returns [CodeBlock omo] element returns [List omos] : labeledElement {$omos = $labeledElement.omos;} | atom[null] {$omos = $atom.omos;} - | ebnf {$omos = Utils.list($ebnf.omo);} - | ACTION {$omos = Utils.list(factory.action($ACTION));} - | FORCED_ACTION {$omos = Utils.list(factory.forcedAction($FORCED_ACTION));} - | SEMPRED {$omos = Utils.list(factory.sempred($SEMPRED));} + | ebnf {$omos = factory.list($ebnf.omo);} + | ACTION {$omos = factory.list(factory.action($ACTION));} + | FORCED_ACTION {$omos = factory.list(factory.forcedAction($FORCED_ACTION));} + | SEMPRED {$omos = factory.list(factory.sempred($SEMPRED));} | GATED_SEMPRED | treeSpec ; labeledElement returns [List omos] : ^(ASSIGN ID atom[$ID] ) {$omos = $atom.omos;} - | ^(ASSIGN ID block[$ID,null]) {$omos = Utils.list($block.omo);} + | ^(ASSIGN ID block[$ID,null]) {$omos = factory.list($block.omo);} | ^(PLUS_ASSIGN ID atom[$ID]) {$omos = $atom.omos;} - | ^(PLUS_ASSIGN ID block[$ID,null]) {$omos = Utils.list($block.omo);} + | ^(PLUS_ASSIGN ID block[$ID,null]) {$omos = factory.list($block.omo);} ; treeSpec returns [SrcOp omo] diff --git a/tool/src/org/antlr/v4/codegen/model/Action.java b/tool/src/org/antlr/v4/codegen/model/Action.java index 060dcb28e..3bba52f42 100644 --- a/tool/src/org/antlr/v4/codegen/model/Action.java +++ b/tool/src/org/antlr/v4/codegen/model/Action.java @@ -10,7 +10,7 @@ import java.util.List; public class Action extends RuleElement { @ModelElement public List chunks; - public Action(OutputModelFactory factory, GrammarAST ast) { + public Action(CoreOutputModelFactory factory, GrammarAST ast) { super(factory,ast); RuleFunction rf = null; if ( factory.currentRule.size()>0 ) rf = factory.currentRule.peek(); diff --git a/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java b/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java index 55311a1db..13a901d36 100644 --- a/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java +++ b/tool/src/org/antlr/v4/codegen/model/AddToLabelList.java @@ -1,13 +1,13 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class AddToLabelList extends SrcOp { public String listName; public LabeledOp opWithResultToAdd; - public AddToLabelList(OutputModelFactory factory, String listName, LabeledOp opWithResultToAdd) { + public AddToLabelList(CoreOutputModelFactory factory, String listName, LabeledOp opWithResultToAdd) { super(factory); this.listName = listName; this.opWithResultToAdd = opWithResultToAdd; diff --git a/tool/src/org/antlr/v4/codegen/model/AltBlock.java b/tool/src/org/antlr/v4/codegen/model/AltBlock.java index 2527937b5..bbd420f0f 100644 --- a/tool/src/org/antlr/v4/codegen/model/AltBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/AltBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.runtime.atn.BlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -9,7 +9,7 @@ import java.util.List; public class AltBlock extends Choice { @ModelElement public ThrowNoViableAlt error; - public AltBlock(OutputModelFactory factory, + public AltBlock(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/Choice.java b/tool/src/org/antlr/v4/codegen/model/Choice.java index aa104e241..96b4f6372 100644 --- a/tool/src/org/antlr/v4/codegen/model/Choice.java +++ b/tool/src/org/antlr/v4/codegen/model/Choice.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.decl.*; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; @@ -23,7 +23,7 @@ public abstract class Choice extends RuleElement { @ModelElement public List alts; @ModelElement public List preamble; - public Choice(OutputModelFactory factory, + public Choice(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/CodeBlock.java b/tool/src/org/antlr/v4/codegen/model/CodeBlock.java index beb631f04..9f8978303 100644 --- a/tool/src/org/antlr/v4/codegen/model/CodeBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/CodeBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import java.util.*; @@ -8,14 +8,14 @@ import java.util.*; public class CodeBlock extends SrcOp { @ModelElement public List ops; - public CodeBlock(OutputModelFactory factory) { this.factory = factory; } + public CodeBlock(CoreOutputModelFactory factory) { this.factory = factory; } - public CodeBlock(OutputModelFactory factory, List ops) { + public CodeBlock(CoreOutputModelFactory factory, List ops) { super(factory); this.ops = ops; } - public CodeBlock(OutputModelFactory factory, final SrcOp elem) { + public CodeBlock(CoreOutputModelFactory factory, final SrcOp elem) { this(factory, new ArrayList() {{ add(elem); }}); } diff --git a/tool/src/org/antlr/v4/codegen/model/ForcedAction.java b/tool/src/org/antlr/v4/codegen/model/ForcedAction.java index 6b2151b26..f95fc98cf 100644 --- a/tool/src/org/antlr/v4/codegen/model/ForcedAction.java +++ b/tool/src/org/antlr/v4/codegen/model/ForcedAction.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; public class ForcedAction extends Action { - public ForcedAction(OutputModelFactory factory, GrammarAST ast) { + public ForcedAction(CoreOutputModelFactory factory, GrammarAST ast) { super(factory, ast); } } diff --git a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java index 3c010e7d8..a5c6a966f 100644 --- a/tool/src/org/antlr/v4/codegen/model/InvokeRule.java +++ b/tool/src/org/antlr/v4/codegen/model/InvokeRule.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.decl.*; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.runtime.atn.RuleTransition; @@ -15,7 +15,7 @@ public class InvokeRule extends RuleElement implements LabeledOp { public String argExprs; public String ctxName; - public InvokeRule(OutputModelFactory factory, GrammarAST ast, GrammarAST labelAST) { + public InvokeRule(CoreOutputModelFactory factory, GrammarAST ast, GrammarAST labelAST) { super(factory, ast); if ( ast.atnState!=null ) { RuleTransition ruleTrans = (RuleTransition)ast.atnState.transition(0); diff --git a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java index 9fe4f3031..ea2befd20 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1AltBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.DecisionState; import org.antlr.v4.tool.GrammarAST; @@ -9,7 +9,7 @@ import java.util.List; /** (A | B | C) */ public class LL1AltBlock extends LL1Choice { - public LL1AltBlock(OutputModelFactory factory, GrammarAST blkAST, List alts) { + public LL1AltBlock(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { super(factory, blkAST, alts); this.decision = ((DecisionState)blkAST.atnState).decision; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java index a715a583a..b1f4dd379 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1Choice.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1Choice.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.List; @@ -10,7 +10,7 @@ public abstract class LL1Choice extends Choice { public List altLook; @ModelElement public ThrowNoViableAlt error; - public LL1Choice(OutputModelFactory factory, GrammarAST blkAST, + public LL1Choice(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { super(factory, blkAST, alts); diff --git a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java index 591a2a8b9..9797514b9 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1Loop.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1Loop.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; @@ -12,7 +12,7 @@ public abstract class LL1Loop extends Choice { @ModelElement public List iteration; @ModelElement public Sync sync; - public LL1Loop(OutputModelFactory factory, + public LL1Loop(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java index adb5964a3..8a2670225 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.List; @@ -11,7 +11,7 @@ import java.util.List; * (A | B | C)? */ public class LL1OptionalBlock extends LL1AltBlock { - public LL1OptionalBlock(OutputModelFactory factory, GrammarAST blkAST, List alts) { + public LL1OptionalBlock(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { super(factory, blkAST, alts); } } diff --git a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java index be16eb02a..183c71212 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1OptionalBlockSingleAlt.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.DecisionState; import org.antlr.v4.tool.GrammarAST; @@ -12,7 +12,7 @@ public class LL1OptionalBlockSingleAlt extends LL1Choice { @ModelElement public OutputModelObject expr; @ModelElement public OutputModelObject followExpr; - public LL1OptionalBlockSingleAlt(OutputModelFactory factory, + public LL1OptionalBlockSingleAlt(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java index 106dbc41b..343e821d4 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -20,7 +20,7 @@ public class LL1PlusBlock extends LL1Loop { @ModelElement public SrcOp loopExpr; @ModelElement public ThrowNoViableAlt error; - public LL1PlusBlock(OutputModelFactory factory, GrammarAST plusRoot, List alts) { + public LL1PlusBlock(CoreOutputModelFactory factory, GrammarAST plusRoot, List alts) { super(factory, plusRoot, alts); PlusBlockStartState blkStart = (PlusBlockStartState)plusRoot.atnState; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java index 2fd1383c8..668ceed35 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1PlusBlockSingleAlt.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.PlusBlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -11,7 +11,7 @@ import java.util.List; public class LL1PlusBlockSingleAlt extends LL1Loop { @ModelElement public Sync iterationSync; - public LL1PlusBlockSingleAlt(OutputModelFactory factory, GrammarAST blkAST, List alts) { + public LL1PlusBlockSingleAlt(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { super(factory, blkAST, alts); PlusBlockStartState plus = (PlusBlockStartState)blkAST.atnState; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java b/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java index 504dc5108..884d62612 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1StarBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.StarBlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -14,7 +14,7 @@ public class LL1StarBlock extends LL1Loop { public String loopLabel; public String[] exitLook; - public LL1StarBlock(OutputModelFactory factory, GrammarAST blkAST, List alts) { + public LL1StarBlock(CoreOutputModelFactory factory, GrammarAST blkAST, List alts) { super(factory, blkAST, alts); StarBlockStartState blkStart = (StarBlockStartState)blkAST.atnState; diff --git a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java index 9d21446cd..a9ee68680 100644 --- a/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/LL1StarBlockSingleAlt.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.runtime.atn.StarBlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -9,7 +9,7 @@ import java.util.List; /** */ public class LL1StarBlockSingleAlt extends LL1Loop { - public LL1StarBlockSingleAlt(OutputModelFactory factory, GrammarAST starRoot, List alts) { + public LL1StarBlockSingleAlt(CoreOutputModelFactory factory, GrammarAST starRoot, List alts) { super(factory, starRoot, alts); StarBlockStartState star = (StarBlockStartState)starRoot.atnState; diff --git a/tool/src/org/antlr/v4/codegen/model/Lexer.java b/tool/src/org/antlr/v4/codegen/model/Lexer.java index dfda5e8a9..025f1e0f3 100644 --- a/tool/src/org/antlr/v4/codegen/model/Lexer.java +++ b/tool/src/org/antlr/v4/codegen/model/Lexer.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.*; import java.util.*; @@ -17,7 +17,7 @@ public class Lexer extends OutputModelObject { @ModelElement public LinkedHashMap actions; @ModelElement public LinkedHashMap sempreds; - public Lexer(OutputModelFactory factory, LexerFile file) { + public Lexer(CoreOutputModelFactory factory, LexerFile file) { this.factory = factory; this.file = file; // who contains us? name = factory.g.getRecognizerName(); diff --git a/tool/src/org/antlr/v4/codegen/model/LexerFile.java b/tool/src/org/antlr/v4/codegen/model/LexerFile.java index d56586945..00a2c2d5c 100644 --- a/tool/src/org/antlr/v4/codegen/model/LexerFile.java +++ b/tool/src/org/antlr/v4/codegen/model/LexerFile.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.*; @@ -11,10 +11,10 @@ public class LexerFile extends OutputModelObject { @ModelElement public Lexer lexer; @ModelElement public Map namedActions; - public LexerFile(OutputModelFactory factory, String fileName) { + public LexerFile(CoreOutputModelFactory factory, String fileName) { super(factory); this.fileName = fileName; - factory.file = this; + factory.root = this; namedActions = new HashMap(); for (String name : factory.gen.g.namedActions.keySet()) { GrammarAST ast = factory.gen.g.namedActions.get(name); diff --git a/tool/src/org/antlr/v4/codegen/model/Loop.java b/tool/src/org/antlr/v4/codegen/model/Loop.java index a69d103a7..9449e36cd 100644 --- a/tool/src/org/antlr/v4/codegen/model/Loop.java +++ b/tool/src/org/antlr/v4/codegen/model/Loop.java @@ -1,13 +1,13 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.List; public class Loop extends Choice { public int exitAlt; - public Loop(OutputModelFactory factory, + public Loop(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/MatchToken.java b/tool/src/org/antlr/v4/codegen/model/MatchToken.java index c7aaf7ce5..4dbc7cedd 100644 --- a/tool/src/org/antlr/v4/codegen/model/MatchToken.java +++ b/tool/src/org/antlr/v4/codegen/model/MatchToken.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.decl.*; import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.tool.*; @@ -12,7 +12,7 @@ public class MatchToken extends RuleElement implements LabeledOp { public String name; public List labels = new ArrayList(); - public MatchToken(OutputModelFactory factory, TerminalAST ast, GrammarAST labelAST) { + public MatchToken(CoreOutputModelFactory factory, TerminalAST ast, GrammarAST labelAST) { super(factory, ast); int ttype = factory.g.getTokenType(ast.getText()); name = factory.gen.target.getTokenTypeAsTargetLabel(factory.g, ttype); diff --git a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java index 4144d1152..7752ba5f5 100644 --- a/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/OptionalBlock.java @@ -1,13 +1,13 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.List; /** */ public class OptionalBlock extends AltBlock { - public OptionalBlock(OutputModelFactory factory, + public OptionalBlock(CoreOutputModelFactory factory, GrammarAST questionAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java index 1365ab04f..bec1ffa6a 100644 --- a/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java +++ b/tool/src/org/antlr/v4/codegen/model/OutputModelObject.java @@ -1,18 +1,18 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; /** */ public abstract class OutputModelObject { - public OutputModelFactory factory; + public CoreOutputModelFactory factory; public GrammarAST ast; public OutputModelObject() {;} - public OutputModelObject(OutputModelFactory factory) { this.factory = factory; } + public OutputModelObject(CoreOutputModelFactory factory) { this.factory = factory; } - public OutputModelObject(OutputModelFactory factory, GrammarAST ast) { + public OutputModelObject(CoreOutputModelFactory factory, GrammarAST ast) { this.factory = factory; this.ast = ast; } diff --git a/tool/src/org/antlr/v4/codegen/model/Parser.java b/tool/src/org/antlr/v4/codegen/model/Parser.java index 5e4637d0d..8c504d516 100644 --- a/tool/src/org/antlr/v4/codegen/model/Parser.java +++ b/tool/src/org/antlr/v4/codegen/model/Parser.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.*; import java.util.*; @@ -18,7 +18,7 @@ public class Parser extends OutputModelObject { @ModelElement public LinkedHashMap actions; @ModelElement public LinkedHashMap sempreds; - public Parser(OutputModelFactory factory, ParserFile file) { + public Parser(CoreOutputModelFactory factory, ParserFile file) { this.factory = factory; this.file = file; // who contains us? name = factory.g.getRecognizerName(); diff --git a/tool/src/org/antlr/v4/codegen/model/ParserFile.java b/tool/src/org/antlr/v4/codegen/model/ParserFile.java index 89554b720..20dd93781 100644 --- a/tool/src/org/antlr/v4/codegen/model/ParserFile.java +++ b/tool/src/org/antlr/v4/codegen/model/ParserFile.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; import java.util.*; @@ -14,10 +14,10 @@ public class ParserFile extends OutputModelObject { @ModelElement public Parser parser; @ModelElement public Map namedActions; - public ParserFile(OutputModelFactory factory, String fileName) { + public ParserFile(CoreOutputModelFactory factory, String fileName) { super(factory); this.fileName = fileName; - factory.file = this; + factory.root = this; TokenLabelType = factory.gen.g.getOption("TokenLabelType"); ASTLabelType = factory.gen.g.getOption("ASTLabelType"); namedActions = new HashMap(); diff --git a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java index f24be6b4a..3743f8338 100644 --- a/tool/src/org/antlr/v4/codegen/model/PlusBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/PlusBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.tool.GrammarAST; @@ -9,7 +9,7 @@ import java.util.List; public class PlusBlock extends Loop { @ModelElement public ThrowNoViableAlt error; - public PlusBlock(OutputModelFactory factory, + public PlusBlock(CoreOutputModelFactory factory, GrammarAST ebnfRootAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/RuleElement.java b/tool/src/org/antlr/v4/codegen/model/RuleElement.java index dc0e9bb29..2d90b8d11 100644 --- a/tool/src/org/antlr/v4/codegen/model/RuleElement.java +++ b/tool/src/org/antlr/v4/codegen/model/RuleElement.java @@ -1,13 +1,13 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; public class RuleElement extends SrcOp { /** Associated ATN state for this rule elements (action, token, ruleref, ...) */ public int stateNumber; - public RuleElement(OutputModelFactory factory, GrammarAST ast) { + public RuleElement(CoreOutputModelFactory factory, GrammarAST ast) { super(factory, ast); if ( ast.atnState!=null ) stateNumber = ast.atnState.stateNumber; } diff --git a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java index 2fe24f0f4..17d9198ae 100644 --- a/tool/src/org/antlr/v4/codegen/model/RuleFunction.java +++ b/tool/src/org/antlr/v4/codegen/model/RuleFunction.java @@ -31,11 +31,11 @@ public class RuleFunction extends OutputModelObject { @ModelElement public Map namedActions; @ModelElement public Action finallyAction; - public RuleFunction(OutputModelFactory factory) { + public RuleFunction(CoreOutputModelFactory factory) { super(factory); } - public RuleFunction(OutputModelFactory factory, Rule r) { + public RuleFunction(CoreOutputModelFactory factory, Rule r) { super(factory); this.name = r.name; if ( r.modifiers!=null && r.modifiers.size()>0 ) { diff --git a/tool/src/org/antlr/v4/codegen/model/SemPred.java b/tool/src/org/antlr/v4/codegen/model/SemPred.java index 3cedf04a2..eae81c033 100644 --- a/tool/src/org/antlr/v4/codegen/model/SemPred.java +++ b/tool/src/org/antlr/v4/codegen/model/SemPred.java @@ -1,9 +1,9 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; /** */ public class SemPred extends Action { - public SemPred(OutputModelFactory factory, GrammarAST ast) { super(factory,ast); } + public SemPred(CoreOutputModelFactory factory, GrammarAST ast) { super(factory,ast); } } diff --git a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java index befca04c2..8357246e0 100644 --- a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java +++ b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java @@ -1,7 +1,7 @@ package org.antlr.v4.codegen.model; import org.antlr.v4.automata.ATNSerializer; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.runtime.atn.ATN; import java.util.*; @@ -9,7 +9,7 @@ import java.util.*; public class SerializedATN extends OutputModelObject { // TODO: make this into a kind of decl or multiple? public List serialized; - public SerializedATN(OutputModelFactory factory, ATN atn) { + public SerializedATN(CoreOutputModelFactory factory, ATN atn) { super(factory); List data = ATNSerializer.getSerialized(atn); serialized = new ArrayList(data.size()); diff --git a/tool/src/org/antlr/v4/codegen/model/SrcOp.java b/tool/src/org/antlr/v4/codegen/model/SrcOp.java index 928890a16..826fc92f2 100644 --- a/tool/src/org/antlr/v4/codegen/model/SrcOp.java +++ b/tool/src/org/antlr/v4/codegen/model/SrcOp.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.tool.GrammarAST; /** */ @@ -9,8 +9,8 @@ public abstract class SrcOp extends OutputModelObject { public int uniqueID; public SrcOp() {;} - public SrcOp(OutputModelFactory factory) { super(factory); } - public SrcOp(OutputModelFactory factory, GrammarAST ast) { + public SrcOp(CoreOutputModelFactory factory) { super(factory); } + public SrcOp(CoreOutputModelFactory factory, GrammarAST ast) { super(factory,ast); uniqueID = ast.token.getTokenIndex(); } diff --git a/tool/src/org/antlr/v4/codegen/model/StarBlock.java b/tool/src/org/antlr/v4/codegen/model/StarBlock.java index 41885033e..14d7a5c8c 100644 --- a/tool/src/org/antlr/v4/codegen/model/StarBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/StarBlock.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.runtime.atn.BlockStartState; import org.antlr.v4.tool.GrammarAST; @@ -9,7 +9,7 @@ import java.util.List; public class StarBlock extends Loop { public String loopLabel; - public StarBlock(OutputModelFactory factory, + public StarBlock(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, List alts) { diff --git a/tool/src/org/antlr/v4/codegen/model/Sync.java b/tool/src/org/antlr/v4/codegen/model/Sync.java index 96b8f559b..ee41f0ccf 100644 --- a/tool/src/org/antlr/v4/codegen/model/Sync.java +++ b/tool/src/org/antlr/v4/codegen/model/Sync.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; @@ -8,7 +8,7 @@ import org.antlr.v4.tool.GrammarAST; public class Sync extends SrcOp { public int decision; // public BitSetDecl expecting; - public Sync(OutputModelFactory factory, + public Sync(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, IntervalSet expecting, int decision, diff --git a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java index 8fae8f791..82b30dc6e 100644 --- a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java +++ b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; @@ -8,14 +8,9 @@ import org.antlr.v4.tool.GrammarAST; public class TestSetInline extends SrcOp { public String varName; public String[] ttypes; -// public CaptureNextToken nextToken; -// public Choice choice; - public TestSetInline(OutputModelFactory factory, GrammarAST ast, IntervalSet set) { + public TestSetInline(CoreOutputModelFactory factory, GrammarAST ast, IntervalSet set) { super(factory, ast); this.ttypes = factory.gen.target.getTokenTypesAsTargetLabels(factory.g, set.toArray()); this.varName = "_la"; -// this.choice = choice; -// nextToken = new CaptureNextToken(); -// choice.addPreambleOp(nextToken); } } diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java index e5f4cfd7f..2ad5523d9 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowEarlyExitException.java @@ -1,12 +1,12 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; /** */ public class ThrowEarlyExitException extends ThrowRecognitionException { - public ThrowEarlyExitException(OutputModelFactory factory, GrammarAST ast, IntervalSet expecting) { + public ThrowEarlyExitException(CoreOutputModelFactory factory, GrammarAST ast, IntervalSet expecting) { super(factory, ast, expecting); } } diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java index 425c88de2..11bab3308 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowNoViableAlt.java @@ -1,12 +1,12 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; /** */ public class ThrowNoViableAlt extends ThrowRecognitionException { - public ThrowNoViableAlt(OutputModelFactory factory, GrammarAST blkOrEbnfRootAST, + public ThrowNoViableAlt(CoreOutputModelFactory factory, GrammarAST blkOrEbnfRootAST, IntervalSet expecting) { super(factory, blkOrEbnfRootAST, expecting); diff --git a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java index 932fe7fb6..987ba4f75 100644 --- a/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java +++ b/tool/src/org/antlr/v4/codegen/model/ThrowRecognitionException.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.tool.GrammarAST; @@ -11,7 +11,7 @@ public class ThrowRecognitionException extends SrcOp { public int grammarLine; public int grammarCharPosInLine; - public ThrowRecognitionException(OutputModelFactory factory, GrammarAST ast, IntervalSet expecting) { + public ThrowRecognitionException(CoreOutputModelFactory factory, GrammarAST ast, IntervalSet expecting) { super(factory, ast); //this.decision = ((BlockStartState)ast.ATNState).decision; grammarLine = ast.getLine(); diff --git a/tool/src/org/antlr/v4/codegen/model/ast/AddLeaf.java b/tool/src/org/antlr/v4/codegen/model/ast/AddLeaf.java index 26d21f976..13ed660c6 100644 --- a/tool/src/org/antlr/v4/codegen/model/ast/AddLeaf.java +++ b/tool/src/org/antlr/v4/codegen/model/ast/AddLeaf.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model.ast; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.*; import org.antlr.v4.codegen.model.decl.Decl; import org.antlr.v4.tool.GrammarAST; @@ -10,7 +10,7 @@ public class AddLeaf extends SrcOp { public LabeledOp opWithResultToAdd; public Decl label; - public AddLeaf(OutputModelFactory factory, GrammarAST ast, LabeledOp opWithResultToAdd) { + public AddLeaf(CoreOutputModelFactory factory, GrammarAST ast, LabeledOp opWithResultToAdd) { super(factory, ast); this.opWithResultToAdd = opWithResultToAdd; label = opWithResultToAdd.getLabels().get(0); diff --git a/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java index 722da0575..586721e37 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/AttributeDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class AttributeDecl extends Decl { - public AttributeDecl(OutputModelFactory factory, String name, String decl) { + public AttributeDecl(CoreOutputModelFactory factory, String name, String decl) { super(factory, name, decl); } } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/Decl.java b/tool/src/org/antlr/v4/codegen/model/decl/Decl.java index 8a554ce71..e45c2e735 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/Decl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/Decl.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.SrcOp; /** */ @@ -9,12 +9,12 @@ public class Decl extends SrcOp { public String decl; // whole thing if copied from action public boolean isLocal; // if local var (not in RuleContext struct) - public Decl(OutputModelFactory factory, String name, String decl) { + public Decl(CoreOutputModelFactory factory, String name, String decl) { this(factory, name); this.decl = decl; } - public Decl(OutputModelFactory factory, String name) { + public Decl(CoreOutputModelFactory factory, String name) { super(factory); this.name = name; } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/KidsListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/KidsListDecl.java index bb605db9f..125533462 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/KidsListDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/KidsListDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; public class KidsListDecl extends Decl { public int level; - public KidsListDecl(OutputModelFactory factory, int level) { + public KidsListDecl(CoreOutputModelFactory factory, int level) { super(factory, factory.gen.target.getKidsListName(level)); } } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RootDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RootDecl.java index e7269373a..10f50a70a 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/RootDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/RootDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; public class RootDecl extends Decl { public int level; - public RootDecl(OutputModelFactory factory, int level) { + public RootDecl(CoreOutputModelFactory factory, int level) { super(factory, factory.gen.target.getRootName(level)); } } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java index da8515cec..7354bba6f 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextDecl.java @@ -1,11 +1,11 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class RuleContextDecl extends Decl { public String ctxName; - public RuleContextDecl(OutputModelFactory factory, String name, String ctxName) { + public RuleContextDecl(CoreOutputModelFactory factory, String name, String ctxName) { super(factory, name); this.ctxName = ctxName; } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java index c34a0ee6e..b0514996f 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/RuleContextListDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; public class RuleContextListDecl extends Decl { public RuleContextDecl decl; - public RuleContextListDecl(OutputModelFactory factory, String name, RuleContextDecl decl) { + public RuleContextListDecl(CoreOutputModelFactory factory, String name, RuleContextDecl decl) { super(factory, name); this.decl = decl; } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java index 68eaaa187..f003286e7 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java @@ -1,6 +1,6 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; import org.antlr.v4.codegen.model.ModelElement; import org.antlr.v4.tool.Attribute; @@ -11,11 +11,11 @@ public class StructDecl extends Decl { @ModelElement public List attrs = new ArrayList(); @ModelElement public Collection ctorAttrs; - public StructDecl(OutputModelFactory factory) { + public StructDecl(CoreOutputModelFactory factory) { super(factory, null); } - public StructDecl(OutputModelFactory factory, String name) { + public StructDecl(CoreOutputModelFactory factory, String name) { super(factory, name); } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java index d00249186..fbabc9e13 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class TokenDecl extends Decl { - public TokenDecl(OutputModelFactory factory, String varName) { + public TokenDecl(CoreOutputModelFactory factory, String varName) { super(factory, varName); } } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java index ba1b0360e..0b3a49ef3 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenListDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class TokenListDecl extends Decl { - public TokenListDecl(OutputModelFactory factory, String varName) { + public TokenListDecl(CoreOutputModelFactory factory, String varName) { super(factory, varName); } } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java index 6921eac72..6224f3e65 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/TokenTypeDecl.java @@ -1,10 +1,10 @@ package org.antlr.v4.codegen.model.decl; -import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.codegen.CoreOutputModelFactory; /** */ public class TokenTypeDecl extends Decl { - public TokenTypeDecl(OutputModelFactory factory, String name) { + public TokenTypeDecl(CoreOutputModelFactory factory, String name) { super(factory, name); } } diff --git a/tool/src/org/antlr/v4/misc/Utils.java b/tool/src/org/antlr/v4/misc/Utils.java index 6bb1acc4d..9fb0edff7 100644 --- a/tool/src/org/antlr/v4/misc/Utils.java +++ b/tool/src/org/antlr/v4/misc/Utils.java @@ -108,14 +108,6 @@ public class Utils { // return x; // } - public static List list(Object... values) { - List x = new ArrayList(values.length); - for (Object v : values) { - if ( v!=null ) x.add(v); - } - return x; - } - public static int[] toIntArray(List list) { if ( list==null ) return null; int[] a = new int[list.size()];