[antlr-interest] Help: What does this mean?

Johannes Luber jaluber at gmx.de
Sat Nov 17 02:53:53 PST 2007


Austin Hastings wrote:
> I get this warning:
> 
>   [antlr3] warning(200):
> /home/austin/gunit/sources/org/antlr/gunit/TestSuite.g:504:51: Decision
> can match input such as "'&&'" using multiple alternatives: 1, 2
>   [antlr3] As a result, alternative(s) 2 were disabled for that input
> 
> 
> For this code:
> 
> outputExpr_and returns [Assertion assertion]
>    : op1=outputExpr_primary ('&&' op2=outputExpr_and)*
>      {
>        if (op2 == null)
>        {
>            $assertion = $op1.assertion;
>        }
>        else
>        {
>            $assertion = new Conjunction($op1.start, $op2.stop);
>            $assertion.addClauses($op1.assertion, $op2.assertion);
>        }
>      }
>    ;
> 
> I don't see two alternatives, unless the * is considered an alternative
> somehow. The 'outputExpr_primary' production is always something
> concrete, either a parenthesized subexpression or a list of keywords -
> never empty. So (1) what are "alternatives 1,2" for this case; and (2)
> how could I display them - is there a "painfully verbose" antlr switch I
> don't know about?

The problem is that the two alternatives come up with interaction of
other rules. outputExpr_primary seems to be able to expand itself to
include '&&'. But without a full grammar I can't help you further. Use
ANTLRworks's Check Grammar facility to get a better idea of the cause.
In the worst case you have to use backtrack='true'; option (try local
first).

Johannes


More information about the antlr-interest mailing list