-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (33 loc) · 806 Bytes
/
main.py
File metadata and controls
38 lines (33 loc) · 806 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
34
35
36
37
38
#!/usr/bin/python3
import sys
from functions import *
from stack import Stack
def main():
stack = Stack()
line_number = 0
number = None
operations = {
"pall": op_pall,
"push": op_push,
"nop": op_nop,
"pint": op_pint,
"swap": op_swap,
"add": op_add,
"pop": op_pop
}
while True:
print("$ ", end="")
line = input()
line_number += 1
words = line.split()
if (len(words) == 0):
continue
instruction = words[0]
if len(words) > 1:
number = words[1]
else:
number = None
operation = operations.get(instruction, error_none_op)
operation(stack, line_number, number, instruction)
if __name__ == "__main__":
main()