antlr4: ATN version 2 expected 3

2019-06-17 05:32发布

问题:

When trying to use a generated grammar and lexer I get:

org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 2 (expected 3).

What's wrong?

回答1:

Your parser was generated with ANTLR 4.0, but you are trying to execute it with ANTLR 4.1. The most likely cause of this is using ANTLRWorks 2.0 to generate the parser, which internally uses ANTLR 4.0. I'm in the process of releasing ANTLRWorks 2.1 which will correct this mismatch.