allowing empty left leaf for operator of 1 arity
This commit is contained in:
parent
b885bb6b8f
commit
7d00d3342a
@ -48,10 +48,8 @@ class Tree(object):
|
||||
>>> t.right_value
|
||||
2
|
||||
"""
|
||||
if node is None or \
|
||||
left_value is None or \
|
||||
right_value is None:
|
||||
raise TypeError("Tree can't have empty node or leaf")
|
||||
if node is None or right_value is None:
|
||||
raise TypeError("Tree can't have an empty node or an empty right leaf")
|
||||
|
||||
self.node = node
|
||||
|
||||
@ -64,7 +62,7 @@ class Tree(object):
|
||||
|
||||
:example:
|
||||
|
||||
>>> t = MutableTree.fromStr("2+3*4")
|
||||
>>> t = MutableTree.fromStr("2+3*4")
|
||||
>>> print(t)
|
||||
+
|
||||
> 2
|
||||
@ -492,7 +490,7 @@ class MutableTree(Tree):
|
||||
try:
|
||||
ans.set_node(c)
|
||||
except ValueError:
|
||||
if OPERATORS[c]["priority"] > OPERATORS[ans.node]["priority"]:
|
||||
if OPERATORS[c]["precedence"] > OPERATORS[ans.node]["precedence"]:
|
||||
ans.append_bot(c)
|
||||
else:
|
||||
ans.append_top(c)
|
||||
|
Loading…
Reference in New Issue
Block a user