[antlr-interest] warning:lexical nondeterminism question

None None new_open_close at yahoo.com
Fri Jun 17 08:48:59 PDT 2005


Hello,

I'm new to antlr and was trying to figure out why a
particular pattern was generating a nondeterminism
warning.  The grammar is:


options {
          k=4;
        }

protected LATLON : DMS "," DMS | FLOAT "," FLOAT;
protected DMS    : (DIGIT)? DIGIT DIGIT ":" DIGIT
DIGIT ":" DIGIT DIGIT "." DIGIT;
protected FLOAT  : (SIGN)? (DIGIT)+ ( "." (DIGIT)* )?
;
protected SIGN   : "+" | "-";
protected DIGIT  : '0'..'9';


And this generates a warning:


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.


		
____________________________________________________ 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com


More information about the antlr-interest mailing list