[antlr-interest] lexer: matching float vs int
Olya Krachina
okrachin at purdue.edu
Mon Sep 8 21:01:08 PDT 2008
Hello,
I am new to antlr and i seem to be stuck on this.
i need to have 2 datatypes defined: int and float, currently i have them defined
like this in my .g file:
INT: ('0'..'9')+;
FLOAT: ('0'..'9')*('.')('0'..'9')+ ;
So, this does not work, when it comes across an int i think it tries to match
the longest string, i.e. float but finds space instead of '.' (since its an int)
and bails out.
ps: i know this is more a regexp question, but if someone could help out, I
would greatly appreciate it.
thanks
More information about the antlr-interest
mailing list