In the past, I noted that one of the ANTLR compile errors was checking a
visual ambiguity and not a syntactic ambiguity. In order to work around
the error, I have placed a label ("right=") on one of the references in
the following rule. However, I still get:
error 132: reference $assign_expression is ambiguous; rule
assign_expression is enclosing rule and referenced in the production
(assuming enclosing rule)
assign_expression
: ( ternary_expression
-> ternary_expression
)
( assignment_operator
right=assign_expression
-> ^(assignment_operator $assign_expression
$right)
)?
;
I've tried to make suggestions for ways to prevent the visual ambiguity
that error 132 seeks to protect the developers from (such as $this or
$self as the implicit label for the enclosing rule), but we never
reached a consensus. Am I going to have to keep a modified version of
the antlr3 source indefinitely? With error 132 disabled, all my grammars
behave exactly as expected, even when written without the explicit
label, as in the following case:
assign_expression
: ( ternary_expression
-> ternary_expression
)
( assignment_operator
assign_expression
-> ^(assignment_operator $assign_expression
assign_expression)
)?
;
Sam
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev