-
Notifications
You must be signed in to change notification settings - Fork 0
/
4me.py
83 lines (83 loc) · 2.91 KB
/
4me.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#important stuff
print("4me. The esolang created by user ractangle")
from tkinter.filedialog import askopenfilename
import re
def imp():
pa = askopenfilename(filetypes=[("Work-Machine Files", "*.wm")])
if pa:
try:
with open(pa, 'r') as file:
lines = [line.rstrip() for line in file]
return lines
except FileNotFoundError:
print("undefined file")
# main code loop
while True:
error = False;inpu = "";i = imp();ln = 1;s=[];ss=[];ts=[];v="";c=0
if i is not None:
for line in i:
ln += 1
matches = re.findall(r'P:(.*?)', line)
for match in matches:
c=1
if c==1:
matches = re.findall(r'out{(.*?)}', line)
for match in matches:
print(end=match)
if line == "is":
inpu = input("string:")
s.append(inpu)
if line == "ns":
inpu = input("number:")
s.append(int(inpu))
if line == "":
print(f"S1456\nCAN YOU. I DON'T KNOW. USE COMMANDS IN THE LINE\nERROR AT LINE {ln}")
error = True
matches = re.findall(r'add{(.*?)}', line)
for match in matches:
s.append(match)
if line == "remove":
s.pop(0)
if line == "get":
print(s[0])
s.pop(0)
if line == "show stack":
print(s)
if line == "+":
r = int(s[0]) + int(s[1])
s.append(r)
s.pop(0)
s.pop(0)
if line == "-":
r = int(s[0]) - int(s[1])
s.append(r)
s.pop(0)
s.pop(0)
if line == "*":
r = int(s[0]) * int(s[1])
s.append(r)
s.pop(0)
s.pop(0)
if line == "/":
r = int(s[0]) / int(s[1])
s.append(r)
s.pop(0)
s.pop(0)
if line == "duplicate":
s.append(s[0])
if line == "store":
ss.append(s[0])
s.pop(0)
if line == "unstore":
s.append(ss[0])
ss.pop(0)
if line == "E:":
break
matches = re.findall(r'# (.*?)', line)
for match in matches:
continue
else:
print("S1245\nP: IS MISSING\nERROR AT LINE 1")
error=True
if error == True:
break