-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (32 loc) · 1013 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
41
42
43
44
from src.token import Class, Token
from src.lexer import Lexer
from src.parser import Parser
from src.grapher import Grapher
from src.symbolizer import Symbolizer
from src.optimizer import Optimizer
from src.generator import Generator
from src.runner import Runner
import argparse
def main():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('read_path')
arg_parser.add_argument('write_path')
args = arg_parser.parse_args()
with open(args.read_path, 'r') as source:
text = source.read()
lexer = Lexer(text)
tokens = lexer.lex()
parser = Parser(tokens)
ast = parser.parse()
symbolizer = Symbolizer(ast)
symbolizer.symbolize()
optimizer = Optimizer(ast)
optimizer.optimize()
grapher = Grapher(ast)
grapher.graph()
generator = Generator(ast)
generator.generate(args.write_path)
runner = Runner(ast)
runner.run()
if __name__ == '__main__':
main()