add def sym; fix errors so they ignore right of ->

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6666]
This commit is contained in:
parrt 2010-02-04 18:01:47 -08:00
parent 9b0d27b1b7
commit ffd60dc26b
11 changed files with 1739 additions and 845 deletions

View File

@ -1,4 +1,4 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 ANTLRLexer.g 2010-02-03 15:37:27
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 ANTLRLexer.g 2010-02-04 17:29:59
/*
[The "BSD licence"]
@ -263,7 +263,7 @@ public class ANTLRLexer extends Lexer {
if ( (( input.LA(2) != '/')) ) {
alt3=1;
}
else if ( (((( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') ))||( true ))) ) {
else if ( ((( true )||(( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') )))) ) {
alt3=2;
}
else {

View File

@ -834,8 +834,7 @@ rewriteTreeAlt
rewriteTreeElement
: rewriteTreeAtom
| rewriteTreeAtom ebnfSuffix
-> ^( ebnfSuffix ^(REWRITE_BLOCK ^(ALT rewriteTreeAtom)) )
| rewriteTreeAtom ebnfSuffix -> ^( ebnfSuffix ^(REWRITE_BLOCK ^(ALT rewriteTreeAtom)) )
| rewriteTree
( ebnfSuffix
-> ^(ebnfSuffix ^(REWRITE_BLOCK ^(ALT rewriteTree)) )
@ -845,9 +844,9 @@ rewriteTreeElement
;
rewriteTreeAtom
: TOKEN_REF ARG_ACTION? -> ^(TOKEN_REF<TerminalAST> ARG_ACTION?) // for imaginary nodes
: TOKEN_REF elementOptions? ARG_ACTION? -> ^(TOKEN_REF<TerminalAST> elementOptions? ARG_ACTION?) // for imaginary nodes
| RULE_REF
| STRING_LITERAL<TerminalAST>
| STRING_LITERAL elementOptions? -> ^(STRING_LITERAL<TerminalAST> elementOptions?)
| DOLLAR id -> LABEL[$DOLLAR,$id.text] // reference to a label in a rewrite rule
| ACTION
;

File diff suppressed because it is too large Load Diff

View File

@ -372,10 +372,13 @@ rewriteTreeElement
;
rewriteTreeAtom
: ^(TOKEN_REF ARG_ACTION)
: ^(TOKEN_REF elementOptions ARG_ACTION)
| ^(TOKEN_REF elementOptions)
| ^(TOKEN_REF ARG_ACTION)
| TOKEN_REF
| RULE_REF
| STRING_LITERAL
| ^(STRING_LITERAL elementOptions)
| STRING_LITERAL
| LABEL
| ACTION
;

View File

@ -1,4 +1,4 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 ASTVerifier.g 2010-02-03 15:37:30
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 ASTVerifier.g 2010-02-04 17:30:02
/*
[The "BSD license"]
@ -3636,102 +3636,106 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTreeAtom"
// ASTVerifier.g:374:1: rewriteTreeAtom : ( ^( TOKEN_REF ARG_ACTION ) | TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL | ACTION );
// ASTVerifier.g:374:1: rewriteTreeAtom : ( ^( TOKEN_REF elementOptions ARG_ACTION ) | ^( TOKEN_REF elementOptions ) | ^( TOKEN_REF ARG_ACTION ) | TOKEN_REF | RULE_REF | ^( STRING_LITERAL elementOptions ) | STRING_LITERAL | LABEL | ACTION );
public final void rewriteTreeAtom() throws RecognitionException {
try {
// ASTVerifier.g:375:5: ( ^( TOKEN_REF ARG_ACTION ) | TOKEN_REF | RULE_REF | STRING_LITERAL | LABEL | ACTION )
int alt51=6;
switch ( input.LA(1) ) {
case TOKEN_REF:
{
int LA51_1 = input.LA(2);
if ( (LA51_1==DOWN) ) {
alt51=1;
}
else if ( (LA51_1==UP||LA51_1==ACTION||LA51_1==TREE_BEGIN||(LA51_1>=TOKEN_REF && LA51_1<=RULE_REF)||LA51_1==STRING_LITERAL||(LA51_1>=OPTIONAL && LA51_1<=POSITIVE_CLOSURE)||LA51_1==LABEL) ) {
alt51=2;
}
else {
NoViableAltException nvae =
new NoViableAltException("", 51, 1, input);
throw nvae;
}
}
break;
case RULE_REF:
{
alt51=3;
}
break;
case STRING_LITERAL:
{
alt51=4;
}
break;
case LABEL:
{
alt51=5;
}
break;
case ACTION:
{
alt51=6;
}
break;
default:
NoViableAltException nvae =
new NoViableAltException("", 51, 0, input);
throw nvae;
}
// ASTVerifier.g:375:5: ( ^( TOKEN_REF elementOptions ARG_ACTION ) | ^( TOKEN_REF elementOptions ) | ^( TOKEN_REF ARG_ACTION ) | TOKEN_REF | RULE_REF | ^( STRING_LITERAL elementOptions ) | STRING_LITERAL | LABEL | ACTION )
int alt51=9;
alt51 = dfa51.predict(input);
switch (alt51) {
case 1 :
// ASTVerifier.g:375:9: ^( TOKEN_REF ARG_ACTION )
// ASTVerifier.g:375:9: ^( TOKEN_REF elementOptions ARG_ACTION )
{
match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom1657);
match(input, Token.DOWN, null);
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_rewriteTreeAtom1659);
pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom1659);
elementOptions();
state._fsp--;
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_rewriteTreeAtom1661);
match(input, Token.UP, null);
}
break;
case 2 :
// ASTVerifier.g:376:6: TOKEN_REF
// ASTVerifier.g:376:9: ^( TOKEN_REF elementOptions )
{
match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom1667);
match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom1673);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom1675);
elementOptions();
state._fsp--;
match(input, Token.UP, null);
}
break;
case 3 :
// ASTVerifier.g:377:9: RULE_REF
// ASTVerifier.g:377:9: ^( TOKEN_REF ARG_ACTION )
{
match(input,RULE_REF,FOLLOW_RULE_REF_in_rewriteTreeAtom1677);
match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom1687);
match(input, Token.DOWN, null);
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_rewriteTreeAtom1689);
match(input, Token.UP, null);
}
break;
case 4 :
// ASTVerifier.g:378:6: STRING_LITERAL
// ASTVerifier.g:378:6: TOKEN_REF
{
match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1684);
match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_rewriteTreeAtom1697);
}
break;
case 5 :
// ASTVerifier.g:379:6: LABEL
// ASTVerifier.g:379:9: RULE_REF
{
match(input,LABEL,FOLLOW_LABEL_in_rewriteTreeAtom1691);
match(input,RULE_REF,FOLLOW_RULE_REF_in_rewriteTreeAtom1707);
}
break;
case 6 :
// ASTVerifier.g:380:4: ACTION
// ASTVerifier.g:380:6: ^( STRING_LITERAL elementOptions )
{
match(input,ACTION,FOLLOW_ACTION_in_rewriteTreeAtom1696);
match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1715);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_elementOptions_in_rewriteTreeAtom1717);
elementOptions();
state._fsp--;
match(input, Token.UP, null);
}
break;
case 7 :
// ASTVerifier.g:381:6: STRING_LITERAL
{
match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1725);
}
break;
case 8 :
// ASTVerifier.g:382:6: LABEL
{
match(input,LABEL,FOLLOW_LABEL_in_rewriteTreeAtom1733);
}
break;
case 9 :
// ASTVerifier.g:383:4: ACTION
{
match(input,ACTION,FOLLOW_ACTION_in_rewriteTreeAtom1738);
}
break;
@ -3750,23 +3754,23 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTreeEbnf"
// ASTVerifier.g:383:1: rewriteTreeEbnf : ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) ) ;
// ASTVerifier.g:386:1: rewriteTreeEbnf : ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) ) ;
public final void rewriteTreeEbnf() throws RecognitionException {
try {
// ASTVerifier.g:384:2: ( ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) ) )
// ASTVerifier.g:384:4: ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) )
// ASTVerifier.g:387:2: ( ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) ) )
// ASTVerifier.g:387:4: ^( ebnfSuffix ^( REWRITE_BLOCK rewriteTreeAlt ) )
{
pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeEbnf1708);
pushFollow(FOLLOW_ebnfSuffix_in_rewriteTreeEbnf1750);
ebnfSuffix();
state._fsp--;
match(input, Token.DOWN, null);
match(input,REWRITE_BLOCK,FOLLOW_REWRITE_BLOCK_in_rewriteTreeEbnf1711);
match(input,REWRITE_BLOCK,FOLLOW_REWRITE_BLOCK_in_rewriteTreeEbnf1753);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf1713);
pushFollow(FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf1755);
rewriteTreeAlt();
state._fsp--;
@ -3791,21 +3795,21 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTree"
// ASTVerifier.g:386:1: rewriteTree : ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* ) ;
// ASTVerifier.g:389:1: rewriteTree : ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* ) ;
public final void rewriteTree() throws RecognitionException {
try {
// ASTVerifier.g:387:2: ( ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* ) )
// ASTVerifier.g:387:4: ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* )
// ASTVerifier.g:390:2: ( ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* ) )
// ASTVerifier.g:390:4: ^( TREE_BEGIN rewriteTreeAtom ( rewriteTreeElement )* )
{
match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_rewriteTree1726);
match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_rewriteTree1768);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTree1728);
pushFollow(FOLLOW_rewriteTreeAtom_in_rewriteTree1770);
rewriteTreeAtom();
state._fsp--;
// ASTVerifier.g:387:33: ( rewriteTreeElement )*
// ASTVerifier.g:390:33: ( rewriteTreeElement )*
loop52:
do {
int alt52=2;
@ -3818,9 +3822,9 @@ public class ASTVerifier extends TreeParser {
switch (alt52) {
case 1 :
// ASTVerifier.g:387:33: rewriteTreeElement
// ASTVerifier.g:390:33: rewriteTreeElement
{
pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTree1730);
pushFollow(FOLLOW_rewriteTreeElement_in_rewriteTree1772);
rewriteTreeElement();
state._fsp--;
@ -3852,20 +3856,20 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTemplate"
// ASTVerifier.g:390:1: rewriteTemplate : ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION );
// ASTVerifier.g:393:1: rewriteTemplate : ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION );
public final void rewriteTemplate() throws RecognitionException {
try {
// ASTVerifier.g:391:2: ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION )
// ASTVerifier.g:394:2: ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION )
int alt55=5;
alt55 = dfa55.predict(input);
switch (alt55) {
case 1 :
// ASTVerifier.g:391:4: ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL )
// ASTVerifier.g:394:4: ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL )
{
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate1745);
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate1787);
match(input, Token.DOWN, null);
// ASTVerifier.g:391:15: ( rewriteTemplateArgs )?
// ASTVerifier.g:394:15: ( rewriteTemplateArgs )?
int alt53=2;
int LA53_0 = input.LA(1);
@ -3874,9 +3878,9 @@ public class ASTVerifier extends TreeParser {
}
switch (alt53) {
case 1 :
// ASTVerifier.g:391:15: rewriteTemplateArgs
// ASTVerifier.g:394:15: rewriteTemplateArgs
{
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1747);
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1789);
rewriteTemplateArgs();
state._fsp--;
@ -3887,19 +3891,19 @@ public class ASTVerifier extends TreeParser {
}
match(input,DOUBLE_QUOTE_STRING_LITERAL,FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate1750);
match(input,DOUBLE_QUOTE_STRING_LITERAL,FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate1792);
match(input, Token.UP, null);
}
break;
case 2 :
// ASTVerifier.g:392:4: ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL )
// ASTVerifier.g:395:4: ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL )
{
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate1757);
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplate1799);
match(input, Token.DOWN, null);
// ASTVerifier.g:392:15: ( rewriteTemplateArgs )?
// ASTVerifier.g:395:15: ( rewriteTemplateArgs )?
int alt54=2;
int LA54_0 = input.LA(1);
@ -3908,9 +3912,9 @@ public class ASTVerifier extends TreeParser {
}
switch (alt54) {
case 1 :
// ASTVerifier.g:392:15: rewriteTemplateArgs
// ASTVerifier.g:395:15: rewriteTemplateArgs
{
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1759);
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1801);
rewriteTemplateArgs();
state._fsp--;
@ -3921,16 +3925,16 @@ public class ASTVerifier extends TreeParser {
}
match(input,DOUBLE_ANGLE_STRING_LITERAL,FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate1762);
match(input,DOUBLE_ANGLE_STRING_LITERAL,FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate1804);
match(input, Token.UP, null);
}
break;
case 3 :
// ASTVerifier.g:393:4: rewriteTemplateRef
// ASTVerifier.g:396:4: rewriteTemplateRef
{
pushFollow(FOLLOW_rewriteTemplateRef_in_rewriteTemplate1768);
pushFollow(FOLLOW_rewriteTemplateRef_in_rewriteTemplate1810);
rewriteTemplateRef();
state._fsp--;
@ -3939,9 +3943,9 @@ public class ASTVerifier extends TreeParser {
}
break;
case 4 :
// ASTVerifier.g:394:4: rewriteIndirectTemplateHead
// ASTVerifier.g:397:4: rewriteIndirectTemplateHead
{
pushFollow(FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate1773);
pushFollow(FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate1815);
rewriteIndirectTemplateHead();
state._fsp--;
@ -3950,9 +3954,9 @@ public class ASTVerifier extends TreeParser {
}
break;
case 5 :
// ASTVerifier.g:395:4: ACTION
// ASTVerifier.g:398:4: ACTION
{
match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplate1778);
match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplate1820);
}
break;
@ -3971,17 +3975,17 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTemplateRef"
// ASTVerifier.g:398:1: rewriteTemplateRef : ^( TEMPLATE ID ( rewriteTemplateArgs )? ) ;
// ASTVerifier.g:401:1: rewriteTemplateRef : ^( TEMPLATE ID ( rewriteTemplateArgs )? ) ;
public final void rewriteTemplateRef() throws RecognitionException {
try {
// ASTVerifier.g:399:2: ( ^( TEMPLATE ID ( rewriteTemplateArgs )? ) )
// ASTVerifier.g:399:4: ^( TEMPLATE ID ( rewriteTemplateArgs )? )
// ASTVerifier.g:402:2: ( ^( TEMPLATE ID ( rewriteTemplateArgs )? ) )
// ASTVerifier.g:402:4: ^( TEMPLATE ID ( rewriteTemplateArgs )? )
{
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplateRef1790);
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteTemplateRef1832);
match(input, Token.DOWN, null);
match(input,ID,FOLLOW_ID_in_rewriteTemplateRef1792);
// ASTVerifier.g:399:18: ( rewriteTemplateArgs )?
match(input,ID,FOLLOW_ID_in_rewriteTemplateRef1834);
// ASTVerifier.g:402:18: ( rewriteTemplateArgs )?
int alt56=2;
int LA56_0 = input.LA(1);
@ -3990,9 +3994,9 @@ public class ASTVerifier extends TreeParser {
}
switch (alt56) {
case 1 :
// ASTVerifier.g:399:18: rewriteTemplateArgs
// ASTVerifier.g:402:18: rewriteTemplateArgs
{
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef1794);
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef1836);
rewriteTemplateArgs();
state._fsp--;
@ -4021,17 +4025,17 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteIndirectTemplateHead"
// ASTVerifier.g:402:1: rewriteIndirectTemplateHead : ^( TEMPLATE ACTION ( rewriteTemplateArgs )? ) ;
// ASTVerifier.g:405:1: rewriteIndirectTemplateHead : ^( TEMPLATE ACTION ( rewriteTemplateArgs )? ) ;
public final void rewriteIndirectTemplateHead() throws RecognitionException {
try {
// ASTVerifier.g:403:2: ( ^( TEMPLATE ACTION ( rewriteTemplateArgs )? ) )
// ASTVerifier.g:403:4: ^( TEMPLATE ACTION ( rewriteTemplateArgs )? )
// ASTVerifier.g:406:2: ( ^( TEMPLATE ACTION ( rewriteTemplateArgs )? ) )
// ASTVerifier.g:406:4: ^( TEMPLATE ACTION ( rewriteTemplateArgs )? )
{
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteIndirectTemplateHead1808);
match(input,TEMPLATE,FOLLOW_TEMPLATE_in_rewriteIndirectTemplateHead1850);
match(input, Token.DOWN, null);
match(input,ACTION,FOLLOW_ACTION_in_rewriteIndirectTemplateHead1810);
// ASTVerifier.g:403:22: ( rewriteTemplateArgs )?
match(input,ACTION,FOLLOW_ACTION_in_rewriteIndirectTemplateHead1852);
// ASTVerifier.g:406:22: ( rewriteTemplateArgs )?
int alt57=2;
int LA57_0 = input.LA(1);
@ -4040,9 +4044,9 @@ public class ASTVerifier extends TreeParser {
}
switch (alt57) {
case 1 :
// ASTVerifier.g:403:22: rewriteTemplateArgs
// ASTVerifier.g:406:22: rewriteTemplateArgs
{
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead1812);
pushFollow(FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead1854);
rewriteTemplateArgs();
state._fsp--;
@ -4071,16 +4075,16 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTemplateArgs"
// ASTVerifier.g:406:1: rewriteTemplateArgs : ^( ARGLIST ( rewriteTemplateArg )+ ) ;
// ASTVerifier.g:409:1: rewriteTemplateArgs : ^( ARGLIST ( rewriteTemplateArg )+ ) ;
public final void rewriteTemplateArgs() throws RecognitionException {
try {
// ASTVerifier.g:407:2: ( ^( ARGLIST ( rewriteTemplateArg )+ ) )
// ASTVerifier.g:407:4: ^( ARGLIST ( rewriteTemplateArg )+ )
// ASTVerifier.g:410:2: ( ^( ARGLIST ( rewriteTemplateArg )+ ) )
// ASTVerifier.g:410:4: ^( ARGLIST ( rewriteTemplateArg )+ )
{
match(input,ARGLIST,FOLLOW_ARGLIST_in_rewriteTemplateArgs1826);
match(input,ARGLIST,FOLLOW_ARGLIST_in_rewriteTemplateArgs1868);
match(input, Token.DOWN, null);
// ASTVerifier.g:407:14: ( rewriteTemplateArg )+
// ASTVerifier.g:410:14: ( rewriteTemplateArg )+
int cnt58=0;
loop58:
do {
@ -4094,9 +4098,9 @@ public class ASTVerifier extends TreeParser {
switch (alt58) {
case 1 :
// ASTVerifier.g:407:14: rewriteTemplateArg
// ASTVerifier.g:410:14: rewriteTemplateArg
{
pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs1828);
pushFollow(FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs1870);
rewriteTemplateArg();
state._fsp--;
@ -4132,17 +4136,17 @@ public class ASTVerifier extends TreeParser {
// $ANTLR start "rewriteTemplateArg"
// ASTVerifier.g:410:1: rewriteTemplateArg : ^( ARG ID ACTION ) ;
// ASTVerifier.g:413:1: rewriteTemplateArg : ^( ARG ID ACTION ) ;
public final void rewriteTemplateArg() throws RecognitionException {
try {
// ASTVerifier.g:411:2: ( ^( ARG ID ACTION ) )
// ASTVerifier.g:411:6: ^( ARG ID ACTION )
// ASTVerifier.g:414:2: ( ^( ARG ID ACTION ) )
// ASTVerifier.g:414:6: ^( ARG ID ACTION )
{
match(input,ARG,FOLLOW_ARG_in_rewriteTemplateArg1844);
match(input,ARG,FOLLOW_ARG_in_rewriteTemplateArg1886);
match(input, Token.DOWN, null);
match(input,ID,FOLLOW_ID_in_rewriteTemplateArg1846);
match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplateArg1848);
match(input,ID,FOLLOW_ID_in_rewriteTemplateArg1888);
match(input,ACTION,FOLLOW_ACTION_in_rewriteTemplateArg1890);
match(input, Token.UP, null);
@ -4165,6 +4169,7 @@ public class ASTVerifier extends TreeParser {
protected DFA26 dfa26 = new DFA26(this);
protected DFA33 dfa33 = new DFA33(this);
protected DFA42 dfa42 = new DFA42(this);
protected DFA51 dfa51 = new DFA51(this);
protected DFA55 dfa55 = new DFA55(this);
static final String DFA26_eotS =
"\14\uffff";
@ -4382,6 +4387,83 @@ public class ASTVerifier extends TreeParser {
return "320:1: terminal : ( ^( STRING_LITERAL elementOptions ) | STRING_LITERAL | ^( TOKEN_REF ARG_ACTION elementOptions ) | ^( TOKEN_REF ARG_ACTION ) | ^( TOKEN_REF elementOptions ) | TOKEN_REF | ^( WILDCARD elementOptions ) | WILDCARD | ^( ROOT terminal ) | ^( BANG terminal ) );";
}
}
static final String DFA51_eotS =
"\30\uffff";
static final String DFA51_eofS =
"\30\uffff";
static final String DFA51_minS =
"\1\20\1\2\1\uffff\1\2\2\uffff\1\16\4\uffff\1\2\1\55\1\3\1\2\1\3"+
"\1\127\2\uffff\1\103\4\3";
static final String DFA51_maxS =
"\2\134\1\uffff\1\134\2\uffff\1\142\4\uffff\1\2\2\127\1\2\1\16\1"+
"\127\2\uffff\1\127\2\3\2\127";
static final String DFA51_acceptS =
"\2\uffff\1\5\1\uffff\1\10\1\11\1\uffff\1\4\1\6\1\7\1\3\6\uffff\1"+
"\1\1\2\5\uffff";
static final String DFA51_specialS =
"\30\uffff}>";
static final String[] DFA51_transitionS = {
"\1\5\55\uffff\1\1\1\2\3\uffff\1\3\30\uffff\1\4",
"\1\6\1\7\14\uffff\1\7\51\uffff\1\7\3\uffff\2\7\3\uffff\1\7"+
"\12\uffff\3\7\13\uffff\1\7",
"",
"\1\10\1\11\14\uffff\1\11\51\uffff\1\11\3\uffff\2\11\3\uffff"+
"\1\11\12\uffff\3\11\13\uffff\1\11",
"",
"",
"\1\12\123\uffff\1\13",
"",
"",
"",
"",
"\1\14",
"\1\16\51\uffff\1\15",
"\1\17\51\uffff\1\16\51\uffff\1\15",
"\1\20",
"\1\22\12\uffff\1\21",
"\1\23",
"",
"",
"\1\25\23\uffff\1\24",
"\1\26",
"\1\27",
"\1\17\51\uffff\1\16\51\uffff\1\15",
"\1\17\51\uffff\1\16\51\uffff\1\15"
};
static final short[] DFA51_eot = DFA.unpackEncodedString(DFA51_eotS);
static final short[] DFA51_eof = DFA.unpackEncodedString(DFA51_eofS);
static final char[] DFA51_min = DFA.unpackEncodedStringToUnsignedChars(DFA51_minS);
static final char[] DFA51_max = DFA.unpackEncodedStringToUnsignedChars(DFA51_maxS);
static final short[] DFA51_accept = DFA.unpackEncodedString(DFA51_acceptS);
static final short[] DFA51_special = DFA.unpackEncodedString(DFA51_specialS);
static final short[][] DFA51_transition;
static {
int numStates = DFA51_transitionS.length;
DFA51_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA51_transition[i] = DFA.unpackEncodedString(DFA51_transitionS[i]);
}
}
class DFA51 extends DFA {
public DFA51(BaseRecognizer recognizer) {
this.recognizer = recognizer;
this.decisionNumber = 51;
this.eot = DFA51_eot;
this.eof = DFA51_eof;
this.min = DFA51_min;
this.max = DFA51_max;
this.accept = DFA51_accept;
this.special = DFA51_special;
this.transition = DFA51_transition;
}
public String getDescription() {
return "374:1: rewriteTreeAtom : ( ^( TOKEN_REF elementOptions ARG_ACTION ) | ^( TOKEN_REF elementOptions ) | ^( TOKEN_REF ARG_ACTION ) | TOKEN_REF | RULE_REF | ^( STRING_LITERAL elementOptions ) | STRING_LITERAL | LABEL | ACTION );";
}
}
static final String DFA55_eotS =
"\20\uffff";
static final String DFA55_eofS =
@ -4393,14 +4475,14 @@ public class ASTVerifier extends TreeParser {
"\1\43\1\2\1\uffff\1\131\2\uffff\1\2\2\uffff\1\130\1\2\1\127\1\20"+
"\1\3\1\130\1\13";
static final String DFA55_acceptS =
"\2\uffff\1\5\1\uffff\1\3\1\4\1\uffff\1\2\1\1\7\uffff";
"\2\uffff\1\5\1\uffff\1\3\1\4\1\uffff\1\1\1\2\7\uffff";
static final String DFA55_specialS =
"\20\uffff}>";
static final String[] DFA55_transitionS = {
"\1\2\22\uffff\1\1",
"\1\3",
"",
"\1\10\1\7\4\uffff\1\5\106\uffff\1\4\1\uffff\1\6",
"\1\7\1\10\4\uffff\1\5\106\uffff\1\4\1\uffff\1\6",
"",
"",
"\1\11",
@ -4412,7 +4494,7 @@ public class ASTVerifier extends TreeParser {
"\1\15",
"\1\16",
"\1\17\124\uffff\1\12",
"\1\10\1\7"
"\1\7\1\10"
};
static final short[] DFA55_eot = DFA.unpackEncodedString(DFA55_eotS);
@ -4445,7 +4527,7 @@ public class ASTVerifier extends TreeParser {
this.transition = DFA55_transition;
}
public String getDescription() {
return "390:1: rewriteTemplate : ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION );";
return "393:1: rewriteTemplate : ( ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_QUOTE_STRING_LITERAL ) | ^( TEMPLATE ( rewriteTemplateArgs )? DOUBLE_ANGLE_STRING_LITERAL ) | rewriteTemplateRef | rewriteIndirectTemplateHead | ACTION );";
}
}
@ -4645,37 +4727,44 @@ public class ASTVerifier extends TreeParser {
public static final BitSet FOLLOW_rewriteTree_in_rewriteTreeElement1633 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_rewriteTreeEbnf_in_rewriteTreeElement1640 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom1657 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_rewriteTreeAtom1659 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom1667 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_REF_in_rewriteTreeAtom1677 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1684 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_LABEL_in_rewriteTreeAtom1691 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ACTION_in_rewriteTreeAtom1696 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeEbnf1708 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_REWRITE_BLOCK_in_rewriteTreeEbnf1711 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf1713 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TREE_BEGIN_in_rewriteTree1726 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTree1728 = new BitSet(new long[]{0xC400000000010008L,0x000000001001C008L});
public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTree1730 = new BitSet(new long[]{0xC400000000010008L,0x000000001001C008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate1745 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1747 = new BitSet(new long[]{0x0000000000000400L});
public static final BitSet FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate1750 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate1757 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1759 = new BitSet(new long[]{0x0000000000000800L});
public static final BitSet FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate1762 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_rewriteTemplateRef_in_rewriteTemplate1768 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate1773 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ACTION_in_rewriteTemplate1778 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplateRef1790 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rewriteTemplateRef1792 = new BitSet(new long[]{0x0000000000000008L,0x0000000002000000L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef1794 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteIndirectTemplateHead1808 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ACTION_in_rewriteIndirectTemplateHead1810 = new BitSet(new long[]{0x0000000000000008L,0x0000000002000000L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead1812 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ARGLIST_in_rewriteTemplateArgs1826 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs1828 = new BitSet(new long[]{0x0000000000000008L,0x0000000001000000L});
public static final BitSet FOLLOW_ARG_in_rewriteTemplateArg1844 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rewriteTemplateArg1846 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_rewriteTemplateArg1848 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom1659 = new BitSet(new long[]{0x0000000000004000L});
public static final BitSet FOLLOW_ARG_ACTION_in_rewriteTreeAtom1661 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom1673 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom1675 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom1687 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_rewriteTreeAtom1689 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TOKEN_REF_in_rewriteTreeAtom1697 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_REF_in_rewriteTreeAtom1707 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1715 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_elementOptions_in_rewriteTreeAtom1717 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_rewriteTreeAtom1725 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_LABEL_in_rewriteTreeAtom1733 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ACTION_in_rewriteTreeAtom1738 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ebnfSuffix_in_rewriteTreeEbnf1750 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_REWRITE_BLOCK_in_rewriteTreeEbnf1753 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTreeAlt_in_rewriteTreeEbnf1755 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TREE_BEGIN_in_rewriteTree1768 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTreeAtom_in_rewriteTree1770 = new BitSet(new long[]{0xC400000000010008L,0x000000001001C008L});
public static final BitSet FOLLOW_rewriteTreeElement_in_rewriteTree1772 = new BitSet(new long[]{0xC400000000010008L,0x000000001001C008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate1787 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1789 = new BitSet(new long[]{0x0000000000000400L});
public static final BitSet FOLLOW_DOUBLE_QUOTE_STRING_LITERAL_in_rewriteTemplate1792 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplate1799 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplate1801 = new BitSet(new long[]{0x0000000000000800L});
public static final BitSet FOLLOW_DOUBLE_ANGLE_STRING_LITERAL_in_rewriteTemplate1804 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_rewriteTemplateRef_in_rewriteTemplate1810 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_rewriteIndirectTemplateHead_in_rewriteTemplate1815 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ACTION_in_rewriteTemplate1820 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteTemplateRef1832 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rewriteTemplateRef1834 = new BitSet(new long[]{0x0000000000000008L,0x0000000002000000L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteTemplateRef1836 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TEMPLATE_in_rewriteIndirectTemplateHead1850 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ACTION_in_rewriteIndirectTemplateHead1852 = new BitSet(new long[]{0x0000000000000008L,0x0000000002000000L});
public static final BitSet FOLLOW_rewriteTemplateArgs_in_rewriteIndirectTemplateHead1854 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ARGLIST_in_rewriteTemplateArgs1868 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_rewriteTemplateArg_in_rewriteTemplateArgs1870 = new BitSet(new long[]{0x0000000000000008L,0x0000000001000000L});
public static final BitSet FOLLOW_ARG_in_rewriteTemplateArg1886 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rewriteTemplateArg1888 = new BitSet(new long[]{0x0000000000010000L});
public static final BitSet FOLLOW_ACTION_in_rewriteTemplateArg1890 = new BitSet(new long[]{0x0000000000000008L});
}

View File

@ -175,12 +175,14 @@ tokenAlias
;
tokenRefWithArgs
: ^(TOKEN_REF ARG_ACTION)
: {!inContext("RESULT ...")}? // if not on right side of ->
^(TOKEN_REF ARG_ACTION)
{BasicSemanticChecks.checkTokenArgs(g.getType(), $TOKEN_REF.token);}
;
elementOption
: ^( ELEMENT_OPTIONS
: {!inContext("RESULT ...")}? // not on right side of ->
^( ELEMENT_OPTIONS
( ^(ASSIGN o=ID value=ID)
| ^(ASSIGN o=ID value=STRING_LITERAL)
| o=ID

View File

@ -1,4 +1,4 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 BasicSemanticTriggers.g 2010-02-03 15:37:39
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 BasicSemanticTriggers.g 2010-02-04 17:59:03
/*
[The "BSD license"]
@ -1048,18 +1048,22 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
// $ANTLR start "tokenRefWithArgs"
// BasicSemanticTriggers.g:177:1: tokenRefWithArgs : ^( TOKEN_REF ARG_ACTION ) ;
// BasicSemanticTriggers.g:177:1: tokenRefWithArgs : {...}? ^( TOKEN_REF ARG_ACTION ) ;
public final void tokenRefWithArgs() throws RecognitionException {
GrammarAST TOKEN_REF7=null;
try {
// BasicSemanticTriggers.g:178:2: ( ^( TOKEN_REF ARG_ACTION ) )
// BasicSemanticTriggers.g:178:4: ^( TOKEN_REF ARG_ACTION )
// BasicSemanticTriggers.g:178:2: ({...}? ^( TOKEN_REF ARG_ACTION ) )
// BasicSemanticTriggers.g:178:4: {...}? ^( TOKEN_REF ARG_ACTION )
{
TOKEN_REF7=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_tokenRefWithArgs530); if (state.failed) return ;
if ( !((!inContext("RESULT ..."))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "tokenRefWithArgs", "!inContext(\"RESULT ...\")");
}
TOKEN_REF7=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_tokenRefWithArgs538); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_tokenRefWithArgs532); if (state.failed) return ;
match(input,ARG_ACTION,FOLLOW_ARG_ACTION_in_tokenRefWithArgs540); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
@ -1083,7 +1087,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
};
// $ANTLR start "elementOption"
// BasicSemanticTriggers.g:182:1: elementOption : ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) ;
// BasicSemanticTriggers.g:183:1: elementOption : {...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) ;
public final BasicSemanticTriggers.elementOption_return elementOption() throws RecognitionException {
BasicSemanticTriggers.elementOption_return retval = new BasicSemanticTriggers.elementOption_return();
retval.start = input.LT(1);
@ -1092,13 +1096,17 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
GrammarAST value=null;
try {
// BasicSemanticTriggers.g:183:5: ( ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) )
// BasicSemanticTriggers.g:183:7: ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) )
// BasicSemanticTriggers.g:184:5: ({...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) ) )
// BasicSemanticTriggers.g:184:7: {...}? ^( ELEMENT_OPTIONS ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID ) )
{
match(input,ELEMENT_OPTIONS,FOLLOW_ELEMENT_OPTIONS_in_elementOption554); if (state.failed) return retval;
if ( !((!inContext("RESULT ..."))) ) {
if (state.backtracking>0) {state.failed=true; return retval;}
throw new FailedPredicateException(input, "elementOption", "!inContext(\"RESULT ...\")");
}
match(input,ELEMENT_OPTIONS,FOLLOW_ELEMENT_OPTIONS_in_elementOption570); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
// BasicSemanticTriggers.g:184:7: ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID )
// BasicSemanticTriggers.g:186:7: ( ^( ASSIGN o= ID value= ID ) | ^( ASSIGN o= ID value= STRING_LITERAL ) | o= ID )
int alt11=3;
int LA11_0 = input.LA(1);
@ -1153,35 +1161,35 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
}
switch (alt11) {
case 1 :
// BasicSemanticTriggers.g:184:9: ^( ASSIGN o= ID value= ID )
// BasicSemanticTriggers.g:186:9: ^( ASSIGN o= ID value= ID )
{
match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption565); if (state.failed) return retval;
match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption581); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption569); if (state.failed) return retval;
value=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption573); if (state.failed) return retval;
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption585); if (state.failed) return retval;
value=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption589); if (state.failed) return retval;
match(input, Token.UP, null); if (state.failed) return retval;
}
break;
case 2 :
// BasicSemanticTriggers.g:185:11: ^( ASSIGN o= ID value= STRING_LITERAL )
// BasicSemanticTriggers.g:187:11: ^( ASSIGN o= ID value= STRING_LITERAL )
{
match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption587); if (state.failed) return retval;
match(input,ASSIGN,FOLLOW_ASSIGN_in_elementOption603); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption591); if (state.failed) return retval;
value=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_elementOption595); if (state.failed) return retval;
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption607); if (state.failed) return retval;
value=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_elementOption611); if (state.failed) return retval;
match(input, Token.UP, null); if (state.failed) return retval;
}
break;
case 3 :
// BasicSemanticTriggers.g:186:10: o= ID
// BasicSemanticTriggers.g:188:10: o= ID
{
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption609); if (state.failed) return retval;
o=(GrammarAST)match(input,ID,FOLLOW_ID_in_elementOption625); if (state.failed) return retval;
}
break;
@ -1224,21 +1232,21 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
};
// $ANTLR start "multiElementAltInTreeGrammar"
// BasicSemanticTriggers.g:206:1: multiElementAltInTreeGrammar : {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) ;
// BasicSemanticTriggers.g:208:1: multiElementAltInTreeGrammar : {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) ;
public final BasicSemanticTriggers.multiElementAltInTreeGrammar_return multiElementAltInTreeGrammar() throws RecognitionException {
BasicSemanticTriggers.multiElementAltInTreeGrammar_return retval = new BasicSemanticTriggers.multiElementAltInTreeGrammar_return();
retval.start = input.LT(1);
try {
// BasicSemanticTriggers.g:207:2: ({...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) )
// BasicSemanticTriggers.g:207:4: {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ )
// BasicSemanticTriggers.g:209:2: ({...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ ) )
// BasicSemanticTriggers.g:209:4: {...}? ^( ALT ~ ( SEMPRED | ACTION ) (~ ( SEMPRED | ACTION ) )+ )
{
if ( !((inContext("ALT_REWRITE") &&
root.getOption("output")!=null && root.getOption("output").equals("template"))) ) {
if (state.backtracking>0) {state.failed=true; return retval;}
throw new FailedPredicateException(input, "multiElementAltInTreeGrammar", "inContext(\"ALT_REWRITE\") &&\n\t\t root.getOption(\"output\")!=null && root.getOption(\"output\").equals(\"template\")");
}
match(input,ALT,FOLLOW_ALT_in_multiElementAltInTreeGrammar649); if (state.failed) return retval;
match(input,ALT,FOLLOW_ALT_in_multiElementAltInTreeGrammar665); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
if ( (input.LA(1)>=FORCED_ACTION && input.LA(1)<=NESTED_ACTION)||(input.LA(1)>=ACTION_ESC && input.LA(1)<=ALT_REWRITE) ) {
@ -1251,7 +1259,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
throw mse;
}
// BasicSemanticTriggers.g:209:28: (~ ( SEMPRED | ACTION ) )+
// BasicSemanticTriggers.g:211:28: (~ ( SEMPRED | ACTION ) )+
int cnt12=0;
loop12:
do {
@ -1265,7 +1273,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
switch (alt12) {
case 1 :
// BasicSemanticTriggers.g:209:28: ~ ( SEMPRED | ACTION )
// BasicSemanticTriggers.g:211:28: ~ ( SEMPRED | ACTION )
{
if ( (input.LA(1)>=FORCED_ACTION && input.LA(1)<=NESTED_ACTION)||(input.LA(1)>=ACTION_ESC && input.LA(1)<=ALT_REWRITE) ) {
input.consume();
@ -1320,7 +1328,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
};
// $ANTLR start "astOps"
// BasicSemanticTriggers.g:220:1: astOps : ( ^( ROOT el= . ) | ^( BANG el= . ) );
// BasicSemanticTriggers.g:222:1: astOps : ( ^( ROOT el= . ) | ^( BANG el= . ) );
public final BasicSemanticTriggers.astOps_return astOps() throws RecognitionException {
BasicSemanticTriggers.astOps_return retval = new BasicSemanticTriggers.astOps_return();
retval.start = input.LT(1);
@ -1328,7 +1336,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
GrammarAST el=null;
try {
// BasicSemanticTriggers.g:221:2: ( ^( ROOT el= . ) | ^( BANG el= . ) )
// BasicSemanticTriggers.g:223:2: ( ^( ROOT el= . ) | ^( BANG el= . ) )
int alt13=2;
int LA13_0 = input.LA(1);
@ -1347,9 +1355,9 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
}
switch (alt13) {
case 1 :
// BasicSemanticTriggers.g:221:4: ^( ROOT el= . )
// BasicSemanticTriggers.g:223:4: ^( ROOT el= . )
{
match(input,ROOT,FOLLOW_ROOT_in_astOps684); if (state.failed) return retval;
match(input,ROOT,FOLLOW_ROOT_in_astOps700); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
el=(GrammarAST)input.LT(1);
@ -1363,9 +1371,9 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
}
break;
case 2 :
// BasicSemanticTriggers.g:222:4: ^( BANG el= . )
// BasicSemanticTriggers.g:224:4: ^( BANG el= . )
{
match(input,BANG,FOLLOW_BANG_in_astOps697); if (state.failed) return retval;
match(input,BANG,FOLLOW_BANG_in_astOps713); if (state.failed) return retval;
match(input, Token.DOWN, null); if (state.failed) return retval;
el=(GrammarAST)input.LT(1);
@ -1393,19 +1401,19 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
// $ANTLR start "wildcardRoot"
// BasicSemanticTriggers.g:225:1: wildcardRoot : ^( TREE_BEGIN WILDCARD ( . )* ) ;
// BasicSemanticTriggers.g:227:1: wildcardRoot : ^( TREE_BEGIN WILDCARD ( . )* ) ;
public final void wildcardRoot() throws RecognitionException {
GrammarAST WILDCARD8=null;
try {
// BasicSemanticTriggers.g:226:5: ( ^( TREE_BEGIN WILDCARD ( . )* ) )
// BasicSemanticTriggers.g:226:7: ^( TREE_BEGIN WILDCARD ( . )* )
// BasicSemanticTriggers.g:228:5: ( ^( TREE_BEGIN WILDCARD ( . )* ) )
// BasicSemanticTriggers.g:228:7: ^( TREE_BEGIN WILDCARD ( . )* )
{
match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_wildcardRoot720); if (state.failed) return ;
match(input,TREE_BEGIN,FOLLOW_TREE_BEGIN_in_wildcardRoot736); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
WILDCARD8=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_wildcardRoot722); if (state.failed) return ;
// BasicSemanticTriggers.g:226:29: ( . )*
WILDCARD8=(GrammarAST)match(input,WILDCARD,FOLLOW_WILDCARD_in_wildcardRoot738); if (state.failed) return ;
// BasicSemanticTriggers.g:228:29: ( . )*
loop14:
do {
int alt14=2;
@ -1421,7 +1429,7 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
switch (alt14) {
case 1 :
// BasicSemanticTriggers.g:226:29: .
// BasicSemanticTriggers.g:228:29: .
{
matchAny(input); if (state.failed) return ;
@ -1580,22 +1588,22 @@ public class BasicSemanticTriggers extends org.antlr.v4.runtime.tree.TreeFilter
public static final BitSet FOLLOW_ASSIGN_in_tokenAlias509 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_tokenAlias511 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_tokenAlias513 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_TOKEN_REF_in_tokenRefWithArgs530 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_tokenRefWithArgs532 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ELEMENT_OPTIONS_in_elementOption554 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ASSIGN_in_elementOption565 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_elementOption569 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L});
public static final BitSet FOLLOW_ID_in_elementOption573 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ASSIGN_in_elementOption587 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_elementOption591 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_elementOption595 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ID_in_elementOption609 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ALT_in_multiElementAltInTreeGrammar649 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar651 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE0L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar658 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE8L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_ROOT_in_astOps684 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_BANG_in_astOps697 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_TREE_BEGIN_in_wildcardRoot720 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_WILDCARD_in_wildcardRoot722 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF8L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_TOKEN_REF_in_tokenRefWithArgs538 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ARG_ACTION_in_tokenRefWithArgs540 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ELEMENT_OPTIONS_in_elementOption570 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ASSIGN_in_elementOption581 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_elementOption585 = new BitSet(new long[]{0x0000000000000000L,0x0000000000800000L});
public static final BitSet FOLLOW_ID_in_elementOption589 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ASSIGN_in_elementOption603 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_elementOption607 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_elementOption611 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ID_in_elementOption625 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_ALT_in_multiElementAltInTreeGrammar665 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar667 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE0L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_set_in_multiElementAltInTreeGrammar674 = new BitSet(new long[]{0xFFFFFFFFFFFEFFE8L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_ROOT_in_astOps700 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_BANG_in_astOps713 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_TREE_BEGIN_in_wildcardRoot736 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_WILDCARD_in_wildcardRoot738 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF8L,0x0000001FFFFFFFFFL});
}

View File

@ -0,0 +1,104 @@
/*
[The "BSD license"]
Copyright (c) 2010 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** Triggers for defining rules, tokens, scopes, and actions.
* Side-effects: ...
*/
tree grammar DefineSymbolTriggers;
options {
language = Java;
tokenVocab = ANTLRParser;
ASTLabelType = GrammarAST;
filter = true;
superClass = 'org.antlr.v4.runtime.tree.TreeFilter';
}
// Include the copyright in this source and also the generated source
@header {
/*
[The "BSD license"]
Copyright (c) 2010 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.semantics;
import org.antlr.v4.tool.*;
}
@members {
Grammar g; // which grammar are we checking
public DefineSymbolTriggers(TreeNodeStream input, Grammar g) {
this(input);
this.g = g;
}
}
topdown
: tokenAlias
| rule
| terminal
;
tokenAlias
: {inContext("TOKENS")}? ^(ASSIGN ID STRING_LITERAL)
{System.out.println("token alias "+$ID.text+"="+$STRING_LITERAL.token);}
;
rule: ^( RULE r=ID .*) {System.out.println("rule "+$r.token);} //{DefineSymbols.checkInvalidRuleDef(g.getType(), $r.token);}
;
terminal
: {!inContext("TOKENS ASSIGN")}? STRING_LITERAL
{System.out.println("terminal "+$STRING_LITERAL.token);}
| TOKEN_REF {System.out.println("terminal "+$TOKEN_REF.token);}
;
/*
ruleref
: ^(ROOT RULE_REF ARG_ACTION?)
| ^(BANG RULE_REF ARG_ACTION?)
| ^(RULE_REF ARG_ACTION?)
;
*/

View File

@ -0,0 +1,422 @@
// $ANTLR 3.2.1-SNAPSHOT Jan 26, 2010 15:12:28 DefineSymbolTriggers.g 2010-02-04 17:59:03
/*
[The "BSD license"]
Copyright (c) 2010 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.semantics;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.TreeNodeStream;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarAST;
/** Triggers for defining rules, tokens, scopes, and actions.
* Side-effects: ...
*/
public class DefineSymbolTriggers extends org.antlr.v4.runtime.tree.TreeFilter {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "SEMPRED", "FORCED_ACTION", "DOC_COMMENT", "SRC", "NLCHARS", "COMMENT", "DOUBLE_QUOTE_STRING_LITERAL", "DOUBLE_ANGLE_STRING_LITERAL", "ACTION_STRING_LITERAL", "ACTION_CHAR_LITERAL", "ARG_ACTION", "NESTED_ACTION", "ACTION", "ACTION_ESC", "WSNLCHARS", "OPTIONS", "TOKENS", "SCOPE", "IMPORT", "FRAGMENT", "LEXER", "PARSER", "TREE", "GRAMMAR", "PROTECTED", "PUBLIC", "PRIVATE", "RETURNS", "THROWS", "CATCH", "FINALLY", "TEMPLATE", "COLON", "COLONCOLON", "COMMA", "SEMI", "LPAREN", "RPAREN", "IMPLIES", "LT", "GT", "ASSIGN", "QUESTION", "BANG", "STAR", "PLUS", "PLUS_ASSIGN", "OR", "ROOT", "DOLLAR", "DOT", "RANGE", "ETC", "RARROW", "TREE_BEGIN", "AT", "NOT", "RBRACE", "TOKEN_REF", "RULE_REF", "INT", "WSCHARS", "ESC_SEQ", "STRING_LITERAL", "HEX_DIGIT", "UNICODE_ESC", "WS", "ERRCHAR", "RULE", "RULES", "RULEMODIFIERS", "RULEACTIONS", "BLOCK", "REWRITE_BLOCK", "OPTIONAL", "CLOSURE", "POSITIVE_CLOSURE", "SYNPRED", "CHAR_RANGE", "EPSILON", "ALT", "ALTLIST", "RESULT", "ID", "ARG", "ARGLIST", "RET", "INITACTION", "LABEL", "GATED_SEMPRED", "SYN_SEMPRED", "BACKTRACK_SEMPRED", "WILDCARD", "LIST", "ELEMENT_OPTIONS", "ST_RESULT", "ALT_REWRITE"
};
public static final int LT=43;
public static final int STAR=48;
public static final int BACKTRACK_SEMPRED=95;
public static final int DOUBLE_ANGLE_STRING_LITERAL=11;
public static final int FORCED_ACTION=5;
public static final int ARGLIST=89;
public static final int ALTLIST=85;
public static final int NOT=60;
public static final int EOF=-1;
public static final int SEMPRED=4;
public static final int ACTION=16;
public static final int TOKEN_REF=62;
public static final int RULEMODIFIERS=74;
public static final int ST_RESULT=99;
public static final int RPAREN=41;
public static final int RET=90;
public static final int IMPORT=22;
public static final int STRING_LITERAL=67;
public static final int ARG=88;
public static final int ARG_ACTION=14;
public static final int DOUBLE_QUOTE_STRING_LITERAL=10;
public static final int COMMENT=9;
public static final int ACTION_CHAR_LITERAL=13;
public static final int GRAMMAR=27;
public static final int RULEACTIONS=75;
public static final int WSCHARS=65;
public static final int INITACTION=91;
public static final int ALT_REWRITE=100;
public static final int IMPLIES=42;
public static final int RULE=72;
public static final int RBRACE=61;
public static final int ACTION_ESC=17;
public static final int PRIVATE=30;
public static final int SRC=7;
public static final int THROWS=32;
public static final int CHAR_RANGE=82;
public static final int INT=64;
public static final int EPSILON=83;
public static final int LIST=97;
public static final int COLONCOLON=37;
public static final int WSNLCHARS=18;
public static final int WS=70;
public static final int LEXER=24;
public static final int OR=51;
public static final int GT=44;
public static final int CATCH=33;
public static final int CLOSURE=79;
public static final int PARSER=25;
public static final int DOLLAR=53;
public static final int PROTECTED=28;
public static final int ELEMENT_OPTIONS=98;
public static final int NESTED_ACTION=15;
public static final int FRAGMENT=23;
public static final int ID=87;
public static final int TREE_BEGIN=58;
public static final int LPAREN=40;
public static final int AT=59;
public static final int ESC_SEQ=66;
public static final int ALT=84;
public static final int TREE=26;
public static final int SCOPE=21;
public static final int ETC=56;
public static final int COMMA=38;
public static final int WILDCARD=96;
public static final int DOC_COMMENT=6;
public static final int PLUS=49;
public static final int REWRITE_BLOCK=77;
public static final int DOT=54;
public static final int RETURNS=31;
public static final int RULES=73;
public static final int RARROW=57;
public static final int UNICODE_ESC=69;
public static final int HEX_DIGIT=68;
public static final int RANGE=55;
public static final int TOKENS=20;
public static final int GATED_SEMPRED=93;
public static final int RESULT=86;
public static final int BANG=47;
public static final int ACTION_STRING_LITERAL=12;
public static final int ROOT=52;
public static final int SEMI=39;
public static final int RULE_REF=63;
public static final int NLCHARS=8;
public static final int OPTIONAL=78;
public static final int SYNPRED=81;
public static final int COLON=36;
public static final int QUESTION=46;
public static final int FINALLY=34;
public static final int TEMPLATE=35;
public static final int LABEL=92;
public static final int SYN_SEMPRED=94;
public static final int ERRCHAR=71;
public static final int BLOCK=76;
public static final int ASSIGN=45;
public static final int PLUS_ASSIGN=50;
public static final int PUBLIC=29;
public static final int POSITIVE_CLOSURE=80;
public static final int OPTIONS=19;
// delegates
// delegators
public DefineSymbolTriggers(TreeNodeStream input) {
this(input, new RecognizerSharedState());
}
public DefineSymbolTriggers(TreeNodeStream input, RecognizerSharedState state) {
super(input, state);
}
public String[] getTokenNames() { return DefineSymbolTriggers.tokenNames; }
public String getGrammarFileName() { return "DefineSymbolTriggers.g"; }
Grammar g; // which grammar are we checking
public DefineSymbolTriggers(TreeNodeStream input, Grammar g) {
this(input);
this.g = g;
}
// $ANTLR start "topdown"
// DefineSymbolTriggers.g:78:1: topdown : ( tokenAlias | rule | terminal );
public final void topdown() throws RecognitionException {
try {
// DefineSymbolTriggers.g:79:5: ( tokenAlias | rule | terminal )
int alt1=3;
switch ( input.LA(1) ) {
case ASSIGN:
{
alt1=1;
}
break;
case RULE:
{
alt1=2;
}
break;
case TOKEN_REF:
case STRING_LITERAL:
{
alt1=3;
}
break;
default:
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 1, 0, input);
throw nvae;
}
switch (alt1) {
case 1 :
// DefineSymbolTriggers.g:79:7: tokenAlias
{
pushFollow(FOLLOW_tokenAlias_in_topdown96);
tokenAlias();
state._fsp--;
if (state.failed) return ;
}
break;
case 2 :
// DefineSymbolTriggers.g:80:7: rule
{
pushFollow(FOLLOW_rule_in_topdown104);
rule();
state._fsp--;
if (state.failed) return ;
}
break;
case 3 :
// DefineSymbolTriggers.g:81:7: terminal
{
pushFollow(FOLLOW_terminal_in_topdown112);
terminal();
state._fsp--;
if (state.failed) return ;
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
return ;
}
// $ANTLR end "topdown"
// $ANTLR start "tokenAlias"
// DefineSymbolTriggers.g:84:1: tokenAlias : {...}? ^( ASSIGN ID STRING_LITERAL ) ;
public final void tokenAlias() throws RecognitionException {
GrammarAST ID1=null;
GrammarAST STRING_LITERAL2=null;
try {
// DefineSymbolTriggers.g:85:2: ({...}? ^( ASSIGN ID STRING_LITERAL ) )
// DefineSymbolTriggers.g:85:4: {...}? ^( ASSIGN ID STRING_LITERAL )
{
if ( !((inContext("TOKENS"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "tokenAlias", "inContext(\"TOKENS\")");
}
match(input,ASSIGN,FOLLOW_ASSIGN_in_tokenAlias126); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
ID1=(GrammarAST)match(input,ID,FOLLOW_ID_in_tokenAlias128); if (state.failed) return ;
STRING_LITERAL2=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_tokenAlias130); if (state.failed) return ;
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
System.out.println("token alias "+(ID1!=null?ID1.getText():null)+"="+STRING_LITERAL2.token);
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
return ;
}
// $ANTLR end "tokenAlias"
// $ANTLR start "rule"
// DefineSymbolTriggers.g:89:1: rule : ^( RULE r= ID ( . )* ) ;
public final void rule() throws RecognitionException {
GrammarAST r=null;
try {
// DefineSymbolTriggers.g:89:5: ( ^( RULE r= ID ( . )* ) )
// DefineSymbolTriggers.g:89:9: ^( RULE r= ID ( . )* )
{
match(input,RULE,FOLLOW_RULE_in_rule148); if (state.failed) return ;
match(input, Token.DOWN, null); if (state.failed) return ;
r=(GrammarAST)match(input,ID,FOLLOW_ID_in_rule152); if (state.failed) return ;
// DefineSymbolTriggers.g:89:22: ( . )*
loop2:
do {
int alt2=2;
int LA2_0 = input.LA(1);
if ( ((LA2_0>=SEMPRED && LA2_0<=ALT_REWRITE)) ) {
alt2=1;
}
else if ( (LA2_0==UP) ) {
alt2=2;
}
switch (alt2) {
case 1 :
// DefineSymbolTriggers.g:89:22: .
{
matchAny(input); if (state.failed) return ;
}
break;
default :
break loop2;
}
} while (true);
match(input, Token.UP, null); if (state.failed) return ;
if ( state.backtracking==1 ) {
System.out.println("rule "+r.token);
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
return ;
}
// $ANTLR end "rule"
// $ANTLR start "terminal"
// DefineSymbolTriggers.g:92:1: terminal : ({...}? STRING_LITERAL | TOKEN_REF );
public final void terminal() throws RecognitionException {
GrammarAST STRING_LITERAL3=null;
GrammarAST TOKEN_REF4=null;
try {
// DefineSymbolTriggers.g:93:5: ({...}? STRING_LITERAL | TOKEN_REF )
int alt3=2;
int LA3_0 = input.LA(1);
if ( (LA3_0==STRING_LITERAL) ) {
alt3=1;
}
else if ( (LA3_0==TOKEN_REF) ) {
alt3=2;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 3, 0, input);
throw nvae;
}
switch (alt3) {
case 1 :
// DefineSymbolTriggers.g:93:7: {...}? STRING_LITERAL
{
if ( !((!inContext("TOKENS ASSIGN"))) ) {
if (state.backtracking>0) {state.failed=true; return ;}
throw new FailedPredicateException(input, "terminal", "!inContext(\"TOKENS ASSIGN\")");
}
STRING_LITERAL3=(GrammarAST)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_terminal178); if (state.failed) return ;
if ( state.backtracking==1 ) {
System.out.println("terminal "+STRING_LITERAL3.token);
}
}
break;
case 2 :
// DefineSymbolTriggers.g:95:7: TOKEN_REF
{
TOKEN_REF4=(GrammarAST)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_terminal193); if (state.failed) return ;
if ( state.backtracking==1 ) {
System.out.println("terminal "+TOKEN_REF4.token);
}
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
return ;
}
// $ANTLR end "terminal"
// Delegated rules
public static final BitSet FOLLOW_tokenAlias_in_topdown96 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_rule_in_topdown104 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_terminal_in_topdown112 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ASSIGN_in_tokenAlias126 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_tokenAlias128 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
public static final BitSet FOLLOW_STRING_LITERAL_in_tokenAlias130 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_RULE_in_rule148 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_ID_in_rule152 = new BitSet(new long[]{0xFFFFFFFFFFFFFFF8L,0x0000001FFFFFFFFFL});
public static final BitSet FOLLOW_STRING_LITERAL_in_terminal178 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_TOKEN_REF_in_terminal193 = new BitSet(new long[]{0x0000000000000002L});
}

View File

@ -0,0 +1,97 @@
LT=43
STAR=48
BACKTRACK_SEMPRED=95
DOUBLE_ANGLE_STRING_LITERAL=11
FORCED_ACTION=5
ARGLIST=89
ALTLIST=85
NOT=60
SEMPRED=4
ACTION=16
TOKEN_REF=62
RULEMODIFIERS=74
ST_RESULT=99
RPAREN=41
RET=90
IMPORT=22
STRING_LITERAL=67
ARG=88
ARG_ACTION=14
DOUBLE_QUOTE_STRING_LITERAL=10
COMMENT=9
ACTION_CHAR_LITERAL=13
GRAMMAR=27
RULEACTIONS=75
WSCHARS=65
INITACTION=91
ALT_REWRITE=100
IMPLIES=42
RULE=72
RBRACE=61
ACTION_ESC=17
PRIVATE=30
SRC=7
THROWS=32
CHAR_RANGE=82
INT=64
EPSILON=83
LIST=97
COLONCOLON=37
WSNLCHARS=18
WS=70
LEXER=24
OR=51
GT=44
CATCH=33
CLOSURE=79
PARSER=25
DOLLAR=53
PROTECTED=28
ELEMENT_OPTIONS=98
NESTED_ACTION=15
FRAGMENT=23
ID=87
TREE_BEGIN=58
LPAREN=40
AT=59
ESC_SEQ=66
ALT=84
TREE=26
SCOPE=21
ETC=56
COMMA=38
WILDCARD=96
DOC_COMMENT=6
PLUS=49
REWRITE_BLOCK=77
DOT=54
RETURNS=31
RULES=73
RARROW=57
UNICODE_ESC=69
HEX_DIGIT=68
RANGE=55
TOKENS=20
GATED_SEMPRED=93
RESULT=86
BANG=47
ACTION_STRING_LITERAL=12
ROOT=52
SEMI=39
RULE_REF=63
NLCHARS=8
OPTIONAL=78
SYNPRED=81
COLON=36
QUESTION=46
FINALLY=34
TEMPLATE=35
LABEL=92
SYN_SEMPRED=94
ERRCHAR=71
BLOCK=76
ASSIGN=45
PLUS_ASSIGN=50
PUBLIC=29
POSITIVE_CLOSURE=80
OPTIONS=19

View File

@ -36,6 +36,9 @@ public class SemanticsPipeline {
}
// DEFINE SYMBOLS
nodes.reset();
DefineSymbolTriggers sym = new DefineSymbolTriggers(nodes,g);
sym.downup(g.ast);
// ASSIGN TOKEN TYPES