-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathops.py
More file actions
33 lines (32 loc) · 768 Bytes
/
ops.py
File metadata and controls
33 lines (32 loc) · 768 Bytes
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
#op values
opnums = {
"1" : "ADD",
"2" : "SUB",
"3" : "CALL",
"4" : "STORE",
"5" : "MULT",
"6" : "DIV"
}
def getop(code):
try:
opnumber = code.split()[0]
except:
opnumber = "none"
for opnum in opnums:
if opnumber == "none":
break
if opnumber == opnum:
return opnums[opnum]
def ADD(num1: float, num2: float) -> str:
return str(num1 + num2)
def SUB(num1: float, num2: float) -> str:
return str(num1 - num2)
def CALL(linenum: int, ret) -> str:
print(ret[linenum])
return str(ret[linenum])
def STORE(inp):
return(inp)
def MULT(num1: float, num2: float) -> str:
return str(num1 * num2)
def DIV(num1: float, num2: float) -> str:
return str(num1 / num2)