Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Remote debugging is enabled for a parser by setting the ANTLR -debug flag (to true) when generating the parser from the grammar.
This has the effect of changing the superclass of the generated parser to subclass DebugParser and inserts various debugging hooks throughout the recursive descent parsing process.
Accordingly the simple driver class to exercise the parser is slightly different.
What is different?

Code Block
borderStylesolid
titlesample.gborderStylesolid
grammar sample;

example : 'SOME TEXT TO PARSE';

...and a corresponding remote debug driver...

Code Block
borderStylesolid
titleremoteDebugDriver.javaborderStylesolid
public class RemoteDebugDriver
 {
    public static void main(String\[\] args) throws Exception {

         InputStream stream = new ByteArrayInputStream("SOME TEXT TO PARSE".getBytes()); // defaults to ISO-1
         ANTLRInputStream inputStream = new ANTLRInputStream(stream);
         sampleLexer lexer = new sampleLexer( inputStream );
         CommonTokenStream tokenStream = new CommonTokenStream(lexer);
         SampleParser parser = new sampleParser(tokenStream);
         parser.example();
         System.exit(0);
    }
 }

...