
|
If you were logged in you would be able to see more operations.
|
|
|
ANTLR v3
Created: 06/Nov/06 06:29 PM
Updated: 20/Apr/07 01:32 PM
|
|
| Component/s: |
ANTLR Core
|
| Affects Version/s: |
3.0
|
| Fix Version/s: |
3.0b8
|
|
|
With the following grammar
grammar a;
options {output=AST;}
tokens {PARMS;}
modulo
: 'modulo' ID ('(' parms+ ')')? -> ^('modulo' ID ^(PARMS parms+)?)
;
parms : '#'|ID;
ID : ('a'..'z' | 'A'..'Z')*;
WS : (' ' | '\t' | '\n' | '\r')+ {channel=99;} ;
The compiler result is
a.java:150: cannot find symbol
symbol : variable n_1
location: class a
if ( n_1 > 1 ) throw new RuntimeException(" list has >
1 elements");
^
a.java :151: cannot find symbol
symbol : variable n_1
location: class a
if ( n_1==1 ) {
^
|
|
Description
|
With the following grammar
grammar a;
options {output=AST;}
tokens {PARMS;}
modulo
: 'modulo' ID ('(' parms+ ')')? -> ^('modulo' ID ^(PARMS parms+)?)
;
parms : '#'|ID;
ID : ('a'..'z' | 'A'..'Z')*;
WS : (' ' | '\t' | '\n' | '\r')+ {channel=99;} ;
The compiler result is
a.java:150: cannot find symbol
symbol : variable n_1
location: class a
if ( n_1 > 1 ) throw new RuntimeException(" list has >
1 elements");
^
a.java :151: cannot find symbol
symbol : variable n_1
location: class a
if ( n_1==1 ) {
^ |
Show » |
|
grammar t;
options {output=AST;}
tokens { VARDEF; }
a : 'int' ID? -> VARDEF? ;