Commit b31467af authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen

Merge branch 'master' of kompiler.org:trs

parents 2ac45d25 ee3de873
graph_drawing @ fa7bed92
Subproject commit 591a3e65e0c08a4e9d316faee92dc3bd58b3dd86 Subproject commit fa7bed9265f59c6ff2375c17c2df4be735d54f66
...@@ -137,7 +137,7 @@ class ExpressionBase(object): ...@@ -137,7 +137,7 @@ class ExpressionBase(object):
return ExpressionNode('^', self, to_expression(other)) return ExpressionNode('^', self, to_expression(other))
def __neg__(self): def __neg__(self):
return ExpressionNode('-', to_expression(self)) return ExpressionNode('-', self)
class ExpressionNode(Node, ExpressionBase): class ExpressionNode(Node, ExpressionBase):
...@@ -205,7 +205,7 @@ class ExpressionNode(Node, ExpressionBase): ...@@ -205,7 +205,7 @@ class ExpressionNode(Node, ExpressionBase):
# r e # r e
# #
# rule: c * r ^ e | (r ^ e) * c # rule: c * r ^ e | (r ^ e) * c
for i, j in [(0, 1), (1, 0)]: for i, j in ((0, 1), (1, 0)):
if self[j].is_power(): if self[j].is_power():
return (self[i], self[j][0], self[j][1]) return (self[i], self[j][0], self[j][1])
...@@ -242,8 +242,7 @@ class ExpressionLeaf(Leaf, ExpressionBase): ...@@ -242,8 +242,7 @@ class ExpressionLeaf(Leaf, ExpressionBase):
self.type = TYPE_MAP[type(args[0])] self.type = TYPE_MAP[type(args[0])]
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, int) or isinstance(other, float) \ if type(other) in (int, float, str):
or isinstance(other, str):
return self.value == other return self.value == other
if other.is_leaf(): if other.is_leaf():
......
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