-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoa.py
More file actions
28 lines (25 loc) · 784 Bytes
/
soa.py
File metadata and controls
28 lines (25 loc) · 784 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
# SOA STACK ONLY ASSEMBLY
import sys
stack = []
with open(sys.argv[1], "r") as file:
program = file.read()
lines = program.split("\n")
for line in lines:
if line=="":
break
parsed = line.split()
if parsed[0]=="push":
for i in range(int(parsed[2])):
for j in parsed[1]:
stack.append(j)
elif parsed[0]=="pushint":
for i in range(int(parsed[2])):
stack.append(int(parsed[1]))
elif parsed[0]=="pprint":
print(stack.pop())
elif parsed[0]=="pprintn":
for i in range(int(parsed[1])):
print(stack.pop(), end="")
print()
elif parsed[0]=="revstack":
stack = stack[::-1]