diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index d1de6c8e3..34be6508a 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -170,11 +170,11 @@ cases(ttypes) ::= << >> InvokeRule(r) ::= << - = (new (,}>)); + = }>(new (,}>)); >> MatchToken(m) ::= << - = (Token)match(, ); + = }>(Token)match(, ); >> // ACTION STUFF @@ -188,6 +188,8 @@ if (!()) throw new FailedPredicateException(input, "", " chunks = new ArrayList(); + OutputModelFactory factory; - public ActionTranslator(ActionAST node) { + public ActionTranslator(OutputModelFactory factory, ActionAST node) { + this.factory = factory; this.node = node; } - public static List translateAction(RuleFunction rf, Token tokenWithinAction, ActionAST node) { - ActionTranslator translator = new ActionTranslator(node); + public static List translateAction(OutputModelFactory factory, + RuleFunction rf, + Token tokenWithinAction, + ActionAST node) + { + String action = tokenWithinAction.getText(); + int firstCurly = action.indexOf('{'); + int lastCurly = action.lastIndexOf('}'); + if ( firstCurly>=0 && lastCurly>=0 ) { + action = action.substring(firstCurly+1, lastCurly); // trim {...} + } + return translateActionChunk(factory, rf, action, node); + } + + public static List translateActionChunk(OutputModelFactory factory, + RuleFunction rf, + String action, + ActionAST node) + { + Token tokenWithinAction = node.token; + ActionTranslator translator = new ActionTranslator(factory, node); translator.rf = rf; - System.out.println("translate "+tokenWithinAction); - ANTLRStringStream in = new ANTLRStringStream(tokenWithinAction.getText()); + System.out.println("translate "+action); + ANTLRStringStream in = new ANTLRStringStream(action); in.setLine(tokenWithinAction.getLine()); in.setCharPositionInLine(tokenWithinAction.getCharPositionInLine()); ActionSplitter trigger = new ActionSplitter(in, translator); @@ -37,28 +60,75 @@ public class ActionTranslator implements ActionSplitterListener { public void attr(String expr, Token x) { System.out.println("attr "+x); + Attribute a = node.resolver.resolveToAttribute(x.getText(), node); - switch ( a.dict.type ) { - case ARG: chunks.add(new ArgRef(x.getText())); break; - case RET: chunks.add(new RetValueRef(x.getText())); break; + if ( a!=null ) { + switch ( a.dict.type ) { + case ARG: chunks.add(new ArgRef(x.getText())); break; + case RET: chunks.add(new RetValueRef(x.getText())); break; +// case PREDEFINED_RULE: chunks.add(new RetValueRef(x.getText())); break; +// case PREDEFINED_TREE_RULE: chunks.add(new RetValueRef(x.getText())); break; + } + } + if ( node.resolver.resolveToDynamicScope(x.getText(), node)!=null ) { + return; // $S for scope S is ok + } + if ( node.resolver.resolvesToToken(x.getText(), node) ) { + if ( node.resolver.resolvesToLabel(x.getText(), node) ) { + chunks.add(new TokenRef(x.getText())); // $label + } + else { // $ID for token ref or label of token; find label + String label = factory.gen.target.getImplicitTokenLabel(x.getText()); + chunks.add(new TokenRef(label)); // $label + } + return; + } + if ( node.resolver.resolvesToListLabel(x.getText(), node) ) { + return; // $ids for ids+=ID etc... + } +// switch ( a.dict.type ) { +// case ARG: chunks.add(new ArgRef(x.getText())); break; +// case RET: chunks.add(new RetValueRef(x.getText())); break; // case PREDEFINED_RULE: chunks.add(new RetValueRef(x.getText())); break; // case PREDEFINED_LEXER_RULE: chunks.add(new RetValueRef(x.getText())); break; // case PREDEFINED_TREE_RULE: chunks.add(new RetValueRef(x.getText())); break; // case GLOBAL_SCOPE: chunks.add(new RetValueRef(x.getText())); break; // case RULE_SCOPE: chunks.add(new RetValueRef(x.getText())); break; -// case TOKEN: chunks.add(new RetValueRef(x.getText())); break; - } +// case TOKEN: chunks.add(new TokenRef(x.getText())); break; +// } } public void setQualifiedAttr(String expr, Token x, Token y, Token rhs) { } public void qualifiedAttr(String expr, Token x, Token y) { + System.out.println("qattr "+x+"."+y); + if ( node.resolver.resolveToAttribute(x.getText(), y.getText(), node)==null ) { + Rule rref = isolatedRuleRef(x.getText()); + if ( rref!=null ) { + if ( rref!=null && rref.args!=null && rref.args.get(y.getText())!=null ) { + g.tool.errMgr.grammarError(ErrorType.INVALID_RULE_PARAMETER_REF, + g.fileName, y, y.getText(), expr); + } + else { + errMgr.grammarError(ErrorType.UNKNOWN_RULE_ATTRIBUTE, + g.fileName, y, y.getText(), rref.name, expr); + } + } + else if ( !node.resolver.resolvesToAttributeDict(x.getText(), node) ) { + errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, + g.fileName, x, x.getText(), expr); + } + else { + errMgr.grammarError(ErrorType.UNKNOWN_ATTRIBUTE_IN_SCOPE, + g.fileName, y, y.getText(), expr); + } + } } public void setAttr(String expr, Token x, Token rhs) { System.out.println("setAttr "+x+" "+rhs); - List exprchunks = translateAction(rf,rhs,node); + List exprchunks = translateActionChunk(factory,rf,rhs.getText(),node); chunks.add(new SetAttr(x.getText(), exprchunks)); } @@ -101,4 +171,13 @@ public class ActionTranslator implements ActionSplitterListener { public void text(String text) { chunks.add(new ActionText(text)); } + +// public String getTokenLabel(String x, ActionAST node) { +// Alternative alt = node.resolver. +// Rule r = node.nfaState.rule; +// if ( r.tokenRefs.get(x)!=null ) return true; +// LabelElementPair anyLabelDef = getAnyLabelDef(x); +// if ( anyLabelDef!=null && anyLabelDef.type== LabelType.TOKEN_LABEL ) return true; +// return false; +// } } diff --git a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java index 46e28243d..994d0c966 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java +++ b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java @@ -10,6 +10,19 @@ public class CodeGenPipeline { } public void process() { CodeGenerator gen = new CodeGenerator(g); + +// for (Rule r : g.rules.values()) { +// for (int i=1; i<=r.numberOfAlts; i++) { +// Alternative alt = r.alt[i]; +// for (String ref : alt.tokenRefs.keySet()) { +// if ( alt.tokenRefsInActions.get(ref)!=null ) { +// String label = gen.target.getImplicitTokenLabel(ast); +// alt.implicitTokenLabels.put(, label); +// } +// } +// } +// } + ST outputFileST = gen.generate(); gen.write(outputFileST); // if ( g.isLexer() ) processLexer(); diff --git a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java index c318b5a7c..647273329 100644 --- a/tool/src/org/antlr/v4/codegen/OutputModelFactory.java +++ b/tool/src/org/antlr/v4/codegen/OutputModelFactory.java @@ -4,6 +4,7 @@ import org.antlr.v4.automata.DFA; import org.antlr.v4.codegen.src.*; import org.antlr.v4.misc.IntervalSet; import org.antlr.v4.parse.ANTLRParser; +import org.antlr.v4.tool.Alternative; import org.antlr.v4.tool.BlockAST; import org.antlr.v4.tool.Grammar; import org.antlr.v4.tool.GrammarAST; @@ -18,7 +19,8 @@ public abstract class OutputModelFactory { // Context ptrs public OutputModelObject file; // root - public Stack currentRule = new Stack(); + public Stack currentRule = new Stack(); + public Alternative currentAlt; protected OutputModelFactory(CodeGenerator gen) { this.gen = gen; diff --git a/tool/src/org/antlr/v4/codegen/ParserFactory.java b/tool/src/org/antlr/v4/codegen/ParserFactory.java index 8b1fa6892..fc6762dbb 100644 --- a/tool/src/org/antlr/v4/codegen/ParserFactory.java +++ b/tool/src/org/antlr/v4/codegen/ParserFactory.java @@ -32,8 +32,8 @@ public class ParserFactory extends OutputModelFactory { public List ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) { InvokeRule r = new InvokeRule(this, ID, label); AddToList a = null; - if ( label!=null && label.parent.getType()== ANTLRParser.PLUS_ASSIGN ) { - a = new AddToList(this, gen.target.getListLabel(r.label), r); + if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { + a = new AddToList(this, gen.target.getListLabel(label.getText()), r); } return Utils.list(r, a); } @@ -42,8 +42,8 @@ public class ParserFactory extends OutputModelFactory { public List tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args) { MatchToken m = new MatchToken(this, (TerminalAST) ID, label); AddToList a = null; - if ( label!=null && label.parent.getType()== ANTLRParser.PLUS_ASSIGN ) { - a = new AddToList(this, gen.target.getListLabel(m.label), m); + if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { + a = new AddToList(this, gen.target.getListLabel(label.getText()), m); } return Utils.list(m, a); } diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g index d7af41610..30dd28580 100644 --- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g +++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.g @@ -36,7 +36,11 @@ block[GrammarAST label, GrammarAST ebnfRoot] returns [SrcOp omo] ; alternative returns [CodeBlock omo] -@init {List elems = new ArrayList();} +@init { + List elems = new ArrayList(); + if ( ((AltAST)$start).alt!=null ) factory.currentAlt = ((AltAST)$start).alt; + +} : ^(ALT_REWRITE a=alternative .) | ^(ALT EPSILON) {$omo = factory.epsilon();} | ^( ALT ( element {elems.addAll($element.omos);} )+ ) {$omo = factory.alternative(elems);} diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java index 40d3137fb..16ac3e48d 100644 --- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java +++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java @@ -1,13 +1,15 @@ -// $ANTLR ${project.version} ${buildNumber} SourceGenTriggers.g 2010-05-12 16:26:01 +// $ANTLR ${project.version} ${buildNumber} SourceGenTriggers.g 2010-05-19 15:23:17 package org.antlr.v4.codegen; import org.antlr.runtime.*; import org.antlr.runtime.tree.TreeNodeStream; import org.antlr.runtime.tree.TreeParser; +import org.antlr.runtime.tree.TreeRuleReturnScope; import org.antlr.v4.codegen.src.CodeBlock; import org.antlr.v4.codegen.src.SrcOp; import org.antlr.v4.misc.Utils; +import org.antlr.v4.tool.AltAST; import org.antlr.v4.tool.BlockAST; import org.antlr.v4.tool.GrammarAST; @@ -151,7 +153,7 @@ public class SourceGenTriggers extends TreeParser { SrcOp omo = null; GrammarAST blk=null; - CodeBlock alternative1 = null; + SourceGenTriggers.alternative_return alternative1 = null; try { @@ -238,7 +240,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; - alts.add(alternative1); + alts.add((alternative1!=null?alternative1.omo:null)); } break; @@ -272,20 +274,28 @@ public class SourceGenTriggers extends TreeParser { } // $ANTLR end "block" + public static class alternative_return extends TreeRuleReturnScope { + public CodeBlock omo; + }; // $ANTLR start "alternative" // SourceGenTriggers.g:38:1: alternative returns [CodeBlock omo] : ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT ( element )+ ) ); - public final CodeBlock alternative() throws RecognitionException { - CodeBlock omo = null; + public final SourceGenTriggers.alternative_return alternative() throws RecognitionException { + SourceGenTriggers.alternative_return retval = new SourceGenTriggers.alternative_return(); + retval.start = input.LT(1); - CodeBlock a = null; + SourceGenTriggers.alternative_return a = null; List element2 = null; - List elems = new ArrayList(); + + List elems = new ArrayList(); + if ( ((AltAST)((GrammarAST)retval.start)).alt!=null ) factory.currentAlt = ((AltAST)((GrammarAST)retval.start)).alt; + + try { - // SourceGenTriggers.g:40:5: ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT ( element )+ ) ) + // SourceGenTriggers.g:44:5: ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT ( element )+ ) ) int alt5=3; int LA5_0 = input.LA(1); @@ -326,7 +336,7 @@ public class SourceGenTriggers extends TreeParser { } switch (alt5) { case 1 : - // SourceGenTriggers.g:40:7: ^( ALT_REWRITE a= alternative . ) + // SourceGenTriggers.g:44:7: ^( ALT_REWRITE a= alternative . ) { match(input,ALT_REWRITE,FOLLOW_ALT_REWRITE_in_alternative141); @@ -343,7 +353,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:41:7: ^( ALT EPSILON ) + // SourceGenTriggers.g:45:7: ^( ALT EPSILON ) { match(input,ALT,FOLLOW_ALT_in_alternative158); @@ -351,17 +361,17 @@ public class SourceGenTriggers extends TreeParser { match(input,EPSILON,FOLLOW_EPSILON_in_alternative160); match(input, Token.UP, null); - omo = factory.epsilon(); + retval.omo = factory.epsilon(); } break; case 3 : - // SourceGenTriggers.g:42:9: ^( ALT ( element )+ ) + // SourceGenTriggers.g:46:9: ^( ALT ( element )+ ) { match(input,ALT,FOLLOW_ALT_in_alternative175); match(input, Token.DOWN, null); - // SourceGenTriggers.g:42:16: ( element )+ + // SourceGenTriggers.g:46:16: ( element )+ int cnt4=0; loop4: do { @@ -375,7 +385,7 @@ public class SourceGenTriggers extends TreeParser { switch (alt4) { case 1 : - // SourceGenTriggers.g:42:18: element + // SourceGenTriggers.g:46:18: element { pushFollow(FOLLOW_element_in_alternative179); element2=element(); @@ -398,7 +408,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); - omo = factory.alternative(elems); + retval.omo = factory.alternative(elems); } break; @@ -411,13 +421,13 @@ public class SourceGenTriggers extends TreeParser { } finally { } - return omo; + return retval; } // $ANTLR end "alternative" // $ANTLR start "element" - // SourceGenTriggers.g:45:1: element returns [List omos] : ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ); + // SourceGenTriggers.g:49:1: element returns [List omos] : ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ); public final List element() throws RecognitionException { List omos = null; @@ -431,12 +441,12 @@ public class SourceGenTriggers extends TreeParser { try { - // SourceGenTriggers.g:46:2: ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ) + // SourceGenTriggers.g:50:2: ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec ) int alt6=7; alt6 = dfa6.predict(input); switch (alt6) { case 1 : - // SourceGenTriggers.g:46:4: labeledElement + // SourceGenTriggers.g:50:4: labeledElement { pushFollow(FOLLOW_labeledElement_in_element206); labeledElement3=labeledElement(); @@ -448,7 +458,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:47:4: atom[null] + // SourceGenTriggers.g:51:4: atom[null] { pushFollow(FOLLOW_atom_in_element217); atom4=atom(null); @@ -460,7 +470,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:48:4: ebnf + // SourceGenTriggers.g:52:4: ebnf { pushFollow(FOLLOW_ebnf_in_element230); ebnf5=ebnf(); @@ -472,7 +482,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 4 : - // SourceGenTriggers.g:49:6: ACTION + // SourceGenTriggers.g:53:6: ACTION { ACTION6=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_element245); omos = Utils.list(factory.action(ACTION6)); @@ -480,7 +490,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 5 : - // SourceGenTriggers.g:50:6: SEMPRED + // SourceGenTriggers.g:54:6: SEMPRED { SEMPRED7=(GrammarAST)match(input,SEMPRED,FOLLOW_SEMPRED_in_element260); omos = Utils.list(factory.sempred(SEMPRED7)); @@ -488,14 +498,14 @@ public class SourceGenTriggers extends TreeParser { } break; case 6 : - // SourceGenTriggers.g:51:4: GATED_SEMPRED + // SourceGenTriggers.g:55:4: GATED_SEMPRED { match(input,GATED_SEMPRED,FOLLOW_GATED_SEMPRED_in_element273); } break; case 7 : - // SourceGenTriggers.g:52:4: treeSpec + // SourceGenTriggers.g:56:4: treeSpec { pushFollow(FOLLOW_treeSpec_in_element279); treeSpec(); @@ -520,7 +530,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "labeledElement" - // SourceGenTriggers.g:55:1: labeledElement returns [List omos] : ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) ); + // SourceGenTriggers.g:59:1: labeledElement returns [List omos] : ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) ); public final List labeledElement() throws RecognitionException { List omos = null; @@ -538,12 +548,12 @@ public class SourceGenTriggers extends TreeParser { try { - // SourceGenTriggers.g:56:2: ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) ) + // SourceGenTriggers.g:60:2: ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) ) int alt7=4; alt7 = dfa7.predict(input); switch (alt7) { case 1 : - // SourceGenTriggers.g:56:4: ^( ASSIGN ID atom[$ID] ) + // SourceGenTriggers.g:60:4: ^( ASSIGN ID atom[$ID] ) { match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement301); @@ -561,7 +571,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:57:4: ^( ASSIGN ID block[$ID,null] ) + // SourceGenTriggers.g:61:4: ^( ASSIGN ID block[$ID,null] ) { match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement319); @@ -579,7 +589,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:58:4: ^( PLUS_ASSIGN ID atom[$ID] ) + // SourceGenTriggers.g:62:4: ^( PLUS_ASSIGN ID atom[$ID] ) { match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement334); @@ -597,7 +607,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 4 : - // SourceGenTriggers.g:59:4: ^( PLUS_ASSIGN ID block[$ID,null] ) + // SourceGenTriggers.g:63:4: ^( PLUS_ASSIGN ID block[$ID,null] ) { match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement350); @@ -629,7 +639,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "treeSpec" - // SourceGenTriggers.g:62:1: treeSpec returns [SrcOp omo] : ^( TREE_BEGIN (e= element )+ ) ; + // SourceGenTriggers.g:66:1: treeSpec returns [SrcOp omo] : ^( TREE_BEGIN (e= element )+ ) ; public final SrcOp treeSpec() throws RecognitionException { SrcOp omo = null; @@ -637,13 +647,13 @@ public class SourceGenTriggers extends TreeParser { try { - // SourceGenTriggers.g:63:5: ( ^( TREE_BEGIN (e= element )+ ) ) - // SourceGenTriggers.g:63:7: ^( TREE_BEGIN (e= element )+ ) + // SourceGenTriggers.g:67:5: ( ^( TREE_BEGIN (e= element )+ ) ) + // SourceGenTriggers.g:67:7: ^( TREE_BEGIN (e= element )+ ) { match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_treeSpec378); match(input, Token.DOWN, null); - // SourceGenTriggers.g:63:21: (e= element )+ + // SourceGenTriggers.g:67:21: (e= element )+ int cnt8=0; loop8: do { @@ -657,7 +667,7 @@ public class SourceGenTriggers extends TreeParser { switch (alt8) { case 1 : - // SourceGenTriggers.g:63:22: e= element + // SourceGenTriggers.g:67:22: e= element { pushFollow(FOLLOW_element_in_treeSpec384); e=element(); @@ -695,7 +705,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "ebnf" - // SourceGenTriggers.g:66:1: ebnf returns [SrcOp omo] : ( ^( astBlockSuffix block[null,null] ) | ^( OPTIONAL block[null,$OPTIONAL] ) | ^( CLOSURE block[null,$CLOSURE] ) | ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) | block[null, null] ); + // SourceGenTriggers.g:70:1: ebnf returns [SrcOp omo] : ( ^( astBlockSuffix block[null,null] ) | ^( OPTIONAL block[null,$OPTIONAL] ) | ^( CLOSURE block[null,$CLOSURE] ) | ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) | block[null, null] ); public final SrcOp ebnf() throws RecognitionException { SrcOp omo = null; @@ -712,7 +722,7 @@ public class SourceGenTriggers extends TreeParser { try { - // SourceGenTriggers.g:67:2: ( ^( astBlockSuffix block[null,null] ) | ^( OPTIONAL block[null,$OPTIONAL] ) | ^( CLOSURE block[null,$CLOSURE] ) | ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) | block[null, null] ) + // SourceGenTriggers.g:71:2: ( ^( astBlockSuffix block[null,null] ) | ^( OPTIONAL block[null,$OPTIONAL] ) | ^( CLOSURE block[null,$CLOSURE] ) | ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) | block[null, null] ) int alt9=5; switch ( input.LA(1) ) { case IMPLIES: @@ -751,7 +761,7 @@ public class SourceGenTriggers extends TreeParser { switch (alt9) { case 1 : - // SourceGenTriggers.g:67:4: ^( astBlockSuffix block[null,null] ) + // SourceGenTriggers.g:71:4: ^( astBlockSuffix block[null,null] ) { pushFollow(FOLLOW_astBlockSuffix_in_ebnf408); astBlockSuffix(); @@ -771,7 +781,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:68:4: ^( OPTIONAL block[null,$OPTIONAL] ) + // SourceGenTriggers.g:72:4: ^( OPTIONAL block[null,$OPTIONAL] ) { OPTIONAL16=(GrammarAST)match(input,OPTIONAL,FOLLOW_OPTIONAL_in_ebnf420); @@ -788,7 +798,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:69:4: ^( CLOSURE block[null,$CLOSURE] ) + // SourceGenTriggers.g:73:4: ^( CLOSURE block[null,$CLOSURE] ) { CLOSURE18=(GrammarAST)match(input,CLOSURE,FOLLOW_CLOSURE_in_ebnf434); @@ -805,7 +815,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 4 : - // SourceGenTriggers.g:70:4: ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) + // SourceGenTriggers.g:74:4: ^( POSITIVE_CLOSURE block[null,$POSITIVE_CLOSURE] ) { POSITIVE_CLOSURE20=(GrammarAST)match(input,POSITIVE_CLOSURE,FOLLOW_POSITIVE_CLOSURE_in_ebnf449); @@ -822,7 +832,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 5 : - // SourceGenTriggers.g:72:5: block[null, null] + // SourceGenTriggers.g:76:5: block[null, null] { pushFollow(FOLLOW_block_in_ebnf475); block22=block(null, null); @@ -848,10 +858,10 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "astBlockSuffix" - // SourceGenTriggers.g:75:1: astBlockSuffix : ( ROOT | IMPLIES | BANG ); + // SourceGenTriggers.g:79:1: astBlockSuffix : ( ROOT | IMPLIES | BANG ); public final void astBlockSuffix() throws RecognitionException { try { - // SourceGenTriggers.g:76:5: ( ROOT | IMPLIES | BANG ) + // SourceGenTriggers.g:80:5: ( ROOT | IMPLIES | BANG ) // SourceGenTriggers.g: { if ( input.LA(1)==IMPLIES||input.LA(1)==BANG||input.LA(1)==ROOT ) { @@ -879,7 +889,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "atom" - // SourceGenTriggers.g:83:1: atom[GrammarAST label] returns [List omos] : ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] ); + // SourceGenTriggers.g:87:1: atom[GrammarAST label] returns [List omos] : ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] ); public final List atom(GrammarAST label) throws RecognitionException { List omos = null; @@ -895,12 +905,12 @@ public class SourceGenTriggers extends TreeParser { try { - // SourceGenTriggers.g:84:2: ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] ) + // SourceGenTriggers.g:88:2: ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] ) int alt10=12; alt10 = dfa10.predict(input); switch (alt10) { case 1 : - // SourceGenTriggers.g:84:4: ^( ROOT range[label] ) + // SourceGenTriggers.g:88:4: ^( ROOT range[label] ) { match(input,ROOT,FOLLOW_ROOT_in_atom537); @@ -916,7 +926,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:85:4: ^( BANG range[label] ) + // SourceGenTriggers.g:89:4: ^( BANG range[label] ) { match(input,BANG,FOLLOW_BANG_in_atom550); @@ -933,7 +943,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:86:4: ^( ROOT notSet[label] ) + // SourceGenTriggers.g:90:4: ^( ROOT notSet[label] ) { match(input,ROOT,FOLLOW_ROOT_in_atom564); @@ -949,7 +959,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 4 : - // SourceGenTriggers.g:87:4: ^( BANG notSet[label] ) + // SourceGenTriggers.g:91:4: ^( BANG notSet[label] ) { match(input,BANG,FOLLOW_BANG_in_atom577); @@ -966,7 +976,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 5 : - // SourceGenTriggers.g:88:4: notSet[label] + // SourceGenTriggers.g:92:4: notSet[label] { pushFollow(FOLLOW_notSet_in_atom590); notSet(label); @@ -977,7 +987,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 6 : - // SourceGenTriggers.g:89:4: range[label] + // SourceGenTriggers.g:93:4: range[label] { pushFollow(FOLLOW_range_in_atom601); range25=range(label); @@ -989,7 +999,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 7 : - // SourceGenTriggers.g:90:4: ^( DOT ID terminal[label] ) + // SourceGenTriggers.g:94:4: ^( DOT ID terminal[label] ) { match(input,DOT,FOLLOW_DOT_in_atom614); @@ -1006,7 +1016,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 8 : - // SourceGenTriggers.g:91:4: ^( DOT ID ruleref[label] ) + // SourceGenTriggers.g:95:4: ^( DOT ID ruleref[label] ) { match(input,DOT,FOLLOW_DOT_in_atom626); @@ -1023,7 +1033,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 9 : - // SourceGenTriggers.g:92:7: ^( WILDCARD . ) + // SourceGenTriggers.g:96:7: ^( WILDCARD . ) { match(input,WILDCARD,FOLLOW_WILDCARD_in_atom641); @@ -1035,14 +1045,14 @@ public class SourceGenTriggers extends TreeParser { } break; case 10 : - // SourceGenTriggers.g:93:7: WILDCARD + // SourceGenTriggers.g:97:7: WILDCARD { match(input,WILDCARD,FOLLOW_WILDCARD_in_atom656); } break; case 11 : - // SourceGenTriggers.g:94:9: terminal[label] + // SourceGenTriggers.g:98:9: terminal[label] { pushFollow(FOLLOW_terminal_in_atom670); terminal26=terminal(label); @@ -1054,7 +1064,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 12 : - // SourceGenTriggers.g:95:9: ruleref[label] + // SourceGenTriggers.g:99:9: ruleref[label] { pushFollow(FOLLOW_ruleref_in_atom686); ruleref27=ruleref(label); @@ -1080,12 +1090,12 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "notSet" - // SourceGenTriggers.g:98:1: notSet[GrammarAST label] returns [List omos] : ( ^( NOT terminal[label] ) | ^( NOT block[label,null] ) ); + // SourceGenTriggers.g:102:1: notSet[GrammarAST label] returns [List omos] : ( ^( NOT terminal[label] ) | ^( NOT block[label,null] ) ); public final List notSet(GrammarAST label) throws RecognitionException { List omos = null; try { - // SourceGenTriggers.g:99:5: ( ^( NOT terminal[label] ) | ^( NOT block[label,null] ) ) + // SourceGenTriggers.g:103:5: ( ^( NOT terminal[label] ) | ^( NOT block[label,null] ) ) int alt11=2; int LA11_0 = input.LA(1); @@ -1123,7 +1133,7 @@ public class SourceGenTriggers extends TreeParser { } switch (alt11) { case 1 : - // SourceGenTriggers.g:99:7: ^( NOT terminal[label] ) + // SourceGenTriggers.g:103:7: ^( NOT terminal[label] ) { match(input,NOT,FOLLOW_NOT_in_notSet715); @@ -1139,7 +1149,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:100:7: ^( NOT block[label,null] ) + // SourceGenTriggers.g:104:7: ^( NOT block[label,null] ) { match(input,NOT,FOLLOW_NOT_in_notSet730); @@ -1169,7 +1179,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "ruleref" - // SourceGenTriggers.g:103:1: ruleref[GrammarAST label] returns [List omos] : ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ); + // SourceGenTriggers.g:107:1: ruleref[GrammarAST label] returns [List omos] : ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ); public final List ruleref(GrammarAST label) throws RecognitionException { List omos = null; @@ -1179,7 +1189,7 @@ public class SourceGenTriggers extends TreeParser { GrammarAST ARG_ACTION31=null; try { - // SourceGenTriggers.g:104:5: ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ) + // SourceGenTriggers.g:108:5: ( ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) | ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) | ^( RULE_REF ( ARG_ACTION )? ) ) int alt15=3; switch ( input.LA(1) ) { case ROOT: @@ -1206,7 +1216,7 @@ public class SourceGenTriggers extends TreeParser { switch (alt15) { case 1 : - // SourceGenTriggers.g:104:7: ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) + // SourceGenTriggers.g:108:7: ^( ROOT ^( RULE_REF ( ARG_ACTION )? ) ) { match(input,ROOT,FOLLOW_ROOT_in_ruleref760); @@ -1215,7 +1225,7 @@ public class SourceGenTriggers extends TreeParser { if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); - // SourceGenTriggers.g:104:25: ( ARG_ACTION )? + // SourceGenTriggers.g:108:25: ( ARG_ACTION )? int alt12=2; int LA12_0 = input.LA(1); @@ -1224,7 +1234,7 @@ public class SourceGenTriggers extends TreeParser { } switch (alt12) { case 1 : - // SourceGenTriggers.g:104:25: ARG_ACTION + // SourceGenTriggers.g:108:25: ARG_ACTION { match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref765); @@ -1242,7 +1252,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:105:7: ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) + // SourceGenTriggers.g:109:7: ^( BANG ^( RULE_REF ( ARG_ACTION )? ) ) { match(input,BANG,FOLLOW_BANG_in_ruleref777); @@ -1251,7 +1261,7 @@ public class SourceGenTriggers extends TreeParser { if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); - // SourceGenTriggers.g:105:25: ( ARG_ACTION )? + // SourceGenTriggers.g:109:25: ( ARG_ACTION )? int alt13=2; int LA13_0 = input.LA(1); @@ -1260,7 +1270,7 @@ public class SourceGenTriggers extends TreeParser { } switch (alt13) { case 1 : - // SourceGenTriggers.g:105:25: ARG_ACTION + // SourceGenTriggers.g:109:25: ARG_ACTION { ARG_ACTION29=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref782); @@ -1279,13 +1289,13 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:106:7: ^( RULE_REF ( ARG_ACTION )? ) + // SourceGenTriggers.g:110:7: ^( RULE_REF ( ARG_ACTION )? ) { RULE_REF30=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref796); if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); - // SourceGenTriggers.g:106:18: ( ARG_ACTION )? + // SourceGenTriggers.g:110:18: ( ARG_ACTION )? int alt14=2; int LA14_0 = input.LA(1); @@ -1294,7 +1304,7 @@ public class SourceGenTriggers extends TreeParser { } switch (alt14) { case 1 : - // SourceGenTriggers.g:106:18: ARG_ACTION + // SourceGenTriggers.g:110:18: ARG_ACTION { ARG_ACTION31=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref798); @@ -1325,7 +1335,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "range" - // SourceGenTriggers.g:109:1: range[GrammarAST label] returns [List omos] : ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ; + // SourceGenTriggers.g:113:1: range[GrammarAST label] returns [List omos] : ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ; public final List range(GrammarAST label) throws RecognitionException { List omos = null; @@ -1333,8 +1343,8 @@ public class SourceGenTriggers extends TreeParser { GrammarAST b=null; try { - // SourceGenTriggers.g:110:5: ( ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ) - // SourceGenTriggers.g:110:7: ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) + // SourceGenTriggers.g:114:5: ( ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) ) + // SourceGenTriggers.g:114:7: ^( RANGE a= STRING_LITERAL b= STRING_LITERAL ) { match(input,RANGE,FOLLOW_RANGE_in_range827); @@ -1359,7 +1369,7 @@ public class SourceGenTriggers extends TreeParser { // $ANTLR start "terminal" - // SourceGenTriggers.g:113:1: terminal[GrammarAST label] returns [List omos] : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) ); + // SourceGenTriggers.g:117:1: terminal[GrammarAST label] returns [List omos] : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) ); public final List terminal(GrammarAST label) throws RecognitionException { List omos = null; @@ -1371,12 +1381,12 @@ public class SourceGenTriggers extends TreeParser { GrammarAST TOKEN_REF37=null; try { - // SourceGenTriggers.g:114:5: ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) ) + // SourceGenTriggers.g:118:5: ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) ) int alt16=7; alt16 = dfa16.predict(input); switch (alt16) { case 1 : - // SourceGenTriggers.g:114:8: ^( STRING_LITERAL . ) + // SourceGenTriggers.g:118:8: ^( STRING_LITERAL . ) { STRING_LITERAL32=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal865); @@ -1389,7 +1399,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 2 : - // SourceGenTriggers.g:115:7: STRING_LITERAL + // SourceGenTriggers.g:119:7: STRING_LITERAL { STRING_LITERAL33=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal880); omos = factory.stringRef(STRING_LITERAL33, label); @@ -1397,7 +1407,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 3 : - // SourceGenTriggers.g:116:7: ^( TOKEN_REF ARG_ACTION . ) + // SourceGenTriggers.g:120:7: ^( TOKEN_REF ARG_ACTION . ) { TOKEN_REF34=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal894); @@ -1411,7 +1421,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 4 : - // SourceGenTriggers.g:117:7: ^( TOKEN_REF . ) + // SourceGenTriggers.g:121:7: ^( TOKEN_REF . ) { TOKEN_REF36=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal910); @@ -1424,7 +1434,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 5 : - // SourceGenTriggers.g:118:7: TOKEN_REF + // SourceGenTriggers.g:122:7: TOKEN_REF { TOKEN_REF37=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal926); omos = factory.tokenRef(TOKEN_REF37, label, null); @@ -1432,7 +1442,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 6 : - // SourceGenTriggers.g:119:7: ^( ROOT terminal[label] ) + // SourceGenTriggers.g:123:7: ^( ROOT terminal[label] ) { match(input,ROOT,FOLLOW_ROOT_in_terminal941); @@ -1448,7 +1458,7 @@ public class SourceGenTriggers extends TreeParser { } break; case 7 : - // SourceGenTriggers.g:120:7: ^( BANG terminal[label] ) + // SourceGenTriggers.g:124:7: ^( BANG terminal[label] ) { match(input,BANG,FOLLOW_BANG_in_terminal957); @@ -1545,7 +1555,7 @@ public class SourceGenTriggers extends TreeParser { this.transition = DFA6_transition; } public String getDescription() { - return "45:1: element returns [List omos] : ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec );"; + return "49:1: element returns [List omos] : ( labeledElement | atom[null] | ebnf | ACTION | SEMPRED | GATED_SEMPRED | treeSpec );"; } } static final String DFA7_eotS = @@ -1606,7 +1616,7 @@ public class SourceGenTriggers extends TreeParser { this.transition = DFA7_transition; } public String getDescription() { - return "55:1: labeledElement returns [List omos] : ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) );"; + return "59:1: labeledElement returns [List omos] : ( ^( ASSIGN ID atom[$ID] ) | ^( ASSIGN ID block[$ID,null] ) | ^( PLUS_ASSIGN ID atom[$ID] ) | ^( PLUS_ASSIGN ID block[$ID,null] ) );"; } } static final String DFA10_eotS = @@ -1688,7 +1698,7 @@ public class SourceGenTriggers extends TreeParser { this.transition = DFA10_transition; } public String getDescription() { - return "83:1: atom[GrammarAST label] returns [List omos] : ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] );"; + return "87:1: atom[GrammarAST label] returns [List omos] : ( ^( ROOT range[label] ) | ^( BANG range[label] ) | ^( ROOT notSet[label] ) | ^( BANG notSet[label] ) | notSet[label] | range[label] | ^( DOT ID terminal[label] ) | ^( DOT ID ruleref[label] ) | ^( WILDCARD . ) | WILDCARD | terminal[label] | ruleref[label] );"; } } static final String DFA16_eotS = @@ -1754,7 +1764,7 @@ public class SourceGenTriggers extends TreeParser { this.transition = DFA16_transition; } public String getDescription() { - return "113:1: terminal[GrammarAST label] returns [List omos] : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) );"; + return "117:1: terminal[GrammarAST label] returns [List omos] : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) );"; } } diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java index eaed9a31b..fa2fb7bbf 100644 --- a/tool/src/org/antlr/v4/codegen/Target.java +++ b/tool/src/org/antlr/v4/codegen/Target.java @@ -136,6 +136,10 @@ public class Target { return r.name+"_ctx"; } public String getDynamicScopeStructName(String ruleName) { return ruleName+"_scope"; } - + + // should be same for all refs to same token like $ID within single rule function + public String getImplicitTokenLabel(String tokenName) { return "_t"+tokenName; } + public String getImplicitRuleLabel(String ruleName) { return "_r"+ruleName; } + public int getInlineTestsVsBitsetThreshold() { return 20; } } diff --git a/tool/src/org/antlr/v4/codegen/src/Action.java b/tool/src/org/antlr/v4/codegen/src/Action.java index b21ecdf87..c3bc7fe03 100644 --- a/tool/src/org/antlr/v4/codegen/src/Action.java +++ b/tool/src/org/antlr/v4/codegen/src/Action.java @@ -15,7 +15,7 @@ public class Action extends SrcOp { public Action(OutputModelFactory factory, GrammarAST ast) { super(factory,ast); RuleFunction rf = factory.currentRule.peek(); - chunks = ActionTranslator.translateAction(rf, ast.token, (ActionAST)ast); + chunks = ActionTranslator.translateAction(factory,rf, ast.token, (ActionAST)ast); System.out.println("actions="+chunks); } diff --git a/tool/src/org/antlr/v4/codegen/src/InvokeRule.java b/tool/src/org/antlr/v4/codegen/src/InvokeRule.java index c492ae6fe..15c1ee90e 100644 --- a/tool/src/org/antlr/v4/codegen/src/InvokeRule.java +++ b/tool/src/org/antlr/v4/codegen/src/InvokeRule.java @@ -8,23 +8,26 @@ import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.Rule; +import java.util.ArrayList; +import java.util.List; + /** */ public class InvokeRule extends SrcOp implements LabeledOp { public String name; - public String label; + public List labels = new ArrayList(); public String argExprs; public BitSetDecl follow; public String ctxName; public InvokeRule(OutputModelFactory factory, GrammarAST ast, GrammarAST labelAST) { - this.factory = factory; - this.ast = ast; + super(factory, ast); this.name = ast.getText(); Rule r = factory.g.getRule(name); ctxName = factory.gen.target.getRuleFunctionContextStructName(r); if ( labelAST!=null ) { - label = labelAST.getText(); + String label = labelAST.getText(); + labels.add(label); RuleContextDecl d = new RuleContextDecl(factory,label,ctxName); factory.currentRule.peek().addDecl(d); if ( labelAST.parent.getType() == ANTLRParser.PLUS_ASSIGN ) { @@ -36,6 +39,14 @@ public class InvokeRule extends SrcOp implements LabeledOp { argExprs = ast.getChild(0).getText(); } + // If action refs as rulename not label, we need to define implicit label + if ( factory.currentAlt.ruleRefsInActions.containsKey(ast.getText()) ) { + String label = factory.gen.target.getImplicitRuleLabel(ast.getText()); + labels.add(label); + RuleContextDecl d = new RuleContextDecl(factory,label,ctxName); + factory.currentRule.peek().addDecl(d); + } + // compute follow LinearApproximator approx = new LinearApproximator(factory.g, -1); IntervalSet fset = approx.LOOK(ast.nfaState.transition(0).target); @@ -44,7 +55,7 @@ public class InvokeRule extends SrcOp implements LabeledOp { factory.defineBitSet(follow); } - public String getLabel() { - return label; + public List getLabels() { + return labels; } } diff --git a/tool/src/org/antlr/v4/codegen/src/LabeledOp.java b/tool/src/org/antlr/v4/codegen/src/LabeledOp.java index 448470603..4109d7750 100644 --- a/tool/src/org/antlr/v4/codegen/src/LabeledOp.java +++ b/tool/src/org/antlr/v4/codegen/src/LabeledOp.java @@ -1,6 +1,8 @@ package org.antlr.v4.codegen.src; +import java.util.List; + /** */ public interface LabeledOp { - public String getLabel(); + public List getLabels(); } diff --git a/tool/src/org/antlr/v4/codegen/src/MatchToken.java b/tool/src/org/antlr/v4/codegen/src/MatchToken.java index 0db11772d..36dc875a0 100644 --- a/tool/src/org/antlr/v4/codegen/src/MatchToken.java +++ b/tool/src/org/antlr/v4/codegen/src/MatchToken.java @@ -7,18 +7,22 @@ import org.antlr.v4.parse.ANTLRParser; import org.antlr.v4.tool.GrammarAST; import org.antlr.v4.tool.TerminalAST; +import java.util.ArrayList; +import java.util.List; + /** */ public class MatchToken extends SrcOp implements LabeledOp { public String name; public BitSetDecl follow; - public String label; + public List labels = new ArrayList(); public MatchToken(OutputModelFactory factory, TerminalAST ast, GrammarAST labelAST) { - this.factory = factory; + super(factory, ast); int ttype = factory.g.getTokenType(ast.getText()); name = factory.gen.target.getTokenTypeAsTargetLabel(factory.g, ttype); if ( labelAST!=null ) { - label = labelAST.getText(); + String label = labelAST.getText(); + labels.add(label); TokenDecl d = new TokenDecl(factory, label); factory.currentRule.peek().addDecl(d); if ( labelAST.parent.getType() == ANTLRParser.PLUS_ASSIGN ) { @@ -27,6 +31,14 @@ public class MatchToken extends SrcOp implements LabeledOp { } } + // If action refs as token not label, we need to define implicit label + if ( factory.currentAlt.tokenRefsInActions.containsKey(ast.getText()) ) { + String label = factory.gen.target.getImplicitTokenLabel(ast.getText()); + labels.add(label); + TokenDecl d = new TokenDecl(factory, label); + factory.currentRule.peek().addDecl(d); + } + LinearApproximator approx = new LinearApproximator(factory.g, -1); IntervalSet fset = approx.LOOK(ast.nfaState.transition(0).target); System.out.println("follow="+fset); @@ -34,7 +46,5 @@ public class MatchToken extends SrcOp implements LabeledOp { factory.defineBitSet(follow); } - public String getLabel() { - return label; - } + public List getLabels() { return labels; } } diff --git a/tool/src/org/antlr/v4/codegen/src/actions/TokenRef.java b/tool/src/org/antlr/v4/codegen/src/actions/TokenRef.java new file mode 100644 index 000000000..54999cbc6 --- /dev/null +++ b/tool/src/org/antlr/v4/codegen/src/actions/TokenRef.java @@ -0,0 +1,10 @@ +package org.antlr.v4.codegen.src.actions; + +/** */ +public class TokenRef extends ActionChunk { + public String name; + + public TokenRef(String name) { + this.name = name; + } +} diff --git a/tool/src/org/antlr/v4/parse/ANTLRLexer.java b/tool/src/org/antlr/v4/parse/ANTLRLexer.java index 266b45193..f3c37e511 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRLexer.java +++ b/tool/src/org/antlr/v4/parse/ANTLRLexer.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-05-16 13:12:30 +// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-05-19 15:07:23 /* [The "BSD licence"] @@ -264,7 +264,7 @@ public class ANTLRLexer extends Lexer { if ( (( input.LA(2) != '/')) ) { alt3=1; } - else if ( (((( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') ))||( true ))) ) { + else if ( ((( true )||(( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') )))) ) { alt3=2; } else { diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.g b/tool/src/org/antlr/v4/parse/ANTLRParser.g index 23a010c1f..585874549 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.g +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.g @@ -549,15 +549,15 @@ alternative @init { paraphrases.push("matching alternative"); } @after { paraphrases.pop(); } : elements - ( rewrite -> ^(ALT_REWRITE elements rewrite) + ( rewrite -> ^(ALT_REWRITE elements rewrite) | -> elements ) - | rewrite -> ^(ALT_REWRITE ^(ALT EPSILON) rewrite) // empty alt with rewrite - | -> ^(ALT EPSILON) // empty alt + | rewrite -> ^(ALT_REWRITE ^(ALT EPSILON) rewrite) // empty alt with rewrite + | -> ^(ALT EPSILON) // empty alt ; elements - : e+=element+ -> ^(ALT $e+) + : e+=element+ -> ^(ALT $e+) ; element diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.java b/tool/src/org/antlr/v4/parse/ANTLRParser.java index b71018931..d1afa55e4 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.java +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-05-16 13:12:33 +// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-05-19 15:07:26 /* [The "BSD licence"] @@ -339,7 +339,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: prequelConstruct, mode, rules, DOC_COMMENT, id, grammarType + // elements: prequelConstruct, id, DOC_COMMENT, mode, rules, grammarType // token labels: // rule labels: retval // token list labels: @@ -1465,7 +1465,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: TOKENS, tokenSpec + // elements: tokenSpec, TOKENS // token labels: // rule labels: retval // token list labels: @@ -1620,7 +1620,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: STRING_LITERAL, id, ASSIGN + // elements: ASSIGN, id, STRING_LITERAL // token labels: // rule labels: retval // token list labels: @@ -1914,7 +1914,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: actionScopeName, ACTION, id, AT + // elements: AT, id, actionScopeName, ACTION // token labels: // rule labels: retval // token list labels: @@ -2214,7 +2214,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, rule, MODE + // elements: MODE, rule, id // token labels: // rule labels: retval // token list labels: @@ -2606,7 +2606,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: rulePrequels, ARG_ACTION, DOC_COMMENT, ruleReturns, ruleBlock, ruleModifiers, id, exceptionGroup + // elements: exceptionGroup, DOC_COMMENT, ruleBlock, ARG_ACTION, ruleModifiers, id, ruleReturns, rulePrequels // token labels: // rule labels: retval // token list labels: @@ -2835,7 +2835,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: CATCH, ACTION, ARG_ACTION + // elements: ACTION, ARG_ACTION, CATCH // token labels: // rule labels: retval // token list labels: @@ -3352,7 +3352,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: THROWS, qid + // elements: qid, THROWS // token labels: // rule labels: retval // token list labels: @@ -3482,7 +3482,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ACTION, SCOPE + // elements: SCOPE, ACTION // token labels: // rule labels: retval // token list labels: @@ -3561,7 +3561,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: SCOPE, id + // elements: id, SCOPE // token labels: // rule labels: retval // token list labels: @@ -4178,7 +4178,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: rewrite, elements + // elements: elements, rewrite // token labels: // rule labels: retval // token list labels: @@ -4194,7 +4194,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:552:19: ^( ALT_REWRITE elements rewrite ) { GrammarAST root_1 = (GrammarAST)adaptor.nil(); - root_1 = (GrammarAST)adaptor.becomeRoot((GrammarAST)adaptor.create(ALT_REWRITE, "ALT_REWRITE"), root_1); + root_1 = (GrammarAST)adaptor.becomeRoot(new AltAST(ALT_REWRITE), root_1); adaptor.addChild(root_1, stream_elements.nextTree()); adaptor.addChild(root_1, stream_rewrite.nextTree()); @@ -4241,7 +4241,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:555:7: rewrite { - pushFollow(FOLLOW_rewrite_in_alternative2619); + pushFollow(FOLLOW_rewrite_in_alternative2622); rewrite112=rewrite(); state._fsp--; @@ -4266,12 +4266,12 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:555:19: ^( ALT_REWRITE ^( ALT EPSILON ) rewrite ) { GrammarAST root_1 = (GrammarAST)adaptor.nil(); - root_1 = (GrammarAST)adaptor.becomeRoot((GrammarAST)adaptor.create(ALT_REWRITE, "ALT_REWRITE"), root_1); + root_1 = (GrammarAST)adaptor.becomeRoot(new AltAST(ALT_REWRITE), root_1); - // ANTLRParser.g:555:33: ^( ALT EPSILON ) + // ANTLRParser.g:555:41: ^( ALT EPSILON ) { GrammarAST root_2 = (GrammarAST)adaptor.nil(); - root_2 = (GrammarAST)adaptor.becomeRoot((GrammarAST)adaptor.create(ALT, "ALT"), root_2); + root_2 = (GrammarAST)adaptor.becomeRoot(new AltAST(ALT), root_2); adaptor.addChild(root_2, (GrammarAST)adaptor.create(EPSILON, "EPSILON")); @@ -4308,7 +4308,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:556:13: ^( ALT EPSILON ) { GrammarAST root_1 = (GrammarAST)adaptor.nil(); - root_1 = (GrammarAST)adaptor.becomeRoot((GrammarAST)adaptor.create(ALT, "ALT"), root_1); + root_1 = (GrammarAST)adaptor.becomeRoot(new AltAST(ALT), root_1); adaptor.addChild(root_1, (GrammarAST)adaptor.create(EPSILON, "EPSILON")); @@ -4381,7 +4381,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:560:8: e+= element { - pushFollow(FOLLOW_element_in_elements2672); + pushFollow(FOLLOW_element_in_elements2684); e=element(); state._fsp--; @@ -4423,7 +4423,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:560:22: ^( ALT ( $e)+ ) { GrammarAST root_1 = (GrammarAST)adaptor.nil(); - root_1 = (GrammarAST)adaptor.becomeRoot((GrammarAST)adaptor.create(ALT, "ALT"), root_1); + root_1 = (GrammarAST)adaptor.becomeRoot(new AltAST(ALT), root_1); if ( !(stream_e.hasNext()) ) { throw new RewriteEarlyExitException(); @@ -4514,7 +4514,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:569:4: labeledElement ( ebnfSuffix -> ^( ebnfSuffix ^( BLOCK[$labeledElement.start,\"BLOCK\"] ^( ALT labeledElement ) ) ) | -> labeledElement ) { - pushFollow(FOLLOW_labeledElement_in_element2709); + pushFollow(FOLLOW_labeledElement_in_element2724); labeledElement113=labeledElement(); state._fsp--; @@ -4541,7 +4541,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:570:5: ebnfSuffix { - pushFollow(FOLLOW_ebnfSuffix_in_element2715); + pushFollow(FOLLOW_ebnfSuffix_in_element2730); ebnfSuffix114=ebnfSuffix(); state._fsp--; @@ -4550,7 +4550,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: labeledElement, ebnfSuffix + // elements: ebnfSuffix, labeledElement // token labels: // rule labels: retval // token list labels: @@ -4628,7 +4628,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:573:4: atom ( ebnfSuffix -> ^( ebnfSuffix ^( BLOCK[$atom.start,\"BLOCK\"] ^( ALT atom ) ) ) | -> atom ) { - pushFollow(FOLLOW_atom_in_element2758); + pushFollow(FOLLOW_atom_in_element2773); atom115=atom(); state._fsp--; @@ -4655,7 +4655,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:574:5: ebnfSuffix { - pushFollow(FOLLOW_ebnfSuffix_in_element2764); + pushFollow(FOLLOW_ebnfSuffix_in_element2779); ebnfSuffix116=ebnfSuffix(); state._fsp--; @@ -4744,7 +4744,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_ebnf_in_element2807); + pushFollow(FOLLOW_ebnf_in_element2822); ebnf117=ebnf(); state._fsp--; @@ -4758,7 +4758,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - ACTION118=(Token)match(input,ACTION,FOLLOW_ACTION_in_element2814); if (state.failed) return retval; + ACTION118=(Token)match(input,ACTION,FOLLOW_ACTION_in_element2829); if (state.failed) return retval; if ( state.backtracking==0 ) { ACTION118_tree = new ActionAST(ACTION118) ; adaptor.addChild(root_0, ACTION118_tree); @@ -4769,7 +4769,7 @@ public class ANTLRParser extends Parser { case 5 : // ANTLRParser.g:579:6: SEMPRED ( IMPLIES -> GATED_SEMPRED[$IMPLIES] | -> SEMPRED ) { - SEMPRED119=(Token)match(input,SEMPRED,FOLLOW_SEMPRED_in_element2824); if (state.failed) return retval; + SEMPRED119=(Token)match(input,SEMPRED,FOLLOW_SEMPRED_in_element2839); if (state.failed) return retval; if ( state.backtracking==0 ) stream_SEMPRED.add(SEMPRED119); // ANTLRParser.g:580:3: ( IMPLIES -> GATED_SEMPRED[$IMPLIES] | -> SEMPRED ) @@ -4793,7 +4793,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:580:5: IMPLIES { - IMPLIES120=(Token)match(input,IMPLIES,FOLLOW_IMPLIES_in_element2830); if (state.failed) return retval; + IMPLIES120=(Token)match(input,IMPLIES,FOLLOW_IMPLIES_in_element2845); if (state.failed) return retval; if ( state.backtracking==0 ) stream_IMPLIES.add(IMPLIES120); @@ -4853,7 +4853,7 @@ public class ANTLRParser extends Parser { case 6 : // ANTLRParser.g:583:6: treeSpec ( ebnfSuffix -> ^( ebnfSuffix ^( BLOCK[$treeSpec.start,\"BLOCK\"] ^( ALT treeSpec ) ) ) | -> treeSpec ) { - pushFollow(FOLLOW_treeSpec_in_element2858); + pushFollow(FOLLOW_treeSpec_in_element2873); treeSpec121=treeSpec(); state._fsp--; @@ -4880,7 +4880,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:584:5: ebnfSuffix { - pushFollow(FOLLOW_ebnfSuffix_in_element2864); + pushFollow(FOLLOW_ebnfSuffix_in_element2879); ebnfSuffix122=ebnfSuffix(); state._fsp--; @@ -5060,7 +5060,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_id_in_labeledElement2926); + pushFollow(FOLLOW_id_in_labeledElement2941); id123=id(); state._fsp--; @@ -5087,7 +5087,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:659:22: ASSIGN { - ASSIGN124=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement2929); if (state.failed) return retval; + ASSIGN124=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement2944); if (state.failed) return retval; if ( state.backtracking==0 ) { ASSIGN124_tree = (GrammarAST)adaptor.create(ASSIGN124); root_0 = (GrammarAST)adaptor.becomeRoot(ASSIGN124_tree, root_0); @@ -5098,7 +5098,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:659:30: PLUS_ASSIGN { - PLUS_ASSIGN125=(Token)match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement2932); if (state.failed) return retval; + PLUS_ASSIGN125=(Token)match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement2947); if (state.failed) return retval; if ( state.backtracking==0 ) { PLUS_ASSIGN125_tree = (GrammarAST)adaptor.create(PLUS_ASSIGN125); root_0 = (GrammarAST)adaptor.becomeRoot(PLUS_ASSIGN125_tree, root_0); @@ -5130,7 +5130,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:659:45: atom { - pushFollow(FOLLOW_atom_in_labeledElement2937); + pushFollow(FOLLOW_atom_in_labeledElement2952); atom126=atom(); state._fsp--; @@ -5142,7 +5142,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:659:50: block { - pushFollow(FOLLOW_block_in_labeledElement2939); + pushFollow(FOLLOW_block_in_labeledElement2954); block127=block(); state._fsp--; @@ -5206,10 +5206,10 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:666:5: ( TREE_BEGIN element ( element )+ RPAREN -> ^( TREE_BEGIN ( element )+ ) ) // ANTLRParser.g:666:7: TREE_BEGIN element ( element )+ RPAREN { - TREE_BEGIN128=(Token)match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_treeSpec2957); if (state.failed) return retval; + TREE_BEGIN128=(Token)match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_treeSpec2972); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TREE_BEGIN.add(TREE_BEGIN128); - pushFollow(FOLLOW_element_in_treeSpec2998); + pushFollow(FOLLOW_element_in_treeSpec3013); element129=element(); state._fsp--; @@ -5231,7 +5231,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:673:10: element { - pushFollow(FOLLOW_element_in_treeSpec3029); + pushFollow(FOLLOW_element_in_treeSpec3044); element130=element(); state._fsp--; @@ -5251,13 +5251,13 @@ public class ANTLRParser extends Parser { cnt40++; } while (true); - RPAREN131=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_treeSpec3038); if (state.failed) return retval; + RPAREN131=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_treeSpec3053); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN131); // AST REWRITE - // elements: element, TREE_BEGIN + // elements: TREE_BEGIN, element // token labels: // rule labels: retval // token list labels: @@ -5336,7 +5336,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:681:5: ( block ( blockSuffixe -> ^( blockSuffixe block ) | -> block ) ) // ANTLRParser.g:681:7: block ( blockSuffixe -> ^( blockSuffixe block ) | -> block ) { - pushFollow(FOLLOW_block_in_ebnf3072); + pushFollow(FOLLOW_block_in_ebnf3087); block132=block(); state._fsp--; @@ -5363,7 +5363,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:685:9: blockSuffixe { - pushFollow(FOLLOW_blockSuffixe_in_ebnf3107); + pushFollow(FOLLOW_blockSuffixe_in_ebnf3122); blockSuffixe133=blockSuffixe(); state._fsp--; @@ -5514,7 +5514,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_ebnfSuffix_in_blockSuffixe3158); + pushFollow(FOLLOW_ebnfSuffix_in_blockSuffixe3173); ebnfSuffix134=ebnfSuffix(); state._fsp--; @@ -5528,7 +5528,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - ROOT135=(Token)match(input,ROOT,FOLLOW_ROOT_in_blockSuffixe3172); if (state.failed) return retval; + ROOT135=(Token)match(input,ROOT,FOLLOW_ROOT_in_blockSuffixe3187); if (state.failed) return retval; if ( state.backtracking==0 ) { ROOT135_tree = (GrammarAST)adaptor.create(ROOT135); adaptor.addChild(root_0, ROOT135_tree); @@ -5541,7 +5541,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - IMPLIES136=(Token)match(input,IMPLIES,FOLLOW_IMPLIES_in_blockSuffixe3180); if (state.failed) return retval; + IMPLIES136=(Token)match(input,IMPLIES,FOLLOW_IMPLIES_in_blockSuffixe3195); if (state.failed) return retval; if ( state.backtracking==0 ) { IMPLIES136_tree = (GrammarAST)adaptor.create(IMPLIES136); adaptor.addChild(root_0, IMPLIES136_tree); @@ -5554,7 +5554,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - BANG137=(Token)match(input,BANG,FOLLOW_BANG_in_blockSuffixe3191); if (state.failed) return retval; + BANG137=(Token)match(input,BANG,FOLLOW_BANG_in_blockSuffixe3206); if (state.failed) return retval; if ( state.backtracking==0 ) { BANG137_tree = (GrammarAST)adaptor.create(BANG137); adaptor.addChild(root_0, BANG137_tree); @@ -5642,7 +5642,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:705:4: QUESTION { - QUESTION138=(Token)match(input,QUESTION,FOLLOW_QUESTION_in_ebnfSuffix3210); if (state.failed) return retval; + QUESTION138=(Token)match(input,QUESTION,FOLLOW_QUESTION_in_ebnfSuffix3225); if (state.failed) return retval; if ( state.backtracking==0 ) stream_QUESTION.add(QUESTION138); @@ -5671,7 +5671,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:706:6: STAR { - STAR139=(Token)match(input,STAR,FOLLOW_STAR_in_ebnfSuffix3222); if (state.failed) return retval; + STAR139=(Token)match(input,STAR,FOLLOW_STAR_in_ebnfSuffix3237); if (state.failed) return retval; if ( state.backtracking==0 ) stream_STAR.add(STAR139); @@ -5700,7 +5700,7 @@ public class ANTLRParser extends Parser { case 3 : // ANTLRParser.g:707:7: PLUS { - PLUS140=(Token)match(input,PLUS,FOLLOW_PLUS_in_ebnfSuffix3237); if (state.failed) return retval; + PLUS140=(Token)match(input,PLUS,FOLLOW_PLUS_in_ebnfSuffix3252); if (state.failed) return retval; if ( state.backtracking==0 ) stream_PLUS.add(PLUS140); @@ -5812,16 +5812,16 @@ public class ANTLRParser extends Parser { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "atom", "\n\t \tinput.LT(1).getCharPositionInLine()+input.LT(1).getText().length()==\n\t input.LT(2).getCharPositionInLine() &&\n\t input.LT(2).getCharPositionInLine()+1==input.LT(3).getCharPositionInLine()\n\t "); } - pushFollow(FOLLOW_id_in_atom3285); + pushFollow(FOLLOW_id_in_atom3300); id141=id(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_id.add(id141.getTree()); - DOT142=(Token)match(input,DOT,FOLLOW_DOT_in_atom3287); if (state.failed) return retval; + DOT142=(Token)match(input,DOT,FOLLOW_DOT_in_atom3302); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOT.add(DOT142); - pushFollow(FOLLOW_ruleref_in_atom3289); + pushFollow(FOLLOW_ruleref_in_atom3304); ruleref143=ruleref(); state._fsp--; @@ -5830,7 +5830,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ruleref, id, DOT + // elements: id, ruleref, DOT // token labels: // rule labels: retval // token list labels: @@ -5864,7 +5864,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_range_in_atom3309); + pushFollow(FOLLOW_range_in_atom3324); range144=range(); state._fsp--; @@ -5884,7 +5884,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:720:19: ROOT { - ROOT145=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3315); if (state.failed) return retval; + ROOT145=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3330); if (state.failed) return retval; if ( state.backtracking==0 ) { ROOT145_tree = (GrammarAST)adaptor.create(ROOT145); root_0 = (GrammarAST)adaptor.becomeRoot(ROOT145_tree, root_0); @@ -5895,7 +5895,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:720:27: BANG { - BANG146=(Token)match(input,BANG,FOLLOW_BANG_in_atom3320); if (state.failed) return retval; + BANG146=(Token)match(input,BANG,FOLLOW_BANG_in_atom3335); if (state.failed) return retval; if ( state.backtracking==0 ) { BANG146_tree = (GrammarAST)adaptor.create(BANG146); root_0 = (GrammarAST)adaptor.becomeRoot(BANG146_tree, root_0); @@ -5914,7 +5914,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_terminal_in_atom3329); + pushFollow(FOLLOW_terminal_in_atom3344); terminal147=terminal(); state._fsp--; @@ -5934,7 +5934,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:721:14: ROOT { - ROOT148=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3332); if (state.failed) return retval; + ROOT148=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3347); if (state.failed) return retval; if ( state.backtracking==0 ) { ROOT148_tree = (GrammarAST)adaptor.create(ROOT148); root_0 = (GrammarAST)adaptor.becomeRoot(ROOT148_tree, root_0); @@ -5945,7 +5945,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:721:22: BANG { - BANG149=(Token)match(input,BANG,FOLLOW_BANG_in_atom3337); if (state.failed) return retval; + BANG149=(Token)match(input,BANG,FOLLOW_BANG_in_atom3352); if (state.failed) return retval; if ( state.backtracking==0 ) { BANG149_tree = (GrammarAST)adaptor.create(BANG149); root_0 = (GrammarAST)adaptor.becomeRoot(BANG149_tree, root_0); @@ -5964,7 +5964,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_ruleref_in_atom3350); + pushFollow(FOLLOW_ruleref_in_atom3365); ruleref150=ruleref(); state._fsp--; @@ -5978,7 +5978,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_notSet_in_atom3358); + pushFollow(FOLLOW_notSet_in_atom3373); notSet151=notSet(); state._fsp--; @@ -5998,7 +5998,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:723:17: ROOT { - ROOT152=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3363); if (state.failed) return retval; + ROOT152=(Token)match(input,ROOT,FOLLOW_ROOT_in_atom3378); if (state.failed) return retval; if ( state.backtracking==0 ) { ROOT152_tree = (GrammarAST)adaptor.create(ROOT152); root_0 = (GrammarAST)adaptor.becomeRoot(ROOT152_tree, root_0); @@ -6009,7 +6009,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:723:23: BANG { - BANG153=(Token)match(input,BANG,FOLLOW_BANG_in_atom3366); if (state.failed) return retval; + BANG153=(Token)match(input,BANG,FOLLOW_BANG_in_atom3381); if (state.failed) return retval; if ( state.backtracking==0 ) { BANG153_tree = (GrammarAST)adaptor.create(BANG153); root_0 = (GrammarAST)adaptor.becomeRoot(BANG153_tree, root_0); @@ -6026,7 +6026,7 @@ public class ANTLRParser extends Parser { case 6 : // ANTLRParser.g:729:6: DOT ( elementOptions )? { - DOT154=(Token)match(input,DOT,FOLLOW_DOT_in_atom3394); if (state.failed) return retval; + DOT154=(Token)match(input,DOT,FOLLOW_DOT_in_atom3409); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOT.add(DOT154); // ANTLRParser.g:729:10: ( elementOptions )? @@ -6040,7 +6040,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:729:10: elementOptions { - pushFollow(FOLLOW_elementOptions_in_atom3396); + pushFollow(FOLLOW_elementOptions_in_atom3411); elementOptions155=elementOptions(); state._fsp--; @@ -6165,10 +6165,10 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:740:7: NOT terminal { - NOT156=(Token)match(input,NOT,FOLLOW_NOT_in_notSet3454); if (state.failed) return retval; + NOT156=(Token)match(input,NOT,FOLLOW_NOT_in_notSet3469); if (state.failed) return retval; if ( state.backtracking==0 ) stream_NOT.add(NOT156); - pushFollow(FOLLOW_terminal_in_notSet3456); + pushFollow(FOLLOW_terminal_in_notSet3471); terminal157=terminal(); state._fsp--; @@ -6208,10 +6208,10 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:741:7: NOT block { - NOT158=(Token)match(input,NOT,FOLLOW_NOT_in_notSet3472); if (state.failed) return retval; + NOT158=(Token)match(input,NOT,FOLLOW_NOT_in_notSet3487); if (state.failed) return retval; if ( state.backtracking==0 ) stream_NOT.add(NOT158); - pushFollow(FOLLOW_block_in_notSet3474); + pushFollow(FOLLOW_block_in_notSet3489); block159=block(); state._fsp--; @@ -6220,7 +6220,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: block, NOT + // elements: NOT, block // token labels: // rule labels: retval // token list labels: @@ -6305,7 +6305,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:752:5: ( LPAREN ( ( optionsSpec )? (ra+= ruleAction )* COLON )? altList RPAREN -> ^( BLOCK[$LPAREN,\"BLOCK\"] ( optionsSpec )? ( $ra)* altList ) ) // ANTLRParser.g:752:7: LPAREN ( ( optionsSpec )? (ra+= ruleAction )* COLON )? altList RPAREN { - LPAREN160=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_block3507); if (state.failed) return retval; + LPAREN160=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_block3522); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN160); // ANTLRParser.g:755:10: ( ( optionsSpec )? (ra+= ruleAction )* COLON )? @@ -6330,7 +6330,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:755:12: optionsSpec { - pushFollow(FOLLOW_optionsSpec_in_block3544); + pushFollow(FOLLOW_optionsSpec_in_block3559); optionsSpec161=optionsSpec(); state._fsp--; @@ -6357,7 +6357,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:755:27: ra+= ruleAction { - pushFollow(FOLLOW_ruleAction_in_block3549); + pushFollow(FOLLOW_ruleAction_in_block3564); ra=ruleAction(); state._fsp--; @@ -6375,7 +6375,7 @@ public class ANTLRParser extends Parser { } } while (true); - COLON162=(Token)match(input,COLON,FOLLOW_COLON_in_block3552); if (state.failed) return retval; + COLON162=(Token)match(input,COLON,FOLLOW_COLON_in_block3567); if (state.failed) return retval; if ( state.backtracking==0 ) stream_COLON.add(COLON162); @@ -6384,13 +6384,13 @@ public class ANTLRParser extends Parser { } - pushFollow(FOLLOW_altList_in_block3566); + pushFollow(FOLLOW_altList_in_block3581); altList163=altList(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_altList.add(altList163.getTree()); - RPAREN164=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_block3583); if (state.failed) return retval; + RPAREN164=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_block3598); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN164); @@ -6485,7 +6485,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:768:5: ( RULE_REF ( ARG_ACTION )? ( (op= ROOT | op= BANG ) -> ^( $op ^( RULE_REF ( ARG_ACTION )? ) ) | -> ^( RULE_REF ( ARG_ACTION )? ) ) ) // ANTLRParser.g:768:7: RULE_REF ( ARG_ACTION )? ( (op= ROOT | op= BANG ) -> ^( $op ^( RULE_REF ( ARG_ACTION )? ) ) | -> ^( RULE_REF ( ARG_ACTION )? ) ) { - RULE_REF165=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref3633); if (state.failed) return retval; + RULE_REF165=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref3648); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RULE_REF.add(RULE_REF165); // ANTLRParser.g:768:16: ( ARG_ACTION )? @@ -6499,7 +6499,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:768:16: ARG_ACTION { - ARG_ACTION166=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref3635); if (state.failed) return retval; + ARG_ACTION166=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref3650); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ARG_ACTION.add(ARG_ACTION166); @@ -6550,7 +6550,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:769:6: op= ROOT { - op=(Token)match(input,ROOT,FOLLOW_ROOT_in_ruleref3645); if (state.failed) return retval; + op=(Token)match(input,ROOT,FOLLOW_ROOT_in_ruleref3660); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ROOT.add(op); @@ -6559,7 +6559,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:769:14: op= BANG { - op=(Token)match(input,BANG,FOLLOW_BANG_in_ruleref3649); if (state.failed) return retval; + op=(Token)match(input,BANG,FOLLOW_BANG_in_ruleref3664); if (state.failed) return retval; if ( state.backtracking==0 ) stream_BANG.add(op); @@ -6618,7 +6618,7 @@ public class ANTLRParser extends Parser { { // AST REWRITE - // elements: ARG_ACTION, RULE_REF + // elements: RULE_REF, ARG_ACTION // token labels: // rule labels: retval // token list labels: @@ -6701,17 +6701,17 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - STRING_LITERAL167=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range3723); if (state.failed) return retval; + STRING_LITERAL167=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range3738); if (state.failed) return retval; if ( state.backtracking==0 ) { STRING_LITERAL167_tree = new TerminalAST(STRING_LITERAL167) ; adaptor.addChild(root_0, STRING_LITERAL167_tree); } - RANGE168=(Token)match(input,RANGE,FOLLOW_RANGE_in_range3728); if (state.failed) return retval; + RANGE168=(Token)match(input,RANGE,FOLLOW_RANGE_in_range3743); if (state.failed) return retval; if ( state.backtracking==0 ) { RANGE168_tree = (GrammarAST)adaptor.create(RANGE168); root_0 = (GrammarAST)adaptor.becomeRoot(RANGE168_tree, root_0); } - STRING_LITERAL169=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range3731); if (state.failed) return retval; + STRING_LITERAL169=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range3746); if (state.failed) return retval; if ( state.backtracking==0 ) { STRING_LITERAL169_tree = new TerminalAST(STRING_LITERAL169) ; adaptor.addChild(root_0, STRING_LITERAL169_tree); @@ -6789,7 +6789,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:790:3: TOKEN_REF ( ARG_ACTION )? ( elementOptions )? { - TOKEN_REF170=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal3756); if (state.failed) return retval; + TOKEN_REF170=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal3771); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TOKEN_REF.add(TOKEN_REF170); // ANTLRParser.g:790:13: ( ARG_ACTION )? @@ -6803,7 +6803,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:790:13: ARG_ACTION { - ARG_ACTION171=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_terminal3758); if (state.failed) return retval; + ARG_ACTION171=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_terminal3773); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ARG_ACTION.add(ARG_ACTION171); @@ -6823,7 +6823,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:790:25: elementOptions { - pushFollow(FOLLOW_elementOptions_in_terminal3761); + pushFollow(FOLLOW_elementOptions_in_terminal3776); elementOptions172=elementOptions(); state._fsp--; @@ -6838,7 +6838,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: TOKEN_REF, elementOptions, ARG_ACTION + // elements: elementOptions, ARG_ACTION, TOKEN_REF // token labels: // rule labels: retval // token list labels: @@ -6880,7 +6880,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:791:6: STRING_LITERAL ( elementOptions )? { - STRING_LITERAL173=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal3784); if (state.failed) return retval; + STRING_LITERAL173=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal3799); if (state.failed) return retval; if ( state.backtracking==0 ) stream_STRING_LITERAL.add(STRING_LITERAL173); // ANTLRParser.g:791:21: ( elementOptions )? @@ -6894,7 +6894,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:791:21: elementOptions { - pushFollow(FOLLOW_elementOptions_in_terminal3786); + pushFollow(FOLLOW_elementOptions_in_terminal3801); elementOptions174=elementOptions(); state._fsp--; @@ -6909,7 +6909,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: STRING_LITERAL, elementOptions + // elements: elementOptions, STRING_LITERAL // token labels: // rule labels: retval // token list labels: @@ -6996,10 +6996,10 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:797:5: ( LT elementOption ( COMMA elementOption )* GT -> ^( ELEMENT_OPTIONS ( elementOption )+ ) ) // ANTLRParser.g:797:7: LT elementOption ( COMMA elementOption )* GT { - LT175=(Token)match(input,LT,FOLLOW_LT_in_elementOptions3818); if (state.failed) return retval; + LT175=(Token)match(input,LT,FOLLOW_LT_in_elementOptions3833); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LT.add(LT175); - pushFollow(FOLLOW_elementOption_in_elementOptions3820); + pushFollow(FOLLOW_elementOption_in_elementOptions3835); elementOption176=elementOption(); state._fsp--; @@ -7020,10 +7020,10 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:797:25: COMMA elementOption { - COMMA177=(Token)match(input,COMMA,FOLLOW_COMMA_in_elementOptions3823); if (state.failed) return retval; + COMMA177=(Token)match(input,COMMA,FOLLOW_COMMA_in_elementOptions3838); if (state.failed) return retval; if ( state.backtracking==0 ) stream_COMMA.add(COMMA177); - pushFollow(FOLLOW_elementOption_in_elementOptions3825); + pushFollow(FOLLOW_elementOption_in_elementOptions3840); elementOption178=elementOption(); state._fsp--; @@ -7038,7 +7038,7 @@ public class ANTLRParser extends Parser { } } while (true); - GT179=(Token)match(input,GT,FOLLOW_GT_in_elementOptions3829); if (state.failed) return retval; + GT179=(Token)match(input,GT,FOLLOW_GT_in_elementOptions3844); if (state.failed) return retval; if ( state.backtracking==0 ) stream_GT.add(GT179); @@ -7199,7 +7199,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_qid_in_elementOption3864); + pushFollow(FOLLOW_qid_in_elementOption3879); qid180=qid(); state._fsp--; @@ -7213,13 +7213,13 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_id_in_elementOption3886); + pushFollow(FOLLOW_id_in_elementOption3901); id181=id(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) adaptor.addChild(root_0, id181.getTree()); - ASSIGN182=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption3888); if (state.failed) return retval; + ASSIGN182=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption3903); if (state.failed) return retval; if ( state.backtracking==0 ) { ASSIGN182_tree = (GrammarAST)adaptor.create(ASSIGN182); root_0 = (GrammarAST)adaptor.becomeRoot(ASSIGN182_tree, root_0); @@ -7245,7 +7245,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:807:19: qid { - pushFollow(FOLLOW_qid_in_elementOption3892); + pushFollow(FOLLOW_qid_in_elementOption3907); qid183=qid(); state._fsp--; @@ -7257,7 +7257,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:807:25: STRING_LITERAL { - STRING_LITERAL184=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_elementOption3896); if (state.failed) return retval; + STRING_LITERAL184=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_elementOption3911); if (state.failed) return retval; if ( state.backtracking==0 ) { STRING_LITERAL184_tree = new TerminalAST(STRING_LITERAL184) ; adaptor.addChild(root_0, STRING_LITERAL184_tree); @@ -7338,7 +7338,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:811:4: predicatedRewrite { - pushFollow(FOLLOW_predicatedRewrite_in_rewrite3914); + pushFollow(FOLLOW_predicatedRewrite_in_rewrite3929); predicatedRewrite185=predicatedRewrite(); state._fsp--; @@ -7353,7 +7353,7 @@ public class ANTLRParser extends Parser { } } while (true); - pushFollow(FOLLOW_nakedRewrite_in_rewrite3917); + pushFollow(FOLLOW_nakedRewrite_in_rewrite3932); nakedRewrite186=nakedRewrite(); state._fsp--; @@ -7362,7 +7362,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: nakedRewrite, predicatedRewrite + // elements: predicatedRewrite, nakedRewrite // token labels: // rule labels: retval // token list labels: @@ -7435,13 +7435,13 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:815:2: ( RARROW SEMPRED rewriteAlt -> {$rewriteAlt.isTemplate}? ^( ST_RESULT[$RARROW] SEMPRED rewriteAlt ) -> ^( RESULT[$RARROW] SEMPRED rewriteAlt ) ) // ANTLRParser.g:815:4: RARROW SEMPRED rewriteAlt { - RARROW187=(Token)match(input,RARROW,FOLLOW_RARROW_in_predicatedRewrite3935); if (state.failed) return retval; + RARROW187=(Token)match(input,RARROW,FOLLOW_RARROW_in_predicatedRewrite3950); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RARROW.add(RARROW187); - SEMPRED188=(Token)match(input,SEMPRED,FOLLOW_SEMPRED_in_predicatedRewrite3937); if (state.failed) return retval; + SEMPRED188=(Token)match(input,SEMPRED,FOLLOW_SEMPRED_in_predicatedRewrite3952); if (state.failed) return retval; if ( state.backtracking==0 ) stream_SEMPRED.add(SEMPRED188); - pushFollow(FOLLOW_rewriteAlt_in_predicatedRewrite3939); + pushFollow(FOLLOW_rewriteAlt_in_predicatedRewrite3954); rewriteAlt189=rewriteAlt(); state._fsp--; @@ -7537,10 +7537,10 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:821:2: ( RARROW rewriteAlt -> {$rewriteAlt.isTemplate}? ^( ST_RESULT[$RARROW] rewriteAlt ) -> ^( RESULT[$RARROW] rewriteAlt ) ) // ANTLRParser.g:821:4: RARROW rewriteAlt { - RARROW190=(Token)match(input,RARROW,FOLLOW_RARROW_in_nakedRewrite3979); if (state.failed) return retval; + RARROW190=(Token)match(input,RARROW,FOLLOW_RARROW_in_nakedRewrite3994); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RARROW.add(RARROW190); - pushFollow(FOLLOW_rewriteAlt_in_nakedRewrite3981); + pushFollow(FOLLOW_rewriteAlt_in_nakedRewrite3996); rewriteAlt191=rewriteAlt(); state._fsp--; @@ -7642,7 +7642,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteTemplate_in_rewriteAlt4045); + pushFollow(FOLLOW_rewriteTemplate_in_rewriteAlt4060); rewriteTemplate192=rewriteTemplate(); state._fsp--; @@ -7659,7 +7659,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteAlt4084); + pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteAlt4099); rewriteTreeAlt193=rewriteTreeAlt(); state._fsp--; @@ -7673,7 +7673,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - ETC194=(Token)match(input,ETC,FOLLOW_ETC_in_rewriteAlt4093); if (state.failed) return retval; + ETC194=(Token)match(input,ETC,FOLLOW_ETC_in_rewriteAlt4108); if (state.failed) return retval; if ( state.backtracking==0 ) { ETC194_tree = (GrammarAST)adaptor.create(ETC194); adaptor.addChild(root_0, ETC194_tree); @@ -7765,7 +7765,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:844:7: rewriteTreeElement { - pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTreeAlt4124); + pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTreeAlt4139); rewriteTreeElement195=rewriteTreeElement(); state._fsp--; @@ -7882,7 +7882,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4148); + pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4163); rewriteTreeAtom196=rewriteTreeAtom(); state._fsp--; @@ -7894,13 +7894,13 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:849:4: rewriteTreeAtom ebnfSuffix { - pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4153); + pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4168); rewriteTreeAtom197=rewriteTreeAtom(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_rewriteTreeAtom.add(rewriteTreeAtom197.getTree()); - pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeElement4155); + pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeElement4170); ebnfSuffix198=ebnfSuffix(); state._fsp--; @@ -7956,7 +7956,7 @@ public class ANTLRParser extends Parser { case 3 : // ANTLRParser.g:850:6: rewriteTree ( ebnfSuffix -> ^( ebnfSuffix ^( REWRITE_BLOCK ^( ALT rewriteTree ) ) ) | -> rewriteTree ) { - pushFollow(FOLLOW_rewriteTree_in_rewriteTreeElement4180); + pushFollow(FOLLOW_rewriteTree_in_rewriteTreeElement4195); rewriteTree199=rewriteTree(); state._fsp--; @@ -7983,7 +7983,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:851:5: ebnfSuffix { - pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeElement4186); + pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeElement4201); ebnfSuffix200=ebnfSuffix(); state._fsp--; @@ -7992,7 +7992,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ebnfSuffix, rewriteTree + // elements: rewriteTree, ebnfSuffix // token labels: // rule labels: retval // token list labels: @@ -8072,7 +8072,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteTreeEbnf_in_rewriteTreeElement4225); + pushFollow(FOLLOW_rewriteTreeEbnf_in_rewriteTreeElement4240); rewriteTreeEbnf201=rewriteTreeEbnf(); state._fsp--; @@ -8182,7 +8182,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:859:9: TOKEN_REF ( elementOptions )? ( ARG_ACTION )? { - TOKEN_REF202=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom4241); if (state.failed) return retval; + TOKEN_REF202=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom4256); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TOKEN_REF.add(TOKEN_REF202); // ANTLRParser.g:859:19: ( elementOptions )? @@ -8196,7 +8196,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:859:19: elementOptions { - pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom4243); + pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom4258); elementOptions203=elementOptions(); state._fsp--; @@ -8219,7 +8219,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:859:35: ARG_ACTION { - ARG_ACTION204=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_rewriteTreeAtom4246); if (state.failed) return retval; + ARG_ACTION204=(Token)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_rewriteTreeAtom4261); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ARG_ACTION.add(ARG_ACTION204); @@ -8231,7 +8231,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: elementOptions, ARG_ACTION, TOKEN_REF + // elements: TOKEN_REF, ARG_ACTION, elementOptions // token labels: // rule labels: retval // token list labels: @@ -8275,7 +8275,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - RULE_REF205=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_rewriteTreeAtom4273); if (state.failed) return retval; + RULE_REF205=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_rewriteTreeAtom4288); if (state.failed) return retval; if ( state.backtracking==0 ) { RULE_REF205_tree = (GrammarAST)adaptor.create(RULE_REF205); adaptor.addChild(root_0, RULE_REF205_tree); @@ -8286,7 +8286,7 @@ public class ANTLRParser extends Parser { case 3 : // ANTLRParser.g:861:6: STRING_LITERAL ( elementOptions )? { - STRING_LITERAL206=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_rewriteTreeAtom4280); if (state.failed) return retval; + STRING_LITERAL206=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_rewriteTreeAtom4295); if (state.failed) return retval; if ( state.backtracking==0 ) stream_STRING_LITERAL.add(STRING_LITERAL206); // ANTLRParser.g:861:21: ( elementOptions )? @@ -8300,7 +8300,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:861:21: elementOptions { - pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom4282); + pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom4297); elementOptions207=elementOptions(); state._fsp--; @@ -8315,7 +8315,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: STRING_LITERAL, elementOptions + // elements: elementOptions, STRING_LITERAL // token labels: // rule labels: retval // token list labels: @@ -8351,10 +8351,10 @@ public class ANTLRParser extends Parser { case 4 : // ANTLRParser.g:862:6: DOLLAR id { - DOLLAR208=(Token)match(input,DOLLAR,FOLLOW_DOLLAR_in_rewriteTreeAtom4305); if (state.failed) return retval; + DOLLAR208=(Token)match(input,DOLLAR,FOLLOW_DOLLAR_in_rewriteTreeAtom4320); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOLLAR.add(DOLLAR208); - pushFollow(FOLLOW_id_in_rewriteTreeAtom4307); + pushFollow(FOLLOW_id_in_rewriteTreeAtom4322); id209=id(); state._fsp--; @@ -8388,7 +8388,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - ACTION210=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTreeAtom4318); if (state.failed) return retval; + ACTION210=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTreeAtom4333); if (state.failed) return retval; if ( state.backtracking==0 ) { ACTION210_tree = new ActionAST(ACTION210) ; adaptor.addChild(root_0, ACTION210_tree); @@ -8451,19 +8451,19 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:874:2: (lp= LPAREN rewriteTreeAlt RPAREN ebnfSuffix -> ^( ebnfSuffix ^( REWRITE_BLOCK[$lp] rewriteTreeAlt ) ) ) // ANTLRParser.g:874:4: lp= LPAREN rewriteTreeAlt RPAREN ebnfSuffix { - lp=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTreeEbnf4344); if (state.failed) return retval; + lp=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTreeEbnf4359); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(lp); - pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf4346); + pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf4361); rewriteTreeAlt211=rewriteTreeAlt(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_rewriteTreeAlt.add(rewriteTreeAlt211.getTree()); - RPAREN212=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTreeEbnf4348); if (state.failed) return retval; + RPAREN212=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTreeEbnf4363); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN212); - pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeEbnf4350); + pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeEbnf4365); ebnfSuffix213=ebnfSuffix(); state._fsp--; @@ -8564,10 +8564,10 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:878:2: ( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* RPAREN -> ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* ) ) // ANTLRParser.g:878:4: TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* RPAREN { - TREE_BEGIN214=(Token)match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_rewriteTree4374); if (state.failed) return retval; + TREE_BEGIN214=(Token)match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_rewriteTree4389); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TREE_BEGIN.add(TREE_BEGIN214); - pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTree4376); + pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTree4391); rewriteTreeAtom215=rewriteTreeAtom(); state._fsp--; @@ -8588,7 +8588,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:878:31: rewriteTreeElement { - pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTree4378); + pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTree4393); rewriteTreeElement216=rewriteTreeElement(); state._fsp--; @@ -8603,13 +8603,13 @@ public class ANTLRParser extends Parser { } } while (true); - RPAREN217=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTree4381); if (state.failed) return retval; + RPAREN217=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTree4396); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN217); // AST REWRITE - // elements: TREE_BEGIN, rewriteTreeAtom, rewriteTreeElement + // elements: rewriteTreeElement, TREE_BEGIN, rewriteTreeAtom // token labels: // rule labels: retval // token list labels: @@ -8707,19 +8707,19 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:894:3: TEMPLATE LPAREN rewriteTemplateArgs RPAREN (str= DOUBLE_QUOTE_STRING_LITERAL | str= DOUBLE_ANGLE_STRING_LITERAL ) { - TEMPLATE218=(Token)match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate4413); if (state.failed) return retval; + TEMPLATE218=(Token)match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate4428); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TEMPLATE.add(TEMPLATE218); - LPAREN219=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTemplate4415); if (state.failed) return retval; + LPAREN219=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTemplate4430); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN219); - pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate4417); + pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate4432); rewriteTemplateArgs220=rewriteTemplateArgs(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_rewriteTemplateArgs.add(rewriteTemplateArgs220.getTree()); - RPAREN221=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTemplate4419); if (state.failed) return retval; + RPAREN221=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTemplate4434); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN221); // ANTLRParser.g:895:3: (str= DOUBLE_QUOTE_STRING_LITERAL | str= DOUBLE_ANGLE_STRING_LITERAL ) @@ -8743,7 +8743,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:895:5: str= DOUBLE_QUOTE_STRING_LITERAL { - str=(Token)match(input,DOUBLE_QUOTE_STRING_LITERAL,FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate4427); if (state.failed) return retval; + str=(Token)match(input,DOUBLE_QUOTE_STRING_LITERAL,FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate4442); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOUBLE_QUOTE_STRING_LITERAL.add(str); @@ -8752,7 +8752,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:895:39: str= DOUBLE_ANGLE_STRING_LITERAL { - str=(Token)match(input,DOUBLE_ANGLE_STRING_LITERAL,FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate4433); if (state.failed) return retval; + str=(Token)match(input,DOUBLE_ANGLE_STRING_LITERAL,FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate4448); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOUBLE_ANGLE_STRING_LITERAL.add(str); @@ -8764,7 +8764,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: TEMPLATE, str, rewriteTemplateArgs + // elements: str, TEMPLATE, rewriteTemplateArgs // token labels: str // rule labels: retval // token list labels: @@ -8804,7 +8804,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteTemplateRef_in_rewriteTemplate4459); + pushFollow(FOLLOW_rewriteTemplateRef_in_rewriteTemplate4474); rewriteTemplateRef222=rewriteTemplateRef(); state._fsp--; @@ -8818,7 +8818,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate4468); + pushFollow(FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate4483); rewriteIndirectTemplateHead223=rewriteIndirectTemplateHead(); state._fsp--; @@ -8832,7 +8832,7 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - ACTION224=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplate4477); if (state.failed) return retval; + ACTION224=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplate4492); if (state.failed) return retval; if ( state.backtracking==0 ) { ACTION224_tree = new ActionAST(ACTION224) ; adaptor.addChild(root_0, ACTION224_tree); @@ -8892,28 +8892,28 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:910:2: ( id LPAREN rewriteTemplateArgs RPAREN -> ^( TEMPLATE[$LPAREN,\"TEMPLATE\"] id ( rewriteTemplateArgs )? ) ) // ANTLRParser.g:910:4: id LPAREN rewriteTemplateArgs RPAREN { - pushFollow(FOLLOW_id_in_rewriteTemplateRef4493); + pushFollow(FOLLOW_id_in_rewriteTemplateRef4508); id225=id(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_id.add(id225.getTree()); - LPAREN226=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTemplateRef4495); if (state.failed) return retval; + LPAREN226=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteTemplateRef4510); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN226); - pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef4497); + pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef4512); rewriteTemplateArgs227=rewriteTemplateArgs(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_rewriteTemplateArgs.add(rewriteTemplateArgs227.getTree()); - RPAREN228=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTemplateRef4499); if (state.failed) return retval; + RPAREN228=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteTemplateRef4514); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN228); // AST REWRITE - // elements: rewriteTemplateArgs, id + // elements: id, rewriteTemplateArgs // token labels: // rule labels: retval // token list labels: @@ -9001,31 +9001,31 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:916:2: (lp= LPAREN ACTION RPAREN LPAREN rewriteTemplateArgs RPAREN -> ^( TEMPLATE[$lp,\"TEMPLATE\"] ACTION ( rewriteTemplateArgs )? ) ) // ANTLRParser.g:916:4: lp= LPAREN ACTION RPAREN LPAREN rewriteTemplateArgs RPAREN { - lp=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4528); if (state.failed) return retval; + lp=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4543); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(lp); - ACTION229=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteIndirectTemplateHead4530); if (state.failed) return retval; + ACTION229=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteIndirectTemplateHead4545); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ACTION.add(ACTION229); - RPAREN230=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4532); if (state.failed) return retval; + RPAREN230=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4547); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN230); - LPAREN231=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4534); if (state.failed) return retval; + LPAREN231=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4549); if (state.failed) return retval; if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN231); - pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead4536); + pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead4551); rewriteTemplateArgs232=rewriteTemplateArgs(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_rewriteTemplateArgs.add(rewriteTemplateArgs232.getTree()); - RPAREN233=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4538); if (state.failed) return retval; + RPAREN233=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4553); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN233); // AST REWRITE - // elements: rewriteTemplateArgs, ACTION + // elements: ACTION, rewriteTemplateArgs // token labels: // rule labels: retval // token list labels: @@ -9123,7 +9123,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:921:4: rewriteTemplateArg ( COMMA rewriteTemplateArg )* { - pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4566); + pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4581); rewriteTemplateArg234=rewriteTemplateArg(); state._fsp--; @@ -9144,10 +9144,10 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:921:24: COMMA rewriteTemplateArg { - COMMA235=(Token)match(input,COMMA,FOLLOW_COMMA_in_rewriteTemplateArgs4569); if (state.failed) return retval; + COMMA235=(Token)match(input,COMMA,FOLLOW_COMMA_in_rewriteTemplateArgs4584); if (state.failed) return retval; if ( state.backtracking==0 ) stream_COMMA.add(COMMA235); - pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4571); + pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4586); rewriteTemplateArg236=rewriteTemplateArg(); state._fsp--; @@ -9256,22 +9256,22 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:927:2: ( id ASSIGN ACTION -> ^( ARG[$ASSIGN] id ACTION ) ) // ANTLRParser.g:927:6: id ASSIGN ACTION { - pushFollow(FOLLOW_id_in_rewriteTemplateArg4600); + pushFollow(FOLLOW_id_in_rewriteTemplateArg4615); id237=id(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) stream_id.add(id237.getTree()); - ASSIGN238=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_rewriteTemplateArg4602); if (state.failed) return retval; + ASSIGN238=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_rewriteTemplateArg4617); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ASSIGN.add(ASSIGN238); - ACTION239=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplateArg4604); if (state.failed) return retval; + ACTION239=(Token)match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplateArg4619); if (state.failed) return retval; if ( state.backtracking==0 ) stream_ACTION.add(ACTION239); // AST REWRITE - // elements: ACTION, id + // elements: id, ACTION // token labels: // rule labels: retval // token list labels: @@ -9376,7 +9376,7 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:937:7: RULE_REF { - RULE_REF240=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_id4646); if (state.failed) return retval; + RULE_REF240=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_id4661); if (state.failed) return retval; if ( state.backtracking==0 ) stream_RULE_REF.add(RULE_REF240); @@ -9405,7 +9405,7 @@ public class ANTLRParser extends Parser { case 2 : // ANTLRParser.g:938:7: TOKEN_REF { - TOKEN_REF241=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_id4659); if (state.failed) return retval; + TOKEN_REF241=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_id4674); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TOKEN_REF.add(TOKEN_REF241); @@ -9434,7 +9434,7 @@ public class ANTLRParser extends Parser { case 3 : // ANTLRParser.g:939:7: TEMPLATE { - TEMPLATE242=(Token)match(input,TEMPLATE,FOLLOW_TEMPLATE_in_id4671); if (state.failed) return retval; + TEMPLATE242=(Token)match(input,TEMPLATE,FOLLOW_TEMPLATE_in_id4686); if (state.failed) return retval; if ( state.backtracking==0 ) stream_TEMPLATE.add(TEMPLATE242); @@ -9512,7 +9512,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:945:2: ( id ( DOT id )* -> ID[$qid.start, $text] ) // ANTLRParser.g:945:4: id ( DOT id )* { - pushFollow(FOLLOW_id_in_qid4705); + pushFollow(FOLLOW_id_in_qid4720); id243=id(); state._fsp--; @@ -9533,10 +9533,10 @@ public class ANTLRParser extends Parser { case 1 : // ANTLRParser.g:945:8: DOT id { - DOT244=(Token)match(input,DOT,FOLLOW_DOT_in_qid4708); if (state.failed) return retval; + DOT244=(Token)match(input,DOT,FOLLOW_DOT_in_qid4723); if (state.failed) return retval; if ( state.backtracking==0 ) stream_DOT.add(DOT244); - pushFollow(FOLLOW_id_in_qid4710); + pushFollow(FOLLOW_id_in_qid4725); id245=id(); state._fsp--; @@ -9622,13 +9622,13 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_alternative_in_alternativeEntry4727); + pushFollow(FOLLOW_alternative_in_alternativeEntry4742); alternative246=alternative(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) adaptor.addChild(root_0, alternative246.getTree()); - EOF247=(Token)match(input,EOF,FOLLOW_EOF_in_alternativeEntry4729); if (state.failed) return retval; + EOF247=(Token)match(input,EOF,FOLLOW_EOF_in_alternativeEntry4744); if (state.failed) return retval; if ( state.backtracking==0 ) { EOF247_tree = (GrammarAST)adaptor.create(EOF247); adaptor.addChild(root_0, EOF247_tree); @@ -9681,13 +9681,13 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_element_in_elementEntry4738); + pushFollow(FOLLOW_element_in_elementEntry4753); element248=element(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) adaptor.addChild(root_0, element248.getTree()); - EOF249=(Token)match(input,EOF,FOLLOW_EOF_in_elementEntry4740); if (state.failed) return retval; + EOF249=(Token)match(input,EOF,FOLLOW_EOF_in_elementEntry4755); if (state.failed) return retval; if ( state.backtracking==0 ) { EOF249_tree = (GrammarAST)adaptor.create(EOF249); adaptor.addChild(root_0, EOF249_tree); @@ -9740,13 +9740,13 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_rule_in_ruleEntry4748); + pushFollow(FOLLOW_rule_in_ruleEntry4763); rule250=rule(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) adaptor.addChild(root_0, rule250.getTree()); - EOF251=(Token)match(input,EOF,FOLLOW_EOF_in_ruleEntry4750); if (state.failed) return retval; + EOF251=(Token)match(input,EOF,FOLLOW_EOF_in_ruleEntry4765); if (state.failed) return retval; if ( state.backtracking==0 ) { EOF251_tree = (GrammarAST)adaptor.create(EOF251); adaptor.addChild(root_0, EOF251_tree); @@ -9799,13 +9799,13 @@ public class ANTLRParser extends Parser { { root_0 = (GrammarAST)adaptor.nil(); - pushFollow(FOLLOW_block_in_blockEntry4758); + pushFollow(FOLLOW_block_in_blockEntry4773); block252=block(); state._fsp--; if (state.failed) return retval; if ( state.backtracking==0 ) adaptor.addChild(root_0, block252.getTree()); - EOF253=(Token)match(input,EOF,FOLLOW_EOF_in_blockEntry4760); if (state.failed) return retval; + EOF253=(Token)match(input,EOF,FOLLOW_EOF_in_blockEntry4775); if (state.failed) return retval; if ( state.backtracking==0 ) { EOF253_tree = (GrammarAST)adaptor.create(EOF253); adaptor.addChild(root_0, EOF253_tree); @@ -9838,7 +9838,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:830:7: ( rewriteTemplate ) // ANTLRParser.g:830:7: rewriteTemplate { - pushFollow(FOLLOW_rewriteTemplate_in_synpred1_ANTLRParser4045); + pushFollow(FOLLOW_rewriteTemplate_in_synpred1_ANTLRParser4060); rewriteTemplate(); state._fsp--; @@ -9853,7 +9853,7 @@ public class ANTLRParser extends Parser { // ANTLRParser.g:836:7: ( rewriteTreeAlt ) // ANTLRParser.g:836:7: rewriteTreeAlt { - pushFollow(FOLLOW_rewriteTreeAlt_in_synpred2_ANTLRParser4084); + pushFollow(FOLLOW_rewriteTreeAlt_in_synpred2_ANTLRParser4099); rewriteTreeAlt(); state._fsp--; @@ -10520,157 +10520,157 @@ public class ANTLRParser extends Parser { public static final BitSet FOLLOW_altList_in_ruleBlock2521 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_elements_in_alternative2572 = new BitSet(new long[]{0x0400000000000002L}); public static final BitSet FOLLOW_rewrite_in_alternative2581 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewrite_in_alternative2619 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_element_in_elements2672 = new BitSet(new long[]{0xA880020800010012L,0x0000000000000011L}); - public static final BitSet FOLLOW_labeledElement_in_element2709 = new BitSet(new long[]{0x0006800000000002L}); - public static final BitSet FOLLOW_ebnfSuffix_in_element2715 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_atom_in_element2758 = new BitSet(new long[]{0x0006800000000002L}); - public static final BitSet FOLLOW_ebnfSuffix_in_element2764 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ebnf_in_element2807 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ACTION_in_element2814 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_SEMPRED_in_element2824 = new BitSet(new long[]{0x0000080000000002L}); - public static final BitSet FOLLOW_IMPLIES_in_element2830 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_treeSpec_in_element2858 = new BitSet(new long[]{0x0006800000000002L}); - public static final BitSet FOLLOW_ebnfSuffix_in_element2864 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_id_in_labeledElement2926 = new BitSet(new long[]{0x0008400000000000L}); - public static final BitSet FOLLOW_ASSIGN_in_labeledElement2929 = new BitSet(new long[]{0xA080020800000000L,0x0000000000000011L}); - public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement2932 = new BitSet(new long[]{0xA080020800000000L,0x0000000000000011L}); - public static final BitSet FOLLOW_atom_in_labeledElement2937 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_block_in_labeledElement2939 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TREE_BEGIN_in_treeSpec2957 = new BitSet(new long[]{0xA880020800010010L,0x0000000000000011L}); - public static final BitSet FOLLOW_element_in_treeSpec2998 = new BitSet(new long[]{0xA880020800010010L,0x0000000000000011L}); - public static final BitSet FOLLOW_element_in_treeSpec3029 = new BitSet(new long[]{0xA880060800010010L,0x0000000000000011L}); - public static final BitSet FOLLOW_RPAREN_in_treeSpec3038 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_block_in_ebnf3072 = new BitSet(new long[]{0x0027880000000002L}); - public static final BitSet FOLLOW_blockSuffixe_in_ebnf3107 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ebnfSuffix_in_blockSuffixe3158 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ROOT_in_blockSuffixe3172 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_IMPLIES_in_blockSuffixe3180 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_BANG_in_blockSuffixe3191 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_QUESTION_in_ebnfSuffix3210 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STAR_in_ebnfSuffix3222 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_PLUS_in_ebnfSuffix3237 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_id_in_atom3285 = new BitSet(new long[]{0x0080000000000000L}); - public static final BitSet FOLLOW_DOT_in_atom3287 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_ruleref_in_atom3289 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_range_in_atom3309 = new BitSet(new long[]{0x0021000000000002L}); - public static final BitSet FOLLOW_ROOT_in_atom3315 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_BANG_in_atom3320 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_terminal_in_atom3329 = new BitSet(new long[]{0x0021000000000002L}); - public static final BitSet FOLLOW_ROOT_in_atom3332 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_BANG_in_atom3337 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ruleref_in_atom3350 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_notSet_in_atom3358 = new BitSet(new long[]{0x0021000000000002L}); - public static final BitSet FOLLOW_ROOT_in_atom3363 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_BANG_in_atom3366 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_DOT_in_atom3394 = new BitSet(new long[]{0x0000100000000002L}); - public static final BitSet FOLLOW_elementOptions_in_atom3396 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_NOT_in_notSet3454 = new BitSet(new long[]{0x8000000000000000L,0x0000000000000010L}); - public static final BitSet FOLLOW_terminal_in_notSet3456 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_NOT_in_notSet3472 = new BitSet(new long[]{0x0000020000000000L}); - public static final BitSet FOLLOW_block_in_notSet3474 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_LPAREN_in_block3507 = new BitSet(new long[]{0xBC90022900290010L,0x0000000000000011L}); - public static final BitSet FOLLOW_optionsSpec_in_block3544 = new BitSet(new long[]{0x1000002100280000L}); - public static final BitSet FOLLOW_ruleAction_in_block3549 = new BitSet(new long[]{0x1000002100280000L}); - public static final BitSet FOLLOW_COLON_in_block3552 = new BitSet(new long[]{0xAC90020800010010L,0x0000000000000011L}); - public static final BitSet FOLLOW_altList_in_block3566 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_block3583 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_RULE_REF_in_ruleref3633 = new BitSet(new long[]{0x0021000000004002L}); - public static final BitSet FOLLOW_ARG_ACTION_in_ruleref3635 = new BitSet(new long[]{0x0021000000000002L}); - public static final BitSet FOLLOW_ROOT_in_ruleref3645 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_BANG_in_ruleref3649 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_range3723 = new BitSet(new long[]{0x0100000000000000L}); - public static final BitSet FOLLOW_RANGE_in_range3728 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_range3731 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TOKEN_REF_in_terminal3756 = new BitSet(new long[]{0x0000100000004002L}); - public static final BitSet FOLLOW_ARG_ACTION_in_terminal3758 = new BitSet(new long[]{0x0000100000000002L}); - public static final BitSet FOLLOW_elementOptions_in_terminal3761 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_terminal3784 = new BitSet(new long[]{0x0000100000000002L}); - public static final BitSet FOLLOW_elementOptions_in_terminal3786 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_LT_in_elementOptions3818 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_elementOption_in_elementOptions3820 = new BitSet(new long[]{0x0000208000000000L}); - public static final BitSet FOLLOW_COMMA_in_elementOptions3823 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_elementOption_in_elementOptions3825 = new BitSet(new long[]{0x0000208000000000L}); - public static final BitSet FOLLOW_GT_in_elementOptions3829 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_qid_in_elementOption3864 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_id_in_elementOption3886 = new BitSet(new long[]{0x0000400000000000L}); - public static final BitSet FOLLOW_ASSIGN_in_elementOption3888 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000011L}); - public static final BitSet FOLLOW_qid_in_elementOption3892 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_elementOption3896 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_predicatedRewrite_in_rewrite3914 = new BitSet(new long[]{0x0400000000000000L}); - public static final BitSet FOLLOW_nakedRewrite_in_rewrite3917 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_RARROW_in_predicatedRewrite3935 = new BitSet(new long[]{0x0000000000000010L}); - public static final BitSet FOLLOW_SEMPRED_in_predicatedRewrite3937 = new BitSet(new long[]{0x8A40020800010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteAlt_in_predicatedRewrite3939 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_RARROW_in_nakedRewrite3979 = new BitSet(new long[]{0x8A40020800010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteAlt_in_nakedRewrite3981 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTemplate_in_rewriteAlt4045 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteAlt4084 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ETC_in_rewriteAlt4093 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTreeAlt4124 = new BitSet(new long[]{0x8840020000010002L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4148 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4153 = new BitSet(new long[]{0x0006800000000000L}); - public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeElement4155 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTree_in_rewriteTreeElement4180 = new BitSet(new long[]{0x0006800000000002L}); - public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeElement4186 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTreeEbnf_in_rewriteTreeElement4225 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom4241 = new BitSet(new long[]{0x0000100000004002L}); - public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom4243 = new BitSet(new long[]{0x0000000000004002L}); - public static final BitSet FOLLOW_ARG_ACTION_in_rewriteTreeAtom4246 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_RULE_REF_in_rewriteTreeAtom4273 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_rewriteTreeAtom4280 = new BitSet(new long[]{0x0000100000000002L}); - public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom4282 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_DOLLAR_in_rewriteTreeAtom4305 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_id_in_rewriteTreeAtom4307 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ACTION_in_rewriteTreeAtom4318 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_LPAREN_in_rewriteTreeEbnf4344 = new BitSet(new long[]{0x8840020000010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf4346 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteTreeEbnf4348 = new BitSet(new long[]{0x0006800000000000L}); - public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeEbnf4350 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TREE_BEGIN_in_rewriteTree4374 = new BitSet(new long[]{0x8040000000010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTree4376 = new BitSet(new long[]{0x8840060000010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTree4378 = new BitSet(new long[]{0x8840060000010000L,0x0000000000000011L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteTree4381 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate4413 = new BitSet(new long[]{0x0000020000000000L}); - public static final BitSet FOLLOW_LPAREN_in_rewriteTemplate4415 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate4417 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteTemplate4419 = new BitSet(new long[]{0x0000000000000C00L}); - public static final BitSet FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate4427 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate4433 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTemplateRef_in_rewriteTemplate4459 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate4468 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_ACTION_in_rewriteTemplate4477 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_id_in_rewriteTemplateRef4493 = new BitSet(new long[]{0x0000020000000000L}); - public static final BitSet FOLLOW_LPAREN_in_rewriteTemplateRef4495 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef4497 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteTemplateRef4499 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4528 = new BitSet(new long[]{0x0000000000010000L}); - public static final BitSet FOLLOW_ACTION_in_rewriteIndirectTemplateHead4530 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4532 = new BitSet(new long[]{0x0000020000000000L}); - public static final BitSet FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4534 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead4536 = new BitSet(new long[]{0x0000040000000000L}); - public static final BitSet FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4538 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4566 = new BitSet(new long[]{0x0000008000000002L}); - public static final BitSet FOLLOW_COMMA_in_rewriteTemplateArgs4569 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4571 = new BitSet(new long[]{0x0000008000000002L}); - public static final BitSet FOLLOW_id_in_rewriteTemplateArg4600 = new BitSet(new long[]{0x0000400000000000L}); - public static final BitSet FOLLOW_ASSIGN_in_rewriteTemplateArg4602 = new BitSet(new long[]{0x0000000000010000L}); - public static final BitSet FOLLOW_ACTION_in_rewriteTemplateArg4604 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_RULE_REF_in_id4646 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TOKEN_REF_in_id4659 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_TEMPLATE_in_id4671 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_id_in_qid4705 = new BitSet(new long[]{0x0080000000000002L}); - public static final BitSet FOLLOW_DOT_in_qid4708 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); - public static final BitSet FOLLOW_id_in_qid4710 = new BitSet(new long[]{0x0080000000000002L}); - public static final BitSet FOLLOW_alternative_in_alternativeEntry4727 = new BitSet(new long[]{0x0000000000000000L}); - public static final BitSet FOLLOW_EOF_in_alternativeEntry4729 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_element_in_elementEntry4738 = new BitSet(new long[]{0x0000000000000000L}); - public static final BitSet FOLLOW_EOF_in_elementEntry4740 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rule_in_ruleEntry4748 = new BitSet(new long[]{0x0000000000000000L}); - public static final BitSet FOLLOW_EOF_in_ruleEntry4750 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_block_in_blockEntry4758 = new BitSet(new long[]{0x0000000000000000L}); - public static final BitSet FOLLOW_EOF_in_blockEntry4760 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTemplate_in_synpred1_ANTLRParser4045 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_rewriteTreeAlt_in_synpred2_ANTLRParser4084 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewrite_in_alternative2622 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_element_in_elements2684 = new BitSet(new long[]{0xA880020800010012L,0x0000000000000011L}); + public static final BitSet FOLLOW_labeledElement_in_element2724 = new BitSet(new long[]{0x0006800000000002L}); + public static final BitSet FOLLOW_ebnfSuffix_in_element2730 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_atom_in_element2773 = new BitSet(new long[]{0x0006800000000002L}); + public static final BitSet FOLLOW_ebnfSuffix_in_element2779 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ebnf_in_element2822 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ACTION_in_element2829 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_SEMPRED_in_element2839 = new BitSet(new long[]{0x0000080000000002L}); + public static final BitSet FOLLOW_IMPLIES_in_element2845 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_treeSpec_in_element2873 = new BitSet(new long[]{0x0006800000000002L}); + public static final BitSet FOLLOW_ebnfSuffix_in_element2879 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_id_in_labeledElement2941 = new BitSet(new long[]{0x0008400000000000L}); + public static final BitSet FOLLOW_ASSIGN_in_labeledElement2944 = new BitSet(new long[]{0xA080020800000000L,0x0000000000000011L}); + public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement2947 = new BitSet(new long[]{0xA080020800000000L,0x0000000000000011L}); + public static final BitSet FOLLOW_atom_in_labeledElement2952 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_block_in_labeledElement2954 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TREE_BEGIN_in_treeSpec2972 = new BitSet(new long[]{0xA880020800010010L,0x0000000000000011L}); + public static final BitSet FOLLOW_element_in_treeSpec3013 = new BitSet(new long[]{0xA880020800010010L,0x0000000000000011L}); + public static final BitSet FOLLOW_element_in_treeSpec3044 = new BitSet(new long[]{0xA880060800010010L,0x0000000000000011L}); + public static final BitSet FOLLOW_RPAREN_in_treeSpec3053 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_block_in_ebnf3087 = new BitSet(new long[]{0x0027880000000002L}); + public static final BitSet FOLLOW_blockSuffixe_in_ebnf3122 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ebnfSuffix_in_blockSuffixe3173 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ROOT_in_blockSuffixe3187 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_IMPLIES_in_blockSuffixe3195 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BANG_in_blockSuffixe3206 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_QUESTION_in_ebnfSuffix3225 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STAR_in_ebnfSuffix3237 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_PLUS_in_ebnfSuffix3252 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_id_in_atom3300 = new BitSet(new long[]{0x0080000000000000L}); + public static final BitSet FOLLOW_DOT_in_atom3302 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_ruleref_in_atom3304 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_range_in_atom3324 = new BitSet(new long[]{0x0021000000000002L}); + public static final BitSet FOLLOW_ROOT_in_atom3330 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BANG_in_atom3335 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_terminal_in_atom3344 = new BitSet(new long[]{0x0021000000000002L}); + public static final BitSet FOLLOW_ROOT_in_atom3347 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BANG_in_atom3352 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ruleref_in_atom3365 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_notSet_in_atom3373 = new BitSet(new long[]{0x0021000000000002L}); + public static final BitSet FOLLOW_ROOT_in_atom3378 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BANG_in_atom3381 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_DOT_in_atom3409 = new BitSet(new long[]{0x0000100000000002L}); + public static final BitSet FOLLOW_elementOptions_in_atom3411 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_NOT_in_notSet3469 = new BitSet(new long[]{0x8000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_terminal_in_notSet3471 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_NOT_in_notSet3487 = new BitSet(new long[]{0x0000020000000000L}); + public static final BitSet FOLLOW_block_in_notSet3489 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_LPAREN_in_block3522 = new BitSet(new long[]{0xBC90022900290010L,0x0000000000000011L}); + public static final BitSet FOLLOW_optionsSpec_in_block3559 = new BitSet(new long[]{0x1000002100280000L}); + public static final BitSet FOLLOW_ruleAction_in_block3564 = new BitSet(new long[]{0x1000002100280000L}); + public static final BitSet FOLLOW_COLON_in_block3567 = new BitSet(new long[]{0xAC90020800010010L,0x0000000000000011L}); + public static final BitSet FOLLOW_altList_in_block3581 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_block3598 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_RULE_REF_in_ruleref3648 = new BitSet(new long[]{0x0021000000004002L}); + public static final BitSet FOLLOW_ARG_ACTION_in_ruleref3650 = new BitSet(new long[]{0x0021000000000002L}); + public static final BitSet FOLLOW_ROOT_in_ruleref3660 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BANG_in_ruleref3664 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_range3738 = new BitSet(new long[]{0x0100000000000000L}); + public static final BitSet FOLLOW_RANGE_in_range3743 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_range3746 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TOKEN_REF_in_terminal3771 = new BitSet(new long[]{0x0000100000004002L}); + public static final BitSet FOLLOW_ARG_ACTION_in_terminal3773 = new BitSet(new long[]{0x0000100000000002L}); + public static final BitSet FOLLOW_elementOptions_in_terminal3776 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_terminal3799 = new BitSet(new long[]{0x0000100000000002L}); + public static final BitSet FOLLOW_elementOptions_in_terminal3801 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_LT_in_elementOptions3833 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_elementOption_in_elementOptions3835 = new BitSet(new long[]{0x0000208000000000L}); + public static final BitSet FOLLOW_COMMA_in_elementOptions3838 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_elementOption_in_elementOptions3840 = new BitSet(new long[]{0x0000208000000000L}); + public static final BitSet FOLLOW_GT_in_elementOptions3844 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_qid_in_elementOption3879 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_id_in_elementOption3901 = new BitSet(new long[]{0x0000400000000000L}); + public static final BitSet FOLLOW_ASSIGN_in_elementOption3903 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000011L}); + public static final BitSet FOLLOW_qid_in_elementOption3907 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_elementOption3911 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_predicatedRewrite_in_rewrite3929 = new BitSet(new long[]{0x0400000000000000L}); + public static final BitSet FOLLOW_nakedRewrite_in_rewrite3932 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_RARROW_in_predicatedRewrite3950 = new BitSet(new long[]{0x0000000000000010L}); + public static final BitSet FOLLOW_SEMPRED_in_predicatedRewrite3952 = new BitSet(new long[]{0x8A40020800010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteAlt_in_predicatedRewrite3954 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_RARROW_in_nakedRewrite3994 = new BitSet(new long[]{0x8A40020800010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteAlt_in_nakedRewrite3996 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTemplate_in_rewriteAlt4060 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteAlt4099 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ETC_in_rewriteAlt4108 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTreeAlt4139 = new BitSet(new long[]{0x8840020000010002L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4163 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTreeElement4168 = new BitSet(new long[]{0x0006800000000000L}); + public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeElement4170 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTree_in_rewriteTreeElement4195 = new BitSet(new long[]{0x0006800000000002L}); + public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeElement4201 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTreeEbnf_in_rewriteTreeElement4240 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom4256 = new BitSet(new long[]{0x0000100000004002L}); + public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom4258 = new BitSet(new long[]{0x0000000000004002L}); + public static final BitSet FOLLOW_ARG_ACTION_in_rewriteTreeAtom4261 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_RULE_REF_in_rewriteTreeAtom4288 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_rewriteTreeAtom4295 = new BitSet(new long[]{0x0000100000000002L}); + public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom4297 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_DOLLAR_in_rewriteTreeAtom4320 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_id_in_rewriteTreeAtom4322 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ACTION_in_rewriteTreeAtom4333 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_LPAREN_in_rewriteTreeEbnf4359 = new BitSet(new long[]{0x8840020000010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf4361 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteTreeEbnf4363 = new BitSet(new long[]{0x0006800000000000L}); + public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeEbnf4365 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TREE_BEGIN_in_rewriteTree4389 = new BitSet(new long[]{0x8040000000010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTree4391 = new BitSet(new long[]{0x8840060000010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTree4393 = new BitSet(new long[]{0x8840060000010000L,0x0000000000000011L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteTree4396 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate4428 = new BitSet(new long[]{0x0000020000000000L}); + public static final BitSet FOLLOW_LPAREN_in_rewriteTemplate4430 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate4432 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteTemplate4434 = new BitSet(new long[]{0x0000000000000C00L}); + public static final BitSet FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate4442 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate4448 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTemplateRef_in_rewriteTemplate4474 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate4483 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ACTION_in_rewriteTemplate4492 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_id_in_rewriteTemplateRef4508 = new BitSet(new long[]{0x0000020000000000L}); + public static final BitSet FOLLOW_LPAREN_in_rewriteTemplateRef4510 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef4512 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteTemplateRef4514 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4543 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ACTION_in_rewriteIndirectTemplateHead4545 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4547 = new BitSet(new long[]{0x0000020000000000L}); + public static final BitSet FOLLOW_LPAREN_in_rewriteIndirectTemplateHead4549 = new BitSet(new long[]{0x8000040800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead4551 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_RPAREN_in_rewriteIndirectTemplateHead4553 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4581 = new BitSet(new long[]{0x0000008000000002L}); + public static final BitSet FOLLOW_COMMA_in_rewriteTemplateArgs4584 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs4586 = new BitSet(new long[]{0x0000008000000002L}); + public static final BitSet FOLLOW_id_in_rewriteTemplateArg4615 = new BitSet(new long[]{0x0000400000000000L}); + public static final BitSet FOLLOW_ASSIGN_in_rewriteTemplateArg4617 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ACTION_in_rewriteTemplateArg4619 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_RULE_REF_in_id4661 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TOKEN_REF_in_id4674 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TEMPLATE_in_id4686 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_id_in_qid4720 = new BitSet(new long[]{0x0080000000000002L}); + public static final BitSet FOLLOW_DOT_in_qid4723 = new BitSet(new long[]{0x8000000800000000L,0x0000000000000001L}); + public static final BitSet FOLLOW_id_in_qid4725 = new BitSet(new long[]{0x0080000000000002L}); + public static final BitSet FOLLOW_alternative_in_alternativeEntry4742 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_alternativeEntry4744 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_element_in_elementEntry4753 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_elementEntry4755 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rule_in_ruleEntry4763 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_ruleEntry4765 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_block_in_blockEntry4773 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_EOF_in_blockEntry4775 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTemplate_in_synpred1_ANTLRParser4060 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_rewriteTreeAlt_in_synpred2_ANTLRParser4099 = new BitSet(new long[]{0x0000000000000002L}); } \ No newline at end of file diff --git a/tool/src/org/antlr/v4/parse/ASTVerifier.java b/tool/src/org/antlr/v4/parse/ASTVerifier.java index 2db264ca4..ed7c2e024 100644 --- a/tool/src/org/antlr/v4/parse/ASTVerifier.java +++ b/tool/src/org/antlr/v4/parse/ASTVerifier.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-05-16 13:12:34 +// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-05-19 15:07:27 /* [The "BSD license"] diff --git a/tool/src/org/antlr/v4/parse/ActionSplitter.java b/tool/src/org/antlr/v4/parse/ActionSplitter.java index 16e68963b..a18f6774b 100644 --- a/tool/src/org/antlr/v4/parse/ActionSplitter.java +++ b/tool/src/org/antlr/v4/parse/ActionSplitter.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-05-18 16:11:58 +// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-05-19 15:07:26 package org.antlr.v4.parse; @@ -2175,6 +2175,20 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } + public final boolean synpred12_ActionSplitter() { + state.backtracking++; + int start = input.mark(); + try { + synpred12_ActionSplitter_fragment(); // can never throw exception + } catch (RecognitionException re) { + System.err.println("impossible: "+re); + } + boolean success = !state.failed; + input.rewind(start); + state.backtracking--; + state.failed=false; + return success; + } public final boolean synpred17_ActionSplitter() { state.backtracking++; int start = input.mark(); @@ -2203,20 +2217,6 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } - public final boolean synpred12_ActionSplitter() { - state.backtracking++; - int start = input.mark(); - try { - synpred12_ActionSplitter_fragment(); // can never throw exception - } catch (RecognitionException re) { - System.err.println("impossible: "+re); - } - boolean success = !state.failed; - input.rewind(start); - state.backtracking--; - state.failed=false; - return success; - } public final boolean synpred9_ActionSplitter() { state.backtracking++; int start = input.mark(); @@ -2329,11 +2329,11 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } - public final boolean synpred2_ActionSplitter() { + public final boolean synpred8_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred2_ActionSplitter_fragment(); // can never throw exception + synpred8_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2343,11 +2343,11 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } - public final boolean synpred8_ActionSplitter() { + public final boolean synpred2_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred8_ActionSplitter_fragment(); // can never throw exception + synpred2_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2399,11 +2399,11 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } - public final boolean synpred3_ActionSplitter() { + public final boolean synpred15_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred3_ActionSplitter_fragment(); // can never throw exception + synpred15_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2413,11 +2413,11 @@ public class ActionSplitter extends Lexer { state.failed=false; return success; } - public final boolean synpred15_ActionSplitter() { + public final boolean synpred3_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred15_ActionSplitter_fragment(); // can never throw exception + synpred3_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2491,21 +2491,30 @@ public class ActionSplitter extends Lexer { } } static final String DFA29_eotS = - "\31\uffff"; + "\32\uffff"; static final String DFA29_eofS = - "\31\uffff"; + "\32\uffff"; static final String DFA29_minS = - "\1\0\1\uffff\1\0\2\uffff\1\0\12\uffff\1\0\6\uffff\1\0\1\uffff"; + "\2\0\6\uffff\1\0\2\uffff\1\0\2\uffff\1\0\13\uffff"; static final String DFA29_maxS = - "\1\uffff\1\uffff\1\0\2\uffff\1\0\12\uffff\1\0\6\uffff\1\0\1\uffff"; + "\1\uffff\1\0\6\uffff\1\0\2\uffff\1\0\2\uffff\1\0\13\uffff"; static final String DFA29_acceptS = - "\1\uffff\1\24\1\uffff\1\1\1\2\1\uffff\1\4\1\5\1\6\1\7\1\10\1\11"+ - "\1\12\1\13\1\14\1\15\1\uffff\1\16\1\17\1\20\1\21\1\22\1\23\1\uffff"+ - "\1\3"; + "\2\uffff\1\16\1\17\1\20\1\21\1\22\1\23\1\uffff\1\3\1\24\1\uffff"+ + "\1\1\1\2\1\uffff\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1"+ + "\24"; static final String DFA29_specialS = - "\1\0\1\uffff\1\1\2\uffff\1\2\12\uffff\1\3\6\uffff\1\4\1\uffff}>"; + "\1\0\1\1\6\uffff\1\2\2\uffff\1\3\2\uffff\1\4\13\uffff}>"; static final String[] DFA29_transitionS = { - "\44\1\1\5\1\20\11\1\1\2\54\1\1\27\uffa3\1", + "\44\31\1\16\1\1\11\31\1\13\54\31\1\10\uffa3\31", + "\1\uffff", + "", + "", + "", + "", + "", + "", + "\1\uffff", + "", "", "\1\uffff", "", @@ -2521,14 +2530,6 @@ public class ActionSplitter extends Lexer { "", "", "", - "\1\uffff", - "", - "", - "", - "", - "", - "", - "\1\uffff", "" }; @@ -2572,102 +2573,102 @@ public class ActionSplitter extends Lexer { int LA29_0 = input.LA(1); s = -1; - if ( ((LA29_0>='\u0000' && LA29_0<='#')||(LA29_0>='&' && LA29_0<='.')||(LA29_0>='0' && LA29_0<='[')||(LA29_0>=']' && LA29_0<='\uFFFF')) ) {s = 1;} + if ( (LA29_0=='%') ) {s = 1;} - else if ( (LA29_0=='/') ) {s = 2;} + else if ( (LA29_0=='\\') ) {s = 8;} - else if ( (LA29_0=='$') ) {s = 5;} + else if ( (LA29_0=='/') ) {s = 11;} - else if ( (LA29_0=='%') ) {s = 16;} + else if ( (LA29_0=='$') ) {s = 14;} - else if ( (LA29_0=='\\') ) {s = 23;} + else if ( ((LA29_0>='\u0000' && LA29_0<='#')||(LA29_0>='&' && LA29_0<='.')||(LA29_0>='0' && LA29_0<='[')||(LA29_0>=']' && LA29_0<='\uFFFF')) ) {s = 25;} if ( s>=0 ) return s; break; case 1 : - int LA29_2 = input.LA(1); + int LA29_1 = input.LA(1); - int index29_2 = input.index(); + int index29_1 = input.index(); input.rewind(); s = -1; - if ( (synpred1_ActionSplitter()) ) {s = 3;} + if ( (synpred14_ActionSplitter()) ) {s = 2;} - else if ( (synpred2_ActionSplitter()) ) {s = 4;} + else if ( (synpred15_ActionSplitter()) ) {s = 3;} - else if ( (true) ) {s = 1;} + else if ( (synpred16_ActionSplitter()) ) {s = 4;} + + else if ( (synpred17_ActionSplitter()) ) {s = 5;} + + else if ( (synpred18_ActionSplitter()) ) {s = 6;} + + else if ( (synpred19_ActionSplitter()) ) {s = 7;} - input.seek(index29_2); + input.seek(index29_1); if ( s>=0 ) return s; break; case 2 : - int LA29_5 = input.LA(1); + int LA29_8 = input.LA(1); - int index29_5 = input.index(); + int index29_8 = input.index(); input.rewind(); s = -1; - if ( (synpred4_ActionSplitter()) ) {s = 6;} + if ( (synpred3_ActionSplitter()) ) {s = 9;} - else if ( (synpred5_ActionSplitter()) ) {s = 7;} - - else if ( (synpred6_ActionSplitter()) ) {s = 8;} - - else if ( (synpred7_ActionSplitter()) ) {s = 9;} - - else if ( (synpred8_ActionSplitter()) ) {s = 10;} - - else if ( (synpred9_ActionSplitter()) ) {s = 11;} - - else if ( (synpred10_ActionSplitter()) ) {s = 12;} - - else if ( (synpred11_ActionSplitter()) ) {s = 13;} - - else if ( (synpred12_ActionSplitter()) ) {s = 14;} - - else if ( (synpred13_ActionSplitter()) ) {s = 15;} + else if ( (true) ) {s = 10;} - input.seek(index29_5); + input.seek(index29_8); if ( s>=0 ) return s; break; case 3 : - int LA29_16 = input.LA(1); + int LA29_11 = input.LA(1); - int index29_16 = input.index(); + int index29_11 = input.index(); input.rewind(); s = -1; - if ( (synpred14_ActionSplitter()) ) {s = 17;} + if ( (synpred1_ActionSplitter()) ) {s = 12;} - else if ( (synpred15_ActionSplitter()) ) {s = 18;} + else if ( (synpred2_ActionSplitter()) ) {s = 13;} - else if ( (synpred16_ActionSplitter()) ) {s = 19;} - - else if ( (synpred17_ActionSplitter()) ) {s = 20;} - - else if ( (synpred18_ActionSplitter()) ) {s = 21;} - - else if ( (synpred19_ActionSplitter()) ) {s = 22;} + else if ( (true) ) {s = 10;} - input.seek(index29_16); + input.seek(index29_11); if ( s>=0 ) return s; break; case 4 : - int LA29_23 = input.LA(1); + int LA29_14 = input.LA(1); - int index29_23 = input.index(); + int index29_14 = input.index(); input.rewind(); s = -1; - if ( (synpred3_ActionSplitter()) ) {s = 24;} + if ( (synpred4_ActionSplitter()) ) {s = 15;} - else if ( (true) ) {s = 1;} + else if ( (synpred5_ActionSplitter()) ) {s = 16;} + + else if ( (synpred6_ActionSplitter()) ) {s = 17;} + + else if ( (synpred7_ActionSplitter()) ) {s = 18;} + + else if ( (synpred8_ActionSplitter()) ) {s = 19;} + + else if ( (synpred9_ActionSplitter()) ) {s = 20;} + + else if ( (synpred10_ActionSplitter()) ) {s = 21;} + + else if ( (synpred11_ActionSplitter()) ) {s = 22;} + + else if ( (synpred12_ActionSplitter()) ) {s = 23;} + + else if ( (synpred13_ActionSplitter()) ) {s = 24;} - input.seek(index29_23); + input.seek(index29_14); if ( s>=0 ) return s; break; } diff --git a/tool/src/org/antlr/v4/parse/NFABuilder.java b/tool/src/org/antlr/v4/parse/NFABuilder.java index bfc1b337d..26c487dcf 100644 --- a/tool/src/org/antlr/v4/parse/NFABuilder.java +++ b/tool/src/org/antlr/v4/parse/NFABuilder.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} NFABuilder.g 2010-05-16 13:12:33 +// $ANTLR ${project.version} ${buildNumber} NFABuilder.g 2010-05-19 15:07:26 /* [The "BSD license"] diff --git a/tool/src/org/antlr/v4/semantics/ActionSniffer.java b/tool/src/org/antlr/v4/semantics/ActionSniffer.java new file mode 100644 index 000000000..538bc339c --- /dev/null +++ b/tool/src/org/antlr/v4/semantics/ActionSniffer.java @@ -0,0 +1,53 @@ +package org.antlr.v4.semantics; + +import org.antlr.runtime.ANTLRStringStream; +import org.antlr.runtime.Token; +import org.antlr.v4.parse.ActionSplitter; +import org.antlr.v4.tool.*; + +import java.util.List; + +/** Find token and rule refs, side-effect: update Alternatives */ +public class ActionSniffer extends BlankActionSplitterListener { + public Grammar g; + public Rule r; // null if action outside of rule + public Alternative alt; // null if action outside of alt; could be in rule + public ActionAST node; + public Token actionToken; // token within action + public ErrorManager errMgr; + + public ActionSniffer(Grammar g, Rule r, Alternative alt, ActionAST node, Token actionToken) { + this.g = g; + this.r = r; + this.alt = alt; + this.node = node; + this.actionToken = actionToken; + this.errMgr = g.tool.errMgr; + } + + public void examineAction() { + //System.out.println("examine "+actionToken); + ANTLRStringStream in = new ANTLRStringStream(actionToken.getText()); + in.setLine(actionToken.getLine()); + in.setCharPositionInLine(actionToken.getCharPositionInLine()); + ActionSplitter splitter = new ActionSplitter(in, this); + // forces eval, triggers listener methods + node.chunks = splitter.getActionTokens(); + System.out.println(node.chunks); + } + + public void attr(String expr, Token x) { + List xRefs = alt.tokenRefs.get(x.getText()); + if ( alt!=null && xRefs!=null ) { + alt.tokenRefsInActions.map(x.getText(), node); + } + List rRefs = alt.ruleRefs.get(x.getText()); + if ( alt!=null && rRefs!=null ) { + alt.ruleRefsInActions.map(x.getText(), node); + } + } + + public void qualifiedAttr(String expr, Token x, Token y) { + attr(expr, x); + } +} diff --git a/tool/src/org/antlr/v4/semantics/AttributeChecks.java b/tool/src/org/antlr/v4/semantics/AttributeChecks.java index 16d2e65c9..4b7617836 100644 --- a/tool/src/org/antlr/v4/semantics/AttributeChecks.java +++ b/tool/src/org/antlr/v4/semantics/AttributeChecks.java @@ -8,7 +8,9 @@ import org.antlr.v4.tool.*; import java.util.List; -/** Trigger checks for various kinds of attribute expressions. no side-effects */ +/** Trigger checks for various kinds of attribute expressions. + * no side-effects. + */ public class AttributeChecks implements ActionSplitterListener { public Grammar g; public Rule r; // null if action outside of rule @@ -89,7 +91,7 @@ public class AttributeChecks implements ActionSplitterListener { g.fileName, y, y.getText(), rref.name, expr); } } - else if ( !resolvesToAttributeDict(x.getText()) ) { + else if ( !node.resolver.resolvesToAttributeDict(x.getText(), node) ) { errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, g.fileName, x, x.getText(), expr); } @@ -113,7 +115,7 @@ public class AttributeChecks implements ActionSplitterListener { if ( node.resolver.resolveToDynamicScope(x.getText(), node)!=null ) { return; // $S for scope S is ok } - if ( resolvesToToken(x.getText()) ) { + if ( node.resolver.resolvesToToken(x.getText(), node) ) { return; // $ID for token ref or label of token } if ( node.resolver.resolvesToListLabel(x.getText(), node) ) { @@ -215,37 +217,4 @@ public class AttributeChecks implements ActionSplitterListener { return null; } - public boolean resolvesToAttributeDict(String x) { - if ( resolvesToToken(x) ) return true; - if ( node.resolver instanceof Grammar ) return g.scopes.get(x)!=null; - - if ( x.equals(r.name) ) return true; // $r for action in rule r, $r is a dict - Rule r = g.getRule(x); - if ( r!=null && r.scope!=null ) return true; - if ( g.scopes.get(x)!=null ) return true; - return false; - } - - public boolean resolvesToToken(String x) { - if ( node.resolver instanceof Grammar ) return false; - - if ( node.resolver instanceof Alternative && - ((Alternative)node.resolver).tokenRefs.get(x)!=null ) - { - return true; - } - List labels = null; - if ( node.resolver instanceof Rule ) { - labels = r.getLabelDefs().get(x); - } - else if ( node.resolver instanceof Alternative ) { - labels = ((Alternative)node.resolver).labelDefs.get(x); - } - if ( labels!=null ) { // it's a label ref. is it a token label? - LabelElementPair anyLabelDef = labels.get(0); - if ( anyLabelDef.type==LabelType.TOKEN_LABEL ) return true; - } - return false; - } - } diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java index 0756ff70d..8dd4cb2dd 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} BasicSemanticTriggers.g 2010-05-06 12:54:52 +// $ANTLR ${project.version} ${buildNumber} BasicSemanticTriggers.g 2010-05-19 15:07:28 /* [The "BSD license"] diff --git a/tool/test/org/antlr/v4/test/BlankActionSplitterListener.java b/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java similarity index 97% rename from tool/test/org/antlr/v4/test/BlankActionSplitterListener.java rename to tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java index 5a81bb4d7..431bbb522 100644 --- a/tool/test/org/antlr/v4/test/BlankActionSplitterListener.java +++ b/tool/src/org/antlr/v4/semantics/BlankActionSplitterListener.java @@ -1,4 +1,4 @@ -package org.antlr.v4.test; +package org.antlr.v4.semantics; import org.antlr.runtime.Token; import org.antlr.v4.parse.ActionSplitterListener; diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.g b/tool/src/org/antlr/v4/semantics/CollectSymbols.g index 6af6e6a51..7d76991b5 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.g +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.g @@ -25,7 +25,7 @@ */ /** Collects rules, terminals, strings, actions, scopes etc... from AST - * Side-effects: None + * No side-effects */ tree grammar CollectSymbols; options { @@ -167,7 +167,10 @@ rule setAlt : {inContext("RULE BLOCK")}? ( ALT | ALT_REWRITE ) - {currentAlt = $start.getChildIndex()+1;} + { + currentAlt = $start.getChildIndex()+1; + currentRule.alt[currentAlt].ast = (AltAST)$start; + } ; finishRule @@ -264,7 +267,7 @@ terminal terminals.add($start); strings.add($STRING_LITERAL.text); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map($STRING_LITERAL.text, $STRING_LITERAL); + currentRule.alt[currentAlt].tokenRefs.map($STRING_LITERAL.text, (TerminalAST)$STRING_LITERAL); } } | TOKEN_REF @@ -272,7 +275,7 @@ terminal terminals.add($TOKEN_REF); tokenIDRefs.add($TOKEN_REF); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map($TOKEN_REF.text, $TOKEN_REF); + currentRule.alt[currentAlt].tokenRefs.map($TOKEN_REF.text, (TerminalAST)$TOKEN_REF); } } ; diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.java b/tool/src/org/antlr/v4/semantics/CollectSymbols.java index acbeeb666..c2c8e58f2 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.java +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} CollectSymbols.g 2010-05-18 17:55:53 +// $ANTLR ${project.version} ${buildNumber} CollectSymbols.g 2010-05-19 15:10:21 /* [The "BSD license"] @@ -38,7 +38,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; /** Collects rules, terminals, strings, actions, scopes etc... from AST - * Side-effects: None + * No side-effects */ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { public static final String[] tokenNames = new String[] { @@ -914,7 +914,10 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } if ( state.backtracking==1 ) { - currentAlt = ((GrammarAST)retval.start).getChildIndex()+1; + + currentAlt = ((GrammarAST)retval.start).getChildIndex()+1; + currentRule.alt[currentAlt].ast = (AltAST)((GrammarAST)retval.start); + } } @@ -932,11 +935,11 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "finishRule" - // CollectSymbols.g:173:1: finishRule : RULE ; + // CollectSymbols.g:176:1: finishRule : RULE ; public final void finishRule() throws RecognitionException { try { - // CollectSymbols.g:174:2: ( RULE ) - // CollectSymbols.g:174:4: RULE + // CollectSymbols.g:177:2: ( RULE ) + // CollectSymbols.g:177:4: RULE { match(input,RULE,FOLLOW_RULE_in_finishRule527); if (state.failed) return ; if ( state.backtracking==1 ) { @@ -958,14 +961,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleNamedAction" - // CollectSymbols.g:177:1: ruleNamedAction : {...}? ^( AT ID ACTION ) ; + // CollectSymbols.g:180:1: ruleNamedAction : {...}? ^( AT ID ACTION ) ; public final void ruleNamedAction() throws RecognitionException { GrammarAST ID9=null; GrammarAST ACTION10=null; try { - // CollectSymbols.g:178:2: ({...}? ^( AT ID ACTION ) ) - // CollectSymbols.g:178:4: {...}? ^( AT ID ACTION ) + // CollectSymbols.g:181:2: ({...}? ^( AT ID ACTION ) ) + // CollectSymbols.g:181:4: {...}? ^( AT ID ACTION ) { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} @@ -1000,13 +1003,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleAction" - // CollectSymbols.g:185:1: ruleAction : {...}? ACTION ; + // CollectSymbols.g:188:1: ruleAction : {...}? ACTION ; public final void ruleAction() throws RecognitionException { GrammarAST ACTION11=null; try { - // CollectSymbols.g:186:2: ({...}? ACTION ) - // CollectSymbols.g:186:4: {...}? ACTION + // CollectSymbols.g:189:2: ({...}? ACTION ) + // CollectSymbols.g:189:4: {...}? ACTION { if ( !((inContext("RULE ...")&&!inContext("SCOPE")&& !inContext("CATCH")&&!inContext("FINALLY")&&!inContext("AT"))) ) { @@ -1036,13 +1039,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "exceptionHandler" - // CollectSymbols.g:195:1: exceptionHandler : ^( CATCH ARG_ACTION ACTION ) ; + // CollectSymbols.g:198:1: exceptionHandler : ^( CATCH ARG_ACTION ACTION ) ; public final void exceptionHandler() throws RecognitionException { GrammarAST ACTION12=null; try { - // CollectSymbols.g:196:2: ( ^( CATCH ARG_ACTION ACTION ) ) - // CollectSymbols.g:196:4: ^( CATCH ARG_ACTION ACTION ) + // CollectSymbols.g:199:2: ( ^( CATCH ARG_ACTION ACTION ) ) + // CollectSymbols.g:199:4: ^( CATCH ARG_ACTION ACTION ) { match(input,CATCH,FOLLOW_CATCH_in_exceptionHandler583); if (state.failed) return ; @@ -1073,13 +1076,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "finallyClause" - // CollectSymbols.g:203:1: finallyClause : ^( FINALLY ACTION ) ; + // CollectSymbols.g:206:1: finallyClause : ^( FINALLY ACTION ) ; public final void finallyClause() throws RecognitionException { GrammarAST ACTION13=null; try { - // CollectSymbols.g:204:2: ( ^( FINALLY ACTION ) ) - // CollectSymbols.g:204:4: ^( FINALLY ACTION ) + // CollectSymbols.g:207:2: ( ^( FINALLY ACTION ) ) + // CollectSymbols.g:207:4: ^( FINALLY ACTION ) { match(input,FINALLY,FOLLOW_FINALLY_in_finallyClause604); if (state.failed) return ; @@ -1109,13 +1112,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleArg" - // CollectSymbols.g:211:1: ruleArg : {...}? ARG_ACTION ; + // CollectSymbols.g:214:1: ruleArg : {...}? ARG_ACTION ; public final void ruleArg() throws RecognitionException { GrammarAST ARG_ACTION14=null; try { - // CollectSymbols.g:212:2: ({...}? ARG_ACTION ) - // CollectSymbols.g:212:4: {...}? ARG_ACTION + // CollectSymbols.g:215:2: ({...}? ARG_ACTION ) + // CollectSymbols.g:215:4: {...}? ARG_ACTION { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} @@ -1145,13 +1148,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleReturns" - // CollectSymbols.g:220:1: ruleReturns : ^( RETURNS ARG_ACTION ) ; + // CollectSymbols.g:223:1: ruleReturns : ^( RETURNS ARG_ACTION ) ; public final void ruleReturns() throws RecognitionException { GrammarAST ARG_ACTION15=null; try { - // CollectSymbols.g:221:2: ( ^( RETURNS ARG_ACTION ) ) - // CollectSymbols.g:221:4: ^( RETURNS ARG_ACTION ) + // CollectSymbols.g:224:2: ( ^( RETURNS ARG_ACTION ) ) + // CollectSymbols.g:224:4: ^( RETURNS ARG_ACTION ) { match(input,RETURNS,FOLLOW_RETURNS_in_ruleReturns643); if (state.failed) return ; @@ -1182,21 +1185,21 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleScopeSpec" - // CollectSymbols.g:229:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; + // CollectSymbols.g:232:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; public final void ruleScopeSpec() throws RecognitionException { GrammarAST ACTION16=null; GrammarAST ids=null; List list_ids=null; try { - // CollectSymbols.g:230:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ) - // CollectSymbols.g:230:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) + // CollectSymbols.g:233:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ) + // CollectSymbols.g:233:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleScopeSpec", "inContext(\"RULE\")"); } - // CollectSymbols.g:231:3: ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) + // CollectSymbols.g:234:3: ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) int alt12=2; int LA12_0 = input.LA(1); @@ -1237,7 +1240,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt12) { case 1 : - // CollectSymbols.g:231:5: ^( SCOPE ACTION ) + // CollectSymbols.g:234:5: ^( SCOPE ACTION ) { match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec668); if (state.failed) return ; @@ -1257,12 +1260,12 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:238:5: ^( SCOPE (ids+= ID )+ ) + // CollectSymbols.g:241:5: ^( SCOPE (ids+= ID )+ ) { match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec683); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - // CollectSymbols.g:238:16: (ids+= ID )+ + // CollectSymbols.g:241:16: (ids+= ID )+ int cnt11=0; loop11: do { @@ -1276,7 +1279,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { switch (alt11) { case 1 : - // CollectSymbols.g:238:16: ids+= ID + // CollectSymbols.g:241:16: ids+= ID { ids=(GrammarAST)match(input,ID,FOLLOW_ID_in_ruleScopeSpec687); if (state.failed) return ; if (list_ids==null) list_ids=new ArrayList(); @@ -1325,14 +1328,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "rewriteElement" - // CollectSymbols.g:242:1: rewriteElement : {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ; + // CollectSymbols.g:245:1: rewriteElement : {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ; public final CollectSymbols.rewriteElement_return rewriteElement() throws RecognitionException { CollectSymbols.rewriteElement_return retval = new CollectSymbols.rewriteElement_return(); retval.start = input.LT(1); try { - // CollectSymbols.g:244:2: ({...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ) - // CollectSymbols.g:245:6: {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) + // CollectSymbols.g:247:2: ({...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ) + // CollectSymbols.g:248:6: {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) { if ( !((inContext("RESULT ..."))) ) { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1369,7 +1372,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "labeledElement" - // CollectSymbols.g:249:1: labeledElement : {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ; + // CollectSymbols.g:252:1: labeledElement : {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ; public final CollectSymbols.labeledElement_return labeledElement() throws RecognitionException { CollectSymbols.labeledElement_return retval = new CollectSymbols.labeledElement_return(); retval.start = input.LT(1); @@ -1378,14 +1381,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { GrammarAST e=null; try { - // CollectSymbols.g:255:2: ({...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ) - // CollectSymbols.g:255:4: {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) + // CollectSymbols.g:258:2: ({...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ) + // CollectSymbols.g:258:4: {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) { if ( !((inContext("RULE ..."))) ) { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "labeledElement", "inContext(\"RULE ...\")"); } - // CollectSymbols.g:256:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) + // CollectSymbols.g:259:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) int alt13=2; int LA13_0 = input.LA(1); @@ -1404,7 +1407,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt13) { case 1 : - // CollectSymbols.g:256:5: ^( ASSIGN id= ID e= . ) + // CollectSymbols.g:259:5: ^( ASSIGN id= ID e= . ) { match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement751); if (state.failed) return retval; @@ -1418,7 +1421,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:257:5: ^( PLUS_ASSIGN id= ID e= . ) + // CollectSymbols.g:260:5: ^( PLUS_ASSIGN id= ID e= . ) { match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement767); if (state.failed) return retval; @@ -1459,7 +1462,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "terminal" - // CollectSymbols.g:261:1: terminal : ({...}? STRING_LITERAL | TOKEN_REF ); + // CollectSymbols.g:264:1: terminal : ({...}? STRING_LITERAL | TOKEN_REF ); public final CollectSymbols.terminal_return terminal() throws RecognitionException { CollectSymbols.terminal_return retval = new CollectSymbols.terminal_return(); retval.start = input.LT(1); @@ -1468,7 +1471,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { GrammarAST TOKEN_REF18=null; try { - // CollectSymbols.g:262:5: ({...}? STRING_LITERAL | TOKEN_REF ) + // CollectSymbols.g:265:5: ({...}? STRING_LITERAL | TOKEN_REF ) int alt14=2; int LA14_0 = input.LA(1); @@ -1487,7 +1490,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt14) { case 1 : - // CollectSymbols.g:262:7: {...}? STRING_LITERAL + // CollectSymbols.g:265:7: {...}? STRING_LITERAL { if ( !((!inContext("TOKENS ASSIGN"))) ) { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1499,7 +1502,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { terminals.add(((GrammarAST)retval.start)); strings.add((STRING_LITERAL17!=null?STRING_LITERAL17.getText():null)); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL17!=null?STRING_LITERAL17.getText():null), STRING_LITERAL17); + currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL17!=null?STRING_LITERAL17.getText():null), (TerminalAST)STRING_LITERAL17); } } @@ -1507,7 +1510,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:270:7: TOKEN_REF + // CollectSymbols.g:273:7: TOKEN_REF { TOKEN_REF18=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal812); if (state.failed) return retval; if ( state.backtracking==1 ) { @@ -1515,7 +1518,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { terminals.add(TOKEN_REF18); tokenIDRefs.add(TOKEN_REF18); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF18!=null?TOKEN_REF18.getText():null), TOKEN_REF18); + currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF18!=null?TOKEN_REF18.getText():null), (TerminalAST)TOKEN_REF18); } } @@ -1537,15 +1540,15 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleref" - // CollectSymbols.g:280:1: ruleref : ({...}?r= RULE_REF | r= RULE_REF ) ; + // CollectSymbols.g:283:1: ruleref : ({...}?r= RULE_REF | r= RULE_REF ) ; public final void ruleref() throws RecognitionException { GrammarAST r=null; try { - // CollectSymbols.g:282:5: ( ({...}?r= RULE_REF | r= RULE_REF ) ) - // CollectSymbols.g:282:7: ({...}?r= RULE_REF | r= RULE_REF ) + // CollectSymbols.g:285:5: ( ({...}?r= RULE_REF | r= RULE_REF ) ) + // CollectSymbols.g:285:7: ({...}?r= RULE_REF | r= RULE_REF ) { - // CollectSymbols.g:282:7: ({...}?r= RULE_REF | r= RULE_REF ) + // CollectSymbols.g:285:7: ({...}?r= RULE_REF | r= RULE_REF ) int alt15=2; int LA15_0 = input.LA(1); @@ -1575,7 +1578,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt15) { case 1 : - // CollectSymbols.g:282:9: {...}?r= RULE_REF + // CollectSymbols.g:285:9: {...}?r= RULE_REF { if ( !((inContext("DOT ..."))) ) { if (state.backtracking>0) {state.failed=true; return ;} @@ -1589,7 +1592,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:284:8: r= RULE_REF + // CollectSymbols.g:287:8: r= RULE_REF { r=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref862); if (state.failed) return ; diff --git a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java index dd97d3793..3d97b226a 100644 --- a/tool/src/org/antlr/v4/semantics/SemanticPipeline.java +++ b/tool/src/org/antlr/v4/semantics/SemanticPipeline.java @@ -74,6 +74,13 @@ public class SemanticPipeline { for (AttributeDict s : collector.scopes) g.defineScope(s); for (GrammarAST a : collector.actions) g.defineAction(a); + // LINK ALT NODES WITH Alternatives + for (Rule r : g.rules.values()) { + for (int i=1; i<=r.numberOfAlts; i++) { + r.alt[i].ast.alt = r.alt[i]; + } + } + // CHECK RULE REFS NOW (that we've defined rules in grammar) symcheck.checkRuleArgs(g, collector.rulerefs); identifyStartRules(collector); @@ -101,6 +108,7 @@ public class SemanticPipeline { UseDefAnalyzer usedef = new UseDefAnalyzer(); usedef.checkRewriteElementsPresentOnLeftSide(g, collector.rules); + usedef.trackTokenRuleRefsInActions(g); } void identifyStartRules(CollectSymbols collector) { diff --git a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java index 630a41ccd..9efadfecd 100644 --- a/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java +++ b/tool/src/org/antlr/v4/semantics/UseDefAnalyzer.java @@ -23,5 +23,19 @@ public class UseDefAnalyzer { } } } - } + } + + // side-effect: updates Alternative with refs in actions + public void trackTokenRuleRefsInActions(Grammar g) { + for (Rule r : g.rules.values()) { + for (int i=1; i<=r.numberOfAlts; i++) { + Alternative alt = r.alt[i]; + for (ActionAST a : alt.actions) { + ActionSniffer sniffer = new ActionSniffer(g, r, alt, a, a.token); + sniffer.examineAction(); + } + } + } + } + } diff --git a/tool/src/org/antlr/v4/tool/ActionAST.java b/tool/src/org/antlr/v4/tool/ActionAST.java index d2354f8c7..6cbef6634 100644 --- a/tool/src/org/antlr/v4/tool/ActionAST.java +++ b/tool/src/org/antlr/v4/tool/ActionAST.java @@ -8,6 +8,8 @@ public class ActionAST extends GrammarAST { // Alt, rule, grammar space public AttributeResolver resolver; public List chunks; // useful for ANTLR IDE developers + /** In which alt does this node live? */ +// public Alternative alt; public ActionAST(Token t) { super(t); } public ActionAST(int type) { super(type); } diff --git a/tool/src/org/antlr/v4/tool/AltAST.java b/tool/src/org/antlr/v4/tool/AltAST.java new file mode 100644 index 000000000..7fcd19735 --- /dev/null +++ b/tool/src/org/antlr/v4/tool/AltAST.java @@ -0,0 +1,12 @@ +package org.antlr.v4.tool; + +import org.antlr.runtime.Token; + +/** An ALT or ALT_REWRITE node (left of ->) */ +public class AltAST extends GrammarAST { + public Alternative alt; + + public AltAST(Token t) { super(t); } + public AltAST(int type) { super(type); } + public AltAST(int type, Token t) { super(type, t); } +} diff --git a/tool/src/org/antlr/v4/tool/Alternative.java b/tool/src/org/antlr/v4/tool/Alternative.java index 533e3c1db..351cfc043 100644 --- a/tool/src/org/antlr/v4/tool/Alternative.java +++ b/tool/src/org/antlr/v4/tool/Alternative.java @@ -12,12 +12,20 @@ import java.util.List; public class Alternative implements AttributeResolver { Rule rule; + public AltAST ast; + // token IDs, string literals in this alt - public MultiMap tokenRefs = new MultiMap(); + public MultiMap tokenRefs = new MultiMap(); + + // does not include labels + public MultiMap tokenRefsInActions = new MultiMap(); // all rule refs in this alt public MultiMap ruleRefs = new MultiMap(); + // does not include labels + public MultiMap ruleRefsInActions = new MultiMap(); + /** A list of all LabelElementPair attached to tokens like id=ID, ids+=ID */ public MultiMap labelDefs = new MultiMap(); @@ -33,15 +41,36 @@ public class Alternative implements AttributeResolver { public Alternative(Rule r) { this.rule = r; } + public boolean resolvesToToken(String x, ActionAST node) { + if ( tokenRefs.get(x)!=null ) return true; + LabelElementPair anyLabelDef = getAnyLabelDef(x); + if ( anyLabelDef!=null && anyLabelDef.type==LabelType.TOKEN_LABEL ) return true; + return false; + } + +// public String getTokenLabel(String x, ActionAST node) { +// LabelElementPair anyLabelDef = getAnyLabelDef(x); +// if ( anyLabelDef!=null ) return anyLabelDef.label.getText(); +// if ( tokenRefs.get(x)!=null ) { +// +// } +// LabelElementPair anyLabelDef = getAnyLabelDef(x); +// if ( anyLabelDef!=null && anyLabelDef.type==LabelType.TOKEN_LABEL ) return true; +// return false; +// } + + public boolean resolvesToAttributeDict(String x, ActionAST node) { + if ( resolvesToToken(x, node) ) return true; + if ( x.equals(rule.name) ) return true; // $r for action in rule r, $r is a dict + if ( rule!=null && rule.scope!=null ) return true; + if ( rule.g.scopes.get(x)!=null ) return true; + return false; + } + /** $x Attribute: rule arguments, return values, predefined rule prop. */ public Attribute resolveToAttribute(String x, ActionAST node) { return rule.resolveToAttribute(x, node); // reuse that code -// if ( rule.args==null ) return null; -// Attribute a = rule.args.get(x); if ( a!=null ) return a; -// a = rule.retvals.get(x); if ( a!=null ) return a; -// AttributeDict properties = rule.getPredefinedScope(LabelType.RULE_LABEL); -// return properties.get(x); } /** $x.y, x can be surrounding rule, token/rule/label ref. y is visible @@ -75,6 +104,13 @@ public class Alternative implements AttributeResolver { return rule.resolveToDynamicScope(x, node); } + public boolean resolvesToLabel(String x, ActionAST node) { + LabelElementPair anyLabelDef = getAnyLabelDef(x); + return anyLabelDef!=null && + (anyLabelDef.type==LabelType.TOKEN_LABEL || + anyLabelDef.type==LabelType.RULE_LABEL); + } + public boolean resolvesToListLabel(String x, ActionAST node) { LabelElementPair anyLabelDef = getAnyLabelDef(x); return anyLabelDef!=null && diff --git a/tool/src/org/antlr/v4/tool/AttributeResolver.java b/tool/src/org/antlr/v4/tool/AttributeResolver.java index 3a2b230cd..9452cb980 100644 --- a/tool/src/org/antlr/v4/tool/AttributeResolver.java +++ b/tool/src/org/antlr/v4/tool/AttributeResolver.java @@ -31,6 +31,9 @@ package org.antlr.v4.tool; */ public interface AttributeResolver { public boolean resolvesToListLabel(String x, ActionAST node); + public boolean resolvesToLabel(String x, ActionAST node); + public boolean resolvesToAttributeDict(String x, ActionAST node); + public boolean resolvesToToken(String x, ActionAST node); public Attribute resolveToAttribute(String x, ActionAST node); public Attribute resolveToAttribute(String x, String y, ActionAST node); public AttributeDict resolveToDynamicScope(String x, ActionAST node); diff --git a/tool/src/org/antlr/v4/tool/Grammar.java b/tool/src/org/antlr/v4/tool/Grammar.java index f1bb331b8..7ef1255b4 100644 --- a/tool/src/org/antlr/v4/tool/Grammar.java +++ b/tool/src/org/antlr/v4/tool/Grammar.java @@ -121,7 +121,7 @@ public class Grammar implements AttributeResolver { this("", grammarText, listener); } - /** For testing */ + /** For testing; only builds trees; no sem anal */ public Grammar(String fileName, String grammarText, ANTLRToolListener listener) throws RecognitionException { @@ -496,9 +496,17 @@ public class Grammar implements AttributeResolver { return scopes.get(x); } + public boolean resolvesToLabel(String x, ActionAST node) { return false; } + public boolean resolvesToListLabel(String x, ActionAST node) { return false; } - - /** Given a grammar type, what should be the default action scope? + + public boolean resolvesToToken(String x, ActionAST node) { return false; } + + public boolean resolvesToAttributeDict(String x, ActionAST node) { + return scopes.get(x)!=null; + } + + /** Given a grammar type, what should be the default action scope? * If I say @members in a COMBINED grammar, for example, the * default scope should be "parser". */ diff --git a/tool/src/org/antlr/v4/tool/GrammarAST.java b/tool/src/org/antlr/v4/tool/GrammarAST.java index 660143b2d..b71780b70 100644 --- a/tool/src/org/antlr/v4/tool/GrammarAST.java +++ b/tool/src/org/antlr/v4/tool/GrammarAST.java @@ -50,6 +50,14 @@ public class GrammarAST extends CommonTree { return nodes; } + public AltAST getOutermostAltNode() { + if ( this instanceof AltAST && parent.parent instanceof RuleAST ) { + return (AltAST)this; + } + if ( parent!=null ) return ((GrammarAST)parent).getOutermostAltNode(); + return null; + } + // @Override // public boolean equals(Object obj) { // return super.equals(obj); diff --git a/tool/src/org/antlr/v4/tool/Rule.java b/tool/src/org/antlr/v4/tool/Rule.java index 8fdfad740..d0e01de86 100644 --- a/tool/src/org/antlr/v4/tool/Rule.java +++ b/tool/src/org/antlr/v4/tool/Rule.java @@ -118,7 +118,7 @@ public class Rule implements AttributeResolver { public Attribute resolveRetvalOrProperty(String y) { if ( retvals!=null ) { Attribute a = retvals.get(y); - if ( a!=null ) return retvals.get(y); + if ( a!=null ) return a; } AttributeDict d = getPredefinedScope(LabelType.RULE_LABEL); return d.get(y); @@ -163,8 +163,14 @@ public class Rule implements AttributeResolver { return defs; } - /** $x Attribute: rule arguments, return values, predefined rule prop, - * or a token/rule list label. + public AttributeDict getUniqueDictFor(String x, ActionAST node) { + if ( name.equals(x) ) { // x is this rule? + return getPredefinedScope(LabelType.RULE_LABEL); + } + return null; + } + + /** $x Attribute: rule arguments, return values, predefined rule prop. */ public Attribute resolveToAttribute(String x, ActionAST node) { if ( args!=null ) { @@ -202,6 +208,10 @@ public class Rule implements AttributeResolver { return g.scopes.get(x); } + public boolean resolvesToLabel(String x, ActionAST node) { + return false; + } + public boolean resolvesToListLabel(String x, ActionAST node) { LabelElementPair anyLabelDef = getAnyLabelDef(x); return anyLabelDef!=null && @@ -209,6 +219,20 @@ public class Rule implements AttributeResolver { anyLabelDef.type==LabelType.TOKEN_LIST_LABEL); } + public boolean resolvesToToken(String x, ActionAST node) { + LabelElementPair anyLabelDef = getAnyLabelDef(x); + if ( anyLabelDef.type==LabelType.TOKEN_LABEL ) return true; + return false; + } + + public boolean resolvesToAttributeDict(String x, ActionAST node) { + if ( resolvesToToken(x, node) ) return true; + if ( x.equals(name) ) return true; // $r for action in rule r, $r is a dict + if ( scope!=null ) return true; + if ( g.scopes.get(x)!=null ) return true; + return false; + } + public Rule resolveToRule(String x) { if ( x.equals(this.name) ) return this; LabelElementPair anyLabelDef = getAnyLabelDef(x); diff --git a/tool/test/org/antlr/v4/test/BaseTest.java b/tool/test/org/antlr/v4/test/BaseTest.java index 46c3de5d9..0c8a52df5 100644 --- a/tool/test/org/antlr/v4/test/BaseTest.java +++ b/tool/test/org/antlr/v4/test/BaseTest.java @@ -37,6 +37,7 @@ import org.antlr.v4.analysis.DFAMinimizer; import org.antlr.v4.analysis.LexerNFAToDFAConverter; import org.antlr.v4.analysis.PredictionDFAFactory; import org.antlr.v4.automata.*; +import org.antlr.v4.misc.Utils; import org.antlr.v4.semantics.SemanticPipeline; import org.antlr.v4.tool.*; import org.junit.After; @@ -545,10 +546,29 @@ public abstract class BaseTest { msg = msg.replaceAll("\n","\\\\n"); msg = msg.replaceAll("\r","\\\\r"); msg = msg.replaceAll("\t","\\\\t"); + + // ignore error number + expect = stripErrorNum(expect); + actual = stripErrorNum(actual); assertEquals("error in: "+msg,expect,actual); } } + // can be multi-line + //error(29): A.g:2:11: unknown attribute reference a in $a + //error(29): A.g:2:11: unknown attribute reference a in $a + String stripErrorNum(String errs) { + String[] lines = errs.split("\n"); + for (int i=0; i