English 中文(简体)
ANTLR parser hanging at proxy.handshake call
原标题:

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:

https://www.bpsite.net/misc/eclipse-antlr-debug.png
(source: bpsite.net)

问题回答

There is a -debug option in Antlr that causes additional code to generated allowing for remote debugging. When the code pauses on the the

dbg.Handshake();

call, it is waiting for the remote debugger to connect to it. In AntlrWorks you can use the Run --> Remote Debug option to connect to it and step through the code.

If you don t wish to use the remote debugging functionality, remove the -debug option from the ANTLR options text box.

File --> Preferences --> General --> ANTLR Options





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签