diff --git a/tool/src/org/antlr/v4/codegen/src/RuleFunction.java b/tool/src/org/antlr/v4/codegen/src/RuleFunction.java index 352adeb64..4c4ce11ba 100644 --- a/tool/src/org/antlr/v4/codegen/src/RuleFunction.java +++ b/tool/src/org/antlr/v4/codegen/src/RuleFunction.java @@ -33,6 +33,10 @@ public class RuleFunction extends OutputModelObject { public OrderedHashSet decls; public SrcOp code; + public RuleFunction(OutputModelFactory factory) { + super(factory); + } + public RuleFunction(OutputModelFactory factory, Rule r) { super(factory); this.name = r.name; diff --git a/tool/src/org/antlr/v4/codegen/src/StartRuleFunction.java b/tool/src/org/antlr/v4/codegen/src/StartRuleFunction.java index f704b451b..0945f9800 100644 --- a/tool/src/org/antlr/v4/codegen/src/StartRuleFunction.java +++ b/tool/src/org/antlr/v4/codegen/src/StartRuleFunction.java @@ -1,11 +1,27 @@ package org.antlr.v4.codegen.src; import org.antlr.v4.codegen.OutputModelFactory; +import org.antlr.v4.misc.Utils; +import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.Rule; +import java.util.ArrayList; + /** */ public class StartRuleFunction extends RuleFunction { public StartRuleFunction(OutputModelFactory factory, Rule r) { - super(factory, r); + super(factory); + this.name = r.name; + if ( r.modifiers!=null && r.modifiers.size()>0 ) { + this.modifiers = new ArrayList(); + for (GrammarAST t : r.modifiers) modifiers.add(t.getText()); + } + modifiers = Utils.nodesToStrings(r.modifiers); + + ctxType = factory.gen.target.getRuleFunctionContextStructName(r); + + if ( r.args!=null ) { + args = r.args.attributes.values(); + } } }