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

Redeclared variables in Go target #2653

Open
MattNot opened this issue Sep 19, 2019 · 3 comments
Open

Redeclared variables in Go target #2653

MattNot opened this issue Sep 19, 2019 · 3 comments

Comments

@MattNot
Copy link

MattNot commented Sep 19, 2019

I noticed a bug.
I've 2 *.g4 files, one with the grammar and one with just the lexer.
I generated my parser with
anltr4 -Dlanguage=Go *.g4
The lexer is imported with
import MyLexer; in the grammar file

So i got all the files but when i tried the code (cut and paste) from the example in the README the golang console says that a lot of variables are redeclared.

How to fix: delete the generated files that is about the MyLexer.g4

@Kish29
Copy link

Kish29 commented Dec 31, 2021

I also have the same problem...

@MattNot
Copy link
Author

MattNot commented Dec 31, 2021

I included a fix to it, not the best but is something

@kaby76
Copy link
Contributor

kaby76 commented Jan 2, 2022

I have a similar issue #3452 for grammars-v4/csharp/. This grammar has two parser grammars (CSharpParser and CSharpPreprocessorParser) with one shared lexer grammar (CSharpLexer). The only reasonable workaround I found was to generate each parser into a separate directory/package and duplicate the generated code for the lexer into each of these separate directories. In addition, because the parser and lexer are implemented as nested structs rather than a pointer to a superclass (implemented as an object), there is no way to create and call a "constructor" (implemented as a "New..."-named func) except by calling some initializer at the top-level fro the parser. #3446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants