start tracking tokens after -> in rewrite; added test

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6677]
This commit is contained in:
parrt 2010-02-07 16:56:15 -08:00
parent 795df39aaa
commit 974c9556fd
7 changed files with 280 additions and 172 deletions

View File

@ -1,4 +1,4 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 BasicSemanticTriggers.g 2010-02-07 15:09:46
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 BasicSemanticTriggers.g 2010-02-07 16:55:18
/*
[The "BSD license"]

View File

@ -76,6 +76,7 @@ public List<Rule> rules = new ArrayList<Rule>();
public List<GrammarAST> rulerefs = new ArrayList<GrammarAST>();
public List<GrammarAST> terminals = new ArrayList<GrammarAST>();
public List<GrammarAST> tokenIDRefs = new ArrayList<GrammarAST>();
public List<GrammarAST> tokenNameRefsInRewrite = new ArrayList<GrammarAST>();
public List<GrammarAST> strings = new ArrayList<GrammarAST>();
public List<GrammarAST> tokensDefs = new ArrayList<GrammarAST>();
public List<GrammarAST> scopes = new ArrayList<GrammarAST>();
@ -100,6 +101,7 @@ topdown
| ruleref
| terminal
| labeledElement
| tokenRefInRewrite
;
bottomup
@ -152,13 +154,19 @@ ruleScopeSpec
)
;
tokenRefInRewrite
: {inContext("RESULT ...")}? TOKEN_REF {tokenNameRefsInRewrite.add($TOKEN_REF);}
;
labeledElement
@after {
LabelElementPair lp = new LabelElementPair(g, $id, $e, $start.getType());
ruleToLabelSpace.map(currentRule.name, lp);
}
: ^(ASSIGN id=ID e=.)
| ^(PLUS_ASSIGN id=ID e=.)
: {inContext("RULE ...")}?
( ^(ASSIGN id=ID e=.)
| ^(PLUS_ASSIGN id=ID e=.)
)
;
terminal

View File

@ -1,4 +1,4 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 CollectSymbols.g 2010-02-07 15:09:46
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 CollectSymbols.g 2010-02-07 16:55:18
/*
[The "BSD license"]
@ -164,6 +164,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
public List<GrammarAST> rulerefs = new ArrayList<GrammarAST>();
public List<GrammarAST> terminals = new ArrayList<GrammarAST>();
public List<GrammarAST> tokenIDRefs = new ArrayList<GrammarAST>();
public List<GrammarAST> tokenNameRefsInRewrite = new ArrayList<GrammarAST>();
public List<GrammarAST> strings = new ArrayList<GrammarAST>();
public List<GrammarAST> tokensDefs = new ArrayList<GrammarAST>();
public List<GrammarAST> scopes = new ArrayList<GrammarAST>();
@ -179,15 +180,15 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "topdown"
// CollectSymbols.g:92:1: topdown : ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement );
// CollectSymbols.g:93:1: topdown : ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement | tokenRefInRewrite );
public final void topdown() throws RecognitionException {
try {
// CollectSymbols.g:93:5: ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement )
int alt1=10;
// CollectSymbols.g:94:5: ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement | tokenRefInRewrite )
int alt1=11;
alt1 = dfa1.predict(input);
switch (alt1) {
case 1 :
// CollectSymbols.g:93:7: globalScope
// CollectSymbols.g:94:7: globalScope
{
pushFollow(FOLLOW_globalScope_in_topdown96);
globalScope();
@ -198,7 +199,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 2 :
// CollectSymbols.g:94:7: action
// CollectSymbols.g:95:7: action
{
pushFollow(FOLLOW_action_in_topdown104);
action();
@ -209,7 +210,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 3 :
// CollectSymbols.g:95:7: tokensSection
// CollectSymbols.g:96:7: tokensSection
{
pushFollow(FOLLOW_tokensSection_in_topdown112);
tokensSection();
@ -220,7 +221,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 4 :
// CollectSymbols.g:96:7: rule
// CollectSymbols.g:97:7: rule
{
pushFollow(FOLLOW_rule_in_topdown120);
rule();
@ -231,7 +232,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 5 :
// CollectSymbols.g:97:7: ruleArg
// CollectSymbols.g:98:7: ruleArg
{
pushFollow(FOLLOW_ruleArg_in_topdown128);
ruleArg();
@ -242,7 +243,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 6 :
// CollectSymbols.g:98:7: ruleReturns
// CollectSymbols.g:99:7: ruleReturns
{
pushFollow(FOLLOW_ruleReturns_in_topdown136);
ruleReturns();
@ -253,7 +254,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 7 :
// CollectSymbols.g:99:7: ruleScopeSpec
// CollectSymbols.g:100:7: ruleScopeSpec
{
pushFollow(FOLLOW_ruleScopeSpec_in_topdown144);
ruleScopeSpec();
@ -264,7 +265,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 8 :
// CollectSymbols.g:100:7: ruleref
// CollectSymbols.g:101:7: ruleref
{
pushFollow(FOLLOW_ruleref_in_topdown152);
ruleref();
@ -275,7 +276,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 9 :
// CollectSymbols.g:101:7: terminal
// CollectSymbols.g:102:7: terminal
{
pushFollow(FOLLOW_terminal_in_topdown160);
terminal();
@ -286,7 +287,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 10 :
// CollectSymbols.g:102:7: labeledElement
// CollectSymbols.g:103:7: labeledElement
{
pushFollow(FOLLOW_labeledElement_in_topdown168);
labeledElement();
@ -294,6 +295,17 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
state._fsp--;
if (state.failed) return ;
}
break;
case 11 :
// CollectSymbols.g:104:7: tokenRefInRewrite
{
pushFollow(FOLLOW_tokenRefInRewrite_in_topdown176);
tokenRefInRewrite();
state._fsp--;
if (state.failed) return ;
}
break;
@ -311,13 +323,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "bottomup"
// CollectSymbols.g:105:1: bottomup : finishRule ;
// CollectSymbols.g:107:1: bottomup : finishRule ;
public final void bottomup() throws RecognitionException {
try {
// CollectSymbols.g:106:2: ( finishRule )
// CollectSymbols.g:106:4: finishRule
// CollectSymbols.g:108:2: ( finishRule )
// CollectSymbols.g:108:4: finishRule
{
pushFollow(FOLLOW_finishRule_in_bottomup179);
pushFollow(FOLLOW_finishRule_in_bottomup187);
finishRule();
state._fsp--;
@ -338,23 +350,23 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "globalScope"
// CollectSymbols.g:109:1: globalScope : {...}? ^( SCOPE ID ACTION ) ;
// CollectSymbols.g:111:1: globalScope : {...}? ^( SCOPE ID ACTION ) ;
public final void globalScope() throws RecognitionException {
GrammarAST SCOPE1=null;
try {
// CollectSymbols.g:110:2: ({...}? ^( SCOPE ID ACTION ) )
// CollectSymbols.g:110:4: {...}? ^( SCOPE ID ACTION )
// CollectSymbols.g:112:2: ({...}? ^( SCOPE ID ACTION ) )
// CollectSymbols.g:112:4: {...}? ^( SCOPE ID ACTION )
{
if ( !((inContext("GRAMMAR"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "globalScope", "inContext(\"GRAMMAR\")");
}
SCOPE1=(GrammarAST)match(input,SCOPE,FOLLOW_SCOPE_in_globalScope193); if (state.failed) return ;
SCOPE1=(GrammarAST)match(input,SCOPE,FOLLOW_SCOPE_in_globalScope201); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
match(input,ID,FOLLOW_ID_in_globalScope195); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_globalScope197); if (state.failed) return ;
match(input,ID,FOLLOW_ID_in_globalScope203); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_globalScope205); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
@ -376,22 +388,22 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "action"
// CollectSymbols.g:113:1: action : {...}? ^( AT ( ID )? ID ACTION ) ;
// CollectSymbols.g:115:1: action : {...}? ^( AT ( ID )? ID ACTION ) ;
public final void action() throws RecognitionException {
GrammarAST AT2=null;
try {
// CollectSymbols.g:114:2: ({...}? ^( AT ( ID )? ID ACTION ) )
// CollectSymbols.g:114:4: {...}? ^( AT ( ID )? ID ACTION )
// CollectSymbols.g:116:2: ({...}? ^( AT ( ID )? ID ACTION ) )
// CollectSymbols.g:116:4: {...}? ^( AT ( ID )? ID ACTION )
{
if ( !((inContext("GRAMMAR"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "action", "inContext(\"GRAMMAR\")");
}
AT2=(GrammarAST)match(input,AT,FOLLOW_AT_in_action214); if (state.failed) return ;
AT2=(GrammarAST)match(input,AT,FOLLOW_AT_in_action222); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
// CollectSymbols.g:114:33: ( ID )?
// CollectSymbols.g:116:33: ( ID )?
int alt2=2;
int LA2_0 = input.LA(1);
@ -404,17 +416,17 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt2) {
case 1 :
// CollectSymbols.g:114:33: ID
// CollectSymbols.g:116:33: ID
{
match(input,ID,FOLLOW_ID_in_action216); if (state.failed) return ;
match(input,ID,FOLLOW_ID_in_action224); if (state.failed) return ;
}
break;
}
match(input,ID,FOLLOW_ID_in_action219); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_action221); if (state.failed) return ;
match(input,ID,FOLLOW_ID_in_action227); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_action229); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
@ -436,21 +448,21 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "tokensSection"
// CollectSymbols.g:118:1: tokensSection : {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ;
// CollectSymbols.g:120:1: tokensSection : {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ;
public final void tokensSection() throws RecognitionException {
GrammarAST t=null;
GrammarAST ASSIGN3=null;
GrammarAST STRING_LITERAL4=null;
try {
// CollectSymbols.g:119:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) )
// CollectSymbols.g:119:4: {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID )
// CollectSymbols.g:121:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) )
// CollectSymbols.g:121: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:120:3: ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID )
// CollectSymbols.g:122:3: ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID )
int alt3=2;
int LA3_0 = input.LA(1);
@ -469,13 +481,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt3) {
case 1 :
// CollectSymbols.g:120:5: ^( ASSIGN t= ID STRING_LITERAL )
// CollectSymbols.g:122:5: ^( ASSIGN t= ID STRING_LITERAL )
{
ASSIGN3=(GrammarAST)match(input,ASSIGN,FOLLOW_ASSIGN_in_tokensSection244); if (state.failed) return ;
ASSIGN3=(GrammarAST)match(input,ASSIGN,FOLLOW_ASSIGN_in_tokensSection252); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection248); if (state.failed) return ;
STRING_LITERAL4=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokensSection250); if (state.failed) return ;
t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection256); if (state.failed) return ;
STRING_LITERAL4=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokensSection258); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
@ -486,9 +498,9 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 2 :
// CollectSymbols.g:123:5: t= ID
// CollectSymbols.g:125:5: t= ID
{
t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection264); if (state.failed) return ;
t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection272); if (state.failed) return ;
if ( state.backtracking==1 ) {
terminals.add(t); tokenIDRefs.add(t); tokensDefs.add(t);
}
@ -514,20 +526,20 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "rule"
// CollectSymbols.g:128:1: rule : ^( RULE name= ID ( . )+ ) ;
// CollectSymbols.g:130:1: rule : ^( RULE name= ID ( . )+ ) ;
public final void rule() throws RecognitionException {
GrammarAST name=null;
GrammarAST RULE5=null;
try {
// CollectSymbols.g:128:5: ( ^( RULE name= ID ( . )+ ) )
// CollectSymbols.g:128:9: ^( RULE name= ID ( . )+ )
// CollectSymbols.g:130:5: ( ^( RULE name= ID ( . )+ ) )
// CollectSymbols.g:130:9: ^( RULE name= ID ( . )+ )
{
RULE5=(GrammarAST)match(input,RULE,FOLLOW_RULE_in_rule286); if (state.failed) return ;
RULE5=(GrammarAST)match(input,RULE,FOLLOW_RULE_in_rule294); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
name=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule290); if (state.failed) return ;
// CollectSymbols.g:128:25: ( . )+
name=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule298); if (state.failed) return ;
// CollectSymbols.g:130:25: ( . )+
int cnt4=0;
loop4:
do {
@ -544,7 +556,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
switch (alt4) {
case 1 :
// CollectSymbols.g:128:25: .
// CollectSymbols.g:130:25: .
{
matchAny(input); if (state.failed) return ;
@ -586,13 +598,13 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "finishRule"
// CollectSymbols.g:136:1: finishRule : RULE ;
// CollectSymbols.g:138:1: finishRule : RULE ;
public final void finishRule() throws RecognitionException {
try {
// CollectSymbols.g:137:2: ( RULE )
// CollectSymbols.g:137:4: RULE
// CollectSymbols.g:139:2: ( RULE )
// CollectSymbols.g:139:4: RULE
{
match(input,RULE,FOLLOW_RULE_in_finishRule312); if (state.failed) return ;
match(input,RULE,FOLLOW_RULE_in_finishRule320); if (state.failed) return ;
if ( state.backtracking==1 ) {
currentRule = null;
}
@ -612,19 +624,19 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "ruleArg"
// CollectSymbols.g:140:1: ruleArg : {...}? ARG_ACTION ;
// CollectSymbols.g:142:1: ruleArg : {...}? ARG_ACTION ;
public final void ruleArg() throws RecognitionException {
GrammarAST ARG_ACTION6=null;
try {
// CollectSymbols.g:141:2: ({...}? ARG_ACTION )
// CollectSymbols.g:141:4: {...}? ARG_ACTION
// CollectSymbols.g:143:2: ({...}? ARG_ACTION )
// CollectSymbols.g:143:4: {...}? ARG_ACTION
{
if ( !((inContext("RULE"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "ruleArg", "inContext(\"RULE\")");
}
ARG_ACTION6=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleArg327); if (state.failed) return ;
ARG_ACTION6=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleArg335); if (state.failed) return ;
if ( state.backtracking==1 ) {
currentRule.arg = ARG_ACTION6;
}
@ -644,18 +656,18 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "ruleReturns"
// CollectSymbols.g:144:1: ruleReturns : ^( RETURNS ARG_ACTION ) ;
// CollectSymbols.g:146:1: ruleReturns : ^( RETURNS ARG_ACTION ) ;
public final void ruleReturns() throws RecognitionException {
GrammarAST ARG_ACTION7=null;
try {
// CollectSymbols.g:145:2: ( ^( RETURNS ARG_ACTION ) )
// CollectSymbols.g:145:4: ^( RETURNS ARG_ACTION )
// CollectSymbols.g:147:2: ( ^( RETURNS ARG_ACTION ) )
// CollectSymbols.g:147:4: ^( RETURNS ARG_ACTION )
{
match(input,RETURNS,FOLLOW_RETURNS_in_ruleReturns342); if (state.failed) return ;
match(input,RETURNS,FOLLOW_RETURNS_in_ruleReturns350); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
ARG_ACTION7=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleReturns344); if (state.failed) return ;
ARG_ACTION7=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleReturns352); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
@ -677,17 +689,17 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "ruleScopeSpec"
// CollectSymbols.g:148:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) ) ;
// CollectSymbols.g:150:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) ) ;
public final void ruleScopeSpec() throws RecognitionException {
try {
// CollectSymbols.g:149:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) ) )
// CollectSymbols.g:149:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) )
// CollectSymbols.g:151:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) ) )
// CollectSymbols.g:151:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) )
{
if ( !((inContext("RULE"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "ruleScopeSpec", "inContext(\"RULE\")");
}
// CollectSymbols.g:150:3: ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) )
// CollectSymbols.g:152:3: ( ^( SCOPE ACTION ) | ^( SCOPE ( ID )+ ) )
int alt6=2;
int LA6_0 = input.LA(1);
@ -728,24 +740,24 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt6) {
case 1 :
// CollectSymbols.g:150:5: ^( SCOPE ACTION )
// CollectSymbols.g:152:5: ^( SCOPE ACTION )
{
match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec365); if (state.failed) return ;
match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec373); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_ruleScopeSpec367); if (state.failed) return ;
match(input,ACTION,FOLLOW_ACTION_in_ruleScopeSpec375); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
}
break;
case 2 :
// CollectSymbols.g:151:5: ^( SCOPE ( ID )+ )
// CollectSymbols.g:153:5: ^( SCOPE ( ID )+ )
{
match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec375); if (state.failed) return ;
match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec383); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
// CollectSymbols.g:151:13: ( ID )+
// CollectSymbols.g:153:13: ( ID )+
int cnt5=0;
loop5:
do {
@ -759,9 +771,9 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
switch (alt5) {
case 1 :
// CollectSymbols.g:151:13: ID
// CollectSymbols.g:153:13: ID
{
match(input,ID,FOLLOW_ID_in_ruleScopeSpec377); if (state.failed) return ;
match(input,ID,FOLLOW_ID_in_ruleScopeSpec385); if (state.failed) return ;
}
break;
@ -798,11 +810,43 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
// $ANTLR end "ruleScopeSpec"
// $ANTLR start "tokenRefInRewrite"
// CollectSymbols.g:157:1: tokenRefInRewrite : {...}? TOKEN_REF ;
public final void tokenRefInRewrite() throws RecognitionException {
GrammarAST TOKEN_REF8=null;
try {
// CollectSymbols.g:158:2: ({...}? TOKEN_REF )
// CollectSymbols.g:158:4: {...}? TOKEN_REF
{
if ( !((inContext("RESULT ..."))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "tokenRefInRewrite", "inContext(\"RESULT ...\")");
}
TOKEN_REF8=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_tokenRefInRewrite404); if (state.failed) return ;
if ( state.backtracking==1 ) {
tokenNameRefsInRewrite.add(TOKEN_REF8);
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
return ;
}
// $ANTLR end "tokenRefInRewrite"
public static class labeledElement_return extends TreeRuleReturnScope {
};
// $ANTLR start "labeledElement"
// CollectSymbols.g:155:1: labeledElement : ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) );
// CollectSymbols.g:161: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);
@ -811,7 +855,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
GrammarAST e=null;
try {
// CollectSymbols.g:160:2: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) )
// CollectSymbols.g:166:2: ({...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) )
// CollectSymbols.g:166:4: {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) )
{
if ( !((inContext("RULE ..."))) ) {
if (state.backtracking>0) {state.failed=true; return retval;}
throw new FailedPredicateException(input, "labeledElement", "inContext(\"RULE ...\")");
}
// CollectSymbols.g:167:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) )
int alt7=2;
int LA7_0 = input.LA(1);
@ -830,12 +881,12 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt7) {
case 1 :
// CollectSymbols.g:160:4: ^( ASSIGN id= ID e= . )
// CollectSymbols.g:167:5: ^( ASSIGN id= ID e= . )
{
match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement400); if (state.failed) return retval;
match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement430); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement404); if (state.failed) return retval;
id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement434); if (state.failed) return retval;
e=(GrammarAST)input.LT(1);
matchAny(input); if (state.failed) return retval;
@ -844,12 +895,12 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
break;
case 2 :
// CollectSymbols.g:161:4: ^( PLUS_ASSIGN id= ID e= . )
// CollectSymbols.g:168:5: ^( PLUS_ASSIGN id= ID e= . )
{
match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement415); if (state.failed) return retval;
match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement446); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement419); if (state.failed) return retval;
id=(GrammarAST)match(input,ID,FOLLOW_ID_in_labeledElement450); if (state.failed) return retval;
e=(GrammarAST)input.LT(1);
matchAny(input); if (state.failed) return retval;
@ -859,6 +910,10 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
break;
}
}
if ( state.backtracking==1 ) {
LabelElementPair lp = new LabelElementPair(g, id, e, ((GrammarAST)retval.start).getType());
@ -880,16 +935,16 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
};
// $ANTLR start "terminal"
// CollectSymbols.g:164:1: terminal : ({...}? STRING_LITERAL | TOKEN_REF );
// CollectSymbols.g:172: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_LITERAL8=null;
GrammarAST TOKEN_REF9=null;
GrammarAST STRING_LITERAL9=null;
GrammarAST TOKEN_REF10=null;
try {
// CollectSymbols.g:165:5: ({...}? STRING_LITERAL | TOKEN_REF )
// CollectSymbols.g:173:5: ({...}? STRING_LITERAL | TOKEN_REF )
int alt8=2;
int LA8_0 = input.LA(1);
@ -908,26 +963,26 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt8) {
case 1 :
// CollectSymbols.g:165:7: {...}? STRING_LITERAL
// CollectSymbols.g:173:7: {...}? STRING_LITERAL
{
if ( !((!inContext("TOKENS ASSIGN"))) ) {
if (state.backtracking>0) {state.failed=true; return retval;}
throw new FailedPredicateException(input, "terminal", "!inContext(\"TOKENS ASSIGN\")");
}
STRING_LITERAL8=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal441); if (state.failed) return retval;
STRING_LITERAL9=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal476); if (state.failed) return retval;
if ( state.backtracking==1 ) {
terminals.add(((GrammarAST)retval.start));
strings.add(STRING_LITERAL8);
strings.add(STRING_LITERAL9);
}
}
break;
case 2 :
// CollectSymbols.g:167:7: TOKEN_REF
// CollectSymbols.g:175:7: TOKEN_REF
{
TOKEN_REF9=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal451); if (state.failed) return retval;
TOKEN_REF10=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal486); if (state.failed) return retval;
if ( state.backtracking==1 ) {
terminals.add(((GrammarAST)retval.start)); tokenIDRefs.add(TOKEN_REF9);
terminals.add(((GrammarAST)retval.start)); tokenIDRefs.add(TOKEN_REF10);
}
}
@ -947,19 +1002,19 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
// $ANTLR start "ruleref"
// CollectSymbols.g:170:1: ruleref : ^( RULE_REF ( ARG_ACTION )? ) ;
// CollectSymbols.g:178:1: ruleref : ^( RULE_REF ( ARG_ACTION )? ) ;
public final void ruleref() throws RecognitionException {
GrammarAST RULE_REF10=null;
GrammarAST RULE_REF11=null;
try {
// CollectSymbols.g:171:5: ( ^( RULE_REF ( ARG_ACTION )? ) )
// CollectSymbols.g:171:7: ^( RULE_REF ( ARG_ACTION )? )
// CollectSymbols.g:179:5: ( ^( RULE_REF ( ARG_ACTION )? ) )
// CollectSymbols.g:179:7: ^( RULE_REF ( ARG_ACTION )? )
{
RULE_REF10=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref471); if (state.failed) return ;
RULE_REF11=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref506); if (state.failed) return ;
if ( input.LA(1)==Token.DOWN ) {
match(input, Token.DOWN, null); if (state.failed) return ;
// CollectSymbols.g:171:18: ( ARG_ACTION )?
// CollectSymbols.g:179:18: ( ARG_ACTION )?
int alt9=2;
int LA9_0 = input.LA(1);
@ -968,9 +1023,9 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
}
switch (alt9) {
case 1 :
// CollectSymbols.g:171:18: ARG_ACTION
// CollectSymbols.g:179:18: ARG_ACTION
{
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref473); if (state.failed) return ;
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleref508); if (state.failed) return ;
}
break;
@ -981,7 +1036,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
match(input, Token.UP, null); if (state.failed) return ;
}
if ( state.backtracking==1 ) {
rulerefs.add(RULE_REF10);
rulerefs.add(RULE_REF11);
}
}
@ -1002,40 +1057,42 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
protected DFA1 dfa1 = new DFA1(this);
static final String DFA1_eotS =
"\23\uffff";
"\25\uffff";
static final String DFA1_eofS =
"\23\uffff";
"\25\uffff";
static final String DFA1_minS =
"\1\16\1\2\1\uffff\1\2\7\uffff\1\20\1\127\1\3\1\uffff\1\4\1\uffff"+
"\1\2\1\0";
"\1\16\1\2\1\uffff\1\2\6\uffff\1\0\1\uffff\1\20\1\127\1\uffff\1\3"+
"\1\uffff\1\4\1\uffff\1\2\1\0";
static final String DFA1_maxS =
"\1\127\1\2\1\uffff\1\2\7\uffff\3\127\1\uffff\1\145\1\uffff\1\3\1"+
"\0";
"\1\127\1\2\1\uffff\1\2\6\uffff\1\0\1\uffff\2\127\1\uffff\1\127\1"+
"\uffff\1\145\1\uffff\1\3\1\0";
static final String DFA1_acceptS =
"\2\uffff\1\2\1\uffff\1\3\1\4\1\5\1\6\1\10\1\11\1\12\3\uffff\1\7"+
"\1\uffff\1\1\2\uffff";
"\2\uffff\1\2\1\uffff\1\3\1\4\1\5\1\6\1\10\1\11\1\uffff\1\12\2\uffff"+
"\1\13\1\uffff\1\7\1\uffff\1\1\2\uffff";
static final String DFA1_specialS =
"\22\uffff\1\0}>";
"\12\uffff\1\0\11\uffff\1\1}>";
static final String[] DFA1_transitionS = {
"\1\6\6\uffff\1\1\11\uffff\1\7\15\uffff\1\3\4\uffff\1\12\10\uffff"+
"\1\2\2\uffff\1\11\1\10\3\uffff\1\11\4\uffff\1\5\16\uffff\1\4",
"\1\13",
"",
"\1\6\6\uffff\1\1\11\uffff\1\7\15\uffff\1\3\4\uffff\1\13\10\uffff"+
"\1\2\2\uffff\1\12\1\10\3\uffff\1\11\4\uffff\1\5\16\uffff\1\4",
"\1\14",
"",
"\1\15",
"",
"",
"",
"",
"",
"",
"\1\16\106\uffff\1\15",
"\1\17",
"\1\16\14\uffff\1\20\106\uffff\1\16",
"\1\uffff",
"",
"\77\12\1\21\42\12",
"\1\20\106\uffff\1\17",
"\1\21",
"",
"\1\12\1\22",
"\1\20\14\uffff\1\22\106\uffff\1\20",
"",
"\77\13\1\23\42\13",
"",
"\1\13\1\24",
"\1\uffff"
};
@ -1069,25 +1126,40 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
this.transition = DFA1_transition;
}
public String getDescription() {
return "92:1: topdown : ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement );";
return "93:1: topdown : ( globalScope | action | tokensSection | rule | ruleArg | ruleReturns | ruleScopeSpec | ruleref | terminal | labeledElement | tokenRefInRewrite );";
}
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TreeNodeStream input = (TreeNodeStream)_input;
int _s = s;
switch ( s ) {
case 0 :
int LA1_18 = input.LA(1);
int LA1_10 = input.LA(1);
int index1_18 = input.index();
int index1_10 = input.index();
input.rewind();
s = -1;
if ( (!(((inContext("RESULT ..."))))) ) {s = 9;}
else if ( ((inContext("RESULT ..."))) ) {s = 14;}
input.seek(index1_10);
if ( s>=0 ) return s;
break;
case 1 :
int LA1_20 = input.LA(1);
int index1_20 = input.index();
input.rewind();
s = -1;
if ( ((inContext("TOKENS"))) ) {s = 4;}
else if ( (true) ) {s = 10;}
else if ( ((inContext("RULE ..."))) ) {s = 11;}
input.seek(index1_18);
input.seek(index1_20);
if ( s>=0 ) return s;
break;
}
@ -1110,35 +1182,37 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter {
public static final BitSet FOLLOW_ruleref_in_topdown152 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_terminal_in_topdown160 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_labeledElement_in_topdown168 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_finishRule_in_bottomup179 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_SCOPE_in_globalScope193 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_globalScope195 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_globalScope197 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_AT_in_action214 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_action216 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L});
public static final BitSet FOLLOW_ID_in_action219 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_action221 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ASSIGN_in_tokensSection244 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_tokensSection248 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_tokensSection250 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ID_in_tokensSection264 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_in_rule286 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rule290 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_RULE_in_finishRule312 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleArg327 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RETURNS_in_ruleReturns342 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleReturns344 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec365 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ACTION_in_ruleScopeSpec367 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec375 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_ruleScopeSpec377 = new BitSet(new long[]{0x0000000000000008L,0x0000000000800000L});
public static final BitSet FOLLOW_ASSIGN_in_labeledElement400 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_labeledElement404 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement415 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_labeledElement419 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_STRING_LITERAL_in_terminal441 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TOKEN_REF_in_terminal451 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_REF_in_ruleref471 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleref473 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_tokenRefInRewrite_in_topdown176 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_finishRule_in_bottomup187 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_SCOPE_in_globalScope201 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_globalScope203 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_globalScope205 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_AT_in_action222 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_action224 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L});
public static final BitSet FOLLOW_ID_in_action227 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_action229 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ASSIGN_in_tokensSection252 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_tokensSection256 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_tokensSection258 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ID_in_tokensSection272 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_in_rule294 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rule298 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_RULE_in_finishRule320 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleArg335 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RETURNS_in_ruleReturns350 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleReturns352 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec373 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ACTION_in_ruleScopeSpec375 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_SCOPE_in_ruleScopeSpec383 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_ruleScopeSpec385 = new BitSet(new long[]{0x0000000000000008L,0x0000000000800000L});
public static final BitSet FOLLOW_TOKEN_REF_in_tokenRefInRewrite404 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ASSIGN_in_labeledElement430 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_labeledElement434 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_PLUS_ASSIGN_in_labeledElement446 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_labeledElement450 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF0L,0x0000003FFFFFFFFFL});
public static final BitSet FOLLOW_STRING_LITERAL_in_terminal476 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TOKEN_REF_in_terminal486 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_REF_in_ruleref506 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_ruleref508 = new BitSet(new long[]{0x0000000000000008L});
}

View File

@ -44,6 +44,7 @@ public class SymbolChecks {
checkRuleArgs(collector.rulerefs);
checkForTokenConflicts(collector.tokenIDRefs); // sets tokenIDs
checkForLabelConflicts(collector.ruleToLabelSpace, collector.rules);
checkTokenNameRefsInRewrite(collector.tokenNameRefsInRewrite);
}
public void checkForRuleConflicts(List<Rule> rules) {
@ -229,7 +230,14 @@ public class SymbolChecks {
// arg2 = r.name;
// }
if ( etype!=ErrorType.INVALID ) {
ErrorManager.grammarError(etype,g,labelID.token,name,arg2);
ErrorManager.grammarError(etype,g.fileName,labelID.token,name,arg2);
}
}
public void checkTokenNameRefsInRewrite(List<GrammarAST> tokenNameRefsInRewrite) {
for (GrammarAST t : tokenNameRefsInRewrite) {
ErrorManager.grammarError(ErrorType.UNDEFINED_TOKEN_REF_IN_REWRITE,
g.fileName, t.token, t.getText());
}
}
}

View File

@ -219,6 +219,7 @@ public class ErrorManager {
}
*/
/*
public static void grammarError(ErrorType etype,
Grammar g,
Token token,
@ -228,6 +229,7 @@ public class ErrorManager {
Message msg = new GrammarSemanticsMessage(etype,g,token,args);
state.get().listener.error(msg);
}
*/
public static void grammarError(ErrorType etype,
String fileName,

View File

@ -1,6 +1,5 @@
package org.antlr.v4.tool;
import java.util.HashMap;
import java.util.Map;
public class Rule {
@ -12,8 +11,8 @@ public class Rule {
/** All labels go in here (TODO: plus being split per the above lists) to
* catch dup label and label type mismatches.
*/
public Map<String, LabelElementPair> labelNameSpace =
new HashMap<String, LabelElementPair>();
public Map<String, LabelElementPair> labelNameSpace;
//= new HashMap<String, LabelElementPair>();
public Rule(String name, GrammarASTWithOptions ast) {
this.name = name;

View File

@ -24,16 +24,33 @@ public class TestSymbolIssues extends BaseTest {
"\n" +
"ID : 'a'..'z'+ ID ;",
// YIELDS
"error(17): A.g:15:0: rule a redefinition\n" +
"error(60): A.g:11:6: scope Blort redefinition\n" +
"error(59): A.g:7:1: redefinition of members action\n" +
"error(59): A.g:9:1: redefinition of header action\n" +
"error(73): A.g:3:19: cannot alias X; token name already defined\n" +
"error(73): A.g:3:26: cannot alias Y; token name already assigned to 'y'\n" +
"error(73): A.g:3:36: cannot alias Z; token name already defined\n" +
"error(45): A.g:13:37: rule b has no defined parameters\n" +
"error(23): A.g:13:43: reference to undefined rule: q\n" +
"error(44): A.g:14:31: missing parameter(s) on rule reference: a",
"error(61): A.g:11:6: scope Blort redefinition\n" +
"error(18): A.g:15:0: rule a redefinition\n" +
"error(60): A.g:7:1: redefinition of members action\n" +
"error(60): A.g:9:1: redefinition of header action\n" +
"error(74): A.g:3:19: cannot alias X; token name already defined\n" +
"error(74): A.g:3:26: cannot alias Y; token name already assigned to 'y'\n" +
"error(74): A.g:3:36: cannot alias Z; token name already defined\n" +
"error(46): A.g:13:37: rule b has no defined parameters\n" +
"error(24): A.g:13:43: reference to undefined rule: q\n" +
"error(45): A.g:14:31: missing parameter(s) on rule reference: a",
// INPUT
"parser grammar B;\n" +
"tokens { X='x'; Y; }\n" +
"scope s { int i; }\n" +
"\n" +
"a : s=ID b+=ID X=ID '.' ;\n" +
"\n" +
"b : x=ID x+=ID ;\n" +
"\n" +
"s : FOO ;",
// YIELDS
"error(34): B.g:9:0: symbol s conflicts with global dynamic scope with same name\n" +
"error(34): B.g:5:4: symbol s conflicts with global dynamic scope with same name\n" +
"error(35): B.g:5:9: label b conflicts with rule with same name\n" +
"error(36): B.g:5:15: label X conflicts with token with same name\n" +
"error(41): B.g:7:9: label x type mismatch with previous definition: TOKEN_LIST_LABEL!=TOKEN_LABEL"
};
@Test public void testErrors() { super.testErrors(pairs); }