When do I need to use remote debugging?
If your lexer and parser grammar rules are contained in a single file
then you can debug it (for example, AST generation) in ANTLRWorks
without using remote debugging or writing any Java code. To do this,
- start ANTLRWorks
- open the combined grammar file
- select Debug... from the Debugger menu
- enter the input to be tested or select a file to be used as input
However, if your lexer and parser grammar rules are in separate files
then you must use remote debugging. To do this,
- generate classes for them using org.antlr.Tool and the -debug option
- write a main class that uses them to parse some input
- compile your code and the generated code
- run your application which will pause waiting for the debugger
- start ANTLRWorks
- open the parser grammar file
- select Debug Remote... from the Debugger menu
- press the Connect button
Do not pass null to the constructor of your Parser or TreeParser class
and attempt to set the stream they read from later
(using setTokenStream and setTreeNodeStream).
This will result in a NullPointerException in DebugTokenStream.