commit
d3d3c47281
@ -121,14 +121,11 @@ class Node:
|
||||
|
||||
def printtree(self, level: int = 0) -> str:
|
||||
'''returns a representation of the tree using indentation'''
|
||||
r = ''
|
||||
for i in range(level):
|
||||
r += ' '
|
||||
r += self.name
|
||||
if self.name in b_operators:
|
||||
r = ' ' * level + self.name
|
||||
if self.name in b_operators and isinstance(self, Binary):
|
||||
r += self.left.printtree(level + 1)
|
||||
r += self.right.printtree(level + 1)
|
||||
elif self.name in u_operators:
|
||||
elif self.name in u_operators and isinstance(self, Unary):
|
||||
r += '\t%s\n' % self.prop
|
||||
r += self.child.printtree(level + 1)
|
||||
return '\n' + r
|
||||
|
Loading…
Reference in New Issue
Block a user