forked from davidcallanan/py-simple-math-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.py
54 lines (40 loc) · 782 Bytes
/
nodes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from dataclasses import dataclass
@dataclass
class NumberNode:
value: any
def __repr__(self):
return f"{self.value}"
@dataclass
class AddNode:
node_a: any
node_b: any
def __repr__(self):
return f"({self.node_a}+{self.node_b})"
@dataclass
class SubtractNode:
node_a: any
node_b: any
def __repr__(self):
return f"({self.node_a}-{self.node_b})"
@dataclass
class MultiplyNode:
node_a: any
node_b: any
def __repr__(self):
return f"({self.node_a}*{self.node_b})"
@dataclass
class DivideNode:
node_a: any
node_b: any
def __repr__(self):
return f"({self.node_a}/{self.node_b})"
@dataclass
class PlusNode:
node: any
def __repr__(self):
return f"(+{self.node})"
@dataclass
class MinusNode:
node: any
def __repr__(self):
return f"(-{self.node})"