-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
36 lines (27 loc) · 776 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
from lexer.scanner import Scanner
from parser_compiler.parser import Parser
from pprint import pprint
import sys
if __name__ == "__main__":
caminho = sys.argv[1]
try:
arquivo = open(caminho, "r")
programa = "".join(arquivo.readlines())
arquivo.close()
except Exception:
print("Error: caminho não informado")
sys.exit(1)
lexer = Scanner(programa)
tabelaDeTokens = lexer.scan()
parser = Parser(tabelaDeTokens)
# print("\nTABELA DE TOKENS:\n")
# for i in tabelaDeTokens:
# print(i)
try:
parser.start()
# print("\nTABELA DE SÍMBOLOS:")
# pprint(parser.tabelaDeSimbolos)
except Exception as e:
print(e)
else:
print("me executou como um módulo")