[antlr-interest] end-of-token
John B. Brodie
jbb at acm.org
Fri Jun 9 19:35:44 PDT 2006
>lookahead set to k=2,
>
>IntDenot: ('+'|'-')? (Digit)+;
>Sign:'+'|'-';
>
>warning generated:
>
>ANTLR Parser Generator Version 2.7.6 (2005-12-22) 1989-2005
>lex.g: warning:lexical nondeterminism between rules IntDenot and Sign upon
>lex.g: k==1:'+','-'
>lex.g: k==2:<end-of-token>
try instead
no lookahead set (or k=1).
IntDenot : ( Digit )+ ;
Sign : ( '+' | '-' ) ( ( Digit )+ { $setType(IntDenot); } )? ;
I believe that Lexer rules in v2 need to be left-factored, regardless
of lookahead...
More information about the antlr-interest
mailing list