ANTLR lexing getting confused over '...' and floats
Posted
by Andy Hull
on Stack Overflow
See other posts from Stack Overflow
or by Andy Hull
Published on 2010-04-20T19:13:37Z
Indexed on
2010/04/20
19:23 UTC
Read the original article
Hit count: 294
I think the ANTLR lexer is treating my attempt at a range expression "1...3" as a float. The expression "x={1..3}" is coming out of the lexer as "x={.3}" when I used the following token definitions:
FLOAT : ('0'..'9')+ ('.' '0'..'9'+)? EXPONENT? | ('.' '0'..'9')+ EXPONENT? ;
AUTO : '...';
When I change FLOAT to just check for integers, as so:
FLOAT : ('0'..'9')+;
then the expression "x={1...3}" is tokenized correctly. Can anyone help me to fix this?
Thanks!
© Stack Overflow or respective owner