allowing empty left leaf for operator of 1 arity

This commit is contained in:
Bertrand Benjamin 2018-01-21 17:05:54 +03:00
parent b885bb6b8f
commit 7d00d3342a

View File

@ -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
@ -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)