From a7bed42c355b2ae4959e8aca3bb665acbfad8ea4 Mon Sep 17 00:00:00 2001 From: parrt Date: Mon, 20 Jun 2011 17:34:57 -0800 Subject: [PATCH] setting up ant build [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 8684] --- build.properties | 5 + build.xml | 154 +- .../antlr/v4/codegen/SourceGenTriggers.java | 1254 +++++++++++------ tool/src/org/antlr/v4/parse/ATNBuilder.g | 2 + .../v4/semantics/BasicSemanticTriggers.java | 758 +++++----- .../v4/semantics/BasicSemanticTriggers.tokens | 196 +-- .../antlr/v4/semantics/CollectSymbols.java | 1171 +++++++++------ .../antlr/v4/semantics/CollectSymbols.tokens | 196 +-- 8 files changed, 2326 insertions(+), 1410 deletions(-) create mode 100644 build.properties diff --git a/build.properties b/build.properties new file mode 100644 index 000000000..e774a1da8 --- /dev/null +++ b/build.properties @@ -0,0 +1,5 @@ +version=4.0ea + +antlr3.jar=/usr/local/lib/antlr-3.4-complete.jar +ant-antlr3.jar=${ant.library.dir}/ant-antlr3.jar +build.sysclasspath=ignore diff --git a/build.xml b/build.xml index 9b7c3c37f..051f0bce4 100644 --- a/build.xml +++ b/build.xml @@ -1,10 +1,152 @@ - - - + - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + parse + + + + + + + + + + + + + + semantics grammars + + + + + + + + + + + + + codegen grammars + + + + + + + + + + + + gunit grammars + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java index 8d2e85feb..f3ced0dbf 100644 --- a/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java +++ b/tool/src/org/antlr/v4/codegen/SourceGenTriggers.java @@ -1,133 +1,137 @@ -// $ANTLR 3.3 Nov 30, 2010 12:50:56 SourceGenTriggers.g 2011-06-13 18:23:30 +// $ANTLR 3.4 SourceGenTriggers.g 2011-06-20 18:31:17 package org.antlr.v4.codegen; -import org.antlr.runtime.*; import org.antlr.runtime.BitSet; +import org.antlr.runtime.*; import org.antlr.runtime.tree.*; -import org.antlr.v4.codegen.model.*; +import org.antlr.v4.codegen.src.*; import org.antlr.v4.misc.Utils; import org.antlr.v4.tool.*; import java.util.*; +@SuppressWarnings({"all", "warnings", "unchecked"}) public class SourceGenTriggers extends TreeParser { public static final String[] tokenNames = new String[] { - "", "", "", "", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "MODE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "ID", "ARG", "ARGLIST", "RET", "COMBINED", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "RESULT", "ALT_REWRITE" + "", "", "", "", "ACTION", "ACTION_CHAR_LITERAL", "ACTION_ESC", "ACTION_STRING_LITERAL", "ARG_ACTION", "ASSIGN", "AT", "BANG", "CATCH", "COLON", "COLONCOLON", "COMMA", "COMMENT", "DOC_COMMENT", "DOLLAR", "DOT", "DOUBLE_ANGLE_STRING_LITERAL", "DOUBLE_QUOTE_STRING_LITERAL", "ERRCHAR", "ESC_SEQ", "ETC", "FINALLY", "FORCED_ACTION", "FRAGMENT", "GRAMMAR", "GT", "HEX_DIGIT", "IMPLIES", "IMPORT", "INT", "LEXER", "LPAREN", "LT", "MODE", "NESTED_ACTION", "NLCHARS", "NOT", "OPTIONS", "OR", "PARSER", "PLUS", "PLUS_ASSIGN", "PRIVATE", "PROTECTED", "PUBLIC", "QUESTION", "RANGE", "RARROW", "RBRACE", "RETURNS", "ROOT", "RPAREN", "RULE_REF", "SCOPE", "SEMI", "SEMPRED", "SRC", "STAR", "STRING_LITERAL", "TEMPLATE", "THROWS", "TOKENS", "TOKEN_REF", "TREE", "TREE_BEGIN", "UNICODE_ESC", "WS", "WSCHARS", "WSNLCHARS", "ALT", "ALTLIST", "ALT_REWRITE", "ARG", "ARGLIST", "BACKTRACK_SEMPRED", "BLOCK", "CHAR_RANGE", "CLOSURE", "COMBINED", "ELEMENT_OPTIONS", "EPSILON", "GATED_SEMPRED", "ID", "INITACTION", "LABEL", "LIST", "OPTIONAL", "POSITIVE_CLOSURE", "RESULT", "RET", "REWRITE_BLOCK", "RULE", "RULEACTIONS", "RULEMODIFIERS", "RULES", "ST_RESULT", "SYNPRED", "SYN_SEMPRED", "WILDCARD" }; + public static final int EOF=-1; - public static final int SEMPRED=4; - public static final int FORCED_ACTION=5; - public static final int DOC_COMMENT=6; - public static final int SRC=7; - public static final int NLCHARS=8; - public static final int COMMENT=9; - public static final int DOUBLE_QUOTE_STRING_LITERAL=10; - public static final int DOUBLE_ANGLE_STRING_LITERAL=11; - public static final int ACTION_STRING_LITERAL=12; - public static final int ACTION_CHAR_LITERAL=13; - public static final int ARG_ACTION=14; - public static final int NESTED_ACTION=15; - public static final int ACTION=16; - public static final int ACTION_ESC=17; - public static final int WSNLCHARS=18; - public static final int OPTIONS=19; - public static final int TOKENS=20; - public static final int SCOPE=21; - public static final int IMPORT=22; - public static final int FRAGMENT=23; - public static final int LEXER=24; - public static final int PARSER=25; - public static final int TREE=26; - public static final int GRAMMAR=27; - public static final int PROTECTED=28; - public static final int PUBLIC=29; - public static final int PRIVATE=30; - public static final int RETURNS=31; - public static final int THROWS=32; - public static final int CATCH=33; - public static final int FINALLY=34; - public static final int TEMPLATE=35; - public static final int MODE=36; - public static final int COLON=37; - public static final int COLONCOLON=38; - public static final int COMMA=39; - public static final int SEMI=40; - public static final int LPAREN=41; - public static final int RPAREN=42; - public static final int IMPLIES=43; - public static final int LT=44; - public static final int GT=45; - public static final int ASSIGN=46; - public static final int QUESTION=47; - public static final int BANG=48; - public static final int STAR=49; - public static final int PLUS=50; - public static final int PLUS_ASSIGN=51; - public static final int OR=52; - public static final int ROOT=53; - public static final int DOLLAR=54; - public static final int DOT=55; - public static final int RANGE=56; - public static final int ETC=57; - public static final int RARROW=58; - public static final int TREE_BEGIN=59; - public static final int AT=60; - public static final int NOT=61; - public static final int RBRACE=62; - public static final int TOKEN_REF=63; - public static final int RULE_REF=64; - public static final int INT=65; - public static final int WSCHARS=66; - public static final int ESC_SEQ=67; - public static final int STRING_LITERAL=68; - public static final int HEX_DIGIT=69; - public static final int UNICODE_ESC=70; - public static final int WS=71; - public static final int ERRCHAR=72; - public static final int RULE=73; - public static final int RULES=74; - public static final int RULEMODIFIERS=75; - public static final int RULEACTIONS=76; - public static final int BLOCK=77; - public static final int REWRITE_BLOCK=78; - public static final int OPTIONAL=79; - public static final int CLOSURE=80; - public static final int POSITIVE_CLOSURE=81; - public static final int SYNPRED=82; - public static final int CHAR_RANGE=83; + public static final int ACTION=4; + public static final int ACTION_CHAR_LITERAL=5; + public static final int ACTION_ESC=6; + public static final int ACTION_STRING_LITERAL=7; + public static final int ARG_ACTION=8; + public static final int ASSIGN=9; + public static final int AT=10; + public static final int BANG=11; + public static final int CATCH=12; + public static final int COLON=13; + public static final int COLONCOLON=14; + public static final int COMMA=15; + public static final int COMMENT=16; + public static final int DOC_COMMENT=17; + public static final int DOLLAR=18; + public static final int DOT=19; + public static final int DOUBLE_ANGLE_STRING_LITERAL=20; + public static final int DOUBLE_QUOTE_STRING_LITERAL=21; + public static final int ERRCHAR=22; + public static final int ESC_SEQ=23; + public static final int ETC=24; + public static final int FINALLY=25; + public static final int FORCED_ACTION=26; + public static final int FRAGMENT=27; + public static final int GRAMMAR=28; + public static final int GT=29; + public static final int HEX_DIGIT=30; + public static final int IMPLIES=31; + public static final int IMPORT=32; + public static final int INT=33; + public static final int LEXER=34; + public static final int LPAREN=35; + public static final int LT=36; + public static final int MODE=37; + public static final int NESTED_ACTION=38; + public static final int NLCHARS=39; + public static final int NOT=40; + public static final int OPTIONS=41; + public static final int OR=42; + public static final int PARSER=43; + public static final int PLUS=44; + public static final int PLUS_ASSIGN=45; + public static final int PRIVATE=46; + public static final int PROTECTED=47; + public static final int PUBLIC=48; + public static final int QUESTION=49; + public static final int RANGE=50; + public static final int RARROW=51; + public static final int RBRACE=52; + public static final int RETURNS=53; + public static final int ROOT=54; + public static final int RPAREN=55; + public static final int RULE_REF=56; + public static final int SCOPE=57; + public static final int SEMI=58; + public static final int SEMPRED=59; + public static final int SRC=60; + public static final int STAR=61; + public static final int STRING_LITERAL=62; + public static final int TEMPLATE=63; + public static final int THROWS=64; + public static final int TOKENS=65; + public static final int TOKEN_REF=66; + public static final int TREE=67; + public static final int TREE_BEGIN=68; + public static final int UNICODE_ESC=69; + public static final int WS=70; + public static final int WSCHARS=71; + public static final int WSNLCHARS=72; + public static final int ALT=73; + public static final int ALTLIST=74; + public static final int ALT_REWRITE=75; + public static final int ARG=76; + public static final int ARGLIST=77; + public static final int BACKTRACK_SEMPRED=78; + public static final int BLOCK=79; + public static final int CHAR_RANGE=80; + public static final int CLOSURE=81; + public static final int COMBINED=82; + public static final int ELEMENT_OPTIONS=83; public static final int EPSILON=84; - public static final int ALT=85; - public static final int ALTLIST=86; - public static final int ID=87; - public static final int ARG=88; - public static final int ARGLIST=89; - public static final int RET=90; - public static final int COMBINED=91; - public static final int INITACTION=92; - public static final int LABEL=93; - public static final int GATED_SEMPRED=94; - public static final int SYN_SEMPRED=95; - public static final int BACKTRACK_SEMPRED=96; - public static final int WILDCARD=97; - public static final int LIST=98; - public static final int ELEMENT_OPTIONS=99; - public static final int ST_RESULT=100; - public static final int RESULT=101; - public static final int ALT_REWRITE=102; + public static final int GATED_SEMPRED=85; + public static final int ID=86; + public static final int INITACTION=87; + public static final int LABEL=88; + public static final int LIST=89; + public static final int OPTIONAL=90; + public static final int POSITIVE_CLOSURE=91; + public static final int RESULT=92; + public static final int RET=93; + public static final int REWRITE_BLOCK=94; + public static final int RULE=95; + public static final int RULEACTIONS=96; + public static final int RULEMODIFIERS=97; + public static final int RULES=98; + public static final int ST_RESULT=99; + public static final int SYNPRED=100; + public static final int SYN_SEMPRED=101; + public static final int WILDCARD=102; // delegates + public TreeParser[] getDelegates() { + return new TreeParser[] {}; + } + // delegators - public SourceGenTriggers(TreeNodeStream input) { - this(input, new RecognizerSharedState()); - } - public SourceGenTriggers(TreeNodeStream input, RecognizerSharedState state) { - super(input, state); - - } - + public SourceGenTriggers(TreeNodeStream input) { + this(input, new RecognizerSharedState()); + } + public SourceGenTriggers(TreeNodeStream input, RecognizerSharedState state) { + super(input, state); + } public String[] getTokenNames() { return SourceGenTriggers.tokenNames; } public String getGrammarFileName() { return "SourceGenTriggers.g"; } @@ -147,8 +151,9 @@ public class SourceGenTriggers extends TreeParser { public final SrcOp block(GrammarAST label, GrammarAST ebnfRoot) throws RecognitionException { SrcOp omo = null; + GrammarAST blk=null; - SourceGenTriggers.alternative_return alternative1 = null; + SourceGenTriggers.alternative_return alternative1 =null; try { @@ -179,7 +184,7 @@ public class SourceGenTriggers extends TreeParser { int alt1=2; int LA1_0 = input.LA(1); - if ( ((LA1_0>=SEMPRED && LA1_0<=ALT_REWRITE)) ) { + if ( ((LA1_0 >= ACTION && LA1_0 <= WILDCARD)) ) { alt1=1; } else if ( (LA1_0==UP) ) { @@ -208,12 +213,15 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; } + List alts = new ArrayList(); + // SourceGenTriggers.g:30:7: ( alternative )+ int cnt3=0; loop3: @@ -235,6 +243,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + alts.add((alternative1!=null?alternative1.omo:null)); } @@ -252,6 +261,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + if ( alts.size()==1 && ebnfRoot==null) return alts.get(0); if ( ebnfRoot==null ) { omo = factory.getChoiceBlock((BlockAST)blk, alts); @@ -268,25 +279,30 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omo; } // $ANTLR end "block" + public static class alternative_return extends TreeRuleReturnScope { public CodeBlock omo; }; + // $ANTLR start "alternative" // SourceGenTriggers.g:43:1: alternative returns [CodeBlock omo] : ( ^( ALT_REWRITE a= alternative . ) | ^( ALT EPSILON ) | ^( ALT ( element )+ ) ); public final SourceGenTriggers.alternative_return alternative() throws RecognitionException { SourceGenTriggers.alternative_return retval = new SourceGenTriggers.alternative_return(); retval.start = input.LT(1); - SourceGenTriggers.alternative_return a = null; - List element2 = null; + SourceGenTriggers.alternative_return a =null; + + List element2 =null; @@ -311,7 +327,7 @@ public class SourceGenTriggers extends TreeParser { if ( (LA5_3==EPSILON) ) { alt5=2; } - else if ( ((LA5_3>=SEMPRED && LA5_3<=FORCED_ACTION)||LA5_3==ACTION||LA5_3==IMPLIES||LA5_3==ASSIGN||LA5_3==BANG||LA5_3==PLUS_ASSIGN||LA5_3==ROOT||(LA5_3>=DOT && LA5_3<=RANGE)||LA5_3==TREE_BEGIN||LA5_3==NOT||(LA5_3>=TOKEN_REF && LA5_3<=RULE_REF)||LA5_3==STRING_LITERAL||LA5_3==BLOCK||(LA5_3>=OPTIONAL && LA5_3<=POSITIVE_CLOSURE)||LA5_3==GATED_SEMPRED||LA5_3==WILDCARD) ) { + else if ( (LA5_3==ACTION||LA5_3==ASSIGN||LA5_3==BANG||LA5_3==DOT||LA5_3==FORCED_ACTION||LA5_3==IMPLIES||LA5_3==NOT||LA5_3==PLUS_ASSIGN||LA5_3==RANGE||LA5_3==ROOT||LA5_3==RULE_REF||LA5_3==SEMPRED||LA5_3==STRING_LITERAL||LA5_3==TOKEN_REF||LA5_3==TREE_BEGIN||LA5_3==BLOCK||LA5_3==CLOSURE||LA5_3==GATED_SEMPRED||(LA5_3 >= OPTIONAL && LA5_3 <= POSITIVE_CLOSURE)||LA5_3==WILDCARD) ) { alt5=3; } else { @@ -319,6 +335,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 5, 3, input); throw nvae; + } } else { @@ -326,6 +343,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 5, 2, input); throw nvae; + } } else { @@ -333,6 +351,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 5, 0, input); throw nvae; + } switch (alt5) { case 1 : @@ -346,10 +365,12 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + matchAny(input); match(input, Token.UP, null); + } break; case 2 : @@ -361,6 +382,8 @@ public class SourceGenTriggers extends TreeParser { match(input,EPSILON,FOLLOW_EPSILON_in_alternative159); match(input, Token.UP, null); + + retval.omo = factory.epsilon(); } @@ -378,7 +401,7 @@ public class SourceGenTriggers extends TreeParser { int alt4=2; int LA4_0 = input.LA(1); - if ( ((LA4_0>=SEMPRED && LA4_0<=FORCED_ACTION)||LA4_0==ACTION||LA4_0==IMPLIES||LA4_0==ASSIGN||LA4_0==BANG||LA4_0==PLUS_ASSIGN||LA4_0==ROOT||(LA4_0>=DOT && LA4_0<=RANGE)||LA4_0==TREE_BEGIN||LA4_0==NOT||(LA4_0>=TOKEN_REF && LA4_0<=RULE_REF)||LA4_0==STRING_LITERAL||LA4_0==BLOCK||(LA4_0>=OPTIONAL && LA4_0<=POSITIVE_CLOSURE)||LA4_0==GATED_SEMPRED||LA4_0==WILDCARD) ) { + if ( (LA4_0==ACTION||LA4_0==ASSIGN||LA4_0==BANG||LA4_0==DOT||LA4_0==FORCED_ACTION||LA4_0==IMPLIES||LA4_0==NOT||LA4_0==PLUS_ASSIGN||LA4_0==RANGE||LA4_0==ROOT||LA4_0==RULE_REF||LA4_0==SEMPRED||LA4_0==STRING_LITERAL||LA4_0==TOKEN_REF||LA4_0==TREE_BEGIN||LA4_0==BLOCK||LA4_0==CLOSURE||LA4_0==GATED_SEMPRED||(LA4_0 >= OPTIONAL && LA4_0 <= POSITIVE_CLOSURE)||LA4_0==WILDCARD) ) { alt4=1; } @@ -392,6 +415,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + elems.addAll(element2); } @@ -408,6 +432,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + retval.omo = factory.alternative(elems); } @@ -419,32 +445,155 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "alternative" + // $ANTLR start "element" // SourceGenTriggers.g:54:1: element returns [List omos] : ( labeledElement | atom[null] | ebnf | ACTION | FORCED_ACTION | SEMPRED | GATED_SEMPRED | treeSpec ); public final List element() throws RecognitionException { List omos = null; + GrammarAST ACTION6=null; GrammarAST FORCED_ACTION7=null; GrammarAST SEMPRED8=null; - List labeledElement3 = null; + List labeledElement3 =null; - List atom4 = null; + List atom4 =null; - SrcOp ebnf5 = null; + SrcOp ebnf5 =null; try { // SourceGenTriggers.g:55:2: ( labeledElement | atom[null] | ebnf | ACTION | FORCED_ACTION | SEMPRED | GATED_SEMPRED | treeSpec ) int alt6=8; - alt6 = dfa6.predict(input); + switch ( input.LA(1) ) { + case ASSIGN: + case PLUS_ASSIGN: + { + alt6=1; + } + break; + case ROOT: + { + int LA6_2 = input.LA(2); + + if ( (LA6_2==DOWN) ) { + int LA6_11 = input.LA(3); + + if ( (LA6_11==BANG||LA6_11==NOT||LA6_11==RANGE||LA6_11==ROOT||LA6_11==RULE_REF||LA6_11==STRING_LITERAL||LA6_11==TOKEN_REF) ) { + alt6=2; + } + else if ( (LA6_11==BLOCK) ) { + alt6=3; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 11, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 2, input); + + throw nvae; + + } + } + break; + case BANG: + { + int LA6_3 = input.LA(2); + + if ( (LA6_3==DOWN) ) { + int LA6_12 = input.LA(3); + + if ( (LA6_12==BANG||LA6_12==NOT||LA6_12==RANGE||LA6_12==ROOT||LA6_12==RULE_REF||LA6_12==STRING_LITERAL||LA6_12==TOKEN_REF) ) { + alt6=2; + } + else if ( (LA6_12==BLOCK) ) { + alt6=3; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 12, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 3, input); + + throw nvae; + + } + } + break; + case DOT: + case NOT: + case RANGE: + case RULE_REF: + case STRING_LITERAL: + case TOKEN_REF: + case WILDCARD: + { + alt6=2; + } + break; + case IMPLIES: + case BLOCK: + case CLOSURE: + case OPTIONAL: + case POSITIVE_CLOSURE: + { + alt6=3; + } + break; + case ACTION: + { + alt6=4; + } + break; + case FORCED_ACTION: + { + alt6=5; + } + break; + case SEMPRED: + { + alt6=6; + } + break; + case GATED_SEMPRED: + { + alt6=7; + } + break; + case TREE_BEGIN: + { + alt6=8; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + + throw nvae; + + } + switch (alt6) { case 1 : // SourceGenTriggers.g:55:4: labeledElement @@ -454,6 +603,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = labeledElement3; } @@ -466,6 +616,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = atom4; } @@ -478,6 +629,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = Utils.list(ebnf5); } @@ -486,6 +638,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:58:6: ACTION { ACTION6=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_element244); + omos = Utils.list(factory.action(ACTION6)); } @@ -494,6 +647,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:59:6: FORCED_ACTION { FORCED_ACTION7=(GrammarAST)match(input,FORCED_ACTION,FOLLOW_FORCED_ACTION_in_element259); + omos = Utils.list(factory.forcedAction(FORCED_ACTION7)); } @@ -502,6 +656,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:60:6: SEMPRED { SEMPRED8=(GrammarAST)match(input,SEMPRED,FOLLOW_SEMPRED_in_element272); + omos = Utils.list(factory.sempred(SEMPRED8)); } @@ -531,35 +686,125 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "element" + // $ANTLR start "labeledElement" // SourceGenTriggers.g:65: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; + GrammarAST ID9=null; GrammarAST ID11=null; GrammarAST ID13=null; GrammarAST ID15=null; - List atom10 = null; + List atom10 =null; - SrcOp block12 = null; + SrcOp block12 =null; - List atom14 = null; + List atom14 =null; - SrcOp block16 = null; + SrcOp block16 =null; try { // SourceGenTriggers.g:66: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); + int LA7_0 = input.LA(1); + + if ( (LA7_0==ASSIGN) ) { + int LA7_1 = input.LA(2); + + if ( (LA7_1==DOWN) ) { + int LA7_3 = input.LA(3); + + if ( (LA7_3==ID) ) { + int LA7_5 = input.LA(4); + + if ( (LA7_5==BANG||LA7_5==DOT||LA7_5==NOT||LA7_5==RANGE||LA7_5==ROOT||LA7_5==RULE_REF||LA7_5==STRING_LITERAL||LA7_5==TOKEN_REF||LA7_5==WILDCARD) ) { + alt7=1; + } + else if ( (LA7_5==BLOCK) ) { + alt7=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 5, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 3, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 1, input); + + throw nvae; + + } + } + else if ( (LA7_0==PLUS_ASSIGN) ) { + int LA7_2 = input.LA(2); + + if ( (LA7_2==DOWN) ) { + int LA7_4 = input.LA(3); + + if ( (LA7_4==ID) ) { + int LA7_6 = input.LA(4); + + if ( (LA7_6==BANG||LA7_6==DOT||LA7_6==NOT||LA7_6==RANGE||LA7_6==ROOT||LA7_6==RULE_REF||LA7_6==STRING_LITERAL||LA7_6==TOKEN_REF||LA7_6==WILDCARD) ) { + alt7=3; + } + else if ( (LA7_6==BLOCK) ) { + alt7=4; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 6, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 4, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 2, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 0, input); + + throw nvae; + + } switch (alt7) { case 1 : // SourceGenTriggers.g:66:4: ^( ASSIGN ID atom[$ID] ) @@ -568,6 +813,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); ID9=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement308); + pushFollow(FOLLOW_atom_in_labeledElement310); atom10=atom(ID9); @@ -575,6 +821,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = atom10; } @@ -586,6 +834,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); ID11=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement326); + pushFollow(FOLLOW_block_in_labeledElement328); block12=block(ID11, null); @@ -593,6 +842,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = Utils.list(block12); } @@ -604,6 +855,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); ID13=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement341); + pushFollow(FOLLOW_atom_in_labeledElement343); atom14=atom(ID13); @@ -611,6 +863,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = atom14; } @@ -622,6 +876,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); ID15=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement357); + pushFollow(FOLLOW_block_in_labeledElement359); block16=block(ID15, null); @@ -629,6 +884,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = Utils.list(block16); } @@ -640,19 +897,23 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "labeledElement" + // $ANTLR start "treeSpec" // SourceGenTriggers.g:72:1: treeSpec returns [SrcOp omo] : ^( TREE_BEGIN (e= element )+ ) ; public final SrcOp treeSpec() throws RecognitionException { SrcOp omo = null; - List e = null; + + List e =null; try { @@ -669,7 +930,7 @@ public class SourceGenTriggers extends TreeParser { int alt8=2; int LA8_0 = input.LA(1); - if ( ((LA8_0>=SEMPRED && LA8_0<=FORCED_ACTION)||LA8_0==ACTION||LA8_0==IMPLIES||LA8_0==ASSIGN||LA8_0==BANG||LA8_0==PLUS_ASSIGN||LA8_0==ROOT||(LA8_0>=DOT && LA8_0<=RANGE)||LA8_0==TREE_BEGIN||LA8_0==NOT||(LA8_0>=TOKEN_REF && LA8_0<=RULE_REF)||LA8_0==STRING_LITERAL||LA8_0==BLOCK||(LA8_0>=OPTIONAL && LA8_0<=POSITIVE_CLOSURE)||LA8_0==GATED_SEMPRED||LA8_0==WILDCARD) ) { + if ( (LA8_0==ACTION||LA8_0==ASSIGN||LA8_0==BANG||LA8_0==DOT||LA8_0==FORCED_ACTION||LA8_0==IMPLIES||LA8_0==NOT||LA8_0==PLUS_ASSIGN||LA8_0==RANGE||LA8_0==ROOT||LA8_0==RULE_REF||LA8_0==SEMPRED||LA8_0==STRING_LITERAL||LA8_0==TOKEN_REF||LA8_0==TREE_BEGIN||LA8_0==BLOCK||LA8_0==CLOSURE||LA8_0==GATED_SEMPRED||(LA8_0 >= OPTIONAL && LA8_0 <= POSITIVE_CLOSURE)||LA8_0==WILDCARD) ) { alt8=1; } @@ -699,6 +960,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } } @@ -706,36 +968,40 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omo; } // $ANTLR end "treeSpec" + // $ANTLR start "ebnf" // SourceGenTriggers.g:76: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; + GrammarAST OPTIONAL17=null; GrammarAST CLOSURE19=null; GrammarAST POSITIVE_CLOSURE21=null; - SrcOp block18 = null; + SrcOp block18 =null; - SrcOp block20 = null; + SrcOp block20 =null; - SrcOp block22 = null; + SrcOp block22 =null; - SrcOp block23 = null; + SrcOp block23 =null; try { // SourceGenTriggers.g:77: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: case BANG: + case IMPLIES: case ROOT: { alt9=1; @@ -766,6 +1032,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 9, 0, input); throw nvae; + } switch (alt9) { @@ -787,6 +1054,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 2 : @@ -802,6 +1070,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omo = block18; } @@ -819,6 +1089,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omo = block20; } @@ -836,6 +1108,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omo = block22; } @@ -848,6 +1122,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omo = block23; } @@ -859,13 +1134,16 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omo; } // $ANTLR end "ebnf" + // $ANTLR start "astBlockSuffix" // SourceGenTriggers.g:85:1: astBlockSuffix : ( ROOT | IMPLIES | BANG ); public final void astBlockSuffix() throws RecognitionException { @@ -873,7 +1151,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:86:5: ( ROOT | IMPLIES | BANG ) // SourceGenTriggers.g: { - if ( input.LA(1)==IMPLIES||input.LA(1)==BANG||input.LA(1)==ROOT ) { + if ( input.LA(1)==BANG||input.LA(1)==IMPLIES||input.LA(1)==ROOT ) { input.consume(); state.errorRecovery=false; } @@ -890,33 +1168,285 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "astBlockSuffix" + // $ANTLR start "atom" // SourceGenTriggers.g:93: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; - List range24 = null; - List notSet25 = null; + List range24 =null; - List range26 = null; + List notSet25 =null; - List terminal27 = null; + List range26 =null; - List ruleref28 = null; + List terminal27 =null; + + List ruleref28 =null; try { // SourceGenTriggers.g:94: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 ( input.LA(1) ) { + case ROOT: + { + int LA10_1 = input.LA(2); + + if ( (LA10_1==DOWN) ) { + switch ( input.LA(3) ) { + case RULE_REF: + { + alt10=12; + } + break; + case RANGE: + { + alt10=1; + } + break; + case NOT: + { + alt10=3; + } + break; + case BANG: + case ROOT: + case STRING_LITERAL: + case TOKEN_REF: + { + alt10=11; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 10, 9, input); + + throw nvae; + + } + + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 1, input); + + throw nvae; + + } + } + break; + case BANG: + { + int LA10_2 = input.LA(2); + + if ( (LA10_2==DOWN) ) { + switch ( input.LA(3) ) { + case RULE_REF: + { + alt10=12; + } + break; + case RANGE: + { + alt10=2; + } + break; + case NOT: + { + alt10=4; + } + break; + case BANG: + case ROOT: + case STRING_LITERAL: + case TOKEN_REF: + { + alt10=11; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 10, 10, input); + + throw nvae; + + } + + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 2, input); + + throw nvae; + + } + } + break; + case NOT: + { + alt10=5; + } + break; + case RANGE: + { + alt10=6; + } + break; + case DOT: + { + int LA10_5 = input.LA(2); + + if ( (LA10_5==DOWN) ) { + int LA10_11 = input.LA(3); + + if ( (LA10_11==ID) ) { + switch ( input.LA(4) ) { + case STRING_LITERAL: + case TOKEN_REF: + { + alt10=7; + } + break; + case ROOT: + { + int LA10_20 = input.LA(5); + + if ( (LA10_20==DOWN) ) { + int LA10_23 = input.LA(6); + + if ( (LA10_23==RULE_REF) ) { + alt10=8; + } + else if ( (LA10_23==BANG||LA10_23==ROOT||LA10_23==STRING_LITERAL||LA10_23==TOKEN_REF) ) { + alt10=7; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 23, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 20, input); + + throw nvae; + + } + } + break; + case BANG: + { + int LA10_21 = input.LA(5); + + if ( (LA10_21==DOWN) ) { + int LA10_24 = input.LA(6); + + if ( (LA10_24==RULE_REF) ) { + alt10=8; + } + else if ( (LA10_24==BANG||LA10_24==ROOT||LA10_24==STRING_LITERAL||LA10_24==TOKEN_REF) ) { + alt10=7; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 24, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 21, input); + + throw nvae; + + } + } + break; + case RULE_REF: + { + alt10=8; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 10, 18, input); + + throw nvae; + + } + + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 11, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 5, input); + + throw nvae; + + } + } + break; + case WILDCARD: + { + int LA10_6 = input.LA(2); + + if ( (LA10_6==DOWN) ) { + alt10=9; + } + else if ( ((LA10_6 >= UP && LA10_6 <= ACTION)||LA10_6==ASSIGN||LA10_6==BANG||LA10_6==DOT||LA10_6==FORCED_ACTION||LA10_6==IMPLIES||LA10_6==NOT||LA10_6==PLUS_ASSIGN||LA10_6==RANGE||LA10_6==ROOT||LA10_6==RULE_REF||LA10_6==SEMPRED||LA10_6==STRING_LITERAL||LA10_6==TOKEN_REF||LA10_6==TREE_BEGIN||LA10_6==BLOCK||LA10_6==CLOSURE||LA10_6==GATED_SEMPRED||(LA10_6 >= OPTIONAL && LA10_6 <= POSITIVE_CLOSURE)||LA10_6==WILDCARD) ) { + alt10=10; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 10, 6, input); + + throw nvae; + + } + } + break; + case STRING_LITERAL: + case TOKEN_REF: + { + alt10=11; + } + break; + case RULE_REF: + { + alt10=12; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 10, 0, input); + + throw nvae; + + } + switch (alt10) { case 1 : // SourceGenTriggers.g:94:4: ^( ROOT range[label] ) @@ -932,6 +1462,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 2 : @@ -947,6 +1478,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = range24; } @@ -965,6 +1498,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 4 : @@ -980,6 +1514,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + + omos = notSet25; } @@ -1003,6 +1539,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = range26; } @@ -1014,6 +1551,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); match(input,ID,FOLLOW_ID_in_atom599); + pushFollow(FOLLOW_terminal_in_atom601); terminal(label); @@ -1022,6 +1560,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 8 : @@ -1031,6 +1570,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); match(input,ID,FOLLOW_ID_in_atom611); + pushFollow(FOLLOW_ruleref_in_atom613); ruleref(label); @@ -1039,6 +1579,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 9 : @@ -1051,6 +1592,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 10 : @@ -1068,6 +1610,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = terminal27; } @@ -1080,6 +1623,7 @@ public class SourceGenTriggers extends TreeParser { state._fsp--; + omos = ruleref28; } @@ -1091,18 +1635,22 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "atom" + // $ANTLR start "notSet" // SourceGenTriggers.g:108: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:109:5: ( ^( NOT terminal[label] ) | ^( NOT block[label,null] ) ) int alt11=2; @@ -1114,7 +1662,7 @@ public class SourceGenTriggers extends TreeParser { if ( (LA11_1==DOWN) ) { int LA11_2 = input.LA(3); - if ( (LA11_2==BANG||LA11_2==ROOT||LA11_2==TOKEN_REF||LA11_2==STRING_LITERAL) ) { + if ( (LA11_2==BANG||LA11_2==ROOT||LA11_2==STRING_LITERAL||LA11_2==TOKEN_REF) ) { alt11=1; } else if ( (LA11_2==BLOCK) ) { @@ -1125,6 +1673,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 11, 2, input); throw nvae; + } } else { @@ -1132,6 +1681,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 11, 1, input); throw nvae; + } } else { @@ -1139,6 +1689,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 11, 0, input); throw nvae; + } switch (alt11) { case 1 : @@ -1155,6 +1706,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 2 : @@ -1171,6 +1723,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; @@ -1180,18 +1733,22 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "notSet" + // $ANTLR start "ruleref" // SourceGenTriggers.g:113: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; + GrammarAST RULE_REF29=null; GrammarAST ARG_ACTION30=null; GrammarAST RULE_REF31=null; @@ -1221,6 +1778,7 @@ public class SourceGenTriggers extends TreeParser { new NoViableAltException("", 15, 0, input); throw nvae; + } switch (alt15) { @@ -1256,8 +1814,10 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); } + match(input, Token.UP, null); + } break; case 2 : @@ -1292,7 +1852,10 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); } + match(input, Token.UP, null); + + omos = factory.ruleRef(RULE_REF29, label, ARG_ACTION30); } @@ -1325,6 +1888,8 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); } + + omos = factory.ruleRef(RULE_REF31, label, ARG_ACTION32); } @@ -1336,18 +1901,22 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "ruleref" + // $ANTLR start "range" // SourceGenTriggers.g:119: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; + GrammarAST a=null; GrammarAST b=null; @@ -1359,10 +1928,12 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); a=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range801); + b=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_range805); match(input, Token.UP, null); + } } @@ -1370,18 +1941,22 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } // $ANTLR end "range" + // $ANTLR start "terminal" // SourceGenTriggers.g:123: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; + GrammarAST STRING_LITERAL33=null; GrammarAST STRING_LITERAL34=null; GrammarAST TOKEN_REF35=null; @@ -1392,7 +1967,91 @@ public class SourceGenTriggers extends TreeParser { try { // SourceGenTriggers.g:124: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 ( input.LA(1) ) { + case STRING_LITERAL: + { + int LA16_1 = input.LA(2); + + if ( (LA16_1==DOWN) ) { + alt16=1; + } + else if ( ((LA16_1 >= UP && LA16_1 <= ACTION)||LA16_1==ASSIGN||LA16_1==BANG||LA16_1==DOT||LA16_1==FORCED_ACTION||LA16_1==IMPLIES||LA16_1==NOT||LA16_1==PLUS_ASSIGN||LA16_1==RANGE||LA16_1==ROOT||LA16_1==RULE_REF||LA16_1==SEMPRED||LA16_1==STRING_LITERAL||LA16_1==TOKEN_REF||LA16_1==TREE_BEGIN||LA16_1==BLOCK||LA16_1==CLOSURE||LA16_1==GATED_SEMPRED||(LA16_1 >= OPTIONAL && LA16_1 <= POSITIVE_CLOSURE)||LA16_1==WILDCARD) ) { + alt16=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 16, 1, input); + + throw nvae; + + } + } + break; + case TOKEN_REF: + { + int LA16_2 = input.LA(2); + + if ( (LA16_2==DOWN) ) { + int LA16_7 = input.LA(3); + + if ( (LA16_7==ARG_ACTION) ) { + int LA16_9 = input.LA(4); + + if ( ((LA16_9 >= ACTION && LA16_9 <= WILDCARD)) ) { + alt16=3; + } + else if ( ((LA16_9 >= DOWN && LA16_9 <= UP)) ) { + alt16=4; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 16, 9, input); + + throw nvae; + + } + } + else if ( ((LA16_7 >= ACTION && LA16_7 <= ACTION_STRING_LITERAL)||(LA16_7 >= ASSIGN && LA16_7 <= WILDCARD)) ) { + alt16=4; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 16, 7, input); + + throw nvae; + + } + } + else if ( ((LA16_2 >= UP && LA16_2 <= ACTION)||LA16_2==ASSIGN||LA16_2==BANG||LA16_2==DOT||LA16_2==FORCED_ACTION||LA16_2==IMPLIES||LA16_2==NOT||LA16_2==PLUS_ASSIGN||LA16_2==RANGE||LA16_2==ROOT||LA16_2==RULE_REF||LA16_2==SEMPRED||LA16_2==STRING_LITERAL||LA16_2==TOKEN_REF||LA16_2==TREE_BEGIN||LA16_2==BLOCK||LA16_2==CLOSURE||LA16_2==GATED_SEMPRED||(LA16_2 >= OPTIONAL && LA16_2 <= POSITIVE_CLOSURE)||LA16_2==WILDCARD) ) { + alt16=5; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 16, 2, input); + + throw nvae; + + } + } + break; + case ROOT: + { + alt16=6; + } + break; + case BANG: + { + alt16=7; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 16, 0, input); + + throw nvae; + + } + switch (alt16) { case 1 : // SourceGenTriggers.g:124:8: ^( STRING_LITERAL . ) @@ -1403,6 +2062,8 @@ public class SourceGenTriggers extends TreeParser { matchAny(input); match(input, Token.UP, null); + + omos = factory.stringRef(STRING_LITERAL33, label); } @@ -1411,6 +2072,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:125:7: STRING_LITERAL { STRING_LITERAL34=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal845); + omos = factory.stringRef(STRING_LITERAL34, label); } @@ -1422,9 +2084,12 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.DOWN, null); ARG_ACTION36=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_terminal861); + matchAny(input); match(input, Token.UP, null); + + omos = factory.tokenRef(TOKEN_REF35, label, ARG_ACTION36); } @@ -1438,6 +2103,8 @@ public class SourceGenTriggers extends TreeParser { matchAny(input); match(input, Token.UP, null); + + omos = factory.tokenRef(TOKEN_REF37, label, null); } @@ -1446,6 +2113,7 @@ public class SourceGenTriggers extends TreeParser { // SourceGenTriggers.g:128:7: TOKEN_REF { TOKEN_REF38=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal891); + omos = factory.tokenRef(TOKEN_REF38, label, null); } @@ -1464,6 +2132,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; case 7 : @@ -1480,6 +2149,7 @@ public class SourceGenTriggers extends TreeParser { match(input, Token.UP, null); + } break; @@ -1489,7 +2159,9 @@ public class SourceGenTriggers extends TreeParser { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return omos; } @@ -1498,296 +2170,17 @@ public class SourceGenTriggers extends TreeParser { // Delegated rules - protected DFA6 dfa6 = new DFA6(this); - protected DFA7 dfa7 = new DFA7(this); - protected DFA10 dfa10 = new DFA10(this); - protected DFA16 dfa16 = new DFA16(this); - static final String DFA6_eotS = - "\15\uffff"; - static final String DFA6_eofS = - "\15\uffff"; - static final String DFA6_minS = - "\1\4\1\uffff\2\2\7\uffff\2\60"; - static final String DFA6_maxS = - "\1\141\1\uffff\2\2\7\uffff\2\115"; - static final String DFA6_acceptS = - "\1\uffff\1\1\2\uffff\1\2\1\3\1\4\1\5\1\6\1\7\1\10\2\uffff"; - static final String DFA6_specialS = - "\15\uffff}>"; - static final String[] DFA6_transitionS = { - "\1\10\1\7\12\uffff\1\6\32\uffff\1\5\2\uffff\1\1\1\uffff\1\3"+ - "\2\uffff\1\1\1\uffff\1\2\1\uffff\2\4\2\uffff\1\12\1\uffff\1"+ - "\4\1\uffff\2\4\3\uffff\1\4\10\uffff\1\5\1\uffff\3\5\14\uffff"+ - "\1\11\2\uffff\1\4", - "", - "\1\13", - "\1\14", - "", - "", - "", - "", - "", - "", - "", - "\1\4\4\uffff\1\4\2\uffff\1\4\4\uffff\1\4\1\uffff\2\4\3\uffff"+ - "\1\4\10\uffff\1\5", - "\1\4\4\uffff\1\4\2\uffff\1\4\4\uffff\1\4\1\uffff\2\4\3\uffff"+ - "\1\4\10\uffff\1\5" - }; - - static final short[] DFA6_eot = DFA.unpackEncodedString(DFA6_eotS); - static final short[] DFA6_eof = DFA.unpackEncodedString(DFA6_eofS); - static final char[] DFA6_min = DFA.unpackEncodedStringToUnsignedChars(DFA6_minS); - static final char[] DFA6_max = DFA.unpackEncodedStringToUnsignedChars(DFA6_maxS); - static final short[] DFA6_accept = DFA.unpackEncodedString(DFA6_acceptS); - static final short[] DFA6_special = DFA.unpackEncodedString(DFA6_specialS); - static final short[][] DFA6_transition; - - static { - int numStates = DFA6_transitionS.length; - DFA6_transition = new short[numStates][]; - for (int i=0; i omos] : ( labeledElement | atom[null] | ebnf | ACTION | FORCED_ACTION | SEMPRED | GATED_SEMPRED | treeSpec );"; - } - } - static final String DFA7_eotS = - "\13\uffff"; - static final String DFA7_eofS = - "\13\uffff"; - static final String DFA7_minS = - "\1\56\2\2\2\127\2\60\4\uffff"; - static final String DFA7_maxS = - "\1\63\2\2\2\127\2\141\4\uffff"; - static final String DFA7_acceptS = - "\7\uffff\1\1\1\2\1\3\1\4"; - static final String DFA7_specialS = - "\13\uffff}>"; - static final String[] DFA7_transitionS = { - "\1\1\4\uffff\1\2", - "\1\3", - "\1\4", - "\1\5", - "\1\6", - "\1\7\4\uffff\1\7\1\uffff\2\7\4\uffff\1\7\1\uffff\2\7\3\uffff"+ - "\1\7\10\uffff\1\10\23\uffff\1\7", - "\1\11\4\uffff\1\11\1\uffff\2\11\4\uffff\1\11\1\uffff\2\11\3"+ - "\uffff\1\11\10\uffff\1\12\23\uffff\1\11", - "", - "", - "", - "" - }; - - static final short[] DFA7_eot = DFA.unpackEncodedString(DFA7_eotS); - static final short[] DFA7_eof = DFA.unpackEncodedString(DFA7_eofS); - static final char[] DFA7_min = DFA.unpackEncodedStringToUnsignedChars(DFA7_minS); - static final char[] DFA7_max = DFA.unpackEncodedStringToUnsignedChars(DFA7_maxS); - static final short[] DFA7_accept = DFA.unpackEncodedString(DFA7_acceptS); - static final short[] DFA7_special = DFA.unpackEncodedString(DFA7_specialS); - static final short[][] DFA7_transition; - - static { - int numStates = DFA7_transitionS.length; - DFA7_transition = new short[numStates][]; - for (int i=0; i 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 = - "\31\uffff"; - static final String DFA10_eofS = - "\31\uffff"; - static final String DFA10_minS = - "\1\60\2\2\2\uffff\2\2\2\uffff\2\60\1\127\6\uffff\1\60\1\uffff\2"+ - "\2\1\uffff\2\60"; - static final String DFA10_maxS = - "\1\141\2\2\2\uffff\1\2\1\141\2\uffff\2\104\1\127\6\uffff\1\104\1"+ - "\uffff\2\2\1\uffff\2\104"; - static final String DFA10_acceptS = - "\3\uffff\1\5\1\6\2\uffff\1\13\1\14\3\uffff\1\11\1\12\1\1\1\3\1\2"+ - "\1\4\1\uffff\1\7\2\uffff\1\10\2\uffff"; - static final String DFA10_specialS = - "\31\uffff}>"; - static final String[] DFA10_transitionS = { - "\1\2\4\uffff\1\1\1\uffff\1\5\1\4\4\uffff\1\3\1\uffff\1\7\1\10"+ - "\3\uffff\1\7\34\uffff\1\6", - "\1\11", - "\1\12", - "", - "", - "\1\13", - "\1\14\3\15\12\uffff\1\15\32\uffff\1\15\2\uffff\1\15\1\uffff"+ - "\1\15\2\uffff\1\15\1\uffff\1\15\1\uffff\2\15\2\uffff\1\15\1"+ - "\uffff\1\15\1\uffff\2\15\3\uffff\1\15\10\uffff\1\15\1\uffff"+ - "\3\15\14\uffff\1\15\2\uffff\1\15", - "", - "", - "\1\7\4\uffff\1\7\2\uffff\1\16\4\uffff\1\17\1\uffff\1\7\1\10"+ - "\3\uffff\1\7", - "\1\7\4\uffff\1\7\2\uffff\1\20\4\uffff\1\21\1\uffff\1\7\1\10"+ - "\3\uffff\1\7", - "\1\22", - "", - "", - "", - "", - "", - "", - "\1\25\4\uffff\1\24\11\uffff\1\23\1\26\3\uffff\1\23", - "", - "\1\27", - "\1\30", - "", - "\1\23\4\uffff\1\23\11\uffff\1\23\1\26\3\uffff\1\23", - "\1\23\4\uffff\1\23\11\uffff\1\23\1\26\3\uffff\1\23" - }; - - static final short[] DFA10_eot = DFA.unpackEncodedString(DFA10_eotS); - static final short[] DFA10_eof = DFA.unpackEncodedString(DFA10_eofS); - static final char[] DFA10_min = DFA.unpackEncodedStringToUnsignedChars(DFA10_minS); - static final char[] DFA10_max = DFA.unpackEncodedStringToUnsignedChars(DFA10_maxS); - static final short[] DFA10_accept = DFA.unpackEncodedString(DFA10_acceptS); - static final short[] DFA10_special = DFA.unpackEncodedString(DFA10_specialS); - static final short[][] DFA10_transition; - - static { - int numStates = DFA10_transitionS.length; - DFA10_transition = new short[numStates][]; - for (int i=0; i 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 = - "\14\uffff"; - static final String DFA16_eofS = - "\14\uffff"; - static final String DFA16_minS = - "\1\60\2\2\4\uffff\1\4\1\uffff\1\2\2\uffff"; - static final String DFA16_maxS = - "\1\104\2\141\4\uffff\1\146\1\uffff\1\146\2\uffff"; - static final String DFA16_acceptS = - "\3\uffff\1\6\1\7\1\1\1\2\1\uffff\1\5\1\uffff\1\4\1\3"; - static final String DFA16_specialS = - "\14\uffff}>"; - static final String[] DFA16_transitionS = { - "\1\4\4\uffff\1\3\11\uffff\1\2\4\uffff\1\1", - "\1\5\3\6\12\uffff\1\6\32\uffff\1\6\2\uffff\1\6\1\uffff\1\6"+ - "\2\uffff\1\6\1\uffff\1\6\1\uffff\2\6\2\uffff\1\6\1\uffff\1\6"+ - "\1\uffff\2\6\3\uffff\1\6\10\uffff\1\6\1\uffff\3\6\14\uffff\1"+ - "\6\2\uffff\1\6", - "\1\7\3\10\12\uffff\1\10\32\uffff\1\10\2\uffff\1\10\1\uffff"+ - "\1\10\2\uffff\1\10\1\uffff\1\10\1\uffff\2\10\2\uffff\1\10\1"+ - "\uffff\1\10\1\uffff\2\10\3\uffff\1\10\10\uffff\1\10\1\uffff"+ - "\3\10\14\uffff\1\10\2\uffff\1\10", - "", - "", - "", - "", - "\12\12\1\11\130\12", - "", - "\2\12\143\13", - "", - "" - }; - - static final short[] DFA16_eot = DFA.unpackEncodedString(DFA16_eotS); - static final short[] DFA16_eof = DFA.unpackEncodedString(DFA16_eofS); - static final char[] DFA16_min = DFA.unpackEncodedStringToUnsignedChars(DFA16_minS); - static final char[] DFA16_max = DFA.unpackEncodedStringToUnsignedChars(DFA16_maxS); - static final short[] DFA16_accept = DFA.unpackEncodedString(DFA16_acceptS); - static final short[] DFA16_special = DFA.unpackEncodedString(DFA16_specialS); - static final short[][] DFA16_transition; - - static { - int numStates = DFA16_transitionS.length; - DFA16_transition = new short[numStates][]; - for (int i=0; i omos] : ( ^( STRING_LITERAL . ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION . ) | ^( TOKEN_REF . ) | TOKEN_REF | ^( ROOT terminal[label] ) | ^( BANG terminal[label] ) );"; - } - } public static final BitSet FOLLOW_BLOCK_in_block71 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_OPTIONS_in_block75 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_alternative_in_block95 = new BitSet(new long[]{0x0000000000000008L,0x0000004000200000L}); + public static final BitSet FOLLOW_alternative_in_block95 = new BitSet(new long[]{0x0000000000000008L,0x0000000000000A00L}); public static final BitSet FOLLOW_ALT_REWRITE_in_alternative141 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_alternative_in_alternative145 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000007FFFFFFFFFL}); public static final BitSet FOLLOW_ALT_in_alternative157 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_EPSILON_in_alternative159 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ALT_in_alternative174 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_element_in_alternative178 = new BitSet(new long[]{0xA9A9480000010038L,0x000000024003A011L}); + public static final BitSet FOLLOW_element_in_alternative178 = new BitSet(new long[]{0x4944210084080A18L,0x000000400C228014L}); public static final BitSet FOLLOW_labeledElement_in_element205 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_atom_in_element216 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ebnf_in_element229 = new BitSet(new long[]{0x0000000000000002L}); @@ -1797,19 +2190,19 @@ public class SourceGenTriggers extends TreeParser { public static final BitSet FOLLOW_GATED_SEMPRED_in_element285 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_treeSpec_in_element290 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ASSIGN_in_labeledElement306 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_labeledElement308 = new BitSet(new long[]{0xA1A1000000000000L,0x0000000200000011L}); + public static final BitSet FOLLOW_ID_in_labeledElement308 = new BitSet(new long[]{0x4144010000080800L,0x0000004000000004L}); public static final BitSet FOLLOW_atom_in_labeledElement310 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ASSIGN_in_labeledElement324 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_labeledElement326 = new BitSet(new long[]{0x0021080000000000L,0x000000000003A000L}); + public static final BitSet FOLLOW_ID_in_labeledElement326 = new BitSet(new long[]{0x0000000000000000L,0x0000000000008000L}); public static final BitSet FOLLOW_block_in_labeledElement328 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement339 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_labeledElement341 = new BitSet(new long[]{0xA1A1000000000000L,0x0000000200000011L}); + public static final BitSet FOLLOW_ID_in_labeledElement341 = new BitSet(new long[]{0x4144010000080800L,0x0000004000000004L}); public static final BitSet FOLLOW_atom_in_labeledElement343 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement355 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_labeledElement357 = new BitSet(new long[]{0x0021080000000000L,0x000000000003A000L}); + public static final BitSet FOLLOW_ID_in_labeledElement357 = new BitSet(new long[]{0x0000000000000000L,0x0000000000008000L}); public static final BitSet FOLLOW_block_in_labeledElement359 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_TREE_BEGIN_in_treeSpec382 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_element_in_treeSpec388 = new BitSet(new long[]{0xA9A9480000010038L,0x000000024003A011L}); + public static final BitSet FOLLOW_element_in_treeSpec388 = new BitSet(new long[]{0x4944210084080A18L,0x000000400C228014L}); public static final BitSet FOLLOW_astBlockSuffix_in_ebnf411 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_block_in_ebnf413 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_OPTIONAL_in_ebnf421 = new BitSet(new long[]{0x0000000000000004L}); @@ -1819,7 +2212,6 @@ public class SourceGenTriggers extends TreeParser { public static final BitSet FOLLOW_POSITIVE_CLOSURE_in_ebnf446 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_block_in_ebnf448 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_block_in_ebnf472 = new BitSet(new long[]{0x0000000000000002L}); - public static final BitSet FOLLOW_set_in_astBlockSuffix0 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ROOT_in_atom534 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_range_in_atom536 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_BANG_in_atom544 = new BitSet(new long[]{0x0000000000000004L}); @@ -1831,10 +2223,10 @@ public class SourceGenTriggers extends TreeParser { public static final BitSet FOLLOW_notSet_in_atom579 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_range_in_atom585 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_DOT_in_atom597 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_atom599 = new BitSet(new long[]{0x8021000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_ID_in_atom599 = new BitSet(new long[]{0x4040000000000800L,0x0000000000000004L}); public static final BitSet FOLLOW_terminal_in_atom601 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_DOT_in_atom609 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_atom611 = new BitSet(new long[]{0xA1A1000000000000L,0x0000000200000011L}); + public static final BitSet FOLLOW_ID_in_atom611 = new BitSet(new long[]{0x0140000000000800L}); public static final BitSet FOLLOW_ruleref_in_atom613 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_WILDCARD_in_atom624 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_WILDCARD_in_atom635 = new BitSet(new long[]{0x0000000000000002L}); @@ -1853,7 +2245,7 @@ public class SourceGenTriggers extends TreeParser { public static final BitSet FOLLOW_RULE_REF_in_ruleref766 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ARG_ACTION_in_ruleref768 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_RANGE_in_range797 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_STRING_LITERAL_in_range801 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_STRING_LITERAL_in_range801 = new BitSet(new long[]{0x4000000000000000L}); public static final BitSet FOLLOW_STRING_LITERAL_in_range805 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_STRING_LITERAL_in_terminal830 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_STRING_LITERAL_in_terminal845 = new BitSet(new long[]{0x0000000000000002L}); diff --git a/tool/src/org/antlr/v4/parse/ATNBuilder.g b/tool/src/org/antlr/v4/parse/ATNBuilder.g index b5d7b2255..1d430fecc 100644 --- a/tool/src/org/antlr/v4/parse/ATNBuilder.g +++ b/tool/src/org/antlr/v4/parse/ATNBuilder.g @@ -73,6 +73,8 @@ import org.antlr.v4.runtime.tree.CommonTree; // use updated v4 one not v3 } } +dummy : block[null] ; // avoid error about no start rule + block[GrammarAST ebnfRoot] returns [ATNFactory.Handle p] @init {List alts = new ArrayList();} : ^(BLOCK (^(OPTIONS .+))? (a=alternative {alts.add($a.p);})+) diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java index e2d4ef7f7..89c157480 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java @@ -1,4 +1,4 @@ -// $ANTLR 3.3 Nov 30, 2010 12:50:56 BasicSemanticTriggers.g 2011-06-11 10:28:59 +// $ANTLR 3.4 BasicSemanticTriggers.g 2011-06-20 18:31:16 /* [The "BSD license"] @@ -27,133 +27,138 @@ */ package org.antlr.v4.semantics; -import org.antlr.runtime.*; import org.antlr.runtime.BitSet; +import org.antlr.runtime.*; import org.antlr.runtime.tree.*; import org.antlr.v4.tool.*; import java.util.*; + /** Triggers for the basic semantics of the input. Side-effects: * Set token, block, rule options in the tree. Load field option * with grammar options. Only legal options are set. */ +@SuppressWarnings({"all", "warnings", "unchecked"}) public class BasicSemanticTriggers extends TreeFilter { public static final String[] tokenNames = new String[] { - "", "", "", "", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "MODE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "ID", "ARG", "ARGLIST", "RET", "COMBINED", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "RESULT", "ALT_REWRITE" + "", "", "", "", "ACTION", "ACTION_CHAR_LITERAL", "ACTION_ESC", "ACTION_STRING_LITERAL", "ARG_ACTION", "ASSIGN", "AT", "BANG", "CATCH", "COLON", "COLONCOLON", "COMMA", "COMMENT", "DOC_COMMENT", "DOLLAR", "DOT", "DOUBLE_ANGLE_STRING_LITERAL", "DOUBLE_QUOTE_STRING_LITERAL", "ERRCHAR", "ESC_SEQ", "ETC", "FINALLY", "FORCED_ACTION", "FRAGMENT", "GRAMMAR", "GT", "HEX_DIGIT", "IMPLIES", "IMPORT", "INT", "LEXER", "LPAREN", "LT", "MODE", "NESTED_ACTION", "NLCHARS", "NOT", "OPTIONS", "OR", "PARSER", "PLUS", "PLUS_ASSIGN", "PRIVATE", "PROTECTED", "PUBLIC", "QUESTION", "RANGE", "RARROW", "RBRACE", "RETURNS", "ROOT", "RPAREN", "RULE_REF", "SCOPE", "SEMI", "SEMPRED", "SRC", "STAR", "STRING_LITERAL", "TEMPLATE", "THROWS", "TOKENS", "TOKEN_REF", "TREE", "TREE_BEGIN", "UNICODE_ESC", "WS", "WSCHARS", "WSNLCHARS", "ALT", "ALTLIST", "ALT_REWRITE", "ARG", "ARGLIST", "BACKTRACK_SEMPRED", "BLOCK", "CHAR_RANGE", "CLOSURE", "COMBINED", "ELEMENT_OPTIONS", "EPSILON", "GATED_SEMPRED", "ID", "INITACTION", "LABEL", "LIST", "OPTIONAL", "POSITIVE_CLOSURE", "RESULT", "RET", "REWRITE_BLOCK", "RULE", "RULEACTIONS", "RULEMODIFIERS", "RULES", "ST_RESULT", "SYNPRED", "SYN_SEMPRED", "WILDCARD" }; + public static final int EOF=-1; - public static final int SEMPRED=4; - public static final int FORCED_ACTION=5; - public static final int DOC_COMMENT=6; - public static final int SRC=7; - public static final int NLCHARS=8; - public static final int COMMENT=9; - public static final int DOUBLE_QUOTE_STRING_LITERAL=10; - public static final int DOUBLE_ANGLE_STRING_LITERAL=11; - public static final int ACTION_STRING_LITERAL=12; - public static final int ACTION_CHAR_LITERAL=13; - public static final int ARG_ACTION=14; - public static final int NESTED_ACTION=15; - public static final int ACTION=16; - public static final int ACTION_ESC=17; - public static final int WSNLCHARS=18; - public static final int OPTIONS=19; - public static final int TOKENS=20; - public static final int SCOPE=21; - public static final int IMPORT=22; - public static final int FRAGMENT=23; - public static final int LEXER=24; - public static final int PARSER=25; - public static final int TREE=26; - public static final int GRAMMAR=27; - public static final int PROTECTED=28; - public static final int PUBLIC=29; - public static final int PRIVATE=30; - public static final int RETURNS=31; - public static final int THROWS=32; - public static final int CATCH=33; - public static final int FINALLY=34; - public static final int TEMPLATE=35; - public static final int MODE=36; - public static final int COLON=37; - public static final int COLONCOLON=38; - public static final int COMMA=39; - public static final int SEMI=40; - public static final int LPAREN=41; - public static final int RPAREN=42; - public static final int IMPLIES=43; - public static final int LT=44; - public static final int GT=45; - public static final int ASSIGN=46; - public static final int QUESTION=47; - public static final int BANG=48; - public static final int STAR=49; - public static final int PLUS=50; - public static final int PLUS_ASSIGN=51; - public static final int OR=52; - public static final int ROOT=53; - public static final int DOLLAR=54; - public static final int DOT=55; - public static final int RANGE=56; - public static final int ETC=57; - public static final int RARROW=58; - public static final int TREE_BEGIN=59; - public static final int AT=60; - public static final int NOT=61; - public static final int RBRACE=62; - public static final int TOKEN_REF=63; - public static final int RULE_REF=64; - public static final int INT=65; - public static final int WSCHARS=66; - public static final int ESC_SEQ=67; - public static final int STRING_LITERAL=68; - public static final int HEX_DIGIT=69; - public static final int UNICODE_ESC=70; - public static final int WS=71; - public static final int ERRCHAR=72; - public static final int RULE=73; - public static final int RULES=74; - public static final int RULEMODIFIERS=75; - public static final int RULEACTIONS=76; - public static final int BLOCK=77; - public static final int REWRITE_BLOCK=78; - public static final int OPTIONAL=79; - public static final int CLOSURE=80; - public static final int POSITIVE_CLOSURE=81; - public static final int SYNPRED=82; - public static final int CHAR_RANGE=83; + public static final int ACTION=4; + public static final int ACTION_CHAR_LITERAL=5; + public static final int ACTION_ESC=6; + public static final int ACTION_STRING_LITERAL=7; + public static final int ARG_ACTION=8; + public static final int ASSIGN=9; + public static final int AT=10; + public static final int BANG=11; + public static final int CATCH=12; + public static final int COLON=13; + public static final int COLONCOLON=14; + public static final int COMMA=15; + public static final int COMMENT=16; + public static final int DOC_COMMENT=17; + public static final int DOLLAR=18; + public static final int DOT=19; + public static final int DOUBLE_ANGLE_STRING_LITERAL=20; + public static final int DOUBLE_QUOTE_STRING_LITERAL=21; + public static final int ERRCHAR=22; + public static final int ESC_SEQ=23; + public static final int ETC=24; + public static final int FINALLY=25; + public static final int FORCED_ACTION=26; + public static final int FRAGMENT=27; + public static final int GRAMMAR=28; + public static final int GT=29; + public static final int HEX_DIGIT=30; + public static final int IMPLIES=31; + public static final int IMPORT=32; + public static final int INT=33; + public static final int LEXER=34; + public static final int LPAREN=35; + public static final int LT=36; + public static final int MODE=37; + public static final int NESTED_ACTION=38; + public static final int NLCHARS=39; + public static final int NOT=40; + public static final int OPTIONS=41; + public static final int OR=42; + public static final int PARSER=43; + public static final int PLUS=44; + public static final int PLUS_ASSIGN=45; + public static final int PRIVATE=46; + public static final int PROTECTED=47; + public static final int PUBLIC=48; + public static final int QUESTION=49; + public static final int RANGE=50; + public static final int RARROW=51; + public static final int RBRACE=52; + public static final int RETURNS=53; + public static final int ROOT=54; + public static final int RPAREN=55; + public static final int RULE_REF=56; + public static final int SCOPE=57; + public static final int SEMI=58; + public static final int SEMPRED=59; + public static final int SRC=60; + public static final int STAR=61; + public static final int STRING_LITERAL=62; + public static final int TEMPLATE=63; + public static final int THROWS=64; + public static final int TOKENS=65; + public static final int TOKEN_REF=66; + public static final int TREE=67; + public static final int TREE_BEGIN=68; + public static final int UNICODE_ESC=69; + public static final int WS=70; + public static final int WSCHARS=71; + public static final int WSNLCHARS=72; + public static final int ALT=73; + public static final int ALTLIST=74; + public static final int ALT_REWRITE=75; + public static final int ARG=76; + public static final int ARGLIST=77; + public static final int BACKTRACK_SEMPRED=78; + public static final int BLOCK=79; + public static final int CHAR_RANGE=80; + public static final int CLOSURE=81; + public static final int COMBINED=82; + public static final int ELEMENT_OPTIONS=83; public static final int EPSILON=84; - public static final int ALT=85; - public static final int ALTLIST=86; - public static final int ID=87; - public static final int ARG=88; - public static final int ARGLIST=89; - public static final int RET=90; - public static final int COMBINED=91; - public static final int INITACTION=92; - public static final int LABEL=93; - public static final int GATED_SEMPRED=94; - public static final int SYN_SEMPRED=95; - public static final int BACKTRACK_SEMPRED=96; - public static final int WILDCARD=97; - public static final int LIST=98; - public static final int ELEMENT_OPTIONS=99; - public static final int ST_RESULT=100; - public static final int RESULT=101; - public static final int ALT_REWRITE=102; + public static final int GATED_SEMPRED=85; + public static final int ID=86; + public static final int INITACTION=87; + public static final int LABEL=88; + public static final int LIST=89; + public static final int OPTIONAL=90; + public static final int POSITIVE_CLOSURE=91; + public static final int RESULT=92; + public static final int RET=93; + public static final int REWRITE_BLOCK=94; + public static final int RULE=95; + public static final int RULEACTIONS=96; + public static final int RULEMODIFIERS=97; + public static final int RULES=98; + public static final int ST_RESULT=99; + public static final int SYNPRED=100; + public static final int SYN_SEMPRED=101; + public static final int WILDCARD=102; // delegates + public TreeFilter[] getDelegates() { + return new TreeFilter[] {}; + } + // delegators - public BasicSemanticTriggers(TreeNodeStream input) { - this(input, new RecognizerSharedState()); - } - public BasicSemanticTriggers(TreeNodeStream input, RecognizerSharedState state) { - super(input, state); - - } - + public BasicSemanticTriggers(TreeNodeStream input) { + this(input, new RecognizerSharedState()); + } + public BasicSemanticTriggers(TreeNodeStream input, RecognizerSharedState state) { + super(input, state); + } public String[] getTokenNames() { return BasicSemanticTriggers.tokenNames; } public String getGrammarFileName() { return "BasicSemanticTriggers.g"; } @@ -180,7 +185,113 @@ public class BasicSemanticTriggers extends TreeFilter { try { // BasicSemanticTriggers.g:87:2: ( grammarSpec | rules | mode | option | rule | tokenAlias | rewrite ) int alt1=7; - alt1 = dfa1.predict(input); + switch ( input.LA(1) ) { + case GRAMMAR: + { + alt1=1; + } + break; + case RULES: + { + alt1=2; + } + break; + case MODE: + { + alt1=3; + } + break; + case ASSIGN: + { + int LA1_4 = input.LA(2); + + if ( (LA1_4==DOWN) ) { + int LA1_7 = input.LA(3); + + if ( (LA1_7==ID) ) { + int LA1_8 = input.LA(4); + + if ( (LA1_8==STRING_LITERAL) ) { + int LA1_9 = input.LA(5); + + if ( (LA1_9==UP) ) { + int LA1_11 = input.LA(6); + + if ( ((inContext("OPTIONS"))) ) { + alt1=4; + } + else if ( ((inContext("TOKENS"))) ) { + alt1=6; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 11, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 9, input); + + throw nvae; + + } + } + else if ( (LA1_8==INT||LA1_8==STAR||LA1_8==ID) ) { + alt1=4; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 8, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 7, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 4, input); + + throw nvae; + + } + } + break; + case RULE: + { + alt1=5; + } + break; + case RESULT: + case ST_RESULT: + { + alt1=7; + } + break; + default: + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 0, input); + + throw nvae; + + } + switch (alt1) { case 1 : // BasicSemanticTriggers.g:87:4: grammarSpec @@ -266,13 +377,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "topdown" + // $ANTLR start "bottomup" // BasicSemanticTriggers.g:96:1: bottomup : ( multiElementAltInTreeGrammar | astOps | ruleref | tokenRefWithArgs | elementOption | checkGrammarOptions | wildcardRoot ); public final void bottomup() throws RecognitionException { @@ -322,6 +436,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 2, 0, input); throw nvae; + } switch (alt2) { @@ -409,21 +524,26 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "bottomup" + public static class grammarSpec_return extends TreeRuleReturnScope { }; + // $ANTLR start "grammarSpec" // BasicSemanticTriggers.g:106:1: grammarSpec : ^( GRAMMAR ID ( DOC_COMMENT )? prequelConstructs ^( RULES ( . )* ) ) ; public final BasicSemanticTriggers.grammarSpec_return grammarSpec() throws RecognitionException { BasicSemanticTriggers.grammarSpec_return retval = new BasicSemanticTriggers.grammarSpec_return(); retval.start = input.LT(1); + GrammarAST ID1=null; try { @@ -434,6 +554,7 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; ID1=(GrammarAST)match(input,ID,FOLLOW_ID_in_grammarSpec180); if (state.failed) return retval; + // BasicSemanticTriggers.g:107:23: ( DOC_COMMENT )? int alt3=2; int LA3_0 = input.LA(1); @@ -452,18 +573,19 @@ public class BasicSemanticTriggers extends TreeFilter { } + if ( state.backtracking==1 ) { + name = (ID1!=null?ID1.getText():null); + checker.checkGrammarName(ID1.token); + root = (GrammarRootAST)((GrammarAST)retval.start); + } - name = (ID1!=null?ID1.getText():null); - checker.checkGrammarName(ID1.token); - root = (GrammarRootAST)((GrammarAST)retval.start); - - } pushFollow(FOLLOW_prequelConstructs_in_grammarSpec199); prequelConstructs(); state._fsp--; if (state.failed) return retval; + match(input,RULES,FOLLOW_RULES_in_grammarSpec202); if (state.failed) return retval; if ( input.LA(1)==Token.DOWN ) { @@ -474,7 +596,7 @@ public class BasicSemanticTriggers extends TreeFilter { int alt4=2; int LA4_0 = input.LA(1); - if ( ((LA4_0>=SEMPRED && LA4_0<=ALT_REWRITE)) ) { + if ( ((LA4_0 >= ACTION && LA4_0 <= WILDCARD)) ) { alt4=1; } else if ( (LA4_0==UP) ) { @@ -500,8 +622,10 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return retval; } + match(input, Token.UP, null); if (state.failed) return retval; + } } @@ -509,13 +633,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "grammarSpec" + // $ANTLR start "checkGrammarOptions" // BasicSemanticTriggers.g:117:1: checkGrammarOptions : GRAMMAR ; public final void checkGrammarOptions() throws RecognitionException { @@ -526,10 +653,9 @@ public class BasicSemanticTriggers extends TreeFilter { // BasicSemanticTriggers.g:118:4: GRAMMAR { GRAMMAR2=(GrammarAST)match(input,GRAMMAR,FOLLOW_GRAMMAR_in_checkGrammarOptions225); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkTreeFilterOptions((GrammarRootAST)GRAMMAR2, - root.getOptions()); - } + + if ( state.backtracking==1 ) {checker.checkTreeFilterOptions((GrammarRootAST)GRAMMAR2, + root.getOptions());} } @@ -538,13 +664,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "checkGrammarOptions" + // $ANTLR start "prequelConstructs" // BasicSemanticTriggers.g:130:1: prequelConstructs : ( ^(o+= OPTIONS ( . )+ ) | ^(i+= IMPORT ( delegateGrammar )+ ) | ^(t+= TOKENS ( . )+ ) )* ; public final void prequelConstructs() throws RecognitionException { @@ -599,7 +728,7 @@ public class BasicSemanticTriggers extends TreeFilter { int alt5=2; int LA5_0 = input.LA(1); - if ( ((LA5_0>=SEMPRED && LA5_0<=ALT_REWRITE)) ) { + if ( ((LA5_0 >= ACTION && LA5_0 <= WILDCARD)) ) { alt5=1; } else if ( (LA5_0==UP) ) { @@ -629,6 +758,7 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + } break; case 2 : @@ -678,6 +808,7 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + } break; case 3 : @@ -696,7 +827,7 @@ public class BasicSemanticTriggers extends TreeFilter { int alt7=2; int LA7_0 = input.LA(1); - if ( ((LA7_0>=SEMPRED && LA7_0<=ALT_REWRITE)) ) { + if ( ((LA7_0 >= ACTION && LA7_0 <= WILDCARD)) ) { alt7=1; } else if ( (LA7_0==UP) ) { @@ -726,6 +857,7 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + } break; @@ -734,9 +866,8 @@ public class BasicSemanticTriggers extends TreeFilter { } } while (true); - if ( state.backtracking==1 ) { - checker.checkNumPrequels(list_o, list_i, list_t); - } + + if ( state.backtracking==1 ) {checker.checkNumPrequels(list_o, list_i, list_t);} } @@ -745,23 +876,26 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "prequelConstructs" + // $ANTLR start "delegateGrammar" - // BasicSemanticTriggers.g:138:1: delegateGrammar : ( ^( ASSIGN ID id= ID ) | id= ID ) ; + // BasicSemanticTriggers.g:138:1: delegateGrammar : ( ^( ASSIGN ID id= ID ) |id= ID ) ; public final void delegateGrammar() throws RecognitionException { GrammarAST id=null; try { - // BasicSemanticTriggers.g:139:5: ( ( ^( ASSIGN ID id= ID ) | id= ID ) ) - // BasicSemanticTriggers.g:139:9: ( ^( ASSIGN ID id= ID ) | id= ID ) + // BasicSemanticTriggers.g:139:5: ( ( ^( ASSIGN ID id= ID ) |id= ID ) ) + // BasicSemanticTriggers.g:139:9: ( ^( ASSIGN ID id= ID ) |id= ID ) { - // BasicSemanticTriggers.g:139:9: ( ^( ASSIGN ID id= ID ) | id= ID ) + // BasicSemanticTriggers.g:139:9: ( ^( ASSIGN ID id= ID ) |id= ID ) int alt9=2; int LA9_0 = input.LA(1); @@ -777,6 +911,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 9, 0, input); throw nvae; + } switch (alt9) { case 1 : @@ -786,10 +921,12 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; match(input,ID,FOLLOW_ID_in_delegateGrammar308); if (state.failed) return ; + id=(GrammarAST)match(input,ID,FOLLOW_ID_in_delegateGrammar312); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + } break; case 2 : @@ -802,9 +939,8 @@ public class BasicSemanticTriggers extends TreeFilter { } - if ( state.backtracking==1 ) { - checker.checkImport(id.token); - } + + if ( state.backtracking==1 ) {checker.checkImport(id.token);} } @@ -813,13 +949,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "delegateGrammar" + // $ANTLR start "rules" // BasicSemanticTriggers.g:145:1: rules : RULES ; public final void rules() throws RecognitionException { @@ -830,9 +969,8 @@ public class BasicSemanticTriggers extends TreeFilter { // BasicSemanticTriggers.g:145:9: RULES { RULES3=(GrammarAST)match(input,RULES,FOLLOW_RULES_in_rules353); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkNumRules(RULES3); - } + + if ( state.backtracking==1 ) {checker.checkNumRules(RULES3);} } @@ -841,13 +979,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "rules" + // $ANTLR start "mode" // BasicSemanticTriggers.g:147:1: mode : ^( MODE ID ( . )* ) ; public final void mode() throws RecognitionException { @@ -861,13 +1002,14 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; ID4=(GrammarAST)match(input,ID,FOLLOW_ID_in_mode367); if (state.failed) return ; + // BasicSemanticTriggers.g:147:18: ( . )* loop10: do { int alt10=2; int LA10_0 = input.LA(1); - if ( ((LA10_0>=SEMPRED && LA10_0<=ALT_REWRITE)) ) { + if ( ((LA10_0 >= ACTION && LA10_0 <= WILDCARD)) ) { alt10=1; } else if ( (LA10_0==UP) ) { @@ -891,9 +1033,9 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkMode(ID4.token); - } + + + if ( state.backtracking==1 ) {checker.checkMode(ID4.token);} } @@ -902,23 +1044,28 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "mode" + public static class option_return extends TreeRuleReturnScope { }; + // $ANTLR start "option" - // BasicSemanticTriggers.g:149:1: option : {...}? ^( ASSIGN o= ID optionValue ) ; + // BasicSemanticTriggers.g:149:1: option :{...}? ^( ASSIGN o= ID optionValue ) ; public final BasicSemanticTriggers.option_return option() throws RecognitionException { BasicSemanticTriggers.option_return retval = new BasicSemanticTriggers.option_return(); retval.start = input.LT(1); + GrammarAST o=null; - BasicSemanticTriggers.optionValue_return optionValue5 = null; + BasicSemanticTriggers.optionValue_return optionValue5 =null; try { @@ -929,10 +1076,12 @@ public class BasicSemanticTriggers extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "option", "inContext(\"OPTIONS\")"); } + match(input,ASSIGN,FOLLOW_ASSIGN_in_option392); if (state.failed) return retval; match(input, Token.DOWN, null); if (state.failed) return retval; o=(GrammarAST)match(input,ID,FOLLOW_ID_in_option396); if (state.failed) return retval; + pushFollow(FOLLOW_optionValue_in_option398); optionValue5=optionValue(); @@ -940,18 +1089,18 @@ public class BasicSemanticTriggers extends TreeFilter { if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; + + if ( state.backtracking==1 ) { - - GrammarAST parent = (GrammarAST)((GrammarAST)retval.start).getParent(); // OPTION - GrammarAST parentWithOptionKind = (GrammarAST)parent.getParent(); - boolean ok = checker.checkOptions(parentWithOptionKind, - o.token, (optionValue5!=null?optionValue5.v:null)); - // store options into XXX_GRAMMAR, RULE, BLOCK nodes - if ( ok ) { - ((GrammarASTWithOptions)parentWithOptionKind).setOption((o!=null?o.getText():null), (optionValue5!=null?optionValue5.v:null)); - } - - } + GrammarAST parent = (GrammarAST)((GrammarAST)retval.start).getParent(); // OPTION + GrammarAST parentWithOptionKind = (GrammarAST)parent.getParent(); + boolean ok = checker.checkOptions(parentWithOptionKind, + o.token, (optionValue5!=null?optionValue5.v:null)); + // store options into XXX_GRAMMAR, RULE, BLOCK nodes + if ( ok ) { + ((GrammarASTWithOptions)parentWithOptionKind).setOption((o!=null?o.getText():null), (optionValue5!=null?optionValue5.v:null)); + } + } } @@ -960,30 +1109,36 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "option" + public static class optionValue_return extends TreeRuleReturnScope { public String v; }; + // $ANTLR start "optionValue" // BasicSemanticTriggers.g:163:1: optionValue returns [String v] : ( ID | STRING_LITERAL | INT | STAR ); public final BasicSemanticTriggers.optionValue_return optionValue() throws RecognitionException { BasicSemanticTriggers.optionValue_return retval = new BasicSemanticTriggers.optionValue_return(); retval.start = input.LT(1); + retval.v = ((GrammarAST)retval.start).token.getText(); try { // BasicSemanticTriggers.g:165:5: ( ID | STRING_LITERAL | INT | STAR ) // BasicSemanticTriggers.g: { - if ( input.LA(1)==STAR||input.LA(1)==INT||input.LA(1)==STRING_LITERAL||input.LA(1)==ID ) { + if ( input.LA(1)==INT||(input.LA(1) >= STAR && input.LA(1) <= STRING_LITERAL)||input.LA(1)==ID ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -999,13 +1154,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "optionValue" + // $ANTLR start "rule" // BasicSemanticTriggers.g:171:1: rule : ^( RULE r= ID ( . )* ) ; public final void rule() throws RecognitionException { @@ -1019,13 +1177,14 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; r=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule484); if (state.failed) return ; + // BasicSemanticTriggers.g:171:22: ( . )* loop11: do { int alt11=2; int LA11_0 = input.LA(1); - if ( ((LA11_0>=SEMPRED && LA11_0<=ALT_REWRITE)) ) { + if ( ((LA11_0 >= ACTION && LA11_0 <= WILDCARD)) ) { alt11=1; } else if ( (LA11_0==UP) ) { @@ -1049,9 +1208,9 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkInvalidRuleDef(r.token); - } + + + if ( state.backtracking==1 ) {checker.checkInvalidRuleDef(r.token);} } @@ -1060,13 +1219,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "rule" + // $ANTLR start "ruleref" // BasicSemanticTriggers.g:174:1: ruleref : RULE_REF ; public final void ruleref() throws RecognitionException { @@ -1077,9 +1239,8 @@ public class BasicSemanticTriggers extends TreeFilter { // BasicSemanticTriggers.g:175:7: RULE_REF { RULE_REF6=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref507); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkInvalidRuleRef(RULE_REF6.token); - } + + if ( state.backtracking==1 ) {checker.checkInvalidRuleRef(RULE_REF6.token);} } @@ -1088,15 +1249,18 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleref" + // $ANTLR start "tokenAlias" - // BasicSemanticTriggers.g:178:1: tokenAlias : {...}? ^( ASSIGN ID STRING_LITERAL ) ; + // BasicSemanticTriggers.g:178:1: tokenAlias :{...}? ^( ASSIGN ID STRING_LITERAL ) ; public final void tokenAlias() throws RecognitionException { GrammarAST ID7=null; @@ -1108,16 +1272,18 @@ public class BasicSemanticTriggers extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "tokenAlias", "inContext(\"TOKENS\")"); } + match(input,ASSIGN,FOLLOW_ASSIGN_in_tokenAlias526); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; ID7=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokenAlias528); if (state.failed) return ; + match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokenAlias530); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkTokenAlias(ID7.token); - } + + + if ( state.backtracking==1 ) {checker.checkTokenAlias(ID7.token);} } @@ -1126,15 +1292,18 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "tokenAlias" + // $ANTLR start "tokenRefWithArgs" - // BasicSemanticTriggers.g:183:1: tokenRefWithArgs : {...}? ^( TOKEN_REF ARG_ACTION ) ; + // BasicSemanticTriggers.g:183:1: tokenRefWithArgs :{...}? ^( TOKEN_REF ARG_ACTION ) ; public final void tokenRefWithArgs() throws RecognitionException { GrammarAST TOKEN_REF8=null; @@ -1146,15 +1315,16 @@ public class BasicSemanticTriggers extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "tokenRefWithArgs", "!inContext(\"RESULT ...\")"); } + TOKEN_REF8=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_tokenRefWithArgs555); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_tokenRefWithArgs557); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkTokenArgs(TOKEN_REF8.token); - } + + + if ( state.backtracking==1 ) {checker.checkTokenArgs(TOKEN_REF8.token);} } @@ -1163,36 +1333,42 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "tokenRefWithArgs" + public static class elementOption_return extends TreeRuleReturnScope { }; + // $ANTLR start "elementOption" - // BasicSemanticTriggers.g:189:1: elementOption : {...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) ; + // BasicSemanticTriggers.g:189:1: elementOption :{...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) |o= ID ) ) ; public final BasicSemanticTriggers.elementOption_return elementOption() throws RecognitionException { BasicSemanticTriggers.elementOption_return retval = new BasicSemanticTriggers.elementOption_return(); retval.start = input.LT(1); + GrammarAST o=null; GrammarAST value=null; try { - // BasicSemanticTriggers.g:190:5: ({...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) ) - // BasicSemanticTriggers.g:190:7: {...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) + // BasicSemanticTriggers.g:190:5: ({...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) |o= ID ) ) ) + // BasicSemanticTriggers.g:190:7: {...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) |o= ID ) ) { if ( !((!inContext("RESULT ..."))) ) { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "elementOption", "!inContext(\"RESULT ...\")"); } + match(input,ELEMENT_OPTIONS,FOLLOW_ELEMENT_OPTIONS_in_elementOption586); if (state.failed) return retval; match(input, Token.DOWN, null); if (state.failed) return retval; - // BasicSemanticTriggers.g:192:7: ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) + // BasicSemanticTriggers.g:192:7: ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) |o= ID ) int alt12=3; int LA12_0 = input.LA(1); @@ -1217,6 +1393,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 12, 4, input); throw nvae; + } } else { @@ -1225,6 +1402,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 12, 3, input); throw nvae; + } } else { @@ -1233,6 +1411,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 12, 1, input); throw nvae; + } } else if ( (LA12_0==ID) ) { @@ -1244,6 +1423,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 12, 0, input); throw nvae; + } switch (alt12) { case 1 : @@ -1253,10 +1433,12 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption601); if (state.failed) return retval; + value=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption605); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; + } break; case 2 : @@ -1266,10 +1448,12 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption623); if (state.failed) return retval; + value=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_elementOption627); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; + } break; case 3 : @@ -1284,22 +1468,22 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return retval; + + if ( state.backtracking==1 ) { - - boolean ok = checker.checkTokenOptions((GrammarAST)o.getParent(), - o.token, (value!=null?value.getText():null)); - if ( ok ) { - if ( value!=null ) { - TerminalAST terminal = (TerminalAST)((GrammarAST)retval.start).getParent(); - terminal.setOption((o!=null?o.getText():null), (value!=null?value.getText():null)); - } - else { - TerminalAST terminal = (TerminalAST)((GrammarAST)retval.start).getParent(); - terminal.setOption(TerminalAST.defaultTokenOption, (o!=null?o.getText():null)); - } - } - - } + boolean ok = checker.checkTokenOptions((GrammarAST)o.getParent(), + o.token, (value!=null?value.getText():null)); + if ( ok ) { + if ( value!=null ) { + TerminalAST terminal = (TerminalAST)((GrammarAST)retval.start).getParent(); + terminal.setOption((o!=null?o.getText():null), (value!=null?value.getText():null)); + } + else { + TerminalAST terminal = (TerminalAST)((GrammarAST)retval.start).getParent(); + terminal.setOption(TerminalAST.defaultTokenOption, (o!=null?o.getText():null)); + } + } + } } @@ -1308,21 +1492,26 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "elementOption" + public static class multiElementAltInTreeGrammar_return extends TreeRuleReturnScope { }; + // $ANTLR start "multiElementAltInTreeGrammar" - // BasicSemanticTriggers.g:214:1: multiElementAltInTreeGrammar : {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) ; + // BasicSemanticTriggers.g:214:1: multiElementAltInTreeGrammar :{...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) ; public final BasicSemanticTriggers.multiElementAltInTreeGrammar_return multiElementAltInTreeGrammar() throws RecognitionException { BasicSemanticTriggers.multiElementAltInTreeGrammar_return retval = new BasicSemanticTriggers.multiElementAltInTreeGrammar_return(); retval.start = input.LT(1); + try { // BasicSemanticTriggers.g:215:2: ({...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) ) // BasicSemanticTriggers.g:215:4: {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) @@ -1331,12 +1520,14 @@ public class BasicSemanticTriggers extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "multiElementAltInTreeGrammar", "inContext(\"ALT_REWRITE\")"); } + match(input,ALT,FOLLOW_ALT_in_multiElementAltInTreeGrammar681); if (state.failed) return retval; match(input, Token.DOWN, null); if (state.failed) return retval; - if ( (input.LA(1)>=FORCED_ACTION && input.LA(1)<=NESTED_ACTION)||(input.LA(1)>=ACTION_ESC && input.LA(1)<=ALT_REWRITE) ) { + if ( (input.LA(1) >= ACTION_CHAR_LITERAL && input.LA(1) <= SEMI)||(input.LA(1) >= SRC && input.LA(1) <= WILDCARD) ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1344,6 +1535,7 @@ public class BasicSemanticTriggers extends TreeFilter { throw mse; } + // BasicSemanticTriggers.g:216:28: (~ ( SEMPRED | ACTION ) )+ int cnt13=0; loop13: @@ -1351,18 +1543,19 @@ public class BasicSemanticTriggers extends TreeFilter { int alt13=2; int LA13_0 = input.LA(1); - if ( ((LA13_0>=FORCED_ACTION && LA13_0<=NESTED_ACTION)||(LA13_0>=ACTION_ESC && LA13_0<=ALT_REWRITE)) ) { + if ( ((LA13_0 >= ACTION_CHAR_LITERAL && LA13_0 <= SEMI)||(LA13_0 >= SRC && LA13_0 <= WILDCARD)) ) { alt13=1; } switch (alt13) { case 1 : - // BasicSemanticTriggers.g:216:28: ~ ( SEMPRED | ACTION ) + // BasicSemanticTriggers.g: { - if ( (input.LA(1)>=FORCED_ACTION && input.LA(1)<=NESTED_ACTION)||(input.LA(1)>=ACTION_ESC && input.LA(1)<=ALT_REWRITE) ) { + if ( (input.LA(1) >= ACTION_CHAR_LITERAL && input.LA(1) <= SEMI)||(input.LA(1) >= SRC && input.LA(1) <= WILDCARD) ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1386,15 +1579,15 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return retval; + + if ( state.backtracking==1 ) { - - int altNum = ((GrammarAST)retval.start).getParent().getChildIndex() + 1; // alts are 1..n - GrammarAST firstNode = (GrammarAST)((GrammarAST)retval.start).getChild(0); - checker.checkRewriteForMultiRootAltInTreeGrammar(root.getOptions(), - firstNode.token, - altNum); - - } + int altNum = ((GrammarAST)retval.start).getParent().getChildIndex() + 1; // alts are 1..n + GrammarAST firstNode = (GrammarAST)((GrammarAST)retval.start).getChild(0); + checker.checkRewriteForMultiRootAltInTreeGrammar(root.getOptions(), + firstNode.token, + altNum); + } } @@ -1403,21 +1596,26 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "multiElementAltInTreeGrammar" + public static class astOps_return extends TreeRuleReturnScope { }; + // $ANTLR start "astOps" // BasicSemanticTriggers.g:227:1: astOps : ( ^( ROOT el= . ) | ^( BANG el= . ) ); public final BasicSemanticTriggers.astOps_return astOps() throws RecognitionException { BasicSemanticTriggers.astOps_return retval = new BasicSemanticTriggers.astOps_return(); retval.start = input.LT(1); + GrammarAST el=null; try { @@ -1437,6 +1635,7 @@ public class BasicSemanticTriggers extends TreeFilter { new NoViableAltException("", 14, 0, input); throw nvae; + } switch (alt14) { case 1 : @@ -1446,12 +1645,13 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; el=(GrammarAST)input.LT(1); + matchAny(input); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; - if ( state.backtracking==1 ) { - checker.checkASTOps(root.getOptions(), ((GrammarAST)retval.start), el); - } + + + if ( state.backtracking==1 ) {checker.checkASTOps(root.getOptions(), ((GrammarAST)retval.start), el);} } break; @@ -1462,12 +1662,13 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; el=(GrammarAST)input.LT(1); + matchAny(input); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; - if ( state.backtracking==1 ) { - checker.checkASTOps(root.getOptions(), ((GrammarAST)retval.start), el); - } + + + if ( state.backtracking==1 ) {checker.checkASTOps(root.getOptions(), ((GrammarAST)retval.start), el);} } break; @@ -1478,28 +1679,34 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "astOps" + public static class rewrite_return extends TreeRuleReturnScope { }; + // $ANTLR start "rewrite" // BasicSemanticTriggers.g:232:1: rewrite : ( RESULT | ST_RESULT ) ; public final BasicSemanticTriggers.rewrite_return rewrite() throws RecognitionException { BasicSemanticTriggers.rewrite_return retval = new BasicSemanticTriggers.rewrite_return(); retval.start = input.LT(1); + try { // BasicSemanticTriggers.g:233:2: ( ( RESULT | ST_RESULT ) ) // BasicSemanticTriggers.g:233:4: ( RESULT | ST_RESULT ) { - if ( (input.LA(1)>=ST_RESULT && input.LA(1)<=RESULT) ) { + if ( input.LA(1)==RESULT||input.LA(1)==ST_RESULT ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1507,9 +1714,8 @@ public class BasicSemanticTriggers extends TreeFilter { throw mse; } - if ( state.backtracking==1 ) { - checker.checkRewriteOk(root.getOptions(),((GrammarAST)retval.start)); - } + + if ( state.backtracking==1 ) {checker.checkRewriteOk(root.getOptions(),((GrammarAST)retval.start));} } @@ -1518,13 +1724,16 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "rewrite" + // $ANTLR start "wildcardRoot" // BasicSemanticTriggers.g:237:1: wildcardRoot : ^( TREE_BEGIN WILDCARD ( . )* ) ; public final void wildcardRoot() throws RecognitionException { @@ -1538,13 +1747,14 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; WILDCARD9=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_wildcardRoot772); if (state.failed) return ; + // BasicSemanticTriggers.g:238:29: ( . )* loop15: do { int alt15=2; int LA15_0 = input.LA(1); - if ( ((LA15_0>=SEMPRED && LA15_0<=ALT_REWRITE)) ) { + if ( ((LA15_0 >= ACTION && LA15_0 <= WILDCARD)) ) { alt15=1; } else if ( (LA15_0==UP) ) { @@ -1568,9 +1778,9 @@ public class BasicSemanticTriggers extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - checker.checkWildcardRoot(WILDCARD9.token); - } + + + if ( state.backtracking==1 ) {checker.checkWildcardRoot(WILDCARD9.token);} } @@ -1579,7 +1789,9 @@ public class BasicSemanticTriggers extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } @@ -1588,94 +1800,6 @@ public class BasicSemanticTriggers extends TreeFilter { // Delegated rules - protected DFA1 dfa1 = new DFA1(this); - static final String DFA1_eotS = - "\15\uffff"; - static final String DFA1_eofS = - "\15\uffff"; - static final String DFA1_minS = - "\1\33\3\uffff\1\2\2\uffff\1\127\1\61\1\3\1\uffff\1\0\1\uffff"; - static final String DFA1_maxS = - "\1\145\3\uffff\1\2\2\uffff\2\127\1\3\1\uffff\1\0\1\uffff"; - static final String DFA1_acceptS = - "\1\uffff\1\1\1\2\1\3\1\uffff\1\5\1\7\3\uffff\1\4\1\uffff\1\6"; - static final String DFA1_specialS = - "\13\uffff\1\0\1\uffff}>"; - static final String[] DFA1_transitionS = { - "\1\1\10\uffff\1\3\11\uffff\1\4\32\uffff\1\5\1\2\31\uffff\2\6", - "", - "", - "", - "\1\7", - "", - "", - "\1\10", - "\1\12\17\uffff\1\12\2\uffff\1\11\22\uffff\1\12", - "\1\13", - "", - "\1\uffff", - "" - }; - - static final short[] DFA1_eot = DFA.unpackEncodedString(DFA1_eotS); - static final short[] DFA1_eof = DFA.unpackEncodedString(DFA1_eofS); - static final char[] DFA1_min = DFA.unpackEncodedStringToUnsignedChars(DFA1_minS); - static final char[] DFA1_max = DFA.unpackEncodedStringToUnsignedChars(DFA1_maxS); - static final short[] DFA1_accept = DFA.unpackEncodedString(DFA1_acceptS); - static final short[] DFA1_special = DFA.unpackEncodedString(DFA1_specialS); - static final short[][] DFA1_transition; - - static { - int numStates = DFA1_transitionS.length; - DFA1_transition = new short[numStates][]; - for (int i=0; i=0 ) return s; - break; - } - if (state.backtracking>0) {state.failed=true; return -1;} - NoViableAltException nvae = - new NoViableAltException(getDescription(), 1, _s, input); - error(nvae); - throw nvae; - } - } public static final BitSet FOLLOW_grammarSpec_in_topdown87 = new BitSet(new long[]{0x0000000000000002L}); @@ -1693,45 +1817,43 @@ public class BasicSemanticTriggers extends TreeFilter { public static final BitSet FOLLOW_checkGrammarOptions_in_bottomup154 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_wildcardRoot_in_bottomup160 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_GRAMMAR_in_grammarSpec178 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_grammarSpec180 = new BitSet(new long[]{0x0000000000580040L,0x0000000000000400L}); - public static final BitSet FOLLOW_DOC_COMMENT_in_grammarSpec182 = new BitSet(new long[]{0x0000000000580000L,0x0000000000000400L}); - public static final BitSet FOLLOW_prequelConstructs_in_grammarSpec199 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_ID_in_grammarSpec180 = new BitSet(new long[]{0x0000020100020000L,0x0000000400000002L}); + public static final BitSet FOLLOW_DOC_COMMENT_in_grammarSpec182 = new BitSet(new long[]{0x0000020100000000L,0x0000000400000002L}); + public static final BitSet FOLLOW_prequelConstructs_in_grammarSpec199 = new BitSet(new long[]{0x0000000000000000L,0x0000000400000000L}); public static final BitSet FOLLOW_RULES_in_grammarSpec202 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_GRAMMAR_in_checkGrammarOptions225 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_OPTIONS_in_prequelConstructs248 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_IMPORT_in_prequelConstructs261 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_delegateGrammar_in_prequelConstructs263 = new BitSet(new long[]{0x0000400000000008L,0x0000000000800000L}); + public static final BitSet FOLLOW_delegateGrammar_in_prequelConstructs263 = new BitSet(new long[]{0x0000000000000208L,0x0000000000400000L}); public static final BitSet FOLLOW_TOKENS_in_prequelConstructs274 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ASSIGN_in_delegateGrammar306 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_delegateGrammar308 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L}); + public static final BitSet FOLLOW_ID_in_delegateGrammar308 = new BitSet(new long[]{0x0000000000000000L,0x0000000000400000L}); public static final BitSet FOLLOW_ID_in_delegateGrammar312 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ID_in_delegateGrammar326 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_RULES_in_rules353 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_MODE_in_mode365 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ID_in_mode367 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF8L,0x0000007FFFFFFFFFL}); public static final BitSet FOLLOW_ASSIGN_in_option392 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_option396 = new BitSet(new long[]{0x0002000000000000L,0x0000000000800012L}); + public static final BitSet FOLLOW_ID_in_option396 = new BitSet(new long[]{0x6000000200000000L,0x0000000000400000L}); public static final BitSet FOLLOW_optionValue_in_option398 = new BitSet(new long[]{0x0000000000000008L}); - public static final BitSet FOLLOW_set_in_optionValue0 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_RULE_in_rule480 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ID_in_rule484 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF8L,0x0000007FFFFFFFFFL}); public static final BitSet FOLLOW_RULE_REF_in_ruleref507 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ASSIGN_in_tokenAlias526 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_tokenAlias528 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_ID_in_tokenAlias528 = new BitSet(new long[]{0x4000000000000000L}); public static final BitSet FOLLOW_STRING_LITERAL_in_tokenAlias530 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_TOKEN_REF_in_tokenRefWithArgs555 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ARG_ACTION_in_tokenRefWithArgs557 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ELEMENT_OPTIONS_in_elementOption586 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ASSIGN_in_elementOption597 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_elementOption601 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L}); + public static final BitSet FOLLOW_ID_in_elementOption601 = new BitSet(new long[]{0x0000000000000000L,0x0000000000400000L}); public static final BitSet FOLLOW_ID_in_elementOption605 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ASSIGN_in_elementOption619 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_elementOption623 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_ID_in_elementOption623 = new BitSet(new long[]{0x4000000000000000L}); public static final BitSet FOLLOW_STRING_LITERAL_in_elementOption627 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ID_in_elementOption641 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ALT_in_multiElementAltInTreeGrammar681 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar683 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE0L,0x0000007FFFFFFFFFL}); - public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar690 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE8L,0x0000007FFFFFFFFFL}); + public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar683 = new BitSet(new long[]{0xF7FFFFFFFFFFFFE0L,0x0000007FFFFFFFFFL}); public static final BitSet FOLLOW_ROOT_in_astOps716 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_BANG_in_astOps729 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_set_in_rewrite747 = new BitSet(new long[]{0x0000000000000002L}); diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.tokens b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.tokens index 45caa06d7..9c114d46d 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.tokens +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.tokens @@ -1,99 +1,99 @@ -SEMPRED=4 -FORCED_ACTION=5 -DOC_COMMENT=6 -SRC=7 -NLCHARS=8 -COMMENT=9 -DOUBLE_QUOTE_STRING_LITERAL=10 -DOUBLE_ANGLE_STRING_LITERAL=11 -ACTION_STRING_LITERAL=12 -ACTION_CHAR_LITERAL=13 -ARG_ACTION=14 -NESTED_ACTION=15 -ACTION=16 -ACTION_ESC=17 -WSNLCHARS=18 -OPTIONS=19 -TOKENS=20 -SCOPE=21 -IMPORT=22 -FRAGMENT=23 -LEXER=24 -PARSER=25 -TREE=26 -GRAMMAR=27 -PROTECTED=28 -PUBLIC=29 -PRIVATE=30 -RETURNS=31 -THROWS=32 -CATCH=33 -FINALLY=34 -TEMPLATE=35 -MODE=36 -COLON=37 -COLONCOLON=38 -COMMA=39 -SEMI=40 -LPAREN=41 -RPAREN=42 -IMPLIES=43 -LT=44 -GT=45 -ASSIGN=46 -QUESTION=47 -BANG=48 -STAR=49 -PLUS=50 -PLUS_ASSIGN=51 -OR=52 -ROOT=53 -DOLLAR=54 -DOT=55 -RANGE=56 -ETC=57 -RARROW=58 -TREE_BEGIN=59 -AT=60 -NOT=61 -RBRACE=62 -TOKEN_REF=63 -RULE_REF=64 -INT=65 -WSCHARS=66 -ESC_SEQ=67 -STRING_LITERAL=68 -HEX_DIGIT=69 -UNICODE_ESC=70 -WS=71 -ERRCHAR=72 -RULE=73 -RULES=74 -RULEMODIFIERS=75 -RULEACTIONS=76 -BLOCK=77 -REWRITE_BLOCK=78 -OPTIONAL=79 -CLOSURE=80 -POSITIVE_CLOSURE=81 -SYNPRED=82 -CHAR_RANGE=83 +ACTION=4 +ACTION_CHAR_LITERAL=5 +ACTION_ESC=6 +ACTION_STRING_LITERAL=7 +ARG_ACTION=8 +ASSIGN=9 +AT=10 +BANG=11 +CATCH=12 +COLON=13 +COLONCOLON=14 +COMMA=15 +COMMENT=16 +DOC_COMMENT=17 +DOLLAR=18 +DOT=19 +DOUBLE_ANGLE_STRING_LITERAL=20 +DOUBLE_QUOTE_STRING_LITERAL=21 +ERRCHAR=22 +ESC_SEQ=23 +ETC=24 +FINALLY=25 +FORCED_ACTION=26 +FRAGMENT=27 +GRAMMAR=28 +GT=29 +HEX_DIGIT=30 +IMPLIES=31 +IMPORT=32 +INT=33 +LEXER=34 +LPAREN=35 +LT=36 +MODE=37 +NESTED_ACTION=38 +NLCHARS=39 +NOT=40 +OPTIONS=41 +OR=42 +PARSER=43 +PLUS=44 +PLUS_ASSIGN=45 +PRIVATE=46 +PROTECTED=47 +PUBLIC=48 +QUESTION=49 +RANGE=50 +RARROW=51 +RBRACE=52 +RETURNS=53 +ROOT=54 +RPAREN=55 +RULE_REF=56 +SCOPE=57 +SEMI=58 +SEMPRED=59 +SRC=60 +STAR=61 +STRING_LITERAL=62 +TEMPLATE=63 +THROWS=64 +TOKENS=65 +TOKEN_REF=66 +TREE=67 +TREE_BEGIN=68 +UNICODE_ESC=69 +WS=70 +WSCHARS=71 +WSNLCHARS=72 +ALT=73 +ALTLIST=74 +ALT_REWRITE=75 +ARG=76 +ARGLIST=77 +BACKTRACK_SEMPRED=78 +BLOCK=79 +CHAR_RANGE=80 +CLOSURE=81 +COMBINED=82 +ELEMENT_OPTIONS=83 EPSILON=84 -ALT=85 -ALTLIST=86 -ID=87 -ARG=88 -ARGLIST=89 -RET=90 -COMBINED=91 -INITACTION=92 -LABEL=93 -GATED_SEMPRED=94 -SYN_SEMPRED=95 -BACKTRACK_SEMPRED=96 -WILDCARD=97 -LIST=98 -ELEMENT_OPTIONS=99 -ST_RESULT=100 -RESULT=101 -ALT_REWRITE=102 +GATED_SEMPRED=85 +ID=86 +INITACTION=87 +LABEL=88 +LIST=89 +OPTIONAL=90 +POSITIVE_CLOSURE=91 +RESULT=92 +RET=93 +REWRITE_BLOCK=94 +RULE=95 +RULEACTIONS=96 +RULEMODIFIERS=97 +RULES=98 +ST_RESULT=99 +SYNPRED=100 +SYN_SEMPRED=101 +WILDCARD=102 diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.java b/tool/src/org/antlr/v4/semantics/CollectSymbols.java index e134896b1..ea3198d73 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.java +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.java @@ -1,4 +1,4 @@ -// $ANTLR 3.3 Nov 30, 2010 12:50:56 CollectSymbols.g 2011-06-11 10:28:59 +// $ANTLR 3.4 CollectSymbols.g 2011-06-20 18:31:15 /* [The "BSD license"] @@ -34,126 +34,131 @@ import org.antlr.v4.parse.ScopeParser; import org.antlr.v4.tool.*; import java.util.*; + /** Collects rules, terminals, strings, actions, scopes etc... from AST * No side-effects */ +@SuppressWarnings({"all", "warnings", "unchecked"}) public class CollectSymbols extends TreeFilter { public static final String[] tokenNames = new String[] { - "", "", "", "", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "MODE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "ID", "ARG", "ARGLIST", "RET", "COMBINED", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "RESULT", "ALT_REWRITE" + "", "", "", "", "ACTION", "ACTION_CHAR_LITERAL", "ACTION_ESC", "ACTION_STRING_LITERAL", "ARG_ACTION", "ASSIGN", "AT", "BANG", "CATCH", "COLON", "COLONCOLON", "COMMA", "COMMENT", "DOC_COMMENT", "DOLLAR", "DOT", "DOUBLE_ANGLE_STRING_LITERAL", "DOUBLE_QUOTE_STRING_LITERAL", "ERRCHAR", "ESC_SEQ", "ETC", "FINALLY", "FORCED_ACTION", "FRAGMENT", "GRAMMAR", "GT", "HEX_DIGIT", "IMPLIES", "IMPORT", "INT", "LEXER", "LPAREN", "LT", "MODE", "NESTED_ACTION", "NLCHARS", "NOT", "OPTIONS", "OR", "PARSER", "PLUS", "PLUS_ASSIGN", "PRIVATE", "PROTECTED", "PUBLIC", "QUESTION", "RANGE", "RARROW", "RBRACE", "RETURNS", "ROOT", "RPAREN", "RULE_REF", "SCOPE", "SEMI", "SEMPRED", "SRC", "STAR", "STRING_LITERAL", "TEMPLATE", "THROWS", "TOKENS", "TOKEN_REF", "TREE", "TREE_BEGIN", "UNICODE_ESC", "WS", "WSCHARS", "WSNLCHARS", "ALT", "ALTLIST", "ALT_REWRITE", "ARG", "ARGLIST", "BACKTRACK_SEMPRED", "BLOCK", "CHAR_RANGE", "CLOSURE", "COMBINED", "ELEMENT_OPTIONS", "EPSILON", "GATED_SEMPRED", "ID", "INITACTION", "LABEL", "LIST", "OPTIONAL", "POSITIVE_CLOSURE", "RESULT", "RET", "REWRITE_BLOCK", "RULE", "RULEACTIONS", "RULEMODIFIERS", "RULES", "ST_RESULT", "SYNPRED", "SYN_SEMPRED", "WILDCARD" }; + public static final int EOF=-1; - public static final int SEMPRED=4; - public static final int FORCED_ACTION=5; - public static final int DOC_COMMENT=6; - public static final int SRC=7; - public static final int NLCHARS=8; - public static final int COMMENT=9; - public static final int DOUBLE_QUOTE_STRING_LITERAL=10; - public static final int DOUBLE_ANGLE_STRING_LITERAL=11; - public static final int ACTION_STRING_LITERAL=12; - public static final int ACTION_CHAR_LITERAL=13; - public static final int ARG_ACTION=14; - public static final int NESTED_ACTION=15; - public static final int ACTION=16; - public static final int ACTION_ESC=17; - public static final int WSNLCHARS=18; - public static final int OPTIONS=19; - public static final int TOKENS=20; - public static final int SCOPE=21; - public static final int IMPORT=22; - public static final int FRAGMENT=23; - public static final int LEXER=24; - public static final int PARSER=25; - public static final int TREE=26; - public static final int GRAMMAR=27; - public static final int PROTECTED=28; - public static final int PUBLIC=29; - public static final int PRIVATE=30; - public static final int RETURNS=31; - public static final int THROWS=32; - public static final int CATCH=33; - public static final int FINALLY=34; - public static final int TEMPLATE=35; - public static final int MODE=36; - public static final int COLON=37; - public static final int COLONCOLON=38; - public static final int COMMA=39; - public static final int SEMI=40; - public static final int LPAREN=41; - public static final int RPAREN=42; - public static final int IMPLIES=43; - public static final int LT=44; - public static final int GT=45; - public static final int ASSIGN=46; - public static final int QUESTION=47; - public static final int BANG=48; - public static final int STAR=49; - public static final int PLUS=50; - public static final int PLUS_ASSIGN=51; - public static final int OR=52; - public static final int ROOT=53; - public static final int DOLLAR=54; - public static final int DOT=55; - public static final int RANGE=56; - public static final int ETC=57; - public static final int RARROW=58; - public static final int TREE_BEGIN=59; - public static final int AT=60; - public static final int NOT=61; - public static final int RBRACE=62; - public static final int TOKEN_REF=63; - public static final int RULE_REF=64; - public static final int INT=65; - public static final int WSCHARS=66; - public static final int ESC_SEQ=67; - public static final int STRING_LITERAL=68; - public static final int HEX_DIGIT=69; - public static final int UNICODE_ESC=70; - public static final int WS=71; - public static final int ERRCHAR=72; - public static final int RULE=73; - public static final int RULES=74; - public static final int RULEMODIFIERS=75; - public static final int RULEACTIONS=76; - public static final int BLOCK=77; - public static final int REWRITE_BLOCK=78; - public static final int OPTIONAL=79; - public static final int CLOSURE=80; - public static final int POSITIVE_CLOSURE=81; - public static final int SYNPRED=82; - public static final int CHAR_RANGE=83; + public static final int ACTION=4; + public static final int ACTION_CHAR_LITERAL=5; + public static final int ACTION_ESC=6; + public static final int ACTION_STRING_LITERAL=7; + public static final int ARG_ACTION=8; + public static final int ASSIGN=9; + public static final int AT=10; + public static final int BANG=11; + public static final int CATCH=12; + public static final int COLON=13; + public static final int COLONCOLON=14; + public static final int COMMA=15; + public static final int COMMENT=16; + public static final int DOC_COMMENT=17; + public static final int DOLLAR=18; + public static final int DOT=19; + public static final int DOUBLE_ANGLE_STRING_LITERAL=20; + public static final int DOUBLE_QUOTE_STRING_LITERAL=21; + public static final int ERRCHAR=22; + public static final int ESC_SEQ=23; + public static final int ETC=24; + public static final int FINALLY=25; + public static final int FORCED_ACTION=26; + public static final int FRAGMENT=27; + public static final int GRAMMAR=28; + public static final int GT=29; + public static final int HEX_DIGIT=30; + public static final int IMPLIES=31; + public static final int IMPORT=32; + public static final int INT=33; + public static final int LEXER=34; + public static final int LPAREN=35; + public static final int LT=36; + public static final int MODE=37; + public static final int NESTED_ACTION=38; + public static final int NLCHARS=39; + public static final int NOT=40; + public static final int OPTIONS=41; + public static final int OR=42; + public static final int PARSER=43; + public static final int PLUS=44; + public static final int PLUS_ASSIGN=45; + public static final int PRIVATE=46; + public static final int PROTECTED=47; + public static final int PUBLIC=48; + public static final int QUESTION=49; + public static final int RANGE=50; + public static final int RARROW=51; + public static final int RBRACE=52; + public static final int RETURNS=53; + public static final int ROOT=54; + public static final int RPAREN=55; + public static final int RULE_REF=56; + public static final int SCOPE=57; + public static final int SEMI=58; + public static final int SEMPRED=59; + public static final int SRC=60; + public static final int STAR=61; + public static final int STRING_LITERAL=62; + public static final int TEMPLATE=63; + public static final int THROWS=64; + public static final int TOKENS=65; + public static final int TOKEN_REF=66; + public static final int TREE=67; + public static final int TREE_BEGIN=68; + public static final int UNICODE_ESC=69; + public static final int WS=70; + public static final int WSCHARS=71; + public static final int WSNLCHARS=72; + public static final int ALT=73; + public static final int ALTLIST=74; + public static final int ALT_REWRITE=75; + public static final int ARG=76; + public static final int ARGLIST=77; + public static final int BACKTRACK_SEMPRED=78; + public static final int BLOCK=79; + public static final int CHAR_RANGE=80; + public static final int CLOSURE=81; + public static final int COMBINED=82; + public static final int ELEMENT_OPTIONS=83; public static final int EPSILON=84; - public static final int ALT=85; - public static final int ALTLIST=86; - public static final int ID=87; - public static final int ARG=88; - public static final int ARGLIST=89; - public static final int RET=90; - public static final int COMBINED=91; - public static final int INITACTION=92; - public static final int LABEL=93; - public static final int GATED_SEMPRED=94; - public static final int SYN_SEMPRED=95; - public static final int BACKTRACK_SEMPRED=96; - public static final int WILDCARD=97; - public static final int LIST=98; - public static final int ELEMENT_OPTIONS=99; - public static final int ST_RESULT=100; - public static final int RESULT=101; - public static final int ALT_REWRITE=102; + public static final int GATED_SEMPRED=85; + public static final int ID=86; + public static final int INITACTION=87; + public static final int LABEL=88; + public static final int LIST=89; + public static final int OPTIONAL=90; + public static final int POSITIVE_CLOSURE=91; + public static final int RESULT=92; + public static final int RET=93; + public static final int REWRITE_BLOCK=94; + public static final int RULE=95; + public static final int RULEACTIONS=96; + public static final int RULEMODIFIERS=97; + public static final int RULES=98; + public static final int ST_RESULT=99; + public static final int SYNPRED=100; + public static final int SYN_SEMPRED=101; + public static final int WILDCARD=102; // delegates + public TreeFilter[] getDelegates() { + return new TreeFilter[] {}; + } + // delegators - public CollectSymbols(TreeNodeStream input) { - this(input, new RecognizerSharedState()); - } - public CollectSymbols(TreeNodeStream input, RecognizerSharedState state) { - super(input, state); - - } - + public CollectSymbols(TreeNodeStream input) { + this(input, new RecognizerSharedState()); + } + public CollectSymbols(TreeNodeStream input, RecognizerSharedState state) { + super(input, state); + } public String[] getTokenNames() { return CollectSymbols.tokenNames; } public String getGrammarFileName() { return "CollectSymbols.g"; } @@ -185,7 +190,330 @@ public class CollectSymbols extends TreeFilter { try { // CollectSymbols.g:96:5: ( globalScope | globalNamedAction | tokensSection | mode | rule | ruleArg | ruleReturns | ruleNamedAction | ruleScopeSpec | ruleref | rewriteElement | terminal | labeledElement | setAlt | ruleAction | sempred | finallyClause | exceptionHandler ) int alt1=18; - alt1 = dfa1.predict(input); + switch ( input.LA(1) ) { + case SCOPE: + { + int LA1_1 = input.LA(2); + + if ( (LA1_1==DOWN) ) { + int LA1_19 = input.LA(3); + + if ( (LA1_19==ID) ) { + int LA1_24 = input.LA(4); + + if ( (LA1_24==ACTION) ) { + alt1=1; + } + else if ( (LA1_24==UP||LA1_24==ID) ) { + alt1=9; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 24, input); + + throw nvae; + + } + } + else if ( (LA1_19==ACTION) ) { + alt1=9; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 19, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 1, input); + + throw nvae; + + } + } + break; + case AT: + { + int LA1_2 = input.LA(2); + + if ( (LA1_2==DOWN) ) { + int LA1_20 = input.LA(3); + + if ( (LA1_20==ID) ) { + int LA1_26 = input.LA(4); + + if ( (LA1_26==ACTION) ) { + int LA1_29 = input.LA(5); + + if ( (LA1_29==UP) ) { + int LA1_32 = input.LA(6); + + if ( ((inContext("GRAMMAR"))) ) { + alt1=2; + } + else if ( ((inContext("RULE"))) ) { + alt1=8; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 32, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 29, input); + + throw nvae; + + } + } + else if ( (LA1_26==ID) ) { + alt1=2; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 26, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 20, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 2, input); + + throw nvae; + + } + } + break; + case ASSIGN: + { + int LA1_3 = input.LA(2); + + if ( (LA1_3==DOWN) ) { + int LA1_21 = input.LA(3); + + if ( (LA1_21==ID) ) { + int LA1_27 = input.LA(4); + + if ( (LA1_27==STRING_LITERAL) ) { + int LA1_31 = input.LA(5); + + if ( (LA1_31==UP) ) { + int LA1_33 = input.LA(6); + + if ( ((inContext("TOKENS"))) ) { + alt1=3; + } + else if ( ((inContext("RULE ..."))) ) { + alt1=13; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 33, input); + + throw nvae; + + } + } + else if ( (LA1_31==DOWN) ) { + alt1=13; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 31, input); + + throw nvae; + + } + } + else if ( ((LA1_27 >= ACTION && LA1_27 <= STAR)||(LA1_27 >= TEMPLATE && LA1_27 <= WILDCARD)) ) { + alt1=13; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 27, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 21, input); + + throw nvae; + + } + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 3, input); + + throw nvae; + + } + } + break; + case ID: + { + alt1=3; + } + break; + case MODE: + { + alt1=4; + } + break; + case RULE: + { + alt1=5; + } + break; + case ARG_ACTION: + { + alt1=6; + } + break; + case RETURNS: + { + alt1=7; + } + break; + case RULE_REF: + { + int LA1_9 = input.LA(2); + + if ( (!(((inContext("RESULT ..."))))) ) { + alt1=10; + } + else if ( ((inContext("RESULT ..."))) ) { + alt1=11; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 9, input); + + throw nvae; + + } + } + break; + case STRING_LITERAL: + { + int LA1_10 = input.LA(2); + + if ( ((inContext("RESULT ..."))) ) { + alt1=11; + } + else if ( ((!inContext("TOKENS ASSIGN"))) ) { + alt1=12; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 10, input); + + throw nvae; + + } + } + break; + case TOKEN_REF: + { + int LA1_11 = input.LA(2); + + if ( ((inContext("RESULT ..."))) ) { + alt1=11; + } + else if ( (true) ) { + alt1=12; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 11, input); + + throw nvae; + + } + } + break; + case LABEL: + { + alt1=11; + } + break; + case PLUS_ASSIGN: + { + alt1=13; + } + break; + case ALT: + case ALT_REWRITE: + { + alt1=14; + } + break; + case ACTION: + case FORCED_ACTION: + { + alt1=15; + } + break; + case SEMPRED: + { + alt1=16; + } + break; + case FINALLY: + { + alt1=17; + } + break; + case CATCH: + { + alt1=18; + } + break; + default: + if (state.backtracking>0) {state.failed=true; return ;} + NoViableAltException nvae = + new NoViableAltException("", 1, 0, input); + + throw nvae; + + } + switch (alt1) { case 1 : // CollectSymbols.g:96:7: globalScope @@ -392,13 +720,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "topdown" + // $ANTLR start "bottomup" // CollectSymbols.g:117:1: bottomup : finishRule ; public final void bottomup() throws RecognitionException { @@ -419,15 +750,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "bottomup" + // $ANTLR start "globalScope" - // CollectSymbols.g:121:1: globalScope : {...}? ^( SCOPE ID ACTION ) ; + // CollectSymbols.g:121:1: globalScope :{...}? ^( SCOPE ID ACTION ) ; public final void globalScope() throws RecognitionException { GrammarAST ACTION1=null; GrammarAST ID2=null; @@ -440,22 +774,24 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "globalScope", "inContext(\"GRAMMAR\")"); } + match(input,SCOPE,FOLLOW_SCOPE_in_globalScope265); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; ID2=(GrammarAST)match(input,ID,FOLLOW_ID_in_globalScope267); if (state.failed) return ; + ACTION1=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_globalScope269); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - AttributeDict s = ScopeParser.parseDynamicScope((ACTION1!=null?ACTION1.getText():null)); - s.type = AttributeDict.DictType.GLOBAL_SCOPE; - s.name = (ID2!=null?ID2.getText():null); - s.ast = ACTION1; - scopes.add(s); - - } + AttributeDict s = ScopeParser.parseDynamicScope((ACTION1!=null?ACTION1.getText():null)); + s.type = AttributeDict.DictType.GLOBAL_SCOPE; + s.name = (ID2!=null?ID2.getText():null); + s.ast = ACTION1; + scopes.add(s); + } } @@ -464,15 +800,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "globalScope" + // $ANTLR start "globalNamedAction" - // CollectSymbols.g:132:1: globalNamedAction : {...}? ^( AT ( ID )? ID ACTION ) ; + // CollectSymbols.g:132:1: globalNamedAction :{...}? ^( AT ( ID )? ID ACTION ) ; public final void globalNamedAction() throws RecognitionException { GrammarAST AT3=null; GrammarAST ACTION4=null; @@ -485,6 +824,7 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "globalNamedAction", "inContext(\"GRAMMAR\")"); } + AT3=(GrammarAST)match(input,AT,FOLLOW_AT_in_globalNamedAction288); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; @@ -510,13 +850,15 @@ public class CollectSymbols extends TreeFilter { } + match(input,ID,FOLLOW_ID_in_globalNamedAction293); if (state.failed) return ; + ACTION4=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_globalNamedAction295); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - actions.add(AT3); ((ActionAST)ACTION4).resolver = g; - } + + + if ( state.backtracking==1 ) {actions.add(AT3); ((ActionAST)ACTION4).resolver = g;} } @@ -525,29 +867,33 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "globalNamedAction" + // $ANTLR start "tokensSection" - // CollectSymbols.g:137:1: tokensSection : {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ; + // CollectSymbols.g:137:1: tokensSection :{...}? ( ^( ASSIGN t= ID STRING_LITERAL ) |t= ID ) ; public final void tokensSection() throws RecognitionException { GrammarAST t=null; GrammarAST ASSIGN5=null; GrammarAST STRING_LITERAL6=null; try { - // CollectSymbols.g:138:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ) - // CollectSymbols.g:138:4: {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) + // CollectSymbols.g:138:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) |t= ID ) ) + // CollectSymbols.g:138:4: {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) |t= ID ) { if ( !((inContext("TOKENS"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "tokensSection", "inContext(\"TOKENS\")"); } - // CollectSymbols.g:139:3: ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) + + // CollectSymbols.g:139:3: ( ^( ASSIGN t= ID STRING_LITERAL ) |t= ID ) int alt3=2; int LA3_0 = input.LA(1); @@ -563,6 +909,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 3, 0, input); throw nvae; + } switch (alt3) { case 1 : @@ -572,13 +919,14 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection322); if (state.failed) return ; + STRING_LITERAL6=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokensSection324); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - terminals.add(t); tokenIDRefs.add(t); - tokensDefs.add(ASSIGN5); strings.add((STRING_LITERAL6!=null?STRING_LITERAL6.getText():null)); - } + + + if ( state.backtracking==1 ) {terminals.add(t); tokenIDRefs.add(t); + tokensDefs.add(ASSIGN5); strings.add((STRING_LITERAL6!=null?STRING_LITERAL6.getText():null));} } break; @@ -586,9 +934,8 @@ public class CollectSymbols extends TreeFilter { // CollectSymbols.g:142:5: t= ID { t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection338); if (state.failed) return ; - if ( state.backtracking==1 ) { - terminals.add(t); tokenIDRefs.add(t); tokensDefs.add(t); - } + + if ( state.backtracking==1 ) {terminals.add(t); tokenIDRefs.add(t); tokensDefs.add(t);} } break; @@ -603,13 +950,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "tokensSection" + // $ANTLR start "mode" // CollectSymbols.g:147:1: mode : ^( MODE ID ( . )+ ) ; public final void mode() throws RecognitionException { @@ -623,6 +973,7 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; ID7=(GrammarAST)match(input,ID,FOLLOW_ID_in_mode359); if (state.failed) return ; + // CollectSymbols.g:147:17: ( . )+ int cnt4=0; loop4: @@ -630,7 +981,7 @@ public class CollectSymbols extends TreeFilter { int alt4=2; int LA4_0 = input.LA(1); - if ( ((LA4_0>=SEMPRED && LA4_0<=ALT_REWRITE)) ) { + if ( ((LA4_0 >= ACTION && LA4_0 <= WILDCARD)) ) { alt4=1; } else if ( (LA4_0==UP) ) { @@ -659,9 +1010,9 @@ public class CollectSymbols extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - currentMode = (ID7!=null?ID7.getText():null); - } + + + if ( state.backtracking==1 ) {currentMode = (ID7!=null?ID7.getText():null);} } @@ -670,13 +1021,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "mode" + // $ANTLR start "rule" // CollectSymbols.g:149:1: rule : ^( RULE name= ID ( options {greedy=false; } : . )* ( ^( RULEMODIFIERS (m= . )+ ) )? ( ^( AT ID ACTION ) )* ^( BLOCK ( . )+ ) ( . )* ) ; public final void rule() throws RecognitionException { @@ -693,6 +1047,7 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; name=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule396); if (state.failed) return ; + // CollectSymbols.g:152:17: ( options {greedy=false; } : . )* loop5: do { @@ -712,6 +1067,7 @@ public class CollectSymbols extends TreeFilter { } } while (true); + // CollectSymbols.g:153:9: ( ^( RULEMODIFIERS (m= . )+ ) )? int alt7=2; int LA7_0 = input.LA(1); @@ -733,7 +1089,7 @@ public class CollectSymbols extends TreeFilter { int alt6=2; int LA6_0 = input.LA(1); - if ( ((LA6_0>=SEMPRED && LA6_0<=ALT_REWRITE)) ) { + if ( ((LA6_0 >= ACTION && LA6_0 <= WILDCARD)) ) { alt6=1; } @@ -743,10 +1099,10 @@ public class CollectSymbols extends TreeFilter { // CollectSymbols.g:153:27: m= . { m=(GrammarAST)input.LT(1); + matchAny(input); if (state.failed) return ; - if ( state.backtracking==1 ) { - modifiers.add(m); - } + + if ( state.backtracking==1 ) {modifiers.add(m);} } break; @@ -764,11 +1120,13 @@ public class CollectSymbols extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + } break; } + // CollectSymbols.g:154:9: ( ^( AT ID ACTION ) )* loop8: do { @@ -788,10 +1146,12 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; match(input,ID,FOLLOW_ID_in_rule446); if (state.failed) return ; + match(input,ACTION,FOLLOW_ACTION_in_rule448); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + } break; @@ -800,6 +1160,7 @@ public class CollectSymbols extends TreeFilter { } } while (true); + match(input,BLOCK,FOLLOW_BLOCK_in_rule462); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; @@ -810,7 +1171,7 @@ public class CollectSymbols extends TreeFilter { int alt9=2; int LA9_0 = input.LA(1); - if ( ((LA9_0>=SEMPRED && LA9_0<=ALT_REWRITE)) ) { + if ( ((LA9_0 >= ACTION && LA9_0 <= WILDCARD)) ) { alt9=1; } else if ( (LA9_0==UP) ) { @@ -839,13 +1200,15 @@ public class CollectSymbols extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + + // CollectSymbols.g:156:9: ( . )* loop10: do { int alt10=2; int LA10_0 = input.LA(1); - if ( ((LA10_0>=SEMPRED && LA10_0<=ALT_REWRITE)) ) { + if ( ((LA10_0 >= ACTION && LA10_0 <= WILDCARD)) ) { alt10=1; } else if ( (LA10_0==UP) ) { @@ -869,17 +1232,17 @@ public class CollectSymbols extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - int numAlts = RULE8.getFirstChildWithType(BLOCK).getChildCount(); - Rule r = new Rule(g, (name!=null?name.getText():null), (RuleAST)RULE8, numAlts); - if ( g.isLexer() ) r.mode = currentMode; - if ( modifiers.size()>0 ) r.modifiers = modifiers; - rules.add(r); - currentRule = r; - currentAlt = 1; - - } + int numAlts = RULE8.getFirstChildWithType(BLOCK).getChildCount(); + Rule r = new Rule(g, (name!=null?name.getText():null), (RuleAST)RULE8, numAlts); + if ( g.isLexer() ) r.mode = currentMode; + if ( modifiers.size()>0 ) r.modifiers = modifiers; + rules.add(r); + currentRule = r; + currentAlt = 1; + } } @@ -888,21 +1251,26 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "rule" + public static class setAlt_return extends TreeRuleReturnScope { }; + // $ANTLR start "setAlt" - // CollectSymbols.g:169:1: setAlt : {...}? ( ALT | ALT_REWRITE ) ; + // CollectSymbols.g:169:1: setAlt :{...}? ( ALT | ALT_REWRITE ) ; public final CollectSymbols.setAlt_return setAlt() throws RecognitionException { CollectSymbols.setAlt_return retval = new CollectSymbols.setAlt_return(); retval.start = input.LT(1); + try { // CollectSymbols.g:170:2: ({...}? ( ALT | ALT_REWRITE ) ) // CollectSymbols.g:170:4: {...}? ( ALT | ALT_REWRITE ) @@ -911,9 +1279,11 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "setAlt", "inContext(\"RULE BLOCK\")"); } + if ( input.LA(1)==ALT||input.LA(1)==ALT_REWRITE ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -921,12 +1291,11 @@ public class CollectSymbols extends TreeFilter { throw mse; } + if ( state.backtracking==1 ) { - - currentAlt = ((GrammarAST)retval.start).getChildIndex()+1; - currentRule.alt[currentAlt].ast = (AltAST)((GrammarAST)retval.start); - - } + currentAlt = ((GrammarAST)retval.start).getChildIndex()+1; + currentRule.alt[currentAlt].ast = (AltAST)((GrammarAST)retval.start); + } } @@ -935,13 +1304,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "setAlt" + // $ANTLR start "finishRule" // CollectSymbols.g:177:1: finishRule : RULE ; public final void finishRule() throws RecognitionException { @@ -950,9 +1322,8 @@ public class CollectSymbols extends TreeFilter { // CollectSymbols.g:178:4: RULE { match(input,RULE,FOLLOW_RULE_in_finishRule528); if (state.failed) return ; - if ( state.backtracking==1 ) { - currentRule = null; - } + + if ( state.backtracking==1 ) {currentRule = null;} } @@ -961,15 +1332,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "finishRule" + // $ANTLR start "ruleNamedAction" - // CollectSymbols.g:181:1: ruleNamedAction : {...}? ^( AT ID ACTION ) ; + // CollectSymbols.g:181:1: ruleNamedAction :{...}? ^( AT ID ACTION ) ; public final void ruleNamedAction() throws RecognitionException { GrammarAST ID9=null; GrammarAST ACTION10=null; @@ -982,19 +1356,21 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleNamedAction", "inContext(\"RULE\")"); } + match(input,AT,FOLLOW_AT_in_ruleNamedAction544); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; ID9=(GrammarAST)match(input,ID,FOLLOW_ID_in_ruleNamedAction546); if (state.failed) return ; + ACTION10=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleNamedAction548); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - currentRule.namedActions.put((ID9!=null?ID9.getText():null),(ActionAST)ACTION10); - ((ActionAST)ACTION10).resolver = currentRule; - - } + currentRule.namedActions.put((ID9!=null?ID9.getText():null),(ActionAST)ACTION10); + ((ActionAST)ACTION10).resolver = currentRule; + } } @@ -1003,13 +1379,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleNamedAction" + // $ANTLR start "ruleAction" // CollectSymbols.g:189:1: ruleAction : ({...}? ACTION | FORCED_ACTION ); public final void ruleAction() throws RecognitionException { @@ -1033,6 +1412,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 11, 0, input); throw nvae; + } switch (alt11) { case 1 : @@ -1043,13 +1423,13 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleAction", "inContext(\"RULE ...\")&&!inContext(\"SCOPE\")&&\n\t\t !inContext(\"CATCH\")&&!inContext(\"FINALLY\")&&!inContext(\"AT\")"); } + ACTION11=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleAction568); if (state.failed) return ; + if ( state.backtracking==1 ) { - - currentRule.defineActionInAlt(currentAlt, (ActionAST)ACTION11); - ((ActionAST)ACTION11).resolver = currentRule.alt[currentAlt]; - - } + currentRule.defineActionInAlt(currentAlt, (ActionAST)ACTION11); + ((ActionAST)ACTION11).resolver = currentRule.alt[currentAlt]; + } } break; @@ -1057,12 +1437,11 @@ public class CollectSymbols extends TreeFilter { // CollectSymbols.g:197:9: FORCED_ACTION { FORCED_ACTION12=(GrammarAST)match(input,FORCED_ACTION,FOLLOW_FORCED_ACTION_in_ruleAction582); if (state.failed) return ; + if ( state.backtracking==1 ) { - - currentRule.defineActionInAlt(currentAlt, (ActionAST)FORCED_ACTION12); - ((ActionAST)FORCED_ACTION12).resolver = currentRule.alt[currentAlt]; - - } + currentRule.defineActionInAlt(currentAlt, (ActionAST)FORCED_ACTION12); + ((ActionAST)FORCED_ACTION12).resolver = currentRule.alt[currentAlt]; + } } break; @@ -1073,15 +1452,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleAction" + // $ANTLR start "sempred" - // CollectSymbols.g:204:1: sempred : {...}? SEMPRED ; + // CollectSymbols.g:204:1: sempred :{...}? SEMPRED ; public final void sempred() throws RecognitionException { GrammarAST SEMPRED13=null; @@ -1093,13 +1475,13 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "sempred", "inContext(\"RULE ...\")"); } + SEMPRED13=(GrammarAST)match(input,SEMPRED,FOLLOW_SEMPRED_in_sempred601); if (state.failed) return ; + if ( state.backtracking==1 ) { - - currentRule.definePredicateInAlt(currentAlt, (PredAST)SEMPRED13); - ((PredAST)SEMPRED13).resolver = currentRule.alt[currentAlt]; - - } + currentRule.definePredicateInAlt(currentAlt, (PredAST)SEMPRED13); + ((PredAST)SEMPRED13).resolver = currentRule.alt[currentAlt]; + } } @@ -1108,13 +1490,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "sempred" + // $ANTLR start "exceptionHandler" // CollectSymbols.g:213:1: exceptionHandler : ^( CATCH ARG_ACTION ACTION ) ; public final void exceptionHandler() throws RecognitionException { @@ -1128,15 +1513,16 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return ; match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_exceptionHandler619); if (state.failed) return ; + ACTION14=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_exceptionHandler621); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - currentRule.exceptionActions.add((ActionAST)ACTION14); - ((ActionAST)ACTION14).resolver = currentRule; - - } + currentRule.exceptionActions.add((ActionAST)ACTION14); + ((ActionAST)ACTION14).resolver = currentRule; + } } @@ -1145,13 +1531,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "exceptionHandler" + // $ANTLR start "finallyClause" // CollectSymbols.g:221:1: finallyClause : ^( FINALLY ACTION ) ; public final void finallyClause() throws RecognitionException { @@ -1167,12 +1556,12 @@ public class CollectSymbols extends TreeFilter { ACTION15=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_finallyClause640); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - currentRule.finallyAction = (ActionAST)ACTION15; - ((ActionAST)ACTION15).resolver = currentRule; - - } + currentRule.finallyAction = (ActionAST)ACTION15; + ((ActionAST)ACTION15).resolver = currentRule; + } } @@ -1181,15 +1570,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "finallyClause" + // $ANTLR start "ruleArg" - // CollectSymbols.g:229:1: ruleArg : {...}? ARG_ACTION ; + // CollectSymbols.g:229:1: ruleArg :{...}? ARG_ACTION ; public final void ruleArg() throws RecognitionException { GrammarAST ARG_ACTION16=null; @@ -1201,14 +1593,14 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleArg", "inContext(\"RULE\")"); } + ARG_ACTION16=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleArg658); if (state.failed) return ; + if ( state.backtracking==1 ) { - - currentRule.args = ScopeParser.parseTypeList((ARG_ACTION16!=null?ARG_ACTION16.getText():null)); - currentRule.args.type = AttributeDict.DictType.ARG; - currentRule.args.ast = ARG_ACTION16; - - } + currentRule.args = ScopeParser.parseTypeList((ARG_ACTION16!=null?ARG_ACTION16.getText():null)); + currentRule.args.type = AttributeDict.DictType.ARG; + currentRule.args.ast = ARG_ACTION16; + } } @@ -1217,13 +1609,16 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleArg" + // $ANTLR start "ruleReturns" // CollectSymbols.g:238:1: ruleReturns : ^( RETURNS ARG_ACTION ) ; public final void ruleReturns() throws RecognitionException { @@ -1239,13 +1634,13 @@ public class CollectSymbols extends TreeFilter { ARG_ACTION17=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleReturns676); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - currentRule.retvals = ScopeParser.parseTypeList((ARG_ACTION17!=null?ARG_ACTION17.getText():null)); - currentRule.retvals.type = AttributeDict.DictType.RET; - currentRule.retvals.ast = ARG_ACTION17; - - } + currentRule.retvals = ScopeParser.parseTypeList((ARG_ACTION17!=null?ARG_ACTION17.getText():null)); + currentRule.retvals.type = AttributeDict.DictType.RET; + currentRule.retvals.ast = ARG_ACTION17; + } } @@ -1254,15 +1649,18 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleReturns" + // $ANTLR start "ruleScopeSpec" - // CollectSymbols.g:247:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; + // CollectSymbols.g:247:1: ruleScopeSpec :{...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; public final void ruleScopeSpec() throws RecognitionException { GrammarAST ACTION18=null; GrammarAST ids=null; @@ -1276,6 +1674,7 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleScopeSpec", "inContext(\"RULE\")"); } + // CollectSymbols.g:249:3: ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) int alt13=2; int LA13_0 = input.LA(1); @@ -1298,6 +1697,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 13, 2, input); throw nvae; + } } else { @@ -1306,6 +1706,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 13, 1, input); throw nvae; + } } else { @@ -1314,6 +1715,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 13, 0, input); throw nvae; + } switch (alt13) { case 1 : @@ -1325,14 +1727,14 @@ public class CollectSymbols extends TreeFilter { ACTION18=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleScopeSpec701); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; + + if ( state.backtracking==1 ) { - - currentRule.scope = ScopeParser.parseDynamicScope((ACTION18!=null?ACTION18.getText():null)); - currentRule.scope.type = AttributeDict.DictType.RULE_SCOPE; - currentRule.scope.name = currentRule.name; - currentRule.scope.ast = ACTION18; - - } + currentRule.scope = ScopeParser.parseDynamicScope((ACTION18!=null?ACTION18.getText():null)); + currentRule.scope.type = AttributeDict.DictType.RULE_SCOPE; + currentRule.scope.name = currentRule.name; + currentRule.scope.ast = ACTION18; + } } break; @@ -1378,9 +1780,9 @@ public class CollectSymbols extends TreeFilter { match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - currentRule.useScopes = list_ids; - } + + + if ( state.backtracking==1 ) {currentRule.useScopes = list_ids;} } break; @@ -1395,21 +1797,26 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } // $ANTLR end "ruleScopeSpec" + public static class rewriteElement_return extends TreeRuleReturnScope { }; + // $ANTLR start "rewriteElement" - // CollectSymbols.g:260:1: rewriteElement : {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ; + // CollectSymbols.g:260: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:262:2: ({...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ) // CollectSymbols.g:263:6: {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) @@ -1418,9 +1825,11 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "rewriteElement", "inContext(\"RESULT ...\")"); } - if ( (input.LA(1)>=TOKEN_REF && input.LA(1)<=RULE_REF)||input.LA(1)==STRING_LITERAL||input.LA(1)==LABEL ) { + + if ( input.LA(1)==RULE_REF||input.LA(1)==STRING_LITERAL||input.LA(1)==TOKEN_REF||input.LA(1)==LABEL ) { input.consume(); - state.errorRecovery=false;state.failed=false; + state.errorRecovery=false; + state.failed=false; } else { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1428,9 +1837,8 @@ public class CollectSymbols extends TreeFilter { throw mse; } - if ( state.backtracking==1 ) { - currentRule.alt[currentAlt].rewriteElements.add(((GrammarAST)retval.start)); - } + + if ( state.backtracking==1 ) {currentRule.alt[currentAlt].rewriteElements.add(((GrammarAST)retval.start));} } @@ -1439,21 +1847,26 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "rewriteElement" + public static class labeledElement_return extends TreeRuleReturnScope { }; + // $ANTLR start "labeledElement" - // CollectSymbols.g:267:1: labeledElement : {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ; + // CollectSymbols.g:267: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); + GrammarAST id=null; GrammarAST e=null; @@ -1465,6 +1878,7 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "labeledElement", "inContext(\"RULE ...\")"); } + // CollectSymbols.g:274:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) int alt14=2; int LA14_0 = input.LA(1); @@ -1481,6 +1895,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 14, 0, input); throw nvae; + } switch (alt14) { case 1 : @@ -1490,11 +1905,14 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement784); if (state.failed) return retval; + e=(GrammarAST)input.LT(1); + matchAny(input); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; + } break; case 2 : @@ -1504,11 +1922,14 @@ public class CollectSymbols extends TreeFilter { match(input, Token.DOWN, null); if (state.failed) return retval; id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement800); if (state.failed) return retval; + e=(GrammarAST)input.LT(1); + matchAny(input); if (state.failed) return retval; match(input, Token.UP, null); if (state.failed) return retval; + } break; @@ -1518,32 +1939,35 @@ public class CollectSymbols extends TreeFilter { } if ( state.backtracking==1 ) { - - LabelElementPair lp = new LabelElementPair(g, id, e, ((GrammarAST)retval.start).getType()); - //currentRule.labelDefs.map((id!=null?id.getText():null), lp); - currentRule.alt[currentAlt].labelDefs.map((id!=null?id.getText():null), lp); - + LabelElementPair lp = new LabelElementPair(g, id, e, ((GrammarAST)retval.start).getType()); + //currentRule.labelDefs.map((id!=null?id.getText():null), lp); + currentRule.alt[currentAlt].labelDefs.map((id!=null?id.getText():null), lp); } } catch (RecognitionException re) { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "labeledElement" + public static class terminal_return extends TreeRuleReturnScope { }; + // $ANTLR start "terminal" // CollectSymbols.g:279: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); + GrammarAST STRING_LITERAL19=null; GrammarAST TOKEN_REF20=null; @@ -1564,6 +1988,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 15, 0, input); throw nvae; + } switch (alt15) { case 1 : @@ -1573,16 +1998,16 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return retval;} throw new FailedPredicateException(input, "terminal", "!inContext(\"TOKENS ASSIGN\")"); } + STRING_LITERAL19=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal825); if (state.failed) return retval; + if ( state.backtracking==1 ) { - - terminals.add(((GrammarAST)retval.start)); - strings.add((STRING_LITERAL19!=null?STRING_LITERAL19.getText():null)); - if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL19!=null?STRING_LITERAL19.getText():null), (TerminalAST)STRING_LITERAL19); - } - - } + terminals.add(((GrammarAST)retval.start)); + strings.add((STRING_LITERAL19!=null?STRING_LITERAL19.getText():null)); + if ( currentRule!=null ) { + currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL19!=null?STRING_LITERAL19.getText():null), (TerminalAST)STRING_LITERAL19); + } + } } break; @@ -1590,15 +2015,14 @@ public class CollectSymbols extends TreeFilter { // CollectSymbols.g:288:7: TOKEN_REF { TOKEN_REF20=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal840); if (state.failed) return retval; + if ( state.backtracking==1 ) { - - terminals.add(TOKEN_REF20); - tokenIDRefs.add(TOKEN_REF20); - if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF20!=null?TOKEN_REF20.getText():null), (TerminalAST)TOKEN_REF20); - } - - } + terminals.add(TOKEN_REF20); + tokenIDRefs.add(TOKEN_REF20); + if ( currentRule!=null ) { + currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF20!=null?TOKEN_REF20.getText():null), (TerminalAST)TOKEN_REF20); + } + } } break; @@ -1609,23 +2033,26 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return retval; } // $ANTLR end "terminal" + // $ANTLR start "ruleref" - // CollectSymbols.g:298:1: ruleref : ({...}?r= RULE_REF | r= RULE_REF ) ; + // CollectSymbols.g:298:1: ruleref : ({...}?r= RULE_REF |r= RULE_REF ) ; public final void ruleref() throws RecognitionException { GrammarAST r=null; try { - // CollectSymbols.g:300:5: ( ({...}?r= RULE_REF | r= RULE_REF ) ) - // CollectSymbols.g:300:7: ({...}?r= RULE_REF | r= RULE_REF ) + // CollectSymbols.g:300:5: ( ({...}?r= RULE_REF |r= RULE_REF ) ) + // CollectSymbols.g:300:7: ({...}?r= RULE_REF |r= RULE_REF ) { - // CollectSymbols.g:300:7: ({...}?r= RULE_REF | r= RULE_REF ) + // CollectSymbols.g:300:7: ({...}?r= RULE_REF |r= RULE_REF ) int alt16=2; int LA16_0 = input.LA(1); @@ -1644,6 +2071,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 16, 1, input); throw nvae; + } } else { @@ -1652,6 +2080,7 @@ public class CollectSymbols extends TreeFilter { new NoViableAltException("", 16, 0, input); throw nvae; + } switch (alt16) { case 1 : @@ -1661,10 +2090,10 @@ public class CollectSymbols extends TreeFilter { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleref", "inContext(\"DOT ...\")"); } + r=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref877); if (state.failed) return ; - if ( state.backtracking==1 ) { - qualifiedRulerefs.add((GrammarAST)r.getParent()); - } + + if ( state.backtracking==1 ) {qualifiedRulerefs.add((GrammarAST)r.getParent());} } break; @@ -1678,14 +2107,13 @@ public class CollectSymbols extends TreeFilter { } + if ( state.backtracking==1 ) { - - rulerefs.add(r); - if ( currentRule!=null ) { - currentRule.alt[currentAlt].ruleRefs.map((r!=null?r.getText():null), r); - } - - } + rulerefs.add(r); + if ( currentRule!=null ) { + currentRule.alt[currentAlt].ruleRefs.map((r!=null?r.getText():null), r); + } + } } @@ -1694,7 +2122,9 @@ public class CollectSymbols extends TreeFilter { reportError(re); recover(input,re); } + finally { + // do for sure before leaving } return ; } @@ -1703,184 +2133,7 @@ public class CollectSymbols extends TreeFilter { // Delegated rules - protected DFA1 dfa1 = new DFA1(this); protected DFA5 dfa5 = new DFA5(this); - static final String DFA1_eotS = - "\43\uffff"; - static final String DFA1_eofS = - "\43\uffff"; - static final String DFA1_minS = - "\1\4\3\2\5\uffff\3\0\7\uffff\1\20\2\127\2\uffff\1\3\1\uffff\1\20"+ - "\1\4\1\uffff\1\3\1\uffff\1\2\2\0\1\uffff"; - static final String DFA1_maxS = - "\1\146\3\2\5\uffff\3\0\7\uffff\3\127\2\uffff\1\127\1\uffff\1\127"+ - "\1\146\1\uffff\1\3\1\uffff\1\3\2\0\1\uffff"; - static final String DFA1_acceptS = - "\4\uffff\1\3\1\4\1\5\1\6\1\7\3\uffff\1\13\1\15\1\16\1\17\1\20\1"+ - "\21\1\22\3\uffff\1\12\1\14\1\uffff\1\11\2\uffff\1\1\1\uffff\1\2"+ - "\3\uffff\1\10"; - static final String DFA1_specialS = - "\11\uffff\1\4\1\0\1\2\24\uffff\1\3\1\1\1\uffff}>"; - static final String[] DFA1_transitionS = { - "\1\20\1\17\10\uffff\1\7\1\uffff\1\17\4\uffff\1\1\11\uffff\1"+ - "\10\1\uffff\1\22\1\21\1\uffff\1\5\11\uffff\1\3\4\uffff\1\15"+ - "\10\uffff\1\2\2\uffff\1\13\1\11\3\uffff\1\12\4\uffff\1\6\13"+ - "\uffff\1\16\1\uffff\1\4\5\uffff\1\14\10\uffff\1\16", - "\1\23", - "\1\24", - "\1\25", - "", - "", - "", - "", - "", - "\1\uffff", - "\1\uffff", - "\1\uffff", - "", - "", - "", - "", - "", - "", - "", - "\1\31\106\uffff\1\30", - "\1\32", - "\1\33", - "", - "", - "\1\31\14\uffff\1\34\106\uffff\1\31", - "", - "\1\35\106\uffff\1\36", - "\100\15\1\37\42\15", - "", - "\1\40", - "", - "\1\15\1\41", - "\1\uffff", - "\1\uffff", - "" - }; - - static final short[] DFA1_eot = DFA.unpackEncodedString(DFA1_eotS); - static final short[] DFA1_eof = DFA.unpackEncodedString(DFA1_eofS); - static final char[] DFA1_min = DFA.unpackEncodedStringToUnsignedChars(DFA1_minS); - static final char[] DFA1_max = DFA.unpackEncodedStringToUnsignedChars(DFA1_maxS); - static final short[] DFA1_accept = DFA.unpackEncodedString(DFA1_acceptS); - static final short[] DFA1_special = DFA.unpackEncodedString(DFA1_specialS); - static final short[][] DFA1_transition; - - static { - int numStates = DFA1_transitionS.length; - DFA1_transition = new short[numStates][]; - for (int i=0; i=0 ) return s; - break; - case 1 : - int LA1_33 = input.LA(1); - - - int index1_33 = input.index(); - input.rewind(); - s = -1; - if ( ((inContext("TOKENS"))) ) {s = 4;} - - else if ( ((inContext("RULE ..."))) ) {s = 13;} - - - input.seek(index1_33); - if ( s>=0 ) return s; - break; - case 2 : - int LA1_11 = input.LA(1); - - - int index1_11 = input.index(); - input.rewind(); - s = -1; - if ( ((inContext("RESULT ..."))) ) {s = 12;} - - else if ( (true) ) {s = 23;} - - - input.seek(index1_11); - if ( s>=0 ) return s; - break; - case 3 : - int LA1_32 = input.LA(1); - - - int index1_32 = input.index(); - input.rewind(); - s = -1; - if ( ((inContext("GRAMMAR"))) ) {s = 30;} - - else if ( ((inContext("RULE"))) ) {s = 34;} - - - input.seek(index1_32); - if ( s>=0 ) return s; - break; - case 4 : - int LA1_9 = input.LA(1); - - - int index1_9 = input.index(); - input.rewind(); - s = -1; - if ( (!(((inContext("RESULT ..."))))) ) {s = 22;} - - else if ( ((inContext("RESULT ..."))) ) {s = 12;} - - - input.seek(index1_9); - if ( s>=0 ) return s; - break; - } - if (state.backtracking>0) {state.failed=true; return -1;} - NoViableAltException nvae = - new NoViableAltException(getDescription(), 1, _s, input); - error(nvae); - throw nvae; - } - } static final String DFA5_eotS = "\41\uffff"; static final String DFA5_eofS = @@ -1895,39 +2148,39 @@ public class CollectSymbols extends TreeFilter { static final String DFA5_specialS = "\41\uffff}>"; static final String[] DFA5_transitionS = { - "\70\4\1\2\16\4\1\1\1\4\1\3\31\4", + "\6\4\1\2\104\4\1\3\21\4\1\1\5\4", "\1\5\1\uffff\143\4", "\1\6\1\uffff\143\4", "\1\7\1\uffff\143\4", "", "\143\10", - "\123\4\1\11\17\4", + "\122\4\1\11\20\4", "\143\12", "\1\13\1\14\143\10", - "\15\4\1\15\126\4", + "\1\4\1\15\142\4", "\1\14\1\16\143\12", "", "", "\1\17\143\4", - "\1\17\70\23\1\21\16\23\1\20\1\23\1\22\31\23", + "\1\17\6\23\1\21\104\23\1\22\21\23\1\20\5\23", "", - "\1\24\1\17\70\23\1\21\16\23\1\20\1\23\1\22\31\23", - "\1\25\1\17\70\23\1\21\16\23\1\20\1\23\1\22\31\23", - "\1\26\1\17\70\23\1\21\16\23\1\20\1\23\1\22\31\23", - "\1\27\1\17\70\23\1\21\16\23\1\20\1\23\1\22\31\23", + "\1\24\1\17\6\23\1\21\104\23\1\22\21\23\1\20\5\23", + "\1\25\1\17\6\23\1\21\104\23\1\22\21\23\1\20\5\23", + "\1\26\1\17\6\23\1\21\104\23\1\22\21\23\1\20\5\23", + "\1\27\1\17\6\23\1\21\104\23\1\22\21\23\1\20\5\23", "\143\30", - "\123\32\1\31\17\32", + "\122\32\1\31\20\32", "\143\33", "\143\32", "\1\4\1\34\143\30", - "\1\36\14\32\1\35\126\32", + "\1\36\1\35\142\32", "\1\36\143\32", "\1\4\1\37\143\33", - "\1\37\70\23\1\21\16\23\1\20\1\23\1\22\31\23", + "\1\37\6\23\1\21\104\23\1\22\21\23\1\20\5\23", "\1\40\143\32", - "\1\37\70\23\1\21\16\23\1\20\1\23\1\22\31\23", + "\1\37\6\23\1\21\104\23\1\22\21\23\1\20\5\23", "", - "\1\37\70\23\1\21\16\23\1\20\1\23\1\22\31\23" + "\1\37\6\23\1\21\104\23\1\22\21\23\1\20\5\23" }; static final short[] DFA5_eot = DFA.unpackEncodedString(DFA5_eotS); @@ -1985,14 +2238,14 @@ public class CollectSymbols extends TreeFilter { public static final BitSet FOLLOW_exceptionHandler_in_topdown240 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_finishRule_in_bottomup251 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_SCOPE_in_globalScope265 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_globalScope267 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ID_in_globalScope267 = new BitSet(new long[]{0x0000000000000010L}); public static final BitSet FOLLOW_ACTION_in_globalScope269 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_AT_in_globalNamedAction288 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_globalNamedAction290 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L}); - public static final BitSet FOLLOW_ID_in_globalNamedAction293 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ID_in_globalNamedAction290 = new BitSet(new long[]{0x0000000000000000L,0x0000000000400000L}); + public static final BitSet FOLLOW_ID_in_globalNamedAction293 = new BitSet(new long[]{0x0000000000000010L}); public static final BitSet FOLLOW_ACTION_in_globalNamedAction295 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ASSIGN_in_tokensSection318 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_tokensSection322 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L}); + public static final BitSet FOLLOW_ID_in_tokensSection322 = new BitSet(new long[]{0x4000000000000000L}); public static final BitSet FOLLOW_STRING_LITERAL_in_tokensSection324 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ID_in_tokensSection338 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_MODE_in_mode357 = new BitSet(new long[]{0x0000000000000004L}); @@ -2001,19 +2254,19 @@ public class CollectSymbols extends TreeFilter { public static final BitSet FOLLOW_ID_in_rule396 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000007FFFFFFFFFL}); public static final BitSet FOLLOW_RULEMODIFIERS_in_rule420 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_AT_in_rule444 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_rule446 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ID_in_rule446 = new BitSet(new long[]{0x0000000000000010L}); public static final BitSet FOLLOW_ACTION_in_rule448 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_BLOCK_in_rule462 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_set_in_setAlt505 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_RULE_in_finishRule528 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_AT_in_ruleNamedAction544 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_ruleNamedAction546 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ID_in_ruleNamedAction546 = new BitSet(new long[]{0x0000000000000010L}); public static final BitSet FOLLOW_ACTION_in_ruleNamedAction548 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ACTION_in_ruleAction568 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_FORCED_ACTION_in_ruleAction582 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_SEMPRED_in_sempred601 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_CATCH_in_exceptionHandler617 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ARG_ACTION_in_exceptionHandler619 = new BitSet(new long[]{0x0000000000010000L}); + public static final BitSet FOLLOW_ARG_ACTION_in_exceptionHandler619 = new BitSet(new long[]{0x0000000000000010L}); public static final BitSet FOLLOW_ACTION_in_exceptionHandler621 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_FINALLY_in_finallyClause638 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ACTION_in_finallyClause640 = new BitSet(new long[]{0x0000000000000008L}); @@ -2023,7 +2276,7 @@ public class CollectSymbols extends TreeFilter { public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec699 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ACTION_in_ruleScopeSpec701 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec714 = new BitSet(new long[]{0x0000000000000004L}); - public static final BitSet FOLLOW_ID_in_ruleScopeSpec718 = new BitSet(new long[]{0x0000000000000008L,0x0000000000800000L}); + public static final BitSet FOLLOW_ID_in_ruleScopeSpec718 = new BitSet(new long[]{0x0000000000000008L,0x0000000000400000L}); public static final BitSet FOLLOW_set_in_rewriteElement745 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ASSIGN_in_labeledElement780 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ID_in_labeledElement784 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000007FFFFFFFFFL}); diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.tokens b/tool/src/org/antlr/v4/semantics/CollectSymbols.tokens index 45caa06d7..9c114d46d 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.tokens +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.tokens @@ -1,99 +1,99 @@ -SEMPRED=4 -FORCED_ACTION=5 -DOC_COMMENT=6 -SRC=7 -NLCHARS=8 -COMMENT=9 -DOUBLE_QUOTE_STRING_LITERAL=10 -DOUBLE_ANGLE_STRING_LITERAL=11 -ACTION_STRING_LITERAL=12 -ACTION_CHAR_LITERAL=13 -ARG_ACTION=14 -NESTED_ACTION=15 -ACTION=16 -ACTION_ESC=17 -WSNLCHARS=18 -OPTIONS=19 -TOKENS=20 -SCOPE=21 -IMPORT=22 -FRAGMENT=23 -LEXER=24 -PARSER=25 -TREE=26 -GRAMMAR=27 -PROTECTED=28 -PUBLIC=29 -PRIVATE=30 -RETURNS=31 -THROWS=32 -CATCH=33 -FINALLY=34 -TEMPLATE=35 -MODE=36 -COLON=37 -COLONCOLON=38 -COMMA=39 -SEMI=40 -LPAREN=41 -RPAREN=42 -IMPLIES=43 -LT=44 -GT=45 -ASSIGN=46 -QUESTION=47 -BANG=48 -STAR=49 -PLUS=50 -PLUS_ASSIGN=51 -OR=52 -ROOT=53 -DOLLAR=54 -DOT=55 -RANGE=56 -ETC=57 -RARROW=58 -TREE_BEGIN=59 -AT=60 -NOT=61 -RBRACE=62 -TOKEN_REF=63 -RULE_REF=64 -INT=65 -WSCHARS=66 -ESC_SEQ=67 -STRING_LITERAL=68 -HEX_DIGIT=69 -UNICODE_ESC=70 -WS=71 -ERRCHAR=72 -RULE=73 -RULES=74 -RULEMODIFIERS=75 -RULEACTIONS=76 -BLOCK=77 -REWRITE_BLOCK=78 -OPTIONAL=79 -CLOSURE=80 -POSITIVE_CLOSURE=81 -SYNPRED=82 -CHAR_RANGE=83 +ACTION=4 +ACTION_CHAR_LITERAL=5 +ACTION_ESC=6 +ACTION_STRING_LITERAL=7 +ARG_ACTION=8 +ASSIGN=9 +AT=10 +BANG=11 +CATCH=12 +COLON=13 +COLONCOLON=14 +COMMA=15 +COMMENT=16 +DOC_COMMENT=17 +DOLLAR=18 +DOT=19 +DOUBLE_ANGLE_STRING_LITERAL=20 +DOUBLE_QUOTE_STRING_LITERAL=21 +ERRCHAR=22 +ESC_SEQ=23 +ETC=24 +FINALLY=25 +FORCED_ACTION=26 +FRAGMENT=27 +GRAMMAR=28 +GT=29 +HEX_DIGIT=30 +IMPLIES=31 +IMPORT=32 +INT=33 +LEXER=34 +LPAREN=35 +LT=36 +MODE=37 +NESTED_ACTION=38 +NLCHARS=39 +NOT=40 +OPTIONS=41 +OR=42 +PARSER=43 +PLUS=44 +PLUS_ASSIGN=45 +PRIVATE=46 +PROTECTED=47 +PUBLIC=48 +QUESTION=49 +RANGE=50 +RARROW=51 +RBRACE=52 +RETURNS=53 +ROOT=54 +RPAREN=55 +RULE_REF=56 +SCOPE=57 +SEMI=58 +SEMPRED=59 +SRC=60 +STAR=61 +STRING_LITERAL=62 +TEMPLATE=63 +THROWS=64 +TOKENS=65 +TOKEN_REF=66 +TREE=67 +TREE_BEGIN=68 +UNICODE_ESC=69 +WS=70 +WSCHARS=71 +WSNLCHARS=72 +ALT=73 +ALTLIST=74 +ALT_REWRITE=75 +ARG=76 +ARGLIST=77 +BACKTRACK_SEMPRED=78 +BLOCK=79 +CHAR_RANGE=80 +CLOSURE=81 +COMBINED=82 +ELEMENT_OPTIONS=83 EPSILON=84 -ALT=85 -ALTLIST=86 -ID=87 -ARG=88 -ARGLIST=89 -RET=90 -COMBINED=91 -INITACTION=92 -LABEL=93 -GATED_SEMPRED=94 -SYN_SEMPRED=95 -BACKTRACK_SEMPRED=96 -WILDCARD=97 -LIST=98 -ELEMENT_OPTIONS=99 -ST_RESULT=100 -RESULT=101 -ALT_REWRITE=102 +GATED_SEMPRED=85 +ID=86 +INITACTION=87 +LABEL=88 +LIST=89 +OPTIONAL=90 +POSITIVE_CLOSURE=91 +RESULT=92 +RET=93 +REWRITE_BLOCK=94 +RULE=95 +RULEACTIONS=96 +RULEMODIFIERS=97 +RULES=98 +ST_RESULT=99 +SYNPRED=100 +SYN_SEMPRED=101 +WILDCARD=102