-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (55 loc) · 1.35 KB
/
main.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
55
i=input(">>")
c=i.split()
cmd=0
s=[]
inp=''
o=[]
while len(c)!=0:
print(c)
cmd+=1
if c[0]=="out":
if c[1]=="char":
o.append(chr(int(c[2])))
c.pop(0)
c.pop(0)
c.pop(0)
else:
o.append(c[1])
c.pop(0)
c.pop(0)
elif c[0]=="note":
c.pop(0)
c.pop(0)
elif c[0]=="in":
inp=input("input\n")
c.pop(0)
elif c[0]=="push":
if c[1]=="in":
s.append(inp)
c.pop(0)
c.pop(0)
elif c[1]=="out":
o.append(s[0])
c.pop(0)
c.pop(0)
s.pop(0)
else:
s.append(c[1])
c.pop(0)
c.pop(0)
elif c[0]=="op":
if c[1]=="plus":
r=int(s[0])+int(s[1])
s.append(r)
s.pop(0)
s.pop(0)
c.pop(0)
c.pop(0)
elif c[0]=="end":
while len(o)>0:
print(end=str(o[0]))
o.pop(0)
break
else:
print(f"CMD:{cmd} UNDEFINED COMMAND")
break