Package schrodinger :: Package application :: Package desmond :: Package antlr3 :: Module tree :: Class TreeVisitor
[hide private]
[frames] | no frames]

Class TreeVisitor

object --+
         |
        TreeVisitor

Do a depth first walk of a tree, applying pre() and post() actions we go.

Instance Methods [hide private]
 
__init__(self, adaptor=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
visit(self, t, pre_action=None, post_action=None)
Visit every node in tree t and trigger an action for each node before/after having visited all of its children.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, adaptor=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

visit(self, t, pre_action=None, post_action=None)

 

Visit every node in tree t and trigger an action for each node before/after having visited all of its children. Bottom up walk. Execute both actions even if t has no children. Ignore return results from transforming children since they will have altered the child list of this node (their parent). Return result of applying post action to this node.

The Python version differs from the Java version by taking two callables 'pre_action' and 'post_action' instead of a class instance that wraps those methods. Those callables must accept a TreeNode as their single argument and return the (potentially transformed or replaced) TreeNode.