[antlr-interest] Understanding the ANTLRworks Debugger's Parse Tree Display

Randall R Schulz rschulz at sonic.net
Tue Jun 26 15:55:06 PDT 2007


Hi,

Once parsing under the ANTLRworks debugger is complete (I single stepped 
for a while, then spent a moment being amazed that you can step 
_backward_ and then just let it run to the end), I get a parse tree 
that appears to contain two duplicated sub-trees with one of them (the 
one on the left) displayed in green.

But wait! At first I though the two parse trees were identical (they're 
large, even though the input is pretty simple—you know how verbose 
parse trees are...), but upon closer inspection, they're not the same. 
I can see places where the green parse tree reflects an incorrect parse 
while the black one appears to be correct.

So I guess this has something to do with backtracking? The green parse 
tree was abandoned because of backtracking? Is it something like that?

And in a later test, using more elaborate constructions, I see red, 
green and black parse nodes, though I believe the parse succeeded in 
the end (nothing was highlighted in red in the debugger's Input pane as 
there is when I introduce deliberate syntax errors in my test input).

So the question is: What do the colors mean? Are there other 
possibilities beyond black, green and red?


By the way, I did look on the ANTLRworks documentation page at 
antlr.org, but could find nothing describing this.


Thanks.


Randall Schulz


More information about the antlr-interest mailing list