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.
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.
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.
Consider grammar with
file
root element. If generate parser for Python2 target the following error will be thrown:But if we change runtime to Java no error and warning will be thrown.
So, I suggest to throw a warning in this case:
This check allows us to write more universal grammars for all targets.
The text was updated successfully, but these errors were encountered: