ANTLRWorks 2.1:在 Eclipse 中生成 Lexer+Parser 导致 UUID 异常 [英] ANTLRWorks 2.1: generated Lexer+Parser in Eclipse causing UUID exception

查看:17
本文介绍了ANTLRWorks 2.1:在 Eclipse 中生成 Lexer+Parser 导致 UUID 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ANTLR 和 ANTLRWorks 的新手,所以我很困惑:我正在使用 ANTLRWorks 2.1 来创建语法并随后创建词法分析器和解析器(Java 目标).然后,我创建了一个小型 Eclipse 项目,并从 ANTLRWorks 导入了 ANTLR4 jar 以手动调用词法分析器和解析器,如 ANTLR 书籍示例中所述.运行应用程序时出现以下异常:

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

然而,当在 ANTLRWorks TestRig 中运行相同的语法和输入数据时,一切正常.这里出了什么问题?我已经找到了关于版本控制问题的类似帖子,但是没有解决这个 UUID 问题.有人能帮我解决这个问题吗?

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?

提前致谢!

推荐答案

ANTLRWorks 使用 ANTLR 的非标准构建,以支持其某些编辑器功能(代码完成等).它的设计方式支持正确的代码生成,但为了编译和运行您的解析器,您需要使用来自 antlr.org.

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.

这篇关于ANTLRWorks 2.1:在 Eclipse 中生成 Lexer+Parser 导致 UUID 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆