-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (31 loc) · 1.19 KB
/
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 26 19:57:00 2019
@author: cmdrlias
"""
from token_model import token_model as tkm
from tag import tag
from colors import colors as clr
from lexer import lexer as lexer
from parser import parser as parser
if __name__ == "__main__":
file = lexer('HelloPyscal.pys')
parser = parser(file)
# print(clr.HEADER + "\n=>Lista de tokens\n" + clr.ENDC)
# tk = file.proximoToken()
# while (tk is not None and tk.getNome() != tag.EOF):
# print(tk.toString(), clr.UNDERLINE + 'Linha: ' + str(tk.getLinha()), 'Coluna: ' + str(tk.getColuna()) + clr.ENDC)
# tk = file.proximoToken()
parser.programa()
parser.lexer.closeFile()
print(clr.HEADER + '\n=>Tabela de simbolos\n' + clr.ENDC)
file.printTabelaDeSimbolos()
file.closeFile()
if(file.status()):
print(clr.OKGREEN + '\n=> Compilado com sucesso\n')
else:
if(file.numErros() > 1):
print(clr.WARNING + '\n=> Compilado com avisos (' + str(file.numErros()) + ' erros léxicos).\n')
else:
print(clr.WARNING + '\n=> Compilado com aviso (' + str(file.numErros()) + ' erro léxico).\n')