[antlr-interest] nondeterminism problem
Jack Hong
jack_xu_hong at yahoo.ca
Fri Oct 11 21:20:03 PDT 2002
Terence,
Thank you so much.
I tried that way before, but somehow it didn't work well.
This is the parser rule I declared in the parser before:
//---------------------------------------------
boolean_literal returns [Boolean b]
{
b = null;
}
: "TRUE" { b = new Boolean(true); }
| "FALSE" { b = new Boolean(false); }
;
//---------------------------------------------
It looks good, but always returns null. So I added a token
BOOLEAN_LITERAL in the lexer, after that my parser can retrieve the
correct value, but another problem raised -- nondeterminism.
Jack
-----Original Message-----
From: Terence Parr [mailto:parrt at jguru.com]
Sent: October 12, 2002 12:11 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] nondeterminism problem
Hi. Just reference "TRUE" and "FALSE" in the parser and the lexer will
automatically test for them :)
Terence
On Friday, October 11, 2002, at 05:51 PM, Jack Hong 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.
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list