[antlr-interest] Some bugs (or features?) in Honey Badger

Jan Finis finis at in.tum.de
Sun Feb 19 07:52:10 PST 2012

Hi folks, hi Ter,

I discovered the following things while using Honey Badger. They seem 
like bugs to me but maybe they are features or I got something wrong:

1. Alternative precedence:

Consider the following left recursive rule for expressions:

     : ID '=' expr;
     | ID
     | expr '+' expr;

ID : 'a' ;

the precedence should be from top to bottom, right? So, the input  a=a+a 
should be parsed as (a=a)+a, since the assignment rule is on the top. 
However, this is not the case, instead, it is parsed as a=(a+a). Bug, or 
am I interpreting something wrong?

2. Name binding

Consider this example:

expr returns [int r]
     : '-' expr { $r = - $expr.r; }

In this example $expr should bind to the sub-expression in my opinion. 
However, it does not. Since the rule is also named expr, $expr refers to 
the rule context instead of the context of the sub-expression. I think 
most of the time this is not what the user wants.


More information about the antlr-interest mailing list