[antlr-interest] Reuse rule-return "shortcuts"

Felix Dorner felix_do at web.de
Wed Apr 2 08:10:16 PDT 2008


Hey,

I try to reuse abbreviations for return values in rules like this:

expression: op=unaryOp e1=expression | op=binaryOp e1=expression 
e2=expression;

It seems like Antlr(3.0.1) can't handle this correctly, as it does not 
suffix the "op" with a unique id. So "op" gets only declared once. In 
generated code for the the second alternative, the assignment is 
completely missing.

Strangely a few minutes ago I got a warning "redefiniton of rule 
attribute with incompatible type" (or so). That warning now doesn't 
appear anymore, instead this silent bogus.

I'd like to be able to reuse these names (how are they called actually?) 
in different  alternatives even  if their types are different.  Antlr 
would have to append unique id in the generated code then.

Thanks for comments.
Felix



More information about the antlr-interest mailing list