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

Throw warning if symbol conflicts with generated code in another language or runtime #1670

Closed
KvanTTT opened this issue Feb 17, 2017 · 4 comments

Comments

@KvanTTT
Copy link
Member

KvanTTT commented Feb 17, 2017

Consider grammar with file root element. If generate parser for Python2 target the following error will be thrown:

error(134): L.g4:18:0: symbol file conflicts with generated code in target language or runtime

But if we change runtime to Java no error and warning will be thrown.

So, I suggest to throw a warning in this case:

warning(134): L.g4:18:0: symbol file conflicts with generated code in another language or runtime

This check allows us to write more universal grammars for all targets.

@mike-lischke
Copy link
Member

mike-lischke commented Feb 22, 2017

Hmm, but then you might get warnings for names that you don't care for, if you don't intent to use a grammar in another language. That doesn't play well with build systems that strive for zero error and warning messages.

@KvanTTT
Copy link
Member Author

KvanTTT commented Mar 2, 2017

Maybe ANTLR should have a command line parameter universal that point on whether grammar should be wide or not? The user from this issue antlr/grammars-v4#568 suffers from runtime keywords.

@mike-lischke
Copy link
Member

How can this work out? You would need to test for all supported languages and as soon as a new language comes up you have to update that. That's this kind of cleverness which gets in the way more than what it solves. If a grammar is not compatible with a target language it must be changed, as easy as that.

@parrt
Copy link
Member

parrt commented Mar 14, 2017

I think most people use a single target and so I think we are okay. Closing.

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

3 participants