[antlr-interest] (no subject)

Harald Mueller harald_m_mueller at gmx.de
Fri Nov 30 09:36:04 PST 2007


Hi -

Use k=3 for the whole grammar. ANTLR will "optimize away" superfluous lookaheads in its follow-set computations.

I simply write k=5 or k=6, if I get stuck with a lookahead - one usually sees pretty fast whether it's only a problem of a too small finite lookahead, or whether the language is not "ANTLR-LL(k)" for any k (ANTLR 2.x's LL(k) is not "real LL(k)" - it is somewhat weaker because it unifies certain follow-sets ... therefore the term "ANTLD-LL(k)" above).

Regards
Harald

-------- Original-Nachricht --------
> Datum: Fri, 30 Nov 2007 12:15:23 -0500
> Von: "Daniels, Troy \\(US SSA\\)" <troy.daniels at baesystems.com>
> An: antlr-interest at antlr.org
> Betreff: [antlr-interest] (no subject)

> I'm using antlr 2.7.6 and I'm trying to write a parser rule of the form
> 
> rule: rule1 rule2* rule3?
> 
> With two levels of look ahead, there's ambiguity between rule2 and
> rule3. The third token would remove the ambiguity. Is there a way to
> increase the look ahead for just one rule? (Setting k only appears to be
> valid in the grammar file options, not in rule options).
> 
> I tried using a syntactic predicate.
> 
> rule: rule1 ((TOK1 TOK2 TOK3)=> rule2*) rule3?
> 
> but antlr ignored it, since it doesn't consider (...)* to be multiple
> options. Adding a blank alternative seems hackish:
> 
> rule: rule1 ((TOK1 TOK2 TOK3)=> rule2*|/* */) rule3?
> 
> Is there a good way to handle this sort of problem?
> 
> Troy
> 
> 
> P.S.  I also posted this on Jguru, but there doesn't seem to be much
> action in the Antlr forum there.  Is this a better place for such
> questions?

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the antlr-interest mailing list