[antlr-interest] setting k Value Versus Predicates

Loring Craymer lgcraymer at yahoo.com
Sun Feb 14 22:12:33 PST 2010


With token caching and optimal pattern matching, it should be possible to almost eliminate any performance differential.  Ter's current implementation does not do that--he generates DFAs that match tokens in order of appearance in the input stream--but the big wins from left factoring are to remove non-LL(*) decisions.  That said, refactoring to reduce the k values of decisions is good practice, so temporarily setting k for this purpose can be helpful--just don't expect much in the way of performance improvement.

--Loring


>
>From: Gokulakannan Somasundaram <gokul007 at gmail.com>
>To: Loring Craymer <lgcraymer at yahoo.com>
>Cc: Gavin Lambert <antlr at mirality.co.nz>; antlr-interest at antlr.org
>Sent: Sun, February 14, 2010 7:55:08 PM
>Subject: Re: [antlr-interest] setting k Value Versus Predicates
>
>
>
>
>>>>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).
>>
>>
>
>I can't understand the statement  "It is best not  to set k". Say there are left factoring opportunities, which we won't come to know, unless it is thrown as an error(after setting k)...
>
>I think, you are assuming that the grammar cannot be left factored further. Or are you saying there is no difference in performance between LL(*) and LL(1)? Please clarify.
>
>Thanks,
>Gokul.
>
>


      


More information about the antlr-interest mailing list