本文介绍了ANTLR解析器挂在proxy.handshake调用上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使基本的ECMAScript解析器正常工作,并为 ECMAScript 3 ,似乎可以编译并生成适当的Lexer/Parser/Walker Java文件.
(在Eclipse 3.5的
ANTLR IDE插件中运行)

I am attempting to get a basic ECMAScript parser working, and found a complete ANTLR grammar for ECMAScript 3, which appears to compile ok and produces the appropriate Lexer/Parser/Walker Java files.
(Running inside ANTLR IDE plugin for Eclipse 3.5)

但是,当实际尝试将其与一些简单的测试代码一起使用时(遵循有关ANTLR Wiki的指南),它只是在尝试创建解析器时挂起:

However, when actually trying to use it with some simple test code (following guide on ANTLR wiki), it just hangs when trying to create the parser:

CharStream MyChars = new ANTLRFileStream(FileName); // FileName is valid
ES3Lexer MyLexer = new ES3Lexer(MyChars);
CommonTokenStream MyTokens = new CommonTokenStream(MyLexer);
MyTokens.setTokenSource(MyLexer);
ES3Parser MyParser = new ES3Parser( MyTokens ); // hangs here
ES3Parser.program_return MyReturn = MyParser.program();

我已经在ES3Parser构造函数内部找到了问题,在该构造函数中调用了函数proxy.handshake()-在此行之前,我可以成功执行System.out.println("text"),但之后却一无所获.

I've tracked down the problem to inside the ES3Parser constructor, where it's calling the function proxy.handshake() - before this line I can successfully do System.out.println("text") but after it I get nothing.

所以,我如何找出它为什么挂起并停止它-甚至只是绕过本节(我可以/应该禁用调试吗?)-只要它能够正常工作并使我继续做有用的事情.

So, how do I go about finding out why it's hanging, and stopping it - or even just bypassing this section (can/should I disable debugging?) - so long as that lets it work and allows me to get on with doing useful stuff.

推荐答案

我通过禁用ANTLR IDE插件中的调试代码生成来解决了这个问题.

I solved this by disabling the generation of debug code within the ANTLR IDE plugin.

此设置位于Windows>偏好设置">"ANTLR">代码生成"下.

The setting for this is under Windows > Preferences > ANTLR > Code Generation.

展开常规"部分,然后取消选中调试选项:

Expand the General section and untick the debug option:



这篇关于ANTLR解析器挂在proxy.handshake调用上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 10:44