[antlr-interest] Determinig the real ambiguities
Monty Zukowski
monty at codetransform.com
Thu Jul 15 11:47:20 PDT 2004
There is a subrule option warnWhenFollowAmbig which you can set to
false. See http://www.antlr.org/doc/options.html#_bb15
Also, the code generated by ANTLR is quite readable and is the very
best way to learn what ANTLR is doing. ANTLR uses a lookahead
compression scheme which we used to call linear approximate lookahead
but which I think is really SLL. Anyhow you'll notice that ANTLR ORs
all the LA(1) tests together and then ANDS that to the LA(2) tests ORed
together. This usually works well, but in some situations it can cause
ambiguities which need to be solved by syntactic predicates or rule
refactoring.
Monty
On Jul 15, 2004, at 11:30 AM, thrutchy wrote:
> Is there a way to turn off the ambiguities warnings that aren't real
> and only affection the parser prediction (and thus performance)? Here
> is an example:
>
> a_must_have_c : (A)? (B)+ C D | (B)+ D ;
>
> It thinks these alternatives are ambiguous because they both can start
> with an indeterminate amount of B's, but the ambiguity is resolved
> right after that.
>
> I assume ANTLR will try matching the first alternative and then go to
> the second if the input matches the second alternative. Is that
> correct?
>
> I know that there are several ways I can turn off the warnings
> (syntactic predicate, options), but it would be nice if ANTLR could
> figure out that the alternatives really don't overlap even though it
> may predict the wrong alternative. Eventually, it would be good to
> fix as many of these mispredictions as possible, but initially
> functionality is what matters.
>
> Eric
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list