From 29c602c202c4c1fde2665cfa41c52681ec0918a5 Mon Sep 17 00:00:00 2001 From: parrt Date: Mon, 15 Feb 2010 16:38:59 -0800 Subject: [PATCH] got dynamic scope checking in [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6696] --- .../tool/templates/messages/languages/en.stg | 4 +- tool/src/org/antlr/v4/parse/ANTLRLexer.java | 2 +- tool/src/org/antlr/v4/parse/ANTLRParser.java | 66 +- tool/src/org/antlr/v4/parse/ASTVerifier.java | 2 +- tool/src/org/antlr/v4/parse/ActionSplitter.g | 2 +- .../org/antlr/v4/parse/ActionSplitter.java | 917 +++++++++--------- .../antlr/v4/semantics/AttributeChecks.java | 46 +- .../v4/semantics/BasicSemanticTriggers.java | 2 +- .../org/antlr/v4/semantics/CollectSymbols.g | 4 +- .../antlr/v4/semantics/CollectSymbols.java | 305 +++--- tool/src/org/antlr/v4/tool/Alternative.java | 7 + .../org/antlr/v4/tool/AttributeResolver.java | 6 +- tool/src/org/antlr/v4/tool/Grammar.java | 10 +- tool/src/org/antlr/v4/tool/Rule.java | 6 + .../antlr/v4/test/TestAttributeChecks.java | 57 +- 15 files changed, 750 insertions(+), 686 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/messages/languages/en.stg b/tool/resources/org/antlr/v4/tool/templates/messages/languages/en.stg index 72d22167c..91618d54e 100644 --- a/tool/resources/org/antlr/v4/tool/templates/messages/languages/en.stg +++ b/tool/resources/org/antlr/v4/tool/templates/messages/languages/en.stg @@ -183,8 +183,8 @@ set complement is empty >> REPEATED_PREQUEL(arg) ::= "repeated grammar prequel spec (option, token, or import); please merge" -UNKNOWN_DYNAMIC_SCOPE(arg) ::= - "unknown dynamic scope: " +UNKNOWN_DYNAMIC_SCOPE(arg, arg2) ::= + "unknown dynamic scope: in " UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE(arg,arg2,arg3) ::= "unknown dynamically-scoped attribute for scope : in " RULE_REF_AMBIG_WITH_RULE_IN_ALT(arg) ::= diff --git a/tool/src/org/antlr/v4/parse/ANTLRLexer.java b/tool/src/org/antlr/v4/parse/ANTLRLexer.java index 5fb06756f..72526b786 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRLexer.java +++ b/tool/src/org/antlr/v4/parse/ANTLRLexer.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-02-15 13:04:55 +// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-02-15 16:36:15 /* [The "BSD licence"] diff --git a/tool/src/org/antlr/v4/parse/ANTLRParser.java b/tool/src/org/antlr/v4/parse/ANTLRParser.java index e6f648057..20d93d316 100644 --- a/tool/src/org/antlr/v4/parse/ANTLRParser.java +++ b/tool/src/org/antlr/v4/parse/ANTLRParser.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-02-15 13:04:58 +// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-02-15 16:36:18 /* [The "BSD licence"] @@ -284,7 +284,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, grammarType, prequelConstruct, rules, DOC_COMMENT + // elements: prequelConstruct, grammarType, DOC_COMMENT, id, rules // token labels: // rule labels: retval // token list labels: @@ -788,7 +788,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: OPTIONS, option + // elements: option, OPTIONS // token labels: // rule labels: retval // token list labels: @@ -1559,7 +1559,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ASSIGN, id, STRING_LITERAL + // elements: STRING_LITERAL, id, ASSIGN // token labels: // rule labels: retval // token list labels: @@ -1699,7 +1699,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, ACTION, SCOPE + // elements: id, SCOPE, ACTION // token labels: // rule labels: retval // token list labels: @@ -1853,7 +1853,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, AT, ACTION, actionScopeName + // elements: actionScopeName, AT, ACTION, id // token labels: // rule labels: retval // token list labels: @@ -2353,7 +2353,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: rulePrequel, ruleReturns, id, DOC_COMMENT, altListAsBlock, exceptionGroup, ARG_ACTION, ruleModifiers + // elements: ruleReturns, ARG_ACTION, ruleModifiers, altListAsBlock, exceptionGroup, id, rulePrequel, DOC_COMMENT // token labels: // rule labels: retval // token list labels: @@ -2579,7 +2579,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ARG_ACTION, ACTION, CATCH + // elements: ARG_ACTION, CATCH, ACTION // token labels: // rule labels: retval // token list labels: @@ -2662,7 +2662,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: FINALLY, ACTION + // elements: ACTION, FINALLY // token labels: // rule labels: retval // token list labels: @@ -2976,7 +2976,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: THROWS, qid + // elements: qid, THROWS // token labels: // rule labels: retval // token list labels: @@ -3106,7 +3106,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ACTION, SCOPE + // elements: SCOPE, ACTION // token labels: // rule labels: retval // token list labels: @@ -3284,7 +3284,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: AT, id, ACTION + // elements: id, AT, ACTION // token labels: // rule labels: retval // token list labels: @@ -4165,7 +4165,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ebnfSuffix, labeledElement + // elements: labeledElement, ebnfSuffix // token labels: // rule labels: retval // token list labels: @@ -4504,7 +4504,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ebnfSuffix, treeSpec + // elements: treeSpec, ebnfSuffix // token labels: // rule labels: retval // token list labels: @@ -4944,7 +4944,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: blockSuffixe, block + // elements: block, blockSuffixe // token labels: // rule labels: retval // token list labels: @@ -5450,7 +5450,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ruleref, DOT, id + // elements: id, DOT, ruleref // token labels: // rule labels: retval // token list labels: @@ -5508,7 +5508,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: terminal, DOT, id + // elements: DOT, terminal, id // token labels: // rule labels: retval // token list labels: @@ -5984,7 +5984,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ra, altList, optionsSpec + // elements: altList, optionsSpec, ra // token labels: // rule labels: retval // token list labels: @@ -6159,7 +6159,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ARG_ACTION, op, RULE_REF + // elements: ARG_ACTION, RULE_REF, op // token labels: op // rule labels: retval // token list labels: @@ -6206,7 +6206,7 @@ public class ANTLRParser extends Parser { { // AST REWRITE - // elements: ARG_ACTION, RULE_REF + // elements: RULE_REF, ARG_ACTION // token labels: // rule labels: retval // token list labels: @@ -6512,7 +6512,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ARG_ACTION, TOKEN_REF, elementOptions + // elements: TOKEN_REF, elementOptions, ARG_ACTION // token labels: // rule labels: retval // token list labels: @@ -6741,7 +6741,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: BANG, terminal + // elements: terminal, BANG // token labels: // rule labels: retval // token list labels: @@ -7193,7 +7193,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: nakedRewrite, predicatedRewrite + // elements: predicatedRewrite, nakedRewrite // token labels: // rule labels: retval // token list labels: @@ -7281,7 +7281,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: SEMPRED, SEMPRED, rewriteAlt, rewriteAlt + // elements: SEMPRED, rewriteAlt, SEMPRED, rewriteAlt // token labels: // rule labels: retval // token list labels: @@ -7740,7 +7740,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: rewriteTreeAtom, ebnfSuffix + // elements: ebnfSuffix, rewriteTreeAtom // token labels: // rule labels: retval // token list labels: @@ -7823,7 +7823,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: ebnfSuffix, rewriteTree + // elements: rewriteTree, ebnfSuffix // token labels: // rule labels: retval // token list labels: @@ -8062,7 +8062,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: elementOptions, ARG_ACTION, TOKEN_REF + // elements: ARG_ACTION, elementOptions, TOKEN_REF // token labels: // rule labels: retval // token list labels: @@ -8146,7 +8146,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: STRING_LITERAL, elementOptions + // elements: elementOptions, STRING_LITERAL // token labels: // rule labels: retval // token list labels: @@ -8440,7 +8440,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: TREE_BEGIN, rewriteTreeElement, rewriteTreeAtom + // elements: TREE_BEGIN, rewriteTreeAtom, rewriteTreeElement // token labels: // rule labels: retval // token list labels: @@ -8595,7 +8595,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: str, TEMPLATE, rewriteTemplateArgs + // elements: rewriteTemplateArgs, str, TEMPLATE // token labels: str // rule labels: retval // token list labels: @@ -8744,7 +8744,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, rewriteTemplateArgs + // elements: rewriteTemplateArgs, id // token labels: // rule labels: retval // token list labels: @@ -8856,7 +8856,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: rewriteTemplateArgs, ACTION + // elements: ACTION, rewriteTemplateArgs // token labels: // rule labels: retval // token list labels: @@ -9102,7 +9102,7 @@ public class ANTLRParser extends Parser { // AST REWRITE - // elements: id, ACTION + // elements: ACTION, id // token labels: // rule labels: retval // token list labels: diff --git a/tool/src/org/antlr/v4/parse/ASTVerifier.java b/tool/src/org/antlr/v4/parse/ASTVerifier.java index 4bbe52f79..849d2a340 100644 --- a/tool/src/org/antlr/v4/parse/ASTVerifier.java +++ b/tool/src/org/antlr/v4/parse/ASTVerifier.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-02-15 13:04:59 +// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-02-15 16:36:19 /* [The "BSD license"] diff --git a/tool/src/org/antlr/v4/parse/ActionSplitter.g b/tool/src/org/antlr/v4/parse/ActionSplitter.g index acba8bded..67f221a57 100644 --- a/tool/src/org/antlr/v4/parse/ActionSplitter.g +++ b/tool/src/org/antlr/v4/parse/ActionSplitter.g @@ -75,7 +75,7 @@ DYNAMIC_SCOPE_ATTR */ SET_DYNAMIC_NEGATIVE_INDEXED_SCOPE_ATTR : '$' x=ID '[' '-' index=SCOPE_INDEX_EXPR ']' '::' y=ID - WS? ('=' expr=ATTR_VALUE_EXPR ';')? + WS? '=' expr=ATTR_VALUE_EXPR ';' {delegate.setDynamicNegativeIndexedScopeAttr($text, $x, $y, $index, $expr);} ; diff --git a/tool/src/org/antlr/v4/parse/ActionSplitter.java b/tool/src/org/antlr/v4/parse/ActionSplitter.java index c0a031fb5..427adaa45 100644 --- a/tool/src/org/antlr/v4/parse/ActionSplitter.java +++ b/tool/src/org/antlr/v4/parse/ActionSplitter.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-02-15 13:04:58 +// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-02-15 16:36:19 package org.antlr.v4.parse; @@ -559,8 +559,8 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { CommonToken y=null; CommonToken expr=null; - // ActionSplitter.g:77:2: ( '$' x= ID '[' '-' index= SCOPE_INDEX_EXPR ']' '::' y= ID ( WS )? ( '=' expr= ATTR_VALUE_EXPR ';' )? ) - // ActionSplitter.g:77:4: '$' x= ID '[' '-' index= SCOPE_INDEX_EXPR ']' '::' y= ID ( WS )? ( '=' expr= ATTR_VALUE_EXPR ';' )? + // ActionSplitter.g:77:2: ( '$' x= ID '[' '-' index= SCOPE_INDEX_EXPR ']' '::' y= ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' ) + // ActionSplitter.g:77:4: '$' x= ID '[' '-' index= SCOPE_INDEX_EXPR ']' '::' y= ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' { match('$'); if (state.failed) return ; int xStart255 = getCharIndex(); @@ -607,32 +607,15 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } - // ActionSplitter.g:78:7: ( '=' expr= ATTR_VALUE_EXPR ';' )? - int alt8=2; - int LA8_0 = input.LA(1); - - if ( (LA8_0=='=') ) { - alt8=1; - } - switch (alt8) { - case 1 : - // ActionSplitter.g:78:8: '=' expr= ATTR_VALUE_EXPR ';' - { - match('='); if (state.failed) return ; - int exprStart283 = getCharIndex(); - int exprStartLine283 = getLine(); - int exprStartCharPos283 = getCharPositionInLine(); - mATTR_VALUE_EXPR(); if (state.failed) return ; - expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart283, getCharIndex()-1); - expr.setLine(exprStartLine283); - expr.setCharPositionInLine(exprStartCharPos283); - match(';'); if (state.failed) return ; - - } - break; - - } - + match('='); if (state.failed) return ; + int exprStart282 = getCharIndex(); + int exprStartLine282 = getLine(); + int exprStartCharPos282 = getCharPositionInLine(); + mATTR_VALUE_EXPR(); if (state.failed) return ; + expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart282, getCharIndex()-1); + expr.setLine(exprStartLine282); + expr.setCharPositionInLine(exprStartCharPos282); + match(';'); if (state.failed) return ; if ( state.backtracking==1 ) { delegate.setDynamicNegativeIndexedScopeAttr(getText(), x, y, index, expr); } @@ -660,32 +643,32 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:83:4: '$' x= ID '[' '-' index= SCOPE_INDEX_EXPR ']' '::' y= ID { match('$'); if (state.failed) return ; - int xStart306 = getCharIndex(); - int xStartLine306 = getLine(); - int xStartCharPos306 = getCharPositionInLine(); + int xStart303 = getCharIndex(); + int xStartLine303 = getLine(); + int xStartCharPos303 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart306, getCharIndex()-1); - x.setLine(xStartLine306); - x.setCharPositionInLine(xStartCharPos306); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart303, getCharIndex()-1); + x.setLine(xStartLine303); + x.setCharPositionInLine(xStartCharPos303); match('['); if (state.failed) return ; match('-'); if (state.failed) return ; - int indexStart314 = getCharIndex(); - int indexStartLine314 = getLine(); - int indexStartCharPos314 = getCharPositionInLine(); + int indexStart311 = getCharIndex(); + int indexStartLine311 = getLine(); + int indexStartCharPos311 = getCharPositionInLine(); mSCOPE_INDEX_EXPR(); if (state.failed) return ; - index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart314, getCharIndex()-1); - index.setLine(indexStartLine314); - index.setCharPositionInLine(indexStartCharPos314); + index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart311, getCharIndex()-1); + index.setLine(indexStartLine311); + index.setCharPositionInLine(indexStartCharPos311); match(']'); if (state.failed) return ; match("::"); if (state.failed) return ; - int yStart322 = getCharIndex(); - int yStartLine322 = getLine(); - int yStartCharPos322 = getCharPositionInLine(); + int yStart319 = getCharIndex(); + int yStartLine319 = getLine(); + int yStartCharPos319 = getCharPositionInLine(); mID(); if (state.failed) return ; - y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart322, getCharIndex()-1); - y.setLine(yStartLine322); - y.setCharPositionInLine(yStartCharPos322); + y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart319, getCharIndex()-1); + y.setLine(yStartLine319); + y.setCharPositionInLine(yStartCharPos319); if ( state.backtracking==1 ) { delegate.dynamicNegativeIndexedScopeAttr(getText(), x, y, index); } @@ -714,39 +697,39 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:88:4: '$' x= ID '[' index= SCOPE_INDEX_EXPR ']' '::' y= ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' { match('$'); if (state.failed) return ; - int xStart341 = getCharIndex(); - int xStartLine341 = getLine(); - int xStartCharPos341 = getCharPositionInLine(); + int xStart338 = getCharIndex(); + int xStartLine338 = getLine(); + int xStartCharPos338 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart341, getCharIndex()-1); - x.setLine(xStartLine341); - x.setCharPositionInLine(xStartCharPos341); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart338, getCharIndex()-1); + x.setLine(xStartLine338); + x.setCharPositionInLine(xStartCharPos338); match('['); if (state.failed) return ; - int indexStart347 = getCharIndex(); - int indexStartLine347 = getLine(); - int indexStartCharPos347 = getCharPositionInLine(); + int indexStart344 = getCharIndex(); + int indexStartLine344 = getLine(); + int indexStartCharPos344 = getCharPositionInLine(); mSCOPE_INDEX_EXPR(); if (state.failed) return ; - index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart347, getCharIndex()-1); - index.setLine(indexStartLine347); - index.setCharPositionInLine(indexStartCharPos347); + index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart344, getCharIndex()-1); + index.setLine(indexStartLine344); + index.setCharPositionInLine(indexStartCharPos344); match(']'); if (state.failed) return ; match("::"); if (state.failed) return ; - int yStart355 = getCharIndex(); - int yStartLine355 = getLine(); - int yStartCharPos355 = getCharPositionInLine(); + int yStart352 = getCharIndex(); + int yStartLine352 = getLine(); + int yStartCharPos352 = getCharPositionInLine(); mID(); if (state.failed) return ; - y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart355, getCharIndex()-1); - y.setLine(yStartLine355); - y.setCharPositionInLine(yStartCharPos355); + y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart352, getCharIndex()-1); + y.setLine(yStartLine352); + y.setCharPositionInLine(yStartCharPos352); // ActionSplitter.g:89:3: ( WS )? - int alt9=2; - int LA9_0 = input.LA(1); + int alt8=2; + int LA8_0 = input.LA(1); - if ( ((LA9_0>='\t' && LA9_0<='\n')||LA9_0=='\r'||LA9_0==' ') ) { - alt9=1; + if ( ((LA8_0>='\t' && LA8_0<='\n')||LA8_0=='\r'||LA8_0==' ') ) { + alt8=1; } - switch (alt9) { + switch (alt8) { case 1 : // ActionSplitter.g:89:3: WS { @@ -758,13 +741,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } match('='); if (state.failed) return ; - int exprStart366 = getCharIndex(); - int exprStartLine366 = getLine(); - int exprStartCharPos366 = getCharPositionInLine(); + int exprStart363 = getCharIndex(); + int exprStartLine363 = getLine(); + int exprStartCharPos363 = getCharPositionInLine(); mATTR_VALUE_EXPR(); if (state.failed) return ; - expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart366, getCharIndex()-1); - expr.setLine(exprStartLine366); - expr.setCharPositionInLine(exprStartCharPos366); + expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart363, getCharIndex()-1); + expr.setLine(exprStartLine363); + expr.setCharPositionInLine(exprStartCharPos363); match(';'); if (state.failed) return ; if ( state.backtracking==1 ) { delegate.setDynamicAbsoluteIndexedScopeAttr(getText(), x, y, index, expr); @@ -793,31 +776,31 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:94:4: '$' x= ID '[' index= SCOPE_INDEX_EXPR ']' '::' y= ID { match('$'); if (state.failed) return ; - int xStart387 = getCharIndex(); - int xStartLine387 = getLine(); - int xStartCharPos387 = getCharPositionInLine(); + int xStart384 = getCharIndex(); + int xStartLine384 = getLine(); + int xStartCharPos384 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart387, getCharIndex()-1); - x.setLine(xStartLine387); - x.setCharPositionInLine(xStartCharPos387); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart384, getCharIndex()-1); + x.setLine(xStartLine384); + x.setCharPositionInLine(xStartCharPos384); match('['); if (state.failed) return ; - int indexStart393 = getCharIndex(); - int indexStartLine393 = getLine(); - int indexStartCharPos393 = getCharPositionInLine(); + int indexStart390 = getCharIndex(); + int indexStartLine390 = getLine(); + int indexStartCharPos390 = getCharPositionInLine(); mSCOPE_INDEX_EXPR(); if (state.failed) return ; - index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart393, getCharIndex()-1); - index.setLine(indexStartLine393); - index.setCharPositionInLine(indexStartCharPos393); + index = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, indexStart390, getCharIndex()-1); + index.setLine(indexStartLine390); + index.setCharPositionInLine(indexStartCharPos390); match(']'); if (state.failed) return ; match("::"); if (state.failed) return ; - int yStart401 = getCharIndex(); - int yStartLine401 = getLine(); - int yStartCharPos401 = getCharPositionInLine(); + int yStart398 = getCharIndex(); + int yStartLine398 = getLine(); + int yStartCharPos398 = getCharPositionInLine(); mID(); if (state.failed) return ; - y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart401, getCharIndex()-1); - y.setLine(yStartLine401); - y.setCharPositionInLine(yStartCharPos401); + y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart398, getCharIndex()-1); + y.setLine(yStartLine398); + y.setCharPositionInLine(yStartCharPos398); if ( state.backtracking==1 ) { delegate.dynamicAbsoluteIndexedScopeAttr(getText(), x, y, index); } @@ -844,21 +827,21 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:99:4: '$' x= ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' { match('$'); if (state.failed) return ; - int xStart420 = getCharIndex(); - int xStartLine420 = getLine(); - int xStartCharPos420 = getCharPositionInLine(); + int xStart417 = getCharIndex(); + int xStartLine417 = getLine(); + int xStartCharPos417 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart420, getCharIndex()-1); - x.setLine(xStartLine420); - x.setCharPositionInLine(xStartCharPos420); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart417, getCharIndex()-1); + x.setLine(xStartLine417); + x.setCharPositionInLine(xStartCharPos417); // ActionSplitter.g:99:13: ( WS )? - int alt10=2; - int LA10_0 = input.LA(1); + int alt9=2; + int LA9_0 = input.LA(1); - if ( ((LA10_0>='\t' && LA10_0<='\n')||LA10_0=='\r'||LA10_0==' ') ) { - alt10=1; + if ( ((LA9_0>='\t' && LA9_0<='\n')||LA9_0=='\r'||LA9_0==' ') ) { + alt9=1; } - switch (alt10) { + switch (alt9) { case 1 : // ActionSplitter.g:99:13: WS { @@ -870,13 +853,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } match('='); if (state.failed) return ; - int exprStart429 = getCharIndex(); - int exprStartLine429 = getLine(); - int exprStartCharPos429 = getCharPositionInLine(); + int exprStart426 = getCharIndex(); + int exprStartLine426 = getLine(); + int exprStartCharPos426 = getCharPositionInLine(); mATTR_VALUE_EXPR(); if (state.failed) return ; - expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart429, getCharIndex()-1); - expr.setLine(exprStartLine429); - expr.setCharPositionInLine(exprStartCharPos429); + expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart426, getCharIndex()-1); + expr.setLine(exprStartLine426); + expr.setCharPositionInLine(exprStartCharPos426); match(';'); if (state.failed) return ; if ( state.backtracking==1 ) { delegate.setAttr(getText(), x, expr); @@ -903,13 +886,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:103:4: '$' x= ID { match('$'); if (state.failed) return ; - int xStart448 = getCharIndex(); - int xStartLine448 = getLine(); - int xStartCharPos448 = getCharPositionInLine(); + int xStart445 = getCharIndex(); + int xStartLine445 = getLine(); + int xStartCharPos445 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart448, getCharIndex()-1); - x.setLine(xStartLine448); - x.setCharPositionInLine(xStartCharPos448); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart445, getCharIndex()-1); + x.setLine(xStartLine445); + x.setCharPositionInLine(xStartCharPos445); if ( state.backtracking==1 ) { delegate.attr(getText(), x); } @@ -936,24 +919,24 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { mID(); if (state.failed) return ; match('('); if (state.failed) return ; // ActionSplitter.g:108:15: ( ( WS )? ARG ( ',' ( WS )? ARG )* ( WS )? )? - int alt15=2; - int LA15_0 = input.LA(1); + int alt14=2; + int LA14_0 = input.LA(1); - if ( ((LA15_0>='\t' && LA15_0<='\n')||LA15_0=='\r'||LA15_0==' '||(LA15_0>='A' && LA15_0<='Z')||LA15_0=='_'||(LA15_0>='a' && LA15_0<='z')) ) { - alt15=1; + if ( ((LA14_0>='\t' && LA14_0<='\n')||LA14_0=='\r'||LA14_0==' '||(LA14_0>='A' && LA14_0<='Z')||LA14_0=='_'||(LA14_0>='a' && LA14_0<='z')) ) { + alt14=1; } - switch (alt15) { + switch (alt14) { case 1 : // ActionSplitter.g:108:17: ( WS )? ARG ( ',' ( WS )? ARG )* ( WS )? { // ActionSplitter.g:108:17: ( WS )? - int alt11=2; - int LA11_0 = input.LA(1); + int alt10=2; + int LA10_0 = input.LA(1); - if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { - alt11=1; + if ( ((LA10_0>='\t' && LA10_0<='\n')||LA10_0=='\r'||LA10_0==' ') ) { + alt10=1; } - switch (alt11) { + switch (alt10) { case 1 : // ActionSplitter.g:108:17: WS { @@ -966,29 +949,29 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { mARG(); if (state.failed) return ; // ActionSplitter.g:108:25: ( ',' ( WS )? ARG )* - loop13: + loop12: do { - int alt13=2; - int LA13_0 = input.LA(1); + int alt12=2; + int LA12_0 = input.LA(1); - if ( (LA13_0==',') ) { - alt13=1; + if ( (LA12_0==',') ) { + alt12=1; } - switch (alt13) { + switch (alt12) { case 1 : // ActionSplitter.g:108:26: ',' ( WS )? ARG { match(','); if (state.failed) return ; // ActionSplitter.g:108:30: ( WS )? - int alt12=2; - int LA12_0 = input.LA(1); + int alt11=2; + int LA11_0 = input.LA(1); - if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) { - alt12=1; + if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { + alt11=1; } - switch (alt12) { + switch (alt11) { case 1 : // ActionSplitter.g:108:30: WS { @@ -1005,18 +988,18 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop13; + break loop12; } } while (true); // ActionSplitter.g:108:40: ( WS )? - int alt14=2; - int LA14_0 = input.LA(1); + int alt13=2; + int LA13_0 = input.LA(1); - if ( ((LA14_0>='\t' && LA14_0<='\n')||LA14_0=='\r'||LA14_0==' ') ) { - alt14=1; + if ( ((LA13_0>='\t' && LA13_0<='\n')||LA13_0=='\r'||LA13_0==' ') ) { + alt13=1; } - switch (alt14) { + switch (alt13) { case 1 : // ActionSplitter.g:108:40: WS { @@ -1059,24 +1042,24 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { match(')'); if (state.failed) return ; match('('); if (state.failed) return ; // ActionSplitter.g:113:27: ( ( WS )? ARG ( ',' ( WS )? ARG )* ( WS )? )? - int alt20=2; - int LA20_0 = input.LA(1); + int alt19=2; + int LA19_0 = input.LA(1); - if ( ((LA20_0>='\t' && LA20_0<='\n')||LA20_0=='\r'||LA20_0==' '||(LA20_0>='A' && LA20_0<='Z')||LA20_0=='_'||(LA20_0>='a' && LA20_0<='z')) ) { - alt20=1; + if ( ((LA19_0>='\t' && LA19_0<='\n')||LA19_0=='\r'||LA19_0==' '||(LA19_0>='A' && LA19_0<='Z')||LA19_0=='_'||(LA19_0>='a' && LA19_0<='z')) ) { + alt19=1; } - switch (alt20) { + switch (alt19) { case 1 : // ActionSplitter.g:113:29: ( WS )? ARG ( ',' ( WS )? ARG )* ( WS )? { // ActionSplitter.g:113:29: ( WS )? - int alt16=2; - int LA16_0 = input.LA(1); + int alt15=2; + int LA15_0 = input.LA(1); - if ( ((LA16_0>='\t' && LA16_0<='\n')||LA16_0=='\r'||LA16_0==' ') ) { - alt16=1; + if ( ((LA15_0>='\t' && LA15_0<='\n')||LA15_0=='\r'||LA15_0==' ') ) { + alt15=1; } - switch (alt16) { + switch (alt15) { case 1 : // ActionSplitter.g:113:29: WS { @@ -1089,29 +1072,29 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { mARG(); if (state.failed) return ; // ActionSplitter.g:113:37: ( ',' ( WS )? ARG )* - loop18: + loop17: do { - int alt18=2; - int LA18_0 = input.LA(1); + int alt17=2; + int LA17_0 = input.LA(1); - if ( (LA18_0==',') ) { - alt18=1; + if ( (LA17_0==',') ) { + alt17=1; } - switch (alt18) { + switch (alt17) { case 1 : // ActionSplitter.g:113:38: ',' ( WS )? ARG { match(','); if (state.failed) return ; // ActionSplitter.g:113:42: ( WS )? - int alt17=2; - int LA17_0 = input.LA(1); + int alt16=2; + int LA16_0 = input.LA(1); - if ( ((LA17_0>='\t' && LA17_0<='\n')||LA17_0=='\r'||LA17_0==' ') ) { - alt17=1; + if ( ((LA16_0>='\t' && LA16_0<='\n')||LA16_0=='\r'||LA16_0==' ') ) { + alt16=1; } - switch (alt17) { + switch (alt16) { case 1 : // ActionSplitter.g:113:42: WS { @@ -1128,18 +1111,18 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop18; + break loop17; } } while (true); // ActionSplitter.g:113:52: ( WS )? - int alt19=2; - int LA19_0 = input.LA(1); + int alt18=2; + int LA18_0 = input.LA(1); - if ( ((LA19_0>='\t' && LA19_0<='\n')||LA19_0=='\r'||LA19_0==' ') ) { - alt19=1; + if ( ((LA18_0>='\t' && LA18_0<='\n')||LA18_0=='\r'||LA18_0==' ') ) { + alt18=1; } - switch (alt19) { + switch (alt18) { case 1 : // ActionSplitter.g:113:52: WS { @@ -1180,23 +1163,23 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:118:4: '%' a= ACTION '.' ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' { match('%'); if (state.failed) return ; - int aStart555 = getCharIndex(); - int aStartLine555 = getLine(); - int aStartCharPos555 = getCharPositionInLine(); + int aStart552 = getCharIndex(); + int aStartLine552 = getLine(); + int aStartCharPos552 = getCharPositionInLine(); mACTION(); if (state.failed) return ; - a = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, aStart555, getCharIndex()-1); - a.setLine(aStartLine555); - a.setCharPositionInLine(aStartCharPos555); + a = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, aStart552, getCharIndex()-1); + a.setLine(aStartLine552); + a.setCharPositionInLine(aStartCharPos552); match('.'); if (state.failed) return ; mID(); if (state.failed) return ; // ActionSplitter.g:118:24: ( WS )? - int alt21=2; - int LA21_0 = input.LA(1); + int alt20=2; + int LA20_0 = input.LA(1); - if ( ((LA21_0>='\t' && LA21_0<='\n')||LA21_0=='\r'||LA21_0==' ') ) { - alt21=1; + if ( ((LA20_0>='\t' && LA20_0<='\n')||LA20_0=='\r'||LA20_0==' ') ) { + alt20=1; } - switch (alt21) { + switch (alt20) { case 1 : // ActionSplitter.g:118:24: WS { @@ -1208,13 +1191,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } match('='); if (state.failed) return ; - int exprStart568 = getCharIndex(); - int exprStartLine568 = getLine(); - int exprStartCharPos568 = getCharPositionInLine(); + int exprStart565 = getCharIndex(); + int exprStartLine565 = getLine(); + int exprStartCharPos565 = getCharPositionInLine(); mATTR_VALUE_EXPR(); if (state.failed) return ; - expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart568, getCharIndex()-1); - expr.setLine(exprStartLine568); - expr.setCharPositionInLine(exprStartCharPos568); + expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart565, getCharIndex()-1); + expr.setLine(exprStartLine565); + expr.setCharPositionInLine(exprStartCharPos565); match(';'); if (state.failed) return ; } @@ -1240,29 +1223,29 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:126:4: '%' x= ID '.' y= ID ( WS )? '=' expr= ATTR_VALUE_EXPR ';' { match('%'); if (state.failed) return ; - int xStart588 = getCharIndex(); - int xStartLine588 = getLine(); - int xStartCharPos588 = getCharPositionInLine(); + int xStart585 = getCharIndex(); + int xStartLine585 = getLine(); + int xStartCharPos585 = getCharPositionInLine(); mID(); if (state.failed) return ; - x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart588, getCharIndex()-1); - x.setLine(xStartLine588); - x.setCharPositionInLine(xStartCharPos588); + x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart585, getCharIndex()-1); + x.setLine(xStartLine585); + x.setCharPositionInLine(xStartCharPos585); match('.'); if (state.failed) return ; - int yStart594 = getCharIndex(); - int yStartLine594 = getLine(); - int yStartCharPos594 = getCharPositionInLine(); + int yStart591 = getCharIndex(); + int yStartLine591 = getLine(); + int yStartCharPos591 = getCharPositionInLine(); mID(); if (state.failed) return ; - y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart594, getCharIndex()-1); - y.setLine(yStartLine594); - y.setCharPositionInLine(yStartCharPos594); + y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart591, getCharIndex()-1); + y.setLine(yStartLine591); + y.setCharPositionInLine(yStartCharPos591); // ActionSplitter.g:126:22: ( WS )? - int alt22=2; - int LA22_0 = input.LA(1); + int alt21=2; + int LA21_0 = input.LA(1); - if ( ((LA22_0>='\t' && LA22_0<='\n')||LA22_0=='\r'||LA22_0==' ') ) { - alt22=1; + if ( ((LA21_0>='\t' && LA21_0<='\n')||LA21_0=='\r'||LA21_0==' ') ) { + alt21=1; } - switch (alt22) { + switch (alt21) { case 1 : // ActionSplitter.g:126:22: WS { @@ -1274,13 +1257,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } match('='); if (state.failed) return ; - int exprStart603 = getCharIndex(); - int exprStartLine603 = getLine(); - int exprStartCharPos603 = getCharPositionInLine(); + int exprStart600 = getCharIndex(); + int exprStartLine600 = getLine(); + int exprStartCharPos600 = getCharPositionInLine(); mATTR_VALUE_EXPR(); if (state.failed) return ; - expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart603, getCharIndex()-1); - expr.setLine(exprStartLine603); - expr.setCharPositionInLine(exprStartCharPos603); + expr = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, exprStart600, getCharIndex()-1); + expr.setLine(exprStartLine600); + expr.setCharPositionInLine(exprStartCharPos600); match(';'); if (state.failed) return ; } @@ -1304,13 +1287,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:131:4: '%' a= ACTION { match('%'); if (state.failed) return ; - int aStart622 = getCharIndex(); - int aStartLine622 = getLine(); - int aStartCharPos622 = getCharPositionInLine(); + int aStart619 = getCharIndex(); + int aStartLine619 = getLine(); + int aStartCharPos619 = getCharPositionInLine(); mACTION(); if (state.failed) return ; - a = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, aStart622, getCharIndex()-1); - a.setLine(aStartLine622); - a.setCharPositionInLine(aStartCharPos622); + a = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, aStart619, getCharIndex()-1); + a.setLine(aStartLine619); + a.setCharPositionInLine(aStartCharPos619); } @@ -1332,11 +1315,11 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { { match('%'); if (state.failed) return ; // ActionSplitter.g:136:8: ( ID | '.' | '(' | ')' | ',' | '{' | '}' | '\"' )* - loop23: + loop22: do { - int alt23=9; - alt23 = dfa23.predict(input); - switch (alt23) { + int alt22=9; + alt22 = dfa22.predict(input); + switch (alt22) { case 1 : // ActionSplitter.g:136:9: ID { @@ -1395,7 +1378,7 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop23; + break loop22; } } while (true); @@ -1421,18 +1404,18 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:142:4: (~ ( '$' | '%' ) )+ { // ActionSplitter.g:142:4: (~ ( '$' | '%' ) )+ - int cnt24=0; - loop24: + int cnt23=0; + loop23: do { - int alt24=2; - int LA24_0 = input.LA(1); + int alt23=2; + int LA23_0 = input.LA(1); - if ( ((LA24_0>='\u0000' && LA24_0<='#')||(LA24_0>='&' && LA24_0<='\uFFFF')) ) { - alt24=1; + if ( ((LA23_0>='\u0000' && LA23_0<='#')||(LA23_0>='&' && LA23_0<='\uFFFF')) ) { + alt23=1; } - switch (alt24) { + switch (alt23) { case 1 : // ActionSplitter.g:142:4: ~ ( '$' | '%' ) { @@ -1451,13 +1434,13 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - if ( cnt24 >= 1 ) break loop24; + if ( cnt23 >= 1 ) break loop23; if (state.backtracking>0) {state.failed=true; return ;} EarlyExitException eee = - new EarlyExitException(24, input); + new EarlyExitException(23, input); throw eee; } - cnt24++; + cnt23++; } while (true); @@ -1481,38 +1464,38 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { { match('{'); if (state.failed) return ; // ActionSplitter.g:147:8: ( '\\\\}' | ~ '}' )* - loop25: + loop24: do { - int alt25=3; - int LA25_0 = input.LA(1); + int alt24=3; + int LA24_0 = input.LA(1); - if ( (LA25_0=='\\') ) { - int LA25_2 = input.LA(2); + if ( (LA24_0=='\\') ) { + int LA24_2 = input.LA(2); - if ( (LA25_2=='}') ) { - int LA25_4 = input.LA(3); + if ( (LA24_2=='}') ) { + int LA24_4 = input.LA(3); - if ( ((LA25_4>='\u0000' && LA25_4<='\uFFFF')) ) { - alt25=1; + if ( ((LA24_4>='\u0000' && LA24_4<='\uFFFF')) ) { + alt24=1; } else { - alt25=2; + alt24=2; } } - else if ( ((LA25_2>='\u0000' && LA25_2<='|')||(LA25_2>='~' && LA25_2<='\uFFFF')) ) { - alt25=2; + else if ( ((LA24_2>='\u0000' && LA24_2<='|')||(LA24_2>='~' && LA24_2<='\uFFFF')) ) { + alt24=2; } } - else if ( ((LA25_0>='\u0000' && LA25_0<='[')||(LA25_0>=']' && LA25_0<='|')||(LA25_0>='~' && LA25_0<='\uFFFF')) ) { - alt25=2; + else if ( ((LA24_0>='\u0000' && LA24_0<='[')||(LA24_0>=']' && LA24_0<='|')||(LA24_0>='~' && LA24_0<='\uFFFF')) ) { + alt24=2; } - switch (alt25) { + switch (alt24) { case 1 : // ActionSplitter.g:147:9: '\\\\}' { @@ -1539,7 +1522,7 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop25; + break loop24; } } while (true); @@ -1588,17 +1571,17 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { throw mse;} // ActionSplitter.g:155:31: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* - loop26: + loop25: do { - int alt26=2; - int LA26_0 = input.LA(1); + int alt25=2; + int LA25_0 = input.LA(1); - if ( ((LA26_0>='0' && LA26_0<='9')||(LA26_0>='A' && LA26_0<='Z')||LA26_0=='_'||(LA26_0>='a' && LA26_0<='z')) ) { - alt26=1; + if ( ((LA25_0>='0' && LA25_0<='9')||(LA25_0>='A' && LA25_0<='Z')||LA25_0=='_'||(LA25_0>='a' && LA25_0<='z')) ) { + alt25=1; } - switch (alt26) { + switch (alt25) { case 1 : // ActionSplitter.g: { @@ -1617,7 +1600,7 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop26; + break loop25; } } while (true); @@ -1647,17 +1630,17 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { throw mse;} // ActionSplitter.g:161:9: (~ ';' )* - loop27: + loop26: do { - int alt27=2; - int LA27_0 = input.LA(1); + int alt26=2; + int LA26_0 = input.LA(1); - if ( ((LA27_0>='\u0000' && LA27_0<=':')||(LA27_0>='<' && LA27_0<='\uFFFF')) ) { - alt27=1; + if ( ((LA26_0>='\u0000' && LA26_0<=':')||(LA26_0>='<' && LA26_0<='\uFFFF')) ) { + alt26=1; } - switch (alt27) { + switch (alt26) { case 1 : // ActionSplitter.g:161:10: ~ ';' { @@ -1676,7 +1659,7 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { break; default : - break loop27; + break loop26; } } while (true); @@ -1696,30 +1679,30 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { // ActionSplitter.g:166:4: ( '\\\\]' | ~ ']' )+ { // ActionSplitter.g:166:4: ( '\\\\]' | ~ ']' )+ - int cnt28=0; - loop28: + int cnt27=0; + loop27: do { - int alt28=3; - int LA28_0 = input.LA(1); + int alt27=3; + int LA27_0 = input.LA(1); - if ( (LA28_0=='\\') ) { - int LA28_2 = input.LA(2); + if ( (LA27_0=='\\') ) { + int LA27_2 = input.LA(2); - if ( (LA28_2==']') ) { - alt28=1; + if ( (LA27_2==']') ) { + alt27=1; } else { - alt28=2; + alt27=2; } } - else if ( ((LA28_0>='\u0000' && LA28_0<='[')||(LA28_0>='^' && LA28_0<='\uFFFF')) ) { - alt28=2; + else if ( ((LA27_0>='\u0000' && LA27_0<='[')||(LA27_0>='^' && LA27_0<='\uFFFF')) ) { + alt27=2; } - switch (alt28) { + switch (alt27) { case 1 : // ActionSplitter.g:166:5: '\\\\]' { @@ -1745,6 +1728,61 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } break; + default : + if ( cnt27 >= 1 ) break loop27; + if (state.backtracking>0) {state.failed=true; return ;} + EarlyExitException eee = + new EarlyExitException(27, input); + throw eee; + } + cnt27++; + } while (true); + + + } + + } + finally { + } + } + // $ANTLR end "SCOPE_INDEX_EXPR" + + // $ANTLR start "WS" + public final void mWS() throws RecognitionException { + try { + // ActionSplitter.g:170:4: ( ( ' ' | '\\t' | '\\n' | '\\r' )+ ) + // ActionSplitter.g:170:6: ( ' ' | '\\t' | '\\n' | '\\r' )+ + { + // ActionSplitter.g:170:6: ( ' ' | '\\t' | '\\n' | '\\r' )+ + int cnt28=0; + loop28: + do { + int alt28=2; + int LA28_0 = input.LA(1); + + if ( ((LA28_0>='\t' && LA28_0<='\n')||LA28_0=='\r'||LA28_0==' ') ) { + alt28=1; + } + + + switch (alt28) { + case 1 : + // ActionSplitter.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + state.failed=false; + } + else { + if (state.backtracking>0) {state.failed=true; return ;} + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + default : if ( cnt28 >= 1 ) break loop28; if (state.backtracking>0) {state.failed=true; return ;} @@ -1756,61 +1794,6 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { } while (true); - } - - } - finally { - } - } - // $ANTLR end "SCOPE_INDEX_EXPR" - - // $ANTLR start "WS" - public final void mWS() throws RecognitionException { - try { - // ActionSplitter.g:170:4: ( ( ' ' | '\\t' | '\\n' | '\\r' )+ ) - // ActionSplitter.g:170:6: ( ' ' | '\\t' | '\\n' | '\\r' )+ - { - // ActionSplitter.g:170:6: ( ' ' | '\\t' | '\\n' | '\\r' )+ - int cnt29=0; - loop29: - do { - int alt29=2; - int LA29_0 = input.LA(1); - - if ( ((LA29_0>='\t' && LA29_0<='\n')||LA29_0=='\r'||LA29_0==' ') ) { - alt29=1; - } - - - switch (alt29) { - case 1 : - // ActionSplitter.g: - { - if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { - input.consume(); - state.failed=false; - } - else { - if (state.backtracking>0) {state.failed=true; return ;} - MismatchedSetException mse = new MismatchedSetException(null,input); - recover(mse); - throw mse;} - - - } - break; - - default : - if ( cnt29 >= 1 ) break loop29; - if (state.backtracking>0) {state.failed=true; return ;} - EarlyExitException eee = - new EarlyExitException(29, input); - throw eee; - } - cnt29++; - } while (true); - - } } @@ -1821,9 +1804,9 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { public void mTokens() throws RecognitionException { // ActionSplitter.g:1:39: ( COMMENT | LINE_COMMENT | ESC | SET_QUALIFIED_ATTR | QUALIFIED_ATTR | SET_DYNAMIC_SCOPE_ATTR | DYNAMIC_SCOPE_ATTR | SET_DYNAMIC_NEGATIVE_INDEXED_SCOPE_ATTR | DYNAMIC_NEGATIVE_INDEXED_SCOPE_ATTR | SET_DYNAMIC_ABSOLUTE_INDEXED_SCOPE_ATTR | DYNAMIC_ABSOLUTE_INDEXED_SCOPE_ATTR | SET_ATTR | ATTR | TEMPLATE_INSTANCE | INDIRECT_TEMPLATE_INSTANCE | SET_EXPR_ATTRIBUTE | SET_ATTRIBUTE | TEMPLATE_EXPR | UNKNOWN_SYNTAX | TEXT ) - int alt30=20; - alt30 = dfa30.predict(input); - switch (alt30) { + int alt29=20; + alt29 = dfa29.predict(input); + switch (alt29) { case 1 : // ActionSplitter.g:1:41: COMMENT { @@ -2346,11 +2329,11 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { state.failed=false; return success; } - public final boolean synpred8_ActionSplitter() { + public final boolean synpred2_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred8_ActionSplitter_fragment(); // can never throw exception + synpred2_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2360,11 +2343,11 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { state.failed=false; return success; } - public final boolean synpred2_ActionSplitter() { + public final boolean synpred8_ActionSplitter() { state.backtracking++; int start = input.mark(); try { - synpred2_ActionSplitter_fragment(); // can never throw exception + synpred8_ActionSplitter_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } @@ -2416,20 +2399,6 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { state.failed=false; return success; } - public final boolean synpred15_ActionSplitter() { - state.backtracking++; - int start = input.mark(); - try { - synpred15_ActionSplitter_fragment(); // can never throw exception - } catch (RecognitionException re) { - System.err.println("impossible: "+re); - } - boolean success = !state.failed; - input.rewind(start); - state.backtracking--; - state.failed=false; - return success; - } public final boolean synpred3_ActionSplitter() { state.backtracking++; int start = input.mark(); @@ -2444,23 +2413,37 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { state.failed=false; return success; } + public final boolean synpred15_ActionSplitter() { + state.backtracking++; + int start = input.mark(); + try { + synpred15_ActionSplitter_fragment(); // can never throw exception + } catch (RecognitionException re) { + System.err.println("impossible: "+re); + } + boolean success = !state.failed; + input.rewind(start); + state.backtracking--; + state.failed=false; + return success; + } - protected DFA23 dfa23 = new DFA23(this); - protected DFA30 dfa30 = new DFA30(this); - static final String DFA23_eotS = + protected DFA22 dfa22 = new DFA22(this); + protected DFA29 dfa29 = new DFA29(this); + static final String DFA22_eotS = "\1\1\11\uffff"; - static final String DFA23_eofS = + static final String DFA22_eofS = "\12\uffff"; - static final String DFA23_minS = + static final String DFA22_minS = "\1\42\11\uffff"; - static final String DFA23_maxS = + static final String DFA22_maxS = "\1\175\11\uffff"; - static final String DFA23_acceptS = + static final String DFA22_acceptS = "\1\uffff\1\11\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10"; - static final String DFA23_specialS = + static final String DFA22_specialS = "\12\uffff}>"; - static final String[] DFA23_transitionS = { + static final String[] DFA22_transitionS = { "\1\11\5\uffff\1\4\1\5\2\uffff\1\6\1\uffff\1\3\22\uffff\32\2"+ "\4\uffff\1\2\1\uffff\32\2\1\7\1\uffff\1\10", "", @@ -2474,54 +2457,54 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { "" }; - static final short[] DFA23_eot = DFA.unpackEncodedString(DFA23_eotS); - static final short[] DFA23_eof = DFA.unpackEncodedString(DFA23_eofS); - static final char[] DFA23_min = DFA.unpackEncodedStringToUnsignedChars(DFA23_minS); - static final char[] DFA23_max = DFA.unpackEncodedStringToUnsignedChars(DFA23_maxS); - static final short[] DFA23_accept = DFA.unpackEncodedString(DFA23_acceptS); - static final short[] DFA23_special = DFA.unpackEncodedString(DFA23_specialS); - static final short[][] DFA23_transition; + static final short[] DFA22_eot = DFA.unpackEncodedString(DFA22_eotS); + static final short[] DFA22_eof = DFA.unpackEncodedString(DFA22_eofS); + static final char[] DFA22_min = DFA.unpackEncodedStringToUnsignedChars(DFA22_minS); + static final char[] DFA22_max = DFA.unpackEncodedStringToUnsignedChars(DFA22_maxS); + static final short[] DFA22_accept = DFA.unpackEncodedString(DFA22_acceptS); + static final short[] DFA22_special = DFA.unpackEncodedString(DFA22_specialS); + static final short[][] DFA22_transition; static { - int numStates = DFA23_transitionS.length; - DFA23_transition = new short[numStates][]; + int numStates = DFA22_transitionS.length; + DFA22_transition = new short[numStates][]; for (int i=0; i"; - static final String[] DFA30_transitionS = { - "\44\16\1\17\1\5\11\16\1\1\54\16\1\14\uffa3\16", + "\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\uffff\1\3\1\24"; + static final String DFA29_specialS = + "\1\0\1\1\3\uffff\1\2\6\uffff\1\3\12\uffff\1\4\2\uffff}>"; + static final String[] DFA29_transitionS = { + "\44\31\1\14\1\5\11\31\1\1\54\31\1\27\uffa3\31", "\1\uffff", "", "", @@ -2536,47 +2519,47 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { "\1\uffff", "", "", + "", + "", + "", + "", + "", + "", + "", + "", "\1\uffff", "", - "", - "", - "", - "", - "", - "", - "", - "", "" }; - static final short[] DFA30_eot = DFA.unpackEncodedString(DFA30_eotS); - static final short[] DFA30_eof = DFA.unpackEncodedString(DFA30_eofS); - static final char[] DFA30_min = DFA.unpackEncodedStringToUnsignedChars(DFA30_minS); - static final char[] DFA30_max = DFA.unpackEncodedStringToUnsignedChars(DFA30_maxS); - static final short[] DFA30_accept = DFA.unpackEncodedString(DFA30_acceptS); - static final short[] DFA30_special = DFA.unpackEncodedString(DFA30_specialS); - static final short[][] DFA30_transition; + static final short[] DFA29_eot = DFA.unpackEncodedString(DFA29_eotS); + static final short[] DFA29_eof = DFA.unpackEncodedString(DFA29_eofS); + static final char[] DFA29_min = DFA.unpackEncodedStringToUnsignedChars(DFA29_minS); + static final char[] DFA29_max = DFA.unpackEncodedStringToUnsignedChars(DFA29_maxS); + static final short[] DFA29_accept = DFA.unpackEncodedString(DFA29_acceptS); + static final short[] DFA29_special = DFA.unpackEncodedString(DFA29_specialS); + static final short[][] DFA29_transition; static { - int numStates = DFA30_transitionS.length; - DFA30_transition = new short[numStates][]; + int numStates = DFA29_transitionS.length; + DFA29_transition = new short[numStates][]; for (int i=0; i='\u0000' && LA30_0<='#')||(LA30_0>='&' && LA30_0<='.')||(LA30_0>='0' && LA30_0<='[')||(LA30_0>=']' && LA30_0<='\uFFFF')) ) {s = 14;} + else if ( (LA29_0=='\\') ) {s = 23;} - else if ( (LA30_0=='$') ) {s = 15;} + else if ( ((LA29_0>='\u0000' && LA29_0<='#')||(LA29_0>='&' && LA29_0<='.')||(LA29_0>='0' && LA29_0<='[')||(LA29_0>=']' && LA29_0<='\uFFFF')) ) {s = 25;} if ( s>=0 ) return s; break; case 1 : - int LA30_1 = input.LA(1); + int LA29_1 = input.LA(1); - int index30_1 = input.index(); + int index29_1 = input.index(); input.rewind(); s = -1; if ( (synpred1_ActionSplitter()) ) {s = 2;} @@ -2615,14 +2598,14 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { else if ( (true) ) {s = 4;} - input.seek(index30_1); + input.seek(index29_1); if ( s>=0 ) return s; break; case 2 : - int LA30_5 = input.LA(1); + int LA29_5 = input.LA(1); - int index30_5 = input.index(); + int index29_5 = input.index(); input.rewind(); s = -1; if ( (synpred14_ActionSplitter()) ) {s = 6;} @@ -2638,59 +2621,59 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer { else if ( (synpred19_ActionSplitter()) ) {s = 11;} - input.seek(index30_5); + input.seek(index29_5); if ( s>=0 ) return s; break; case 3 : - int LA30_12 = input.LA(1); + int LA29_12 = input.LA(1); - int index30_12 = input.index(); + int index29_12 = input.index(); input.rewind(); s = -1; - if ( (synpred3_ActionSplitter()) ) {s = 13;} + if ( (synpred4_ActionSplitter()) ) {s = 13;} + + else if ( (synpred5_ActionSplitter()) ) {s = 14;} + + else if ( (synpred6_ActionSplitter()) ) {s = 15;} + + else if ( (synpred7_ActionSplitter()) ) {s = 16;} + + else if ( (synpred8_ActionSplitter()) ) {s = 17;} + + else if ( (synpred9_ActionSplitter()) ) {s = 18;} + + else if ( (synpred10_ActionSplitter()) ) {s = 19;} + + else if ( (synpred11_ActionSplitter()) ) {s = 20;} + + else if ( (synpred12_ActionSplitter()) ) {s = 21;} + + else if ( (synpred13_ActionSplitter()) ) {s = 22;} + + + input.seek(index29_12); + if ( s>=0 ) return s; + break; + case 4 : + int LA29_23 = input.LA(1); + + + int index29_23 = input.index(); + input.rewind(); + s = -1; + if ( (synpred3_ActionSplitter()) ) {s = 24;} else if ( (true) ) {s = 4;} - input.seek(index30_12); - if ( s>=0 ) return s; - break; - case 4 : - int LA30_15 = input.LA(1); - - - int index30_15 = input.index(); - input.rewind(); - s = -1; - if ( (synpred4_ActionSplitter()) ) {s = 16;} - - else if ( (synpred5_ActionSplitter()) ) {s = 17;} - - else if ( (synpred6_ActionSplitter()) ) {s = 18;} - - else if ( (synpred7_ActionSplitter()) ) {s = 19;} - - else if ( (synpred8_ActionSplitter()) ) {s = 20;} - - else if ( (synpred9_ActionSplitter()) ) {s = 21;} - - else if ( (synpred10_ActionSplitter()) ) {s = 22;} - - else if ( (synpred11_ActionSplitter()) ) {s = 23;} - - else if ( (synpred12_ActionSplitter()) ) {s = 24;} - - else if ( (synpred13_ActionSplitter()) ) {s = 25;} - - - input.seek(index30_15); + input.seek(index29_23); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = - new NoViableAltException(getDescription(), 30, _s, input); + new NoViableAltException(getDescription(), 29, _s, input); error(nvae); throw nvae; } diff --git a/tool/src/org/antlr/v4/semantics/AttributeChecks.java b/tool/src/org/antlr/v4/semantics/AttributeChecks.java index dc934da36..ab961dce8 100644 --- a/tool/src/org/antlr/v4/semantics/AttributeChecks.java +++ b/tool/src/org/antlr/v4/semantics/AttributeChecks.java @@ -114,40 +114,44 @@ public class AttributeChecks implements ActionSplitterListener { } public void setDynamicScopeAttr(String expr, Token x, Token y, Token rhs) { - System.out.println("SET "+x+" :: "+y); + //System.out.println("SET "+x+" :: "+y); + dynamicScopeAttr(expr, x, y); + new AttributeChecks(g, r, alt, node, rhs).examineAction(); } public void dynamicScopeAttr(String expr, Token x, Token y) { - System.out.println(x+" :: "+y); -// if ( !node.resolver.resolves(x.getText(), y.getText(), node) ) { -// if ( !node.resolver.resolves(x.getText(), node) && -// (r==null || !r.name.equals(x.getText())) ) -// { -// ErrorManager.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, -// g.fileName, x, x.getText(), expr); -// } -// else { -// ErrorManager.grammarError(ErrorType.UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE, -// g.fileName, y, x.getText(), y.getText(), expr); -// } -// } - } - - public void setDynamicNegativeIndexedScopeAttr(String expr, Token x, Token y, - Token index, Token rhs) { - + //System.out.println(x+" :: "+y); + AttributeScope s = node.resolver.resolveToDynamicScope(x.getText(), node); + if ( s==null ) { + ErrorManager.grammarError(ErrorType.UNKNOWN_DYNAMIC_SCOPE, + g.fileName, x, x.getText(), expr); + return; + } + Attribute a = s.get(y.getText()); + if ( a==null ) { + ErrorManager.grammarError(ErrorType.UNKNOWN_DYNAMIC_SCOPE_ATTRIBUTE, + g.fileName, y, x.getText(), y.getText(), expr); + } } - public void dynamicNegativeIndexedScopeAttr(String expr, Token x, Token y, + public void setDynamicNegativeIndexedScopeAttr(String expr, Token x, Token y, + Token index, Token rhs) { + setDynamicScopeAttr(expr, x, y, rhs); + } + + public void dynamicNegativeIndexedScopeAttr(String expr, Token x, Token y, Token index) { + dynamicScopeAttr(expr, x, y); } - public void setDynamicAbsoluteIndexedScopeAttr(String expr, Token x, Token y, + public void setDynamicAbsoluteIndexedScopeAttr(String expr, Token x, Token y, Token index, Token rhs) { + setDynamicScopeAttr(expr, x, y, rhs); } public void dynamicAbsoluteIndexedScopeAttr(String expr, Token x, Token y, Token index) { + dynamicScopeAttr(expr, x, y); } public void unknownSyntax(String text) { diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java index b2cf02229..d570b9842 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticTriggers.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} BasicSemanticTriggers.g 2010-02-15 13:05:00 +// $ANTLR ${project.version} ${buildNumber} BasicSemanticTriggers.g 2010-02-15 16:36:20 /* [The "BSD license"] diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.g b/tool/src/org/antlr/v4/semantics/CollectSymbols.g index d5954f14c..4c3c0d9dd 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.g +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.g @@ -117,7 +117,8 @@ globalScope : {inContext("GRAMMAR")}? ^(SCOPE ID ACTION) { AttributeScope s = ScopeParser.parseDynamicScope($ACTION.text); - s.ast = $ACTION; + s.name = $ID.text; + s.ast = $ACTION; scopes.add(s); } ; @@ -211,6 +212,7 @@ ruleScopeSpec ( ^(SCOPE ACTION) { currentRule.scope = ScopeParser.parseDynamicScope($ACTION.text); + currentRule.scope.name = currentRule.name; currentRule.scope.ast = $ACTION; } | ^(SCOPE ids+=ID+) {currentRule.useScopes = $ids;} diff --git a/tool/src/org/antlr/v4/semantics/CollectSymbols.java b/tool/src/org/antlr/v4/semantics/CollectSymbols.java index 7c0d181a5..a1ef9bafe 100644 --- a/tool/src/org/antlr/v4/semantics/CollectSymbols.java +++ b/tool/src/org/antlr/v4/semantics/CollectSymbols.java @@ -1,4 +1,4 @@ -// $ANTLR ${project.version} ${buildNumber} CollectSymbols.g 2010-02-15 13:05:00 +// $ANTLR ${project.version} ${buildNumber} CollectSymbols.g 2010-02-15 16:36:20 /* [The "BSD license"] @@ -395,6 +395,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // CollectSymbols.g:116:1: globalScope : {...}? ^( SCOPE ID ACTION ) ; public final void globalScope() throws RecognitionException { GrammarAST ACTION1=null; + GrammarAST ID2=null; try { // CollectSymbols.g:117:2: ({...}? ^( SCOPE ID ACTION ) ) @@ -407,14 +408,15 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { match(input,SCOPE,FOLLOW_SCOPE_in_globalScope247); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - match(input,ID,FOLLOW_ID_in_globalScope249); if (state.failed) return ; + ID2=(GrammarAST)match(input,ID,FOLLOW_ID_in_globalScope249); if (state.failed) return ; ACTION1=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_globalScope251); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { AttributeScope s = ScopeParser.parseDynamicScope((ACTION1!=null?ACTION1.getText():null)); - s.ast = ACTION1; + s.name = (ID2!=null?ID2.getText():null); + s.ast = ACTION1; scopes.add(s); } @@ -434,23 +436,23 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "globalNamedAction" - // CollectSymbols.g:125:1: globalNamedAction : {...}? ^( AT ( ID )? ID ACTION ) ; + // CollectSymbols.g:126:1: globalNamedAction : {...}? ^( AT ( ID )? ID ACTION ) ; public final void globalNamedAction() throws RecognitionException { - GrammarAST AT2=null; - GrammarAST ACTION3=null; + GrammarAST AT3=null; + GrammarAST ACTION4=null; try { - // CollectSymbols.g:126:2: ({...}? ^( AT ( ID )? ID ACTION ) ) - // CollectSymbols.g:126:4: {...}? ^( AT ( ID )? ID ACTION ) + // CollectSymbols.g:127:2: ({...}? ^( AT ( ID )? ID ACTION ) ) + // CollectSymbols.g:127:4: {...}? ^( AT ( ID )? ID ACTION ) { if ( !((inContext("GRAMMAR"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "globalNamedAction", "inContext(\"GRAMMAR\")"); } - AT2=(GrammarAST)match(input,AT,FOLLOW_AT_in_globalNamedAction270); if (state.failed) return ; + AT3=(GrammarAST)match(input,AT,FOLLOW_AT_in_globalNamedAction270); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - // CollectSymbols.g:126:33: ( ID )? + // CollectSymbols.g:127:33: ( ID )? int alt2=2; int LA2_0 = input.LA(1); @@ -463,7 +465,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt2) { case 1 : - // CollectSymbols.g:126:33: ID + // CollectSymbols.g:127:33: ID { match(input,ID,FOLLOW_ID_in_globalNamedAction272); if (state.failed) return ; @@ -473,11 +475,11 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } match(input,ID,FOLLOW_ID_in_globalNamedAction275); if (state.failed) return ; - ACTION3=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_globalNamedAction277); if (state.failed) return ; + ACTION4=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_globalNamedAction277); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { - actions.add(AT2); ((ActionAST)ACTION3).resolver = g; + actions.add(AT3); ((ActionAST)ACTION4).resolver = g; } } @@ -495,21 +497,21 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "tokensSection" - // CollectSymbols.g:130:1: tokensSection : {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ; + // CollectSymbols.g:131:1: tokensSection : {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ; public final void tokensSection() throws RecognitionException { GrammarAST t=null; - GrammarAST ASSIGN4=null; - GrammarAST STRING_LITERAL5=null; + GrammarAST ASSIGN5=null; + GrammarAST STRING_LITERAL6=null; try { - // CollectSymbols.g:131:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ) - // CollectSymbols.g:131:4: {...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) + // CollectSymbols.g:132:2: ({...}? ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) ) + // CollectSymbols.g:132: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:132:3: ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) + // CollectSymbols.g:133:3: ( ^( ASSIGN t= ID STRING_LITERAL ) | t= ID ) int alt3=2; int LA3_0 = input.LA(1); @@ -528,24 +530,24 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt3) { case 1 : - // CollectSymbols.g:132:5: ^( ASSIGN t= ID STRING_LITERAL ) + // CollectSymbols.g:133:5: ^( ASSIGN t= ID STRING_LITERAL ) { - ASSIGN4=(GrammarAST)match(input,ASSIGN,FOLLOW_ASSIGN_in_tokensSection300); if (state.failed) return ; + ASSIGN5=(GrammarAST)match(input,ASSIGN,FOLLOW_ASSIGN_in_tokensSection300); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection304); if (state.failed) return ; - STRING_LITERAL5=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokensSection306); if (state.failed) return ; + STRING_LITERAL6=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokensSection306); 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(ASSIGN4); strings.add(STRING_LITERAL5); + tokensDefs.add(ASSIGN5); strings.add(STRING_LITERAL6); } } break; case 2 : - // CollectSymbols.g:135:5: t= ID + // CollectSymbols.g:136:5: t= ID { t=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokensSection320); if (state.failed) return ; if ( state.backtracking==1 ) { @@ -573,20 +575,20 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "rule" - // CollectSymbols.g:140:1: rule : ^( RULE name= ID ( . )+ ) ; + // CollectSymbols.g:141:1: rule : ^( RULE name= ID ( . )+ ) ; public final void rule() throws RecognitionException { GrammarAST name=null; - GrammarAST RULE6=null; + GrammarAST RULE7=null; try { - // CollectSymbols.g:140:5: ( ^( RULE name= ID ( . )+ ) ) - // CollectSymbols.g:140:9: ^( RULE name= ID ( . )+ ) + // CollectSymbols.g:141:5: ( ^( RULE name= ID ( . )+ ) ) + // CollectSymbols.g:141:9: ^( RULE name= ID ( . )+ ) { - RULE6=(GrammarAST)match(input,RULE,FOLLOW_RULE_in_rule342); if (state.failed) return ; + RULE7=(GrammarAST)match(input,RULE,FOLLOW_RULE_in_rule342); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; name=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule346); if (state.failed) return ; - // CollectSymbols.g:140:25: ( . )+ + // CollectSymbols.g:141:25: ( . )+ int cnt4=0; loop4: do { @@ -603,7 +605,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { switch (alt4) { case 1 : - // CollectSymbols.g:140:25: . + // CollectSymbols.g:141:25: . { matchAny(input); if (state.failed) return ; @@ -624,8 +626,8 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { - int numAlts = RULE6.getFirstChildWithType(BLOCK).getChildCount(); - Rule r = new Rule(g, (name!=null?name.getText():null), (GrammarASTWithOptions)RULE6, numAlts); + int numAlts = RULE7.getFirstChildWithType(BLOCK).getChildCount(); + Rule r = new Rule(g, (name!=null?name.getText():null), (GrammarASTWithOptions)RULE7, numAlts); rules.add(r); currentRule = r; currentAlt = 1; @@ -649,14 +651,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "setAlt" - // CollectSymbols.g:150:1: setAlt : {...}? ( ALT | ALT_REWRITE ) ; + // CollectSymbols.g:151: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:151:2: ({...}? ( ALT | ALT_REWRITE ) ) - // CollectSymbols.g:151:4: {...}? ( ALT | ALT_REWRITE ) + // CollectSymbols.g:152:2: ({...}? ( ALT | ALT_REWRITE ) ) + // CollectSymbols.g:152:4: {...}? ( ALT | ALT_REWRITE ) { if ( !((inContext("RULE BLOCK"))) ) { if (state.backtracking>0) {state.failed=true; return retval;} @@ -691,11 +693,11 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "finishRule" - // CollectSymbols.g:155:1: finishRule : RULE ; + // CollectSymbols.g:156:1: finishRule : RULE ; public final void finishRule() throws RecognitionException { try { - // CollectSymbols.g:156:2: ( RULE ) - // CollectSymbols.g:156:4: RULE + // CollectSymbols.g:157:2: ( RULE ) + // CollectSymbols.g:157:4: RULE { match(input,RULE,FOLLOW_RULE_in_finishRule394); if (state.failed) return ; if ( state.backtracking==1 ) { @@ -717,14 +719,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleNamedAction" - // CollectSymbols.g:159:1: ruleNamedAction : {...}? ^( AT ID ACTION ) ; + // CollectSymbols.g:160:1: ruleNamedAction : {...}? ^( AT ID ACTION ) ; public final void ruleNamedAction() throws RecognitionException { - GrammarAST ID7=null; - GrammarAST ACTION8=null; + GrammarAST ID8=null; + GrammarAST ACTION9=null; try { - // CollectSymbols.g:160:2: ({...}? ^( AT ID ACTION ) ) - // CollectSymbols.g:160:4: {...}? ^( AT ID ACTION ) + // CollectSymbols.g:161:2: ({...}? ^( AT ID ACTION ) ) + // CollectSymbols.g:161:4: {...}? ^( AT ID ACTION ) { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} @@ -733,14 +735,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { match(input,AT,FOLLOW_AT_in_ruleNamedAction410); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - ID7=(GrammarAST)match(input,ID,FOLLOW_ID_in_ruleNamedAction412); if (state.failed) return ; - ACTION8=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleNamedAction414); if (state.failed) return ; + ID8=(GrammarAST)match(input,ID,FOLLOW_ID_in_ruleNamedAction412); if (state.failed) return ; + ACTION9=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleNamedAction414); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { - currentRule.namedActions.put((ID7!=null?ID7.getText():null),(ActionAST)ACTION8); - ((ActionAST)ACTION8).resolver = currentRule; + currentRule.namedActions.put((ID8!=null?ID8.getText():null),(ActionAST)ACTION9); + ((ActionAST)ACTION9).resolver = currentRule; } @@ -759,24 +761,24 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleAction" - // CollectSymbols.g:167:1: ruleAction : {...}? ACTION ; + // CollectSymbols.g:168:1: ruleAction : {...}? ACTION ; public final void ruleAction() throws RecognitionException { - GrammarAST ACTION9=null; + GrammarAST ACTION10=null; try { - // CollectSymbols.g:168:2: ({...}? ACTION ) - // CollectSymbols.g:168:4: {...}? ACTION + // CollectSymbols.g:169:2: ({...}? ACTION ) + // CollectSymbols.g:169:4: {...}? ACTION { if ( !((inContext("RULE ...")&&!inContext("SCOPE")&& !inContext("CATCH")&&!inContext("FINALLY"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleAction", "inContext(\"RULE ...\")&&!inContext(\"SCOPE\")&&\n\t\t !inContext(\"CATCH\")&&!inContext(\"FINALLY\")"); } - ACTION9=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleAction434); if (state.failed) return ; + ACTION10=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleAction434); if (state.failed) return ; if ( state.backtracking==1 ) { - currentRule.alt[currentAlt].actions.add((ActionAST)ACTION9); - ((ActionAST)ACTION9).resolver = currentRule.alt[currentAlt]; + currentRule.alt[currentAlt].actions.add((ActionAST)ACTION10); + ((ActionAST)ACTION10).resolver = currentRule.alt[currentAlt]; } @@ -795,55 +797,19 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "exceptionHandler" - // CollectSymbols.g:177:1: exceptionHandler : ^( CATCH ARG_ACTION ACTION ) ; + // CollectSymbols.g:178:1: exceptionHandler : ^( CATCH ARG_ACTION ACTION ) ; public final void exceptionHandler() throws RecognitionException { - GrammarAST ACTION10=null; + GrammarAST ACTION11=null; try { - // CollectSymbols.g:178:2: ( ^( CATCH ARG_ACTION ACTION ) ) - // CollectSymbols.g:178:4: ^( CATCH ARG_ACTION ACTION ) + // CollectSymbols.g:179:2: ( ^( CATCH ARG_ACTION ACTION ) ) + // CollectSymbols.g:179:4: ^( CATCH ARG_ACTION ACTION ) { match(input,CATCH,FOLLOW_CATCH_in_exceptionHandler450); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_exceptionHandler452); if (state.failed) return ; - ACTION10=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_exceptionHandler454); if (state.failed) return ; - - match(input, Token.UP, null); if (state.failed) return ; - if ( state.backtracking==1 ) { - - currentRule.exceptionActions.add((ActionAST)ACTION10); - ((ActionAST)ACTION10).resolver = currentRule; - - } - - } - - } - catch (RecognitionException re) { - reportError(re); - recover(input,re); - } - finally { - } - return ; - } - // $ANTLR end "exceptionHandler" - - - // $ANTLR start "finallyClause" - // CollectSymbols.g:185:1: finallyClause : ^( FINALLY ACTION ) ; - public final void finallyClause() throws RecognitionException { - GrammarAST ACTION11=null; - - try { - // CollectSymbols.g:186:2: ( ^( FINALLY ACTION ) ) - // CollectSymbols.g:186:4: ^( FINALLY ACTION ) - { - match(input,FINALLY,FOLLOW_FINALLY_in_finallyClause471); if (state.failed) return ; - - match(input, Token.DOWN, null); if (state.failed) return ; - ACTION11=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_finallyClause473); if (state.failed) return ; + ACTION11=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_exceptionHandler454); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { @@ -864,27 +830,63 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } return ; } + // $ANTLR end "exceptionHandler" + + + // $ANTLR start "finallyClause" + // CollectSymbols.g:186:1: finallyClause : ^( FINALLY ACTION ) ; + public final void finallyClause() throws RecognitionException { + GrammarAST ACTION12=null; + + try { + // CollectSymbols.g:187:2: ( ^( FINALLY ACTION ) ) + // CollectSymbols.g:187:4: ^( FINALLY ACTION ) + { + match(input,FINALLY,FOLLOW_FINALLY_in_finallyClause471); if (state.failed) return ; + + match(input, Token.DOWN, null); if (state.failed) return ; + ACTION12=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_finallyClause473); if (state.failed) return ; + + match(input, Token.UP, null); if (state.failed) return ; + if ( state.backtracking==1 ) { + + currentRule.exceptionActions.add((ActionAST)ACTION12); + ((ActionAST)ACTION12).resolver = currentRule; + + } + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + finally { + } + return ; + } // $ANTLR end "finallyClause" // $ANTLR start "ruleArg" - // CollectSymbols.g:193:1: ruleArg : {...}? ARG_ACTION ; + // CollectSymbols.g:194:1: ruleArg : {...}? ARG_ACTION ; public final void ruleArg() throws RecognitionException { - GrammarAST ARG_ACTION12=null; + GrammarAST ARG_ACTION13=null; try { - // CollectSymbols.g:194:2: ({...}? ARG_ACTION ) - // CollectSymbols.g:194:4: {...}? ARG_ACTION + // CollectSymbols.g:195:2: ({...}? ARG_ACTION ) + // CollectSymbols.g:195:4: {...}? ARG_ACTION { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleArg", "inContext(\"RULE\")"); } - ARG_ACTION12=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleArg493); if (state.failed) return ; + ARG_ACTION13=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleArg493); if (state.failed) return ; if ( state.backtracking==1 ) { - currentRule.args = ScopeParser.parseTypeList((ARG_ACTION12!=null?ARG_ACTION12.getText():null)); - currentRule.args.ast = ARG_ACTION12; + currentRule.args = ScopeParser.parseTypeList((ARG_ACTION13!=null?ARG_ACTION13.getText():null)); + currentRule.args.ast = ARG_ACTION13; } @@ -903,24 +905,24 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleReturns" - // CollectSymbols.g:201:1: ruleReturns : ^( RETURNS ARG_ACTION ) ; + // CollectSymbols.g:202:1: ruleReturns : ^( RETURNS ARG_ACTION ) ; public final void ruleReturns() throws RecognitionException { - GrammarAST ARG_ACTION13=null; + GrammarAST ARG_ACTION14=null; try { - // CollectSymbols.g:202:2: ( ^( RETURNS ARG_ACTION ) ) - // CollectSymbols.g:202:4: ^( RETURNS ARG_ACTION ) + // CollectSymbols.g:203:2: ( ^( RETURNS ARG_ACTION ) ) + // CollectSymbols.g:203:4: ^( RETURNS ARG_ACTION ) { match(input,RETURNS,FOLLOW_RETURNS_in_ruleReturns510); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - ARG_ACTION13=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleReturns512); if (state.failed) return ; + ARG_ACTION14=(GrammarAST)match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_ruleReturns512); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { - currentRule.retvals = ScopeParser.parseTypeList((ARG_ACTION13!=null?ARG_ACTION13.getText():null)); - currentRule.retvals.ast = ARG_ACTION13; + currentRule.retvals = ScopeParser.parseTypeList((ARG_ACTION14!=null?ARG_ACTION14.getText():null)); + currentRule.retvals.ast = ARG_ACTION14; } @@ -939,21 +941,21 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleScopeSpec" - // CollectSymbols.g:209:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; + // CollectSymbols.g:210:1: ruleScopeSpec : {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ; public final void ruleScopeSpec() throws RecognitionException { - GrammarAST ACTION14=null; + GrammarAST ACTION15=null; GrammarAST ids=null; List list_ids=null; try { - // CollectSymbols.g:210:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ) - // CollectSymbols.g:210:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) + // CollectSymbols.g:211:2: ({...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) ) + // CollectSymbols.g:211:4: {...}? ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) { if ( !((inContext("RULE"))) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "ruleScopeSpec", "inContext(\"RULE\")"); } - // CollectSymbols.g:211:3: ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) + // CollectSymbols.g:212:3: ( ^( SCOPE ACTION ) | ^( SCOPE (ids+= ID )+ ) ) int alt6=2; int LA6_0 = input.LA(1); @@ -994,30 +996,31 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt6) { case 1 : - // CollectSymbols.g:211:5: ^( SCOPE ACTION ) + // CollectSymbols.g:212:5: ^( SCOPE ACTION ) { match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec535); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - ACTION14=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleScopeSpec537); if (state.failed) return ; + ACTION15=(GrammarAST)match(input,ACTION,FOLLOW_ACTION_in_ruleScopeSpec537); if (state.failed) return ; match(input, Token.UP, null); if (state.failed) return ; if ( state.backtracking==1 ) { - currentRule.scope = ScopeParser.parseDynamicScope((ACTION14!=null?ACTION14.getText():null)); - currentRule.scope.ast = ACTION14; + currentRule.scope = ScopeParser.parseDynamicScope((ACTION15!=null?ACTION15.getText():null)); + currentRule.scope.name = currentRule.name; + currentRule.scope.ast = ACTION15; } } break; case 2 : - // CollectSymbols.g:216:5: ^( SCOPE (ids+= ID )+ ) + // CollectSymbols.g:218:5: ^( SCOPE (ids+= ID )+ ) { match(input,SCOPE,FOLLOW_SCOPE_in_ruleScopeSpec550); if (state.failed) return ; match(input, Token.DOWN, null); if (state.failed) return ; - // CollectSymbols.g:216:16: (ids+= ID )+ + // CollectSymbols.g:218:16: (ids+= ID )+ int cnt5=0; loop5: do { @@ -1031,7 +1034,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { switch (alt5) { case 1 : - // CollectSymbols.g:216:16: ids+= ID + // CollectSymbols.g:218:16: ids+= ID { ids=(GrammarAST)match(input,ID,FOLLOW_ID_in_ruleScopeSpec554); if (state.failed) return ; if (list_ids==null) list_ids=new ArrayList(); @@ -1080,14 +1083,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "rewriteElement" - // CollectSymbols.g:220:1: rewriteElement : {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ; + // CollectSymbols.g:222: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:222:2: ({...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ) - // CollectSymbols.g:223:6: {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) + // CollectSymbols.g:224:2: ({...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) ) + // CollectSymbols.g:225:6: {...}? ( TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL ) { if ( !((inContext("RESULT ..."))) ) { if (state.backtracking>0) {state.failed=true; return retval;} @@ -1124,7 +1127,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "labeledElement" - // CollectSymbols.g:227:1: labeledElement : {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ; + // CollectSymbols.g:229: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); @@ -1133,14 +1136,14 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { GrammarAST e=null; try { - // CollectSymbols.g:233:2: ({...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ) - // CollectSymbols.g:233:4: {...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) + // CollectSymbols.g:235:2: ({...}? ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) ) + // CollectSymbols.g:235: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:234:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) + // CollectSymbols.g:236:3: ( ^( ASSIGN id= ID e= . ) | ^( PLUS_ASSIGN id= ID e= . ) ) int alt7=2; int LA7_0 = input.LA(1); @@ -1159,7 +1162,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt7) { case 1 : - // CollectSymbols.g:234:5: ^( ASSIGN id= ID e= . ) + // CollectSymbols.g:236:5: ^( ASSIGN id= ID e= . ) { match(input,ASSIGN,FOLLOW_ASSIGN_in_labeledElement618); if (state.failed) return retval; @@ -1173,7 +1176,7 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:235:5: ^( PLUS_ASSIGN id= ID e= . ) + // CollectSymbols.g:237:5: ^( PLUS_ASSIGN id= ID e= . ) { match(input,PLUS_ASSIGN,FOLLOW_PLUS_ASSIGN_in_labeledElement634); if (state.failed) return retval; @@ -1214,16 +1217,16 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { }; // $ANTLR start "terminal" - // CollectSymbols.g:239:1: terminal : ({...}? STRING_LITERAL | TOKEN_REF ); + // CollectSymbols.g:241: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_LITERAL15=null; - GrammarAST TOKEN_REF16=null; + GrammarAST STRING_LITERAL16=null; + GrammarAST TOKEN_REF17=null; try { - // CollectSymbols.g:240:5: ({...}? STRING_LITERAL | TOKEN_REF ) + // CollectSymbols.g:242:5: ({...}? STRING_LITERAL | TOKEN_REF ) int alt8=2; int LA8_0 = input.LA(1); @@ -1242,19 +1245,19 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } switch (alt8) { case 1 : - // CollectSymbols.g:240:7: {...}? STRING_LITERAL + // CollectSymbols.g:242: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_LITERAL15=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal664); if (state.failed) return retval; + STRING_LITERAL16=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal664); if (state.failed) return retval; if ( state.backtracking==1 ) { terminals.add(((GrammarAST)retval.start)); - strings.add(STRING_LITERAL15); + strings.add(STRING_LITERAL16); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL15!=null?STRING_LITERAL15.getText():null), STRING_LITERAL15); + currentRule.alt[currentAlt].tokenRefs.map((STRING_LITERAL16!=null?STRING_LITERAL16.getText():null), STRING_LITERAL16); } } @@ -1262,15 +1265,15 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { } break; case 2 : - // CollectSymbols.g:248:7: TOKEN_REF + // CollectSymbols.g:250:7: TOKEN_REF { - TOKEN_REF16=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal679); if (state.failed) return retval; + TOKEN_REF17=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal679); if (state.failed) return retval; if ( state.backtracking==1 ) { - terminals.add(TOKEN_REF16); - tokenIDRefs.add(TOKEN_REF16); + terminals.add(TOKEN_REF17); + tokenIDRefs.add(TOKEN_REF17); if ( currentRule!=null ) { - currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF16!=null?TOKEN_REF16.getText():null), TOKEN_REF16); + currentRule.alt[currentAlt].tokenRefs.map((TOKEN_REF17!=null?TOKEN_REF17.getText():null), TOKEN_REF17); } } @@ -1292,20 +1295,20 @@ public class CollectSymbols extends org.antlr.v4.runtime.tree.TreeFilter { // $ANTLR start "ruleref" - // CollectSymbols.g:258:1: ruleref : RULE_REF ; + // CollectSymbols.g:260:1: ruleref : RULE_REF ; public final void ruleref() throws RecognitionException { - GrammarAST RULE_REF17=null; + GrammarAST RULE_REF18=null; try { - // CollectSymbols.g:260:5: ( RULE_REF ) - // CollectSymbols.g:260:7: RULE_REF + // CollectSymbols.g:262:5: ( RULE_REF ) + // CollectSymbols.g:262:7: RULE_REF { - RULE_REF17=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref704); if (state.failed) return ; + RULE_REF18=(GrammarAST)match(input,RULE_REF,FOLLOW_RULE_REF_in_ruleref704); if (state.failed) return ; if ( state.backtracking==1 ) { - rulerefs.add(RULE_REF17); + rulerefs.add(RULE_REF18); if ( currentRule!=null ) { - currentRule.alt[currentAlt].ruleRefs.map((RULE_REF17!=null?RULE_REF17.getText():null), RULE_REF17); + currentRule.alt[currentAlt].ruleRefs.map((RULE_REF18!=null?RULE_REF18.getText():null), RULE_REF18); } } diff --git a/tool/src/org/antlr/v4/tool/Alternative.java b/tool/src/org/antlr/v4/tool/Alternative.java index d676f988f..932da6d34 100644 --- a/tool/src/org/antlr/v4/tool/Alternative.java +++ b/tool/src/org/antlr/v4/tool/Alternative.java @@ -82,6 +82,13 @@ public class Alternative implements AttributeResolver { // return getParent().resolves(x, y, node); // } + + public AttributeScope resolveToDynamicScope(String x, ActionAST node) { + Rule r = resolveToRule(x, node); + if ( r!=null && r.scope!=null ) return r.scope; + return getParent().resolveToDynamicScope(x, node); + } + public Rule resolveToRule(String x, ActionAST node) { if ( ruleRefs.get(x)!=null ) return rule.g.getRule(x); List labels = labelDefs.get(x); diff --git a/tool/src/org/antlr/v4/tool/AttributeResolver.java b/tool/src/org/antlr/v4/tool/AttributeResolver.java index f1b427034..ca3ad004e 100644 --- a/tool/src/org/antlr/v4/tool/AttributeResolver.java +++ b/tool/src/org/antlr/v4/tool/AttributeResolver.java @@ -1,8 +1,8 @@ package org.antlr.v4.tool; /** Grammars, rules, and alternatives all have symbols visible to - * actions. To evaluate attr exprs, ask action for its space - * then ask space to resolve. If not found in one space we look + * actions. To evaluate attr exprs, ask action for its resolver + * then ask resolver to look up. If not found in one space we look * at parent. Alt's parent is rule; rule's parent is grammar. */ public interface AttributeResolver { @@ -10,6 +10,8 @@ public interface AttributeResolver { public Attribute resolveToAttribute(String x, ActionAST node); public Attribute resolveToAttribute(String x, String y, ActionAST node); public AttributeScope resolveToScope(String x, ActionAST node); + public AttributeScope resolveToDynamicScope(String x, ActionAST node); + //public Attribute resolveToDynamicScopeAttribute(String x, String y, ActionAST node); /** Resolve to surrounding rule, rule ref/label if in alt, or other rule */ public Rule resolveToRule(String x, ActionAST node); } diff --git a/tool/src/org/antlr/v4/tool/Grammar.java b/tool/src/org/antlr/v4/tool/Grammar.java index 26e8cb1f1..4404f748f 100644 --- a/tool/src/org/antlr/v4/tool/Grammar.java +++ b/tool/src/org/antlr/v4/tool/Grammar.java @@ -226,8 +226,16 @@ public class Grammar implements AttributeResolver { // $x can be scope (but not rule with scope) public AttributeScope resolveToScope(String x, ActionAST node) { + return resolveToDynamicScope(x, node); + } + + public AttributeScope resolveToDynamicScope(String x, ActionAST node) { AttributeScope s = scopes.get(x); - if ( s!=null ) return s; + if ( s !=null ) return s; + if ( node.resolver != this ) { // if not member action, can ref rule + Rule r = rules.get(x); + if ( r!=null ) return r.scope; + } return null; } diff --git a/tool/src/org/antlr/v4/tool/Rule.java b/tool/src/org/antlr/v4/tool/Rule.java index b2fccd527..de0d0a4c5 100644 --- a/tool/src/org/antlr/v4/tool/Rule.java +++ b/tool/src/org/antlr/v4/tool/Rule.java @@ -167,6 +167,12 @@ public class Rule implements AttributeResolver { return getParent().resolveToScope(x, node); } + public AttributeScope resolveToDynamicScope(String x, ActionAST node) { + Rule r = resolveToRule(x, node); + if ( r!=null && r.scope!=null ) return r.scope; + return getParent().resolveToDynamicScope(x, node); + } + public Rule resolveToRule(String x, ActionAST node) { if ( x.equals(this.name) ) return this; if ( node.resolver == this ) { // action not in alt (attr space is this rule) diff --git a/tool/test/org/antlr/v4/test/TestAttributeChecks.java b/tool/test/org/antlr/v4/test/TestAttributeChecks.java index 6ae42cbce..63d65a311 100644 --- a/tool/test/org/antlr/v4/test/TestAttributeChecks.java +++ b/tool/test/org/antlr/v4/test/TestAttributeChecks.java @@ -24,18 +24,19 @@ public class TestAttributeChecks extends BaseTest { String scopeTemplate = "parser grammar A;\n"+ "@members {\n" + + "\n" + "}\n" + "scope S { int i; }\n" + "a[int x] returns [int y]\n" + "scope { int z; }\n" + "scope S;\n" + - "@init {}\n" + - " : {}\n" + + "@init {}\n" + + " : {}\n" + " ;\n" + - " finally {}\n" + + " finally {}\n" + "b[int d] returns [int e]\n" + "scope { int f; }\n" + - " : {}\n" + + " : {}\n" + " ;\n" + "c : ;"; @@ -85,6 +86,38 @@ public class TestAttributeChecks extends BaseTest { "$lab.d", "error(31): A.g:8:18: unknown attribute rule d in $lab.d", }; + String[] dynMembersChecks = { + "$b::f", "error(54): A.g:3:1: unknown dynamic scope: b in $b::f", + "$S::j", "error(55): A.g:3:4: unknown dynamically-scoped attribute for scope S: j in $S::j", + "$S::j = 3;", "error(55): A.g:3:4: unknown dynamically-scoped attribute for scope S: j in $S::j = 3;", + "$S::j = $S::k;", "error(55): A.g:3:4: unknown dynamically-scoped attribute for scope S: j in $S::j = $S::k;\n" + + "error(55): A.g:3:12: unknown dynamically-scoped attribute for scope S: k in $S::k", + }; + + String[] dynInitChecks = { + "$b::f", "", + "$S::j", "error(55): A.g:8:11: unknown dynamically-scoped attribute for scope S: j in $S::j", + "$S::j = 3;", "error(55): A.g:8:11: unknown dynamically-scoped attribute for scope S: j in $S::j = 3;", + "$S::j = $S::k;", "error(55): A.g:8:11: unknown dynamically-scoped attribute for scope S: j in $S::j = $S::k;\n" + + "error(55): A.g:8:19: unknown dynamically-scoped attribute for scope S: k in $S::k", + }; + + String[] dynInlineChecks = { + "$b::f", "", + "$S::j", "error(55): A.g:9:13: unknown dynamically-scoped attribute for scope S: j in $S::j", + "$S::j = 3;", "error(55): A.g:9:13: unknown dynamically-scoped attribute for scope S: j in $S::j = 3;", + "$S::j = $S::k;", "error(55): A.g:9:13: unknown dynamically-scoped attribute for scope S: j in $S::j = $S::k;\n" + + "error(55): A.g:9:21: unknown dynamically-scoped attribute for scope S: k in $S::k", + }; + + String[] dynFinallyChecks = { + "$b::f", "", + "$S::j", "error(55): A.g:11:17: unknown dynamically-scoped attribute for scope S: j in $S::j", + "$S::j = 3;", "error(55): A.g:11:17: unknown dynamically-scoped attribute for scope S: j in $S::j = 3;", + "$S::j = $S::k;", "error(55): A.g:11:17: unknown dynamically-scoped attribute for scope S: j in $S::j = $S::k;\n" + + "error(55): A.g:11:25: unknown dynamically-scoped attribute for scope S: k in $S::k", + }; + @Test public void testMembersActions() throws RecognitionException { testActions("members", membersChecks, attributeTemplate); } @@ -101,6 +134,22 @@ public class TestAttributeChecks extends BaseTest { testActions("finally", finallyChecks, attributeTemplate); } + @Test public void testDynMembersActions() throws RecognitionException { + testActions("members", dynMembersChecks, scopeTemplate); + } + + @Test public void testDynInitActions() throws RecognitionException { + testActions("init", dynInitChecks, scopeTemplate); + } + + @Test public void testDynInlineActions() throws RecognitionException { + testActions("inline", dynInlineChecks, scopeTemplate); + } + + @Test public void testDynFinallyActions() throws RecognitionException { + testActions("finally", dynFinallyChecks, scopeTemplate); + } + public void testActions(String location, String[] pairs, String template) { for (int i = 0; i < pairs.length; i+=2) { String action = pairs[i];