add Node.visit() method
This commit is contained in:
parent
ba80f5d9f7
commit
854b82e088
@ -4,6 +4,10 @@ class Node(object):
|
|||||||
self.children = children
|
self.children = children
|
||||||
if self.children is None:
|
if self.children is None:
|
||||||
self.children = []
|
self.children = []
|
||||||
|
def visit(self, callback, *args):
|
||||||
|
callback(self, *args)
|
||||||
|
for c in self.children:
|
||||||
|
c.visit(callback, *args)
|
||||||
|
|
||||||
class StatementNode(Node):
|
class StatementNode(Node):
|
||||||
def __init__(self, children=None):
|
def __init__(self, children=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user