[antlr-interest] nondeterminism problem

Terence Parr parrt at jguru.com
Fri Oct 11 21:39:43 PDT 2002


On Friday, October 11, 2002, at 09:20  PM, Jack Hong wrote:

> 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.
>
The above parser rule should work.  You must have a token type issue 
like import/exportVocab.  If the parser/lexer are not in the same file 
you will have to have the lexer import the vocab.  Also check to ensure 
you are not turning of "testLiterals".

Terence


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list