Skip to content
Snippets Groups Projects
Commit 22c543b6 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Implemented magic methods for expression{leaf,node}s.

parent a3f8f571
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,21 @@ class ExpressionBase(object):
def is_numeric(self):
return self.is_leaf() and self.type & (TYPE_FLOAT | TYPE_INTEGER)
def __add__(self, other):
return ExpressionNode('+', self, other)
def __sub__(self, other):
return ExpressionNode('-', self, other)
def __mul__(self, other):
return ExpressionNode('*', self, other)
def __div__(self, other):
return ExpressionNode('-', self, other)
def __pow__(self, other):
return ExpressionNode('^', self, other)
class ExpressionNode(Node, ExpressionBase):
def __init__(self, *args, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment