[antlr-interest] tree parsers and stacks

John Allen Green greenj at ix.netcom.com
Mon Nov 15 12:24:14 PST 2004



> From Terence Parr, 11/15/2004 9:44 AM -0800:
> 
> Almost.  You need a stack of them.  Imagine that you need a reference 
> to the declarations for each {...} block.  Now if you set an instance 
> variable, what happens when you nest {..}?  Clearly you need a stack.
>  Why do this by hand?  Believe me, in my experience, you need context 
> and generally you need it to nest.


I haven't looked into the source, but is there an option in the tree
parser generator so that the resulting parser keeps a stack of the head
nodes, as the tree is descended? That would allow you to climb up the
tree at any point within the tree parser, to find the enclosing
expression, statement, function, etc. It might save you from some of
the effort of writing actions in the grammar manually, for keeping
stacks for scopes and whatnot.

I'm using the tree parser for analysis, but not transforms, so I just
use an AST with additional "back" and "up" links. So... I don't really
need it, I'm just curious.  :)


John
www.joanju.com
 


 
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