[antlr-interest] Ambiguous grammar or Antlr?
Loring Craymer
lgcraymer at yahoo.com
Thu Jul 2 23:44:26 PDT 2009
Don't believe everything you read--excessive optimism is the developer's friend, and Ter was in the full throes of developing ANTLR when he wrote TDAR. Refactoring is a normal (and usually critical) part of grammar development; Jim was offering good advice.
--Loring
----- Original Message ----
> From: Gary R. Van Sickle <g.r.vansickle at att.net>
> To: antlr-interest at antlr.org
> Sent: Thursday, July 2, 2009 10:47:30 PM
> Subject: Re: [antlr-interest] Ambiguous grammar or Antlr?
>
> Jim Idle wrote:
>
> [snip]
> > Even with backtracking, you still need to know something
> > about LL(k) and parsing etc, and switching on backtrack mode
> > will hide all your problems. It also means, as you have found
> > out, that in the event of a syntax error, you cannot
> > determine much about the location of your error.
> >
> > Basically, you will need to left factor at least some parts
> > of your grammar. In this case, if you have something like:
> >
> > | ID
> > | ID '(' expr ')'
> > | ID something else
> >
> > and (probably more complicated than that is your issue), then
> > look to do:
> >
> > | ID ( '(' expr
> > | something
> > )?
> >
> > and so on.
>
> But isn't the whole point of LL(*) to eliminate the need to do exactly this
> sort of left-factoring? Section 11.3 of Ter's book gives essentially the
> former as an example of why LL(*) makes it so you don't have to do a manual
> refactoring such as the latter. In fact, that section makes the argument
> that one should *not* do the left-factoring manually, if for no other reason
> than to maintain the readability of the grammar.
>
> --
> Gary R. Van Sickle
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list