[antlr-interest] warning:lexical nondeterminism question

Nigel Sheridan-Smith nbsherid at secsme.org.au
Sat Jun 18 13:31:04 PDT 2005


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of None None
> Sent: Saturday, 18 June 2005 1:49 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] warning:lexical nondeterminism question
> 
> ANTLR Parser Generator   Version 2.7.5 (20050615)
> 1989-2005 jGuru.com
> test.g:7: warning:lexical nondeterminism between alts
> 1 and 2 of block upon
> test.g:7:     k==1:'0'..'9'
> test.g:7:     k==2:'0'..'9'
> test.g:7:     k==3:'0'..'9'
> test.g:7:     k==4:'0'..'9'
> 
> 
> I think the problem is the DMS rule, which starts
> with:
> 
>       (DIGIT)? DIGIT DIGIT ":"
> 
> If it's changed to:
> 
>       DIGIT DIGIT DIGIT ":"
> 
> that stops the warning.  Why would making the first
> token optional be a problem? I would think it would be
> unique by the fourth token? Thanks.
> 

Are all your lexer rules protected? Try switching some out as there may be a
conflict between DMS and FLOAT. 

Alternatively try k=5... I think you need at least one more look-ahead to
distinguish, because of the way ANTLR grabs the characters in the lexer.

Another option is to make "(DIGIT)? DIGIT DIGIT" into "DIGIT DIGIT
(DIGIT)?". I suspect that will also make a difference, helping to reduce 'k'
as well (for performance).

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435
 




More information about the antlr-interest mailing list