by AC <user@[EMAIL PROTECTED]
>
Sep 1, 2007 at 08:06 AM
Cesare Zecca wrote:
> ID and GROUP_ID share a common prefix and cause a lookahead problem.
Actually, the problem is that there are two ways to parse an <ID>,
either
Factor() -> Id() -> <ID>
or
Factor() -> GroupId() -> <ID>
The parser doesn't know which one to choose.
For the example grammar, this is unnecessary, so the fix is to
eliminate the redundancy.
Approach 1: Eliminate Id() and GroupId() and replace the body of
Factor() with the body of GroupId(). This results in the simplest
grammar. Then <ID> would be parsed via
Factor() -> <ID>
Approach 2: Remove <ID> from GroupId(), since it is already covered by
the Id() call in Factor(). Then <ID> would be parsed via
Factor() -> Id() -> <ID>
Hope this helps!