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

Build issue on generated golang code #8

Open
pierredittgen opened this issue May 24, 2016 · 3 comments
Open

Build issue on generated golang code #8

pierredittgen opened this issue May 24, 2016 · 3 comments
Labels

Comments

@pierredittgen
Copy link

Hi!

I wrote a simple grammar to parse instance lines in STEP format (STEP.g4)

Grammar is ok, i already generated working Python code.
Golang code generation works too, but I can't build the generated golang source, especially step_parser.go:

tech.fr/parser

tech.fr/parser/step_parser.go:408: cannot use s (type *ParameterContext) as type antlr4.RuleContext in return argument:
*ParameterContext does not implement antlr4.RuleContext (wrong type for String method)
have String() antlr4.TerminalNode
want String([]string, antlr4.RuleContext) string
tech.fr/parser/step_parser.go:425: cannot use NewParameterContext(p, p.BaseParser.GetParserRuleContext(), p.BaseParser.BaseRecognizer.GetState()) (type *ParameterContext) as type IParameterContext in assignment:
*ParameterContext does not implement IParameterContext (wrong type for String method)
have String() antlr4.TerminalNode
want String([]string, antlr4.RuleContext) string

Any clue to make this work?
Pierre
STEP.g4.txt
step_parser.go.txt

@pboyer
Copy link
Owner

pboyer commented May 25, 2016

Thanks @pierredittgen. Sounds like an issue with the templates. I'm presently at a conference but I'll look soon.

@pierredittgen
Copy link
Author

Thanks
I stay tuned!

@pboyer
Copy link
Owner

pboyer commented Oct 13, 2016

I've taken a look at this and I think the issue is certainly to do with the "String" value here:

parameter : Number | ByteString | String | Enum | Empty | Id | parameters ;

Consider if you named such a member toString. This would collide in other languages.

For Go, this collides with an internal String method. This shouldn't be hard to fix, but there's more than one option on how to do it.

  1. Rename the internal method
  2. Rename the method in generated code

millergarym pushed a commit to millergarym/antlr4 that referenced this issue Nov 16, 2016
Additionally a warning was fixed (std::move prevents copy elision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants