[antlr-interest] How to define a FLOAT number
Alexander Gängel
alexander at gaengel.de
Thu Feb 28 12:00:44 PST 2008
This should do it
Alexander
start : (Float|UINT)+ EOF;
Float :d=UINT
(
(DOT UINT)=>(DOT UINT)
|{ $type = UINT; }
)
;
DOT :'.';
fragment
DIGIT_10 :'0'..'9' ;
fragment
UINT :DIGIT_10+ ;
maulattu schrieb:
> Hello, here is a little surprise..
> With the following grammar, the input "1" is not recognized as float
> (note that the rule DIGIT isn't used):
> ------------------------------
> grammar float_recon;
> offset
> :
> FLOAT
> ;
> DIGIT
> : '0'..'9'
> ;
> FLOAT
> :
> ('0'..'9')+ ('.' (('0'..'9')+))?
> ;
> ------------------------------
>
>
> Conversely, with this one the input "1" is recognized as float:
> ------------------------------
> grammar float_recon;
> offset
> :
> FLOAT
> ;
> FLOAT
> :
> ('0'..'9')+ ('.' (('0'..'9')+))?
> ;
> DIGIT
> : '0'..'9'
> ;
> ------------------------------
>
> How can it be possible? Is it related to this bug?
> http://www.antlr.org:8888/browse/ANTLR-41
>
> I'm using ANTLRWorks 1.1.7 and 1.1.5 some days ago...
>
> Bye!
>
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo!
> Mail
> <http://us.rd.yahoo.com/mail/it/taglines/hotmail/nowyoucan/nextgen/*http://it.docs.yahoo.com/nowyoucan.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080228/263a7b29/attachment.html
More information about the antlr-interest
mailing list