antlr / antlrcs

The C# port of ANTLR 3, StringTemplate 3, and StringTemplate 4
Other
282 stars 81 forks source link

antlr3 template generating wrong code #127

Open IRebo opened 4 years ago

IRebo commented 4 years ago

Hi,

i was trying to upgrade our project from older antlr 3.4 to the latest 3.5 (tried various version including the latest 3.5.2-rc1) but I keep getting a compilation error of the produced .cs file.

I have found traces of other people running into the same issue and they can describe it better then me :) https://stackoverflow.com/questions/9923639/antlr-grammar-generating-invalid-c-sharp-code https://www.antlr3.org/pipermail/antlr-interest/2012-February/044153.html

But the solution suggested (setting ASTLabelType to StringTemplate) doesnt make much sense as ASTLabelType should be of the AST type.

I have attached a minimal solution for easier diagnosing.

IRebo commented 4 years ago

antlr_test.zip

IRebo commented 3 years ago

curiously i found a solution discussed back in 2011 if anyone else runs into it - https://raw.githubusercontent.com/antlr/website-antlr3/aa6181595356409f8dc624e54715f56bd10707a8/pipermail/antlr-interest/2011-September/042586.html