antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.17k stars 3.28k forks source link

Use of "expressions" in a parser grammar for Dart target causes compiler errors #3203

Open kaby76 opened 3 years ago

kaby76 commented 3 years ago

This seems like an Antlr4 4.9.2 bug with Dart code generation. When I use "expressions" in grammars-v4/sql/plsql/PlSqlParser.g4, the generated code from Dart contains two methods for "expressions()" with different return values. I can work around the problem by renaming "expressions" to "expressions_" in the grammar.

lingyv-li commented 3 years ago

This is because Dart doesn't support method overloading like Java, so the signature can clash if there is another token/rule of the same name. I saw some other targets use <rule name>List() instead of <rule name>s() so the issue doesn't happen in this case. However that doesn't completely solve the issue. I can raise a PR to do the same, though it would introduce backward incompatibility.