[antlr-interest] Lexer generator bug?

Arthur Goldberg goldberg at cbio.mskcc.org
Wed Nov 24 06:55:18 PST 2010


Hello

ANTLRWorks can automatically generate
FLOAT
     :   ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
     |   '.' ('0'..'9')+ EXPONENT?
     |   ('0'..'9')+ EXPONENT
     ;

fragment
EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;

But I want a FLOAT that doesn't require an exponent:
FLOAT_NOE2
     :   '.' ('0'..'9')+
     | ('0'..'9')+ ('.' ('0'..'9')* )?
     ;

It seems that this should recognize any of these: 1.2 .3 4
But this doesn't recognize 4. I cant find a branch in the generated 
Lexer that doesn't enter '.' ( '0' .. '9' )*

Also

FLOAT
     :   ('0'..'9')+ '.' ('0'..'9')*
     |   '.' ('0'..'9')+
     |   ('0'..'9')+
     ;

doesn't recognize 4, but I've not examined that lexer.

Do I misunderstand lexer syntax or is this a Lexer generator bug?

Regards
Arthur

-- 
Senior Research Scientist
Computational Biology
Memorial Sloan-Kettering Cancer Center



More information about the antlr-interest mailing list