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

Diehl, Matthew J matthew.j.diehl at intel.com
Tue Jun 26 16:16:29 PDT 2007


Yes, as far as I've read, you're on track.  The green sub tree is from
parsing the predicates (which do backtrack if wrong).  Red sub trees
indicate that that particular alternative of the rule has failed (page
341 Figure 14.4).  Dark green has to do with a syntactic predicate that
was correct (page 339 Figure 14.2) and black has to do with
chosen/finalized paths.  

There's a huge section in the book from page 336 to 341 that talks all
about this and more.  I highly recommend getting it. It has pictures too
:)   So the multiple trees come from running through the predicates to
see if it should take that path (hence why it's only part of the black
tree), and then it runs through the rule to create the 'real' sub tree.

Matt

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Randall R Schulz
Sent: Tuesday, June 26, 2007 3:55 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Understanding the ANTLRworks Debugger's Parse
TreeDisplay

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