[antlr-interest] nondeterminism problem

Jack Hong jack_xu_hong at yahoo.ca
Mon Oct 14 08:36:25 PDT 2002


Ram,

Because it was set to "testLiterals=false" before, and I didn't know
that "testLiterals=true" is the default setting.
Thanks for your hint, Ram.

Jack

-----Original Message-----
From: Sriram Durbha [mailto:cintyram at yahoo.com] 
Sent: October 14, 2002 11:13 AM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] nondeterminism problem


quote form the documentation :

testLiterals: Generate literal-testing code

By default, ANTLR will generate code in all lexers to test each token
against the literals table (the table generated for literal strings),
and change the token type if it matches the table. However, you may
suppress this code generation in the lexer by using a grammar option:

class L extends Lexer;
options { testLiterals=false; }
...
===================
question :
why did he have to explicitly set it to true? does it not default to
true ? 
====================
cheers
ram
<eom>

--- Jack Hong <jack_xu_hong at yahoo.ca> wrote:
> Dear Terence,
> 
> You are great!  I fixed the problem by adding "testLiterals=true" into
> my lexer.  Thank you very much!
> 
> Jack
> 
> -----Original Message-----
> From: Terence Parr [mailto:parrt at jguru.com]
> Sent: October 12, 2002 12:40 AM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] nondeterminism problem
> 
> 
> 
> 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/
> 
> 
>
______________________________________________________________________
> 
> Post your free ad now! http://personals.yahoo.ca
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
> 
> 


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

 

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


______________________________________________________________________ 
Post your ad for free 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