-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
40 lines (34 loc) · 858 Bytes
/
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
import myParser
from functools import reduce
from environment import Env
def main():
parser = myParser.Parser()
while True:
inp = input(">>> ")
if (inp == None) or ("exit" in inp) or (inp == ""):
exit(1)
program = parser.produce_AST(inp)
print(program)
def from_file():
parser = myParser.Parser()
lines = ""
with open("bsp.txt") as file:
lines = reduce(lambda a, b: a + b, file.readlines())
file.close()
program = parser.produce_AST(lines)
print(program)
return program
def from_to_file():
env = Env()
code = from_file().generate_code(env)
#print(code)
file = open("mips1.asm", "w")
file.write(code)
file.close()
def test():
a = [1, 2, 3]
print( a[-1])
if __name__ == "__main__":
from_to_file()
#test()
#from_file()