I need to see what rules my parser is using, and need to know if there is a simple debugging option like the -gd option to antlr in v1.33? Or, I have no idea what is wrong with my parser/lexer; what can I do?

Monty Zukowski

From ANTLR 2.2.0 you can use '-traceLexer', '-traceParser' or -'traceTreeParser'. These call traceIn and traceOut methods you can override for more info if you wish. I over-rode them to print the name of the token with the tokenNames array:

  public void traceIn(String rname) {
    System.out.println("enter "+rname+"; LA(1)==("+
                       tokenNames[LT(1).getType()] + ") " + LT(1).getText()+
                       ((guessing>0)?" [guessing]":""));
  public void traceOut(String rname) {
    System.out.println("exit "+rname+"; LA(1)==("+
                       tokenNames[LT(1).getType()] + ") "+LT(1).getText()+
                       ((guessing>0)?" [guessing]":""));