[antlr-interest] parse trees and syntax of parse trees

Monty Zukowski monty at codetransform.com
Thu Apr 22 09:57:45 PDT 2004


On Apr 22, 2004, at 8:25 AM, ronald.petty at milliman.com wrote:

>
> So when using the parser without any tree syntax that would still 
> produce a AST correct?  If so, why have the manual intervention of the 
> Tree syntax?  I believe I am confused on the seperation of the parser 
> and trees.
>

No, a parser doesn't have to create a tree.  Turn off tree building and 
the parser merely parses and executes whatever action code you have.  
Turn it on and you get a "tree" which has no structure--it will be a 
linked list of all the tokens as nodes but there will never be a child 
node, they will all be siblings.

You start getting a tree structure once you start building a tree by 
adding the ^ operator to make root nodes with children.  There are, in 
fact, many different ways to structure your trees.  I'm going through 
the process right now myself with an SQL grammar.  I've been taking 
notes and when I understand what I've been doing I'll post and open up 
for discussion, after which I hope to write an article about it.

Terence has an excellent tutorial on tree building on his USF lecture 
notes site, linked to from antlr.org.  That should help clarify some 
typical uses for trees.

Monty Zukowski

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list