This is ANTLR 2.7, so it is different. However it isn't always longest match, the order of rules can also affect things. Basically it is always better to left factor, just a matter of getting used to the idea.
Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of David-Sarah Hopwood > Sent: Friday, December 11, 2009 4:38 PM > To: [email protected] > Subject: Re: [antlr-interest] newbie problem about expressions & number > representations > > 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 List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
