[antlr-interest] overlapping lexer rules

Terence Parr parrt at cs.usfca.edu
Thu Jan 10 12:17:23 PST 2008


On Nov 7, 2007, at 8:39 PM, Curtis Clauson wrote:

> The second example is technically valid because of the undocumented  
> fact that the *ORDER* of lexer rules is also significant.

google search finds

http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No+Past+Experience+Required

on first page.

> As to why this poor example is in the book, and why the effect of  
> rule order on the lexer is not appropriately documented - ya got me.

   It is clearly marked as an issue. perhaps you should look at the  
title which is "ambiguities and Nondeterminisms" as well is the text  
inside.

> cimbroken wrote:
>> quoting two examples from the book (pg.280-281):
>> 1)
>> INT : DIGIT+ ;
>> DIGIT : '0'..'9' ;
>> 2)
>> INT : '0'..'9' +;
>> FLOAT : '0'..'9' + ('.' '0'..'9'*)? ;
>> I don't understand very well why the second is *not* a mistake.

it IS a mistake, clearly specified in the book as a problem.

Ter


More information about the antlr-interest mailing list