[antlr-interest] lexer: matching float vs int
cvrebert at gmail.com
Mon Sep 8 21:19:26 PDT 2008
I think you might need to left-factor here.
Have you tried:
FLOAT: INT? '.' INT;
Sent from my iPod
On Sep 8, 2008, at 9:01 PM, Olya Krachina <okrachin at purdue.edu> wrote:
> 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.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest