Moved magic methods from ExpressionNode to Node.

parent e377e758
......@@ -2,8 +2,12 @@
class Node(object):
def __init__(self, label, *nodes):
self.label, self.nodes = label, list(nodes)
def __init__(self, value, *nodes):
self.value, self.nodes = value, list(nodes)
self.parent = None
for a in self.nodes:
a.parent = self
def __getitem__(self, n):
return self.nodes[n]
......@@ -18,12 +22,19 @@ class Node(object):
return len(self.nodes)
def title(self):
return str(self.label)
return str(self.value)
class Leaf(object):
def __init__(self, label):
self.label = label
def __init__(self, value):
self.value = value
self.parent = None
def __repr__(self):
return repr(self.value)
def __str__(self):
return str(self.value)
def title(self):
return str(self.label)
return str(self.value)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment