1
votes

I'm new to ANTLR and ANTLRWorks, so I'm quite puzzled by this: I'm using ANTLRWorks 2.1 for grammar creation and subsequent creation of the lexer and parser (Java target). I have then created a small Eclipse project and imported the ANTLR4 jars from ANTLRWorks to manually call the lexer and parser as described in the ANTLR book examples. When running the application I get the following exception:

Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not  deserialize ATN with UUID 33761b2d-78bb-4a43-8b0b-4f5bee8aacf3 (expected e4178468-df95-44d0-ad87-f22a5d5fb6d3).
    at org.antlr.v4.runtime.atn.ATNSimulator.deserialize(ATNSimulator.java:111)
    at org.antlr.v4.runtime.atn.ATNSimulator.deserialize(ATNSimulator.java:90)
    at TestLexer.<clinit>(TestLexer.java:177)
    ... 1 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 33761b2d-78bb-4a43-8b0b-4f5bee8aacf3 (expected e4178468-df95-44d0-ad87-f22a5d5fb6d3).
    ... 4 more

However, when running the same grammar and input data in the ANTLRWorks TestRig, everything works fine. What is going wrong here? I have already found similar posts regarding versioning issues, however none addressing this UUID issue. Can anyone help me with this?

Thanks in advance!

2

2 Answers

2
votes

ANTLRWorks uses a non-standard build of ANTLR in order to support some of its editor features (code completion, etc.). It is designed in a way that supports proper code generation, but in order to compile and run your parser you'll need to use the reference ANTLR library from antlr.org.

0
votes

The most probable reason is that you're using different version of the antlr runtime at parser generation time and at runtime.

Make double sure you use the exact same antlr version in both cases, and the error should go away.

Disclaimer: I may be wrong, as I'm using antlr in .Net.