ANTLR 解析器挂在 proxy.handshake 调用中 [英] ANTLR parser hanging at proxy.handshake call
问题描述
我正在尝试让基本的 ECMAScript 解析器正常工作,并为
(来源:bpsite.net)
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)
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();
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.
I solved this by disabling the generation of debug code within the ANTLR IDE plugin.
The setting for this is under Windows > Preferences > ANTLR > Code Generation.
Expand the General section and untick the debug option:
(source: bpsite.net)
这篇关于ANTLR 解析器挂在 proxy.handshake 调用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!