antlr/antlr4 — Issue #13: Getters in context objects can go wrong when some alternatives have labels and some do not
Author: parrt
Created: 2012-02-15 00:45:25+00:00
State: open

It gets ugly when you only partially label the alternatives and rule because it can cause type collisions with overridden methods. For unlabeled alternatives, we get getters in the main context object. The context objects for labeled alternatives are subclasses of that context. We might have a collision when we override:

e : e '+' e -> Add
| '(' e ')'
| ID
;

The unlabeled alternatives get methods in eContext:

public eContext e() { }
public Token ID() { }

But in the AddContext, we find an override with a different return type:

public List e() { }

since e can have multiple values in that context. I'm not sure how to resolve.