[antlr-interest] lexer: matching float vs int
jimi at temporal-wave.com
Tue Sep 9 10:03:59 PDT 2008
On Wed, 2008-09-10 at 02:38 +1000, Thomas Brandon wrote:
> On Tue, Sep 9, 2008 at 2:01 PM, Olya Krachina <okrachin at purdue.edu> wrote:
> > 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
> Those two rules work fine for me. I think either other rules are
> interfering or you are providing invalid input to the grammar. Try
> making a minimal grammar that reproduces the problem and post that
> along with the exact input that fails.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest