antlr/antlr4 — Issue #19: Getter for context is not a list when it should be
Author: parrt
Created: 2012-02-18 18:12:09+00:00
State: open
Labels: trees-contexts, type:bug:1

For this rule

compilationUnit
locals[CymbolProperties props]
@init{$compilationUnit.props = new CymbolProperties();}
: (structDeclaration
| methodDeclaration
| varDeclaration)+
;

I would expect

ctx.methodDeclaration();

To hand back a list of methodDeclCtxs (ditto for structDecls and varDecls)

However, here is the generated code:

public structDeclarationContext structDeclaration() {
return (structDeclarationContext)getRuleContext(structDeclarationContext.class,0);
}
public varDeclarationContext varDeclaration() {
return (varDeclarationContext)getRuleContext(varDeclarationContext.class,0);
}
public methodDeclarationContext methodDeclaration() {
return (methodDeclarationContext)getRuleContext(methodDeclarationContext.class,0);
}