I'm working on an ANTLR project that should basically implement this simple grammar:
WS : ' '
;
MINUS : '-' ;
DIGIT : '0'..'9'
;
int4
@init{
int n = 0;
}
: (({n<4}?=> WS {n++;})* (MINUS{n++;})?({n<4}?=> DIGIT{n++;})*){n==4}? ;
numbers
: (int4)*;
int4 follow the format I4 of Fortran (stands for an integer with width four)
this code are giving me the following errors:
[10:17:20] C:\Users\guille\Documents\output\testParser.java:277: cannot find symbol
[10:17:20] symbol : variable n
[10:17:20] location: class testParser
[10:17:20] if ( (evalPredicate(n==4,"n==4")) ) {
[10:17:20] ^
[10:17:20] C:\Users\guille\Documents\output\testParser.java:283: cannot find symbol
[10:17:20] symbol : variable n
[10:17:20] location: class testParser
[10:17:20] else if ( (LA4_0==WS) && (evalPredicate(n<4,"n<4"))) {
[10:17:20] ^
[10:17:20] C:\Users\guille\Documents\output\testParser.java:289: cannot find symbol
[10:17:20] symbol : variable n
[10:17:20] location: class testParser
[10:17:20] else if ( (LA4_0==DIGIT) && (evalPredicate(n<4,"n<4"))) {
[10:17:20] ^
[10:17:20] 3 errors
Any Idea?