-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodes.py
More file actions
22 lines (19 loc) · 691 Bytes
/
Copy pathnodes.py
File metadata and controls
22 lines (19 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import tokens
class NumberNode:
def __init__(self,value: float):
self.value = value
def __repr__(self) -> str:
return str(self.value)
class BinaryNode:
def __init__(self,type:str,left_node,right_node):
self.type =type
self.left_node = left_node
self.right_node = right_node
def __repr(self) -> str:
return("(" + str(self.left_node) + tokens.operator_to_character(self.type) + str(self.right_node) + ")")
class UnaryNode:
def __init__(self,type:str,node):
self.type = type
self.node = node
def __repr__(self) -> str:
return "(" + tokens.operator_to_character(self.type) + str(self.node) + ")"