[antlr-interest] nondeterminism problem

Jack Hong jack_xu_hong at yahoo.ca
Fri Oct 11 19:47:45 PDT 2002


Thanks a lot, Xiaomin.
 
I understand your solution, should I declare BOOLEAN_LITERAL as a
"protected" token to avoid nondeterminism?
 
And where should I add the code you told me?  Sorry, I'm really new to
ANTLR.
IDENT.equals("TRUE") ==> tokenType = BOOLEAN_LITERAL and tokenValue =
TRUE; 


IDENT.equals("FALSE") ==> tokenType = BOOLEAN_LITERAL and tokeValue =
FALSE; 

Thanks again.
 
Jack
 
 
 

-----Original Message-----
From: Xiangmin Wang [mailto:xiang4232002 at yahoo.com] 
Sent: October 11, 2002 10:30 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] nondeterminism problem




One solution is to grab TRUE and FALSE as IDENT, then test the string,
as follows 


IDENT.equals("TRUE") ==> tokenType = BOOLEAN_LITERAL and tokenValue =
TRUE; 


IDENT.equals("FALSE") ==> tokenType = BOOLEAN_LITERAL and tokeValue =
FALSE; 


else it is a IDENT token. 


wxm 



 Jack Hong <jack_xu_hong at yahoo.ca> wrote: 


Hi all,
 
I get following warning messages when I run ANTLR:
 
warning: lexical nondeterminism between rules IDENT and BOOLEAN_LITERAL
upon
petal.g:0:  k==1:'F','T'
petal.g:0:  k==2:'A','R'
petal.g:0:  k==3:'L','U'
 
related token definitions in my grammar file:
 
BOOLEAN_LITERAL
    :    "TRUE"
    |    "FALSE"
    ;
 
IDENT
    :    ( 'a'..'z' | 'A'..'Z' | '_') ( 'a'..'z' | 'A'..'Z' | '_' |
'0'..'9')*
    ;
 
 
Any idea of how to fix these two nondeterministic tokens will be greatly
appreciated.
 
 
Thanks
Jack
 

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> . 





  _____  

Do you Yahoo!?
Faith Hill <http://faith.yahoo.com>  - Exclusive Performances, Videos, &
more
faith.yahoo.com 
Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20021011/b134e66a/attachment.html


More information about the antlr-interest mailing list