antlr / antlrworks

AntlrWorks tool for ANTLR
http://www.antlr.org/works
97 stars 45 forks source link

ANTLRworks fails to generate proper Java Code #5

Closed FriedrichGretz closed 11 years ago

FriedrichGretz commented 11 years ago

I have a simple grammar (cf. https://gist.github.com/4499299)

If I compile it manually with antlr-3.5-complete.jar and set up a manual test rig, everything works as expected.

However, if I use ANTLRworks 1.5, I check the grammar.. OK, I generate code.. OK I click on debug and it starts compiling and complains abour errors in the parser (cf. gist above).

sharwell commented 11 years ago

I am not able to reproduce this bug. The grammar you provided compiled and ran in the ANTLRWorks debugger without problems.

FriedrichGretz commented 11 years ago

OK, that's funny. So here is what happens on my machine: Open ANTLRworks, create new grammar "test", c&p the grammar from above, check grammar, generate code, debug... At this point an error occurrs and you see the output I posted in the gist on the console.

I am using Windows 7, ANTLRworks 1.5, in the preferences the compiler is set to javac, so I assume it takes the javac which is in the OS's PATH variable and that is JDK version 1.6.0_26.

(I do have also java 7 on my system but I changed the path for javac back to java 6 since something ANTLR related would not work with 7 as before...)

tyconnell commented 11 years ago

I am having the same issue. I downloaded the csv grammar from http://www.harward.us/~nharward/antlr/csv.g (linked of of http://www.antlr.org/grammar/list.html). Open it up in antlrworks 1.5 - generate code. Debug mode generates: https://gist.github.com/4513995

housephd commented 11 years ago

I too have experienced the same issue after upgrading to ANTLRworks 1.5. I have tested it on two machines---my home computer (Win7 64-bit with the latest 64-bit Java7 release) and a fresh install on my work computer (Win 7 64-bit with 32-bit Java6 and Java7). Both my own work and the example provided by Friedrich (https://gist.github.com/4499299) generate incorrect code, missing the exception types after all of the "throws" keywords.

Running the same test grammar in ANTLRworks 1.4.3 seemed to work just fine.

LordZoltan commented 11 years ago

I'm just adding a repro vote to this. Running on Windows, have got JDK 1.7 update 13 installed and Antlrworks 1.5.

The parser code that is generated (note - the lexer is fine) has empty 'throws' keywords - i.e. is missing the 'RecognitionException' type.

Generating code for the same grammar in 1.4.3 works fine.

LordZoltan commented 11 years ago

Hi Sam just a quick note to say a) thank you and b) I've just started using v2 which, I believe, didn't have this bug. SoiI appreciate you fixing something in this earlier version!

TonyGrayCanada commented 11 years ago

Thanks for fixing, I had this too. I'm in the C# world, so when I want to debug/interpret I have to keep parallel grammars that are suitable for the Java target. When the debugger stopped working for those, I was stuck. I'll use 1.4.3 until the update is released.

rensink commented 7 years ago

Glad to have found this fix almost as soon as I encountered the bug; however, please note that the default download link from http://www.antlr3.org/download.html points to the broken version 1.5, not the repaired version 1.5.1. --Arend