[antlr-interest] newbie problem about expressions & number representations

David-Sarah Hopwood david-sarah at jacaranda.org
Fri Dec 11 16:37:30 PST 2009


Gavin Lambert wrote:
> At 13:41 11/12/2009, Duygu Altinok wrote:
>> INT :    (DIGIT )+
>>     ;
>>
>> FLOAT
>>     :   ('0'..'9')+ '.' ('0'..'9')* (EXPONENT)?
>>     |   '.' ('0'..'9')+ (EXPONENT)?
>>     |   ('0'..'9')+ EXPONENT
>>     ;
> 
> These two rules have a common left prefix, and are thus 
> ambiguous.  Even ANTLR v3 with * lookahead has trouble with this; 
> ANTLR v2's fixed (typically small) lookahead doesn't stand a 
> chance.

I thought lexer rules were supposed to find the longest match?
How can they do that if they're unable to handle common left prefixes?

(I have the impression that "longest match" may not be quite accurate,
but if so, I've never seen the actual behaviour documented precisely.)

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20091212/fc73250c/attachment.bin 


More information about the antlr-interest mailing list