Lines Matching refs:self
50 def __init__ (self): argument
51 self.left = None
52 self.right = None
53 self.parent = None
54 self.op = None
58 def __init__ (self, tokens): argument
59 self.tokens = tokens
61 def jumpToRoot (self): argument
62 while self.ptr.parent != None:
63 self.ptr = self.ptr.parent
65 def build (self): argument
66 self.ptr = Node()
68 for token in self.tokens:
71 if self.ptr.left == None:
73 if self.ptr.right == None:
74 self.ptr.op = token
76 self.jumpToRoot()
77 self.ptr.parent = Node()
78 self.ptr.parent.left = self.ptr
79 self.ptr = self.ptr.parent
80 self.ptr.op = token
83 if self.ptr.left == None:
85 elif self.ptr.right == None:
86 self.ptr.op = token
88 num = self.ptr.right
89 self.ptr.right = Node()
90 self.ptr.right.parent = self.ptr
91 self.ptr.right.left = num
92 self.ptr.right.op = token
93 self.ptr = self.ptr.right
96 if self.ptr.left == None:
97 self.ptr.left = Node()
98 self.ptr.left.parent = self.ptr
99 self.ptr = self.ptr.left
100 elif self.ptr.right == None:
101 self.ptr.right = Node()
102 self.ptr.right.parent = self.ptr
103 self.ptr = self.ptr.right
108 if self.ptr.left == None:
110 elif self.ptr.right == None:
112 elif self.ptr.parent == None:
115 self.ptr = self.ptr.parent
119 if self.ptr.left == None:
120 self.ptr.left = num
121 elif self.ptr.right == None:
122 self.ptr.right = num
126 def dumpTree (self): argument
127 self.jumpToRoot()
128 print(toString(self.ptr))