[antlr-interest] Please advice about float
Bryan Ewbank
ewbank at gmail.com
Mon Sep 19 09:36:36 PDT 2005
The original looks okay to me as a way to parse integers or simple
floats. The problem with proposed change:
NUMBER : (INT '.' INT) | INT ;
is that it is ambiguous under LL, whereas the original:
NUMBER : INT ('.' INT)? ;
is not - it has been left-factored.
Note that it does not allow .019, but requires the leading zero before
the dot: 0.019.
- Bryan
On 9/19/05, denis, alexis <adenis at bristol.ca> wrote:
> I'm no expert in grammars but I'd say a float is an (INT'.'INT) and a NUMBER is
> a FLOAT or an INT.
>
> -----Original Message-----
> From: Gevik babakhani [mailto:gevik at xs4all.nl]
>
> NUMBER : INT ((FLOAT)?) ;
> FLOAT : ('.' INT) ;
> INT : (DIGIT)+ ;
> DIGIT : '0'..'9' ;
More information about the antlr-interest
mailing list