@@ -41,18 +41,23 @@ def previsitor(tree, fn, fn_parent=None):
41
41
previsitor (child , fn , fn_out )
42
42
43
43
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.
46
46
47
47
Parameters
48
48
----------
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)
52
52
A function to be applied at each node. The function should take the
53
53
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.
55
59
'''
56
60
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