[antlr-interest] Why this grammar doesn't work?

Cristian Peraferrer corellian.c at gmail.com
Tue Oct 23 10:38:38 PDT 2007


Ok, I'm trying to adapt some of the Java.g example from ANTLR web (wiki?),
but I see the example doesn't work too. In the example file the "backtrack &
memoize" are defined globally, but if I comment it, it find a couple of
ambiguities.

Let's see it in parts; in a Java-like statement rule, there are two
alternatives to match IF-THEN-ELSE constructions.

How we could fix it?

2007/10/23, Jim Idle <jimi at temporal-wave.com>:
>
>  Cristian,
>
>
>
> It is likely that the true error here is part of the larger grammar
> structure. When you 'overuse' (if there is such a thing) the backtrack=true
> option, you are masking ambiguities in your grammar that really, should be
> teased out of it. This option is great for smaller grammars or where you
> don't really care that much about the performance, but in the end it can get
> you into trouble if you just use it to get rid of warnings/errors you would
> otherwise get.
>
>
>
> At least as an exercise, I would try turning off backtracking/memoizing,
> and see what ANTLR tells you about the grammar then. Though you may get more
> warnings and errors than you care to fix at this point, you might be able to
> see what is truly going on and at least fix that part. After that, you can
> turn backtracking on again and ignore the other warnings of course if you
> wish, though personally I would recommend that you try to construct your
> grammar such that the global use of backtracking is no required.
>
>
>
> I hope that this is of some help to you,
>
>
>
> Jim
>

-- 
GPG Key-ID: 0x564903FA - JID: corellian at swissjabber.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071023/86b46db1/attachment.html 


More information about the antlr-interest mailing list