Add support for extra (*) arguments to preorder.
Change default dispatch to use extended call syntax in place of apply.
This commit is contained in:
parent
9ab019bee7
commit
d91bbba89d
|
@ -61,13 +61,13 @@ class ASTVisitor:
|
|||
print "dispatch", className
|
||||
else:
|
||||
print "dispatch", className, (meth and meth.__name__ or '')
|
||||
return apply(meth, (node,) + args)
|
||||
return meth(node, *args)
|
||||
|
||||
def preorder(self, tree, visitor):
|
||||
def preorder(self, tree, visitor, *args):
|
||||
"""Do preorder walk of tree using visitor"""
|
||||
self.visitor = visitor
|
||||
visitor.visit = self._preorder
|
||||
self._preorder(tree)
|
||||
self._preorder(tree, *args) # XXX *args make sense?
|
||||
|
||||
_preorder = dispatch
|
||||
|
||||
|
|
|
@ -61,13 +61,13 @@ class ASTVisitor:
|
|||
print "dispatch", className
|
||||
else:
|
||||
print "dispatch", className, (meth and meth.__name__ or '')
|
||||
return apply(meth, (node,) + args)
|
||||
return meth(node, *args)
|
||||
|
||||
def preorder(self, tree, visitor):
|
||||
def preorder(self, tree, visitor, *args):
|
||||
"""Do preorder walk of tree using visitor"""
|
||||
self.visitor = visitor
|
||||
visitor.visit = self._preorder
|
||||
self._preorder(tree)
|
||||
self._preorder(tree, *args) # XXX *args make sense?
|
||||
|
||||
_preorder = dispatch
|
||||
|
||||
|
|
Loading…
Reference in New Issue