[antlr-interest] More ANTLR meta-syntax questions

Bogdan Mitu bogdan_mt at yahoo.com
Tue May 14 01:57:01 PDT 2002


> (2) In ANTLR, you have to specify a lookahead distince (k) for the 
> parser. My OCL grammar is LL(1) for all rules except one, which requires 
> 2 tokens of lookahead. So, I changed my grammar to be specified as 
> LL(2). Does this affect the performance of my LL(1) rules? Is there a 
> runtime performance penalty to saying k=2 for rules where k=1 is 
> sufficient? If not, is it (theoretically) possible for ANTLR to compute 
> the minimum value of k needed for my grammar to be unambiguous?

No, there is no performance penalty. ANTLR always computes the minimum
lookahead required for each rule (can be different from rule to rule). The
value of k is just an upper limit, above which ANTLR gives a non-determinism
warning.

This also answers (3), I guess. For the others, maybe someone more savvy
will answer.

Regards,
Bogdan


> (3) I know that I have to use a syntactic predicate for "infinite" 
> lookahead. But, if I only need a larger-than-k finite lookahead (say, 
> two tokens when k=1), is there any advantage to using a syntactic 
> predicate instead of increasing the value of k (e.g. performance)? I 
> would rather increase k since my grammar is then more readable
> 
> (4) I know that ANTLR handles grammars that are "approximately" LL(k), 
> and that LL(k) is a subset of LALR(1). But, is LL(k)+syntactic 
> predicates still a subset of LALR(1)? That is, are there LALR(1), 
> LALR(k), or LR(k) grammars that cannot be specified in ANTLR's 
> LL(k)+syntactic predicates?
> 
> Thanks a lot,
> Brian
> 
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

 

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



More information about the antlr-interest mailing list