[antlr-interest] setting k Value Versus Predicates

Loring Craymer lgcraymer at yahoo.com
Sun Feb 14 03:27:30 PST 2010


Gavin--

Actually, ANTLR uses the minimum lookahead needed at each decision point so setting k=2 in your example is preferable to using predicates and setting k=1.

With ANTLR 3, the default is k='*' and it is best not to set k.  Syntactic predicates are still needed to disambiguate decisions with potentially infinite lookahead (usually due to recursion or looping).

--Loring



----- Original Message ----
> From: Gavin Lambert <antlr at mirality.co.nz>
> To: Gokulakannan Somasundaram <gokul007 at gmail.com>; antlr-interest at antlr.org
> Sent: Sun, February 14, 2010 2:44:04 AM
> Subject: Re: [antlr-interest] setting k Value Versus Predicates
> 
> At 22:59 14/02/2010, Gokulakannan Somasundaram wrote:
> >Actually i intended to ask a question, whether there are any
> >cases under which i should prefer predicates than increasing
> >the value of k. Is it a very obvious one???
> 
> Your analysis assumes that every rule must contain at least one 
> ambiguity at k=1.  That is not the case.
> 
> If at k=2 you require no predicates, and at k=1 you only need a 
> few, then k=1 is probably the better choice.  If at k=1 you 
> require lots, then k=2 is probably the better choice.  It all 
> depends on the language you are analysing and your specific rule 
> layout (how well they are optimised).  Some languages are just 
> inherently ambiguous and thus require larger values for k.
> 
> At the end of the day, though, it's all up to what the benchmarks 
> say.
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address



      



More information about the antlr-interest mailing list