Nested blocks - on a leaf node, how do I know which one I'm in?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   martin_braid
Posted On:   Tuesday, March 25, 2003 06:14 PM

I'm parsing a language which allows nested blocks of expressions. I have created an AST tree that allows an arbitrary depth of nested blocks - each block has as a root an imaginary AST of type BLOCK. I need to maintain a symbol table that is BLOCK specific; that is, down at the leaf nodes, I need to know which BLOCK I'm in. But I cannot label the BLOCK (eg. curBlk:BLOCK) because curBlk is not set until after is has matched everything in the block (ie after it has visited all the leaf nodes). On a leaf node, I cannot look back up the tree to get the BLOCK because the AST's cannot be walked up, they only point down or to the right. What are my other options? By the way, this is the same issue in a FAQ question regarding "con   More>>

I'm parsing a language which allows nested blocks of expressions. I have created an AST tree that allows an arbitrary depth of nested blocks - each block has as a root an imaginary AST of type BLOCK.

I need to maintain a symbol table that is BLOCK specific; that is, down at the leaf nodes, I need to know which BLOCK I'm in. But I cannot label the BLOCK (eg. curBlk:BLOCK) because curBlk is not set until after is has matched everything in the block (ie after it has visited all the leaf nodes). On a leaf node, I cannot look back up the tree to get the BLOCK because the AST's cannot be walked up, they only point down or to the right. What are my other options?

By the way, this is the same issue in a FAQ question regarding "context" from Sep 1999, but isn't really answered.

   <<Less
About | Sitemap | Contact