Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getter for context is not a list when it should be #19

Closed
parrt opened this issue Feb 18, 2012 · 3 comments
Closed

Getter for context is not a list when it should be #19

parrt opened this issue Feb 18, 2012 · 3 comments

Comments

@parrt
Copy link
Member

parrt commented Feb 18, 2012

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);
}
@sharwell
Copy link
Member

Also, now that getRuleContext is a generic method, the return value cast is unnecessary.

@parrt
Copy link
Member Author

parrt commented Feb 18, 2012

rm'd already :)

sharwell added a commit to sharwell/antlr4 that referenced this issue Oct 25, 2012
@sharwell
Copy link
Member

This issue has been resolved, and a regression test is added in the associated pull request.

parrt pushed a commit that referenced this issue Nov 7, 2016
Added code to detect and handle the UTF-8 BOM if present
@ericvergnaud ericvergnaud mentioned this issue Nov 8, 2016
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants