[antlr-interest] Bug with "ambiguous rules" check
    Sam Harwell 
    sharwell at pixelminegames.com
       
    Sat Aug  2 10:35:12 PDT 2008
    
    
  
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)
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080802/6b9eda62/attachment.html 
    
    
More information about the antlr-interest
mailing list