@@ -41,18 +41,23 @@ def previsitor(tree, fn, fn_parent=None):
4141 previsitor (child , fn , fn_out )
4242
4343
44- def postvisitor (tree , fn , ** kwargs ):
45- '''Traverse tree in postorder applying a function to every node.
44+ def postvisitor (expr , fn , ** kwargs ):
45+ '''Traverse an Expression in postorder applying a function to every node.
4646
4747 Parameters
4848 ----------
49- tree: TreeNode
50- The tree to be visited.
51- fn: ` function(node, *fn_children)`
49+ expr: Expression
50+ The expression to be visited.
51+ fn: function(node, *o, **kwargs)
5252 A function to be applied at each node. The function should take the
5353 node to be visited as its first argument, and the results of visiting
54- its children as any further arguments.
54+ its operands as any further positional arguments. Any additional
55+ information that the visitor requires can be passed in as keyword
56+ arguments.
57+ **kwargs:
58+ Any additional keyword arguments to be passed to fn.
5559 '''
5660
57- return fn (tree ,
58- * (postvisitor (c , fn , ** kwargs ) for c in tree .children ), ** kwargs )
61+ return fn (expr ,
62+ * (postvisitor (c , fn , ** kwargs ) for c in expr .operands ),
63+ ** kwargs )
0 commit comments