-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmscript.py
31 lines (20 loc) · 1 KB
/
mscript.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
import numpy as np
def read(file: str):
if file.endswith(".mscript"):
pass
else:
raise "INCORRECT FILE TYPE ERROR :: Should be *.mscript"
with open(file, "r") as f:
data = f.read()
return data
def mscrToPy(fileName: str):
file = read(fileName)
mprint = file.replace("println(", "print(")
mprint2 = mprint.replace('")', '\\n")')
expections = mprint2.replace("except", "except Exception")
equalTo = expections.replace("++", "+=").replace("--", "-=").replace("**", "*=").replace("//", "/=")
threads = equalTo.replace("parallel", "threading.Thread")
python = threads.replace("func", "def").replace("&", "and").replace("|", "or").replace("switch", "match").replace("enum", "enumerate").replace("true", "True").replace("false", "False").replace("^", "**").replace("r+", "raise").replace(">>", "->").replace("none", "None")
impPython: str = "import threading\n" + python
with open("exe.py", "w") as i:
i.write(str(impPython))