[antlr-interest] Bug with "ambiguous rules" check
Terence Parr
parrt at cs.usfca.edu
Sat Aug 2 11:40:30 PDT 2008
Hi Sam,
$r can refer to r reference or enclosing rule r in recursive rules.
The error is correct I believe.
T
On Aug 2, 2008, at 10:35 AM, Sam Harwell wrote:
> The following code generates an error, even though the rule is not
> ambiguous. As far as I can tell, this rule shouldn’t even produce a
> warning. If the $ isn’t enough to make the code clear (visually; it
> already is syntactically), we need a keyword to reference the
> enclosing rule (which might not be a bad idea anyway). The error is
> reported in codegen.g, and removing the if statement that checks for
> it let my grammar compile/work again :)
>
> assignment_expression
> // left-factoring the assignment expression and
> conditional_expression for speed
> : ( logical_or_expression
> -> ^(logical_or_expression)
> )
> ( assignment_operator assignment_expression
> -> ^(assignment_operator
> $assignment_expression assignment_expression)
> | '?' expression ':' assignment_expression
> -> ^(AST_CONDITIONAL $assignment_expression
> expression assignment_expression)
> )?
> | throw_expression
> -> ^(throw_expression)
> ;
>
> ANTLR Parser Generator Version 3.1b2 (July 17, 2008) 1989-2008
> Grammar.g3(6159,29): error 132: reference $assignment_expression is
> ambiguous; rule assignment_expression is enclosing rule and
> referenced in the production (assuming enclosing rule)
> Grammar.g3(6161,25): error 132: reference $assignment_expression is
> ambiguous; rule assignment_expression is enclosing rule and
> referenced in the production (assuming enclosing rule)
>
>
More information about the antlr-interest
mailing list