2 Commits

Author SHA1 Message Date
  Nicolas T e1d7177133 fixando importações 4 years ago
  Nicolas T a2eb0f7b8f fixando importações 4 years ago
4 changed files with 14 additions and 14 deletions
  1. 4
    5
      beuty.py
  2. 4
    3
      main.py
  3. 4
    5
      selection.py
  4. 2
    1
      semantico.py

+ 4
- 5
beuty.py View File

1
+from bs4 import BeautifulSoup
2
+import os
3
+import pickle
4
+
1
 def beut(tabela1, tabela2):
5
 def beut(tabela1, tabela2):
2
-    from bs4 import BeautifulSoup
3
     with open('tabela.html', 'r') as file:
6
     with open('tabela.html', 'r') as file:
4
         soup = BeautifulSoup(file, "html5lib")
7
         soup = BeautifulSoup(file, "html5lib")
5
         soup.prettify()#reorganiza as tags
8
         soup.prettify()#reorganiza as tags
28
     return (''.join(numero))
31
     return (''.join(numero))
29
 
32
 
30
 def initsintatico(token, args,erro):
33
 def initsintatico(token, args,erro):
31
-    import os
32
     if not(os.path.isfile('dicionario1.dtc')and os.path.isfile('dicionario2.dtc')):
34
     if not(os.path.isfile('dicionario1.dtc')and os.path.isfile('dicionario2.dtc')):
33
         save()
35
         save()
34
 
36
 
38
     analisadorsintatico(dict_tabela1, dict_tabela2, token, args,erro)
40
     analisadorsintatico(dict_tabela1, dict_tabela2, token, args,erro)
39
 
41
 
40
 def load(filename):
42
 def load(filename):
41
-    import pickle
42
     file = open(filename, "rb")
43
     file = open(filename, "rb")
43
     return pickle.load(file)
44
     return pickle.load(file)
44
-
45
 def save():
45
 def save():
46
     tabela1 = []
46
     tabela1 = []
47
     tabela2 = []
47
     tabela2 = []
65
     saveFile(dict_tabela2, "dicionario2.dtc")
65
     saveFile(dict_tabela2, "dicionario2.dtc")
66
 
66
 
67
 def saveFile(dict, filename):
67
 def saveFile(dict, filename):
68
-    import pickle
69
     dicionario = open(filename, "wb")
68
     dicionario = open(filename, "wb")
70
     pickle.dump(dict, dicionario)
69
     pickle.dump(dict, dicionario)
71
     dicionario.close()
70
     dicionario.close()

+ 4
- 3
main.py View File

1
+import sys
2
+import argparse
3
+from selection import opction
4
+
1
 def main():
5
 def main():
2
 
6
 
3
     parser = argparse.ArgumentParser(description='Compilador para uma linguagem do tipo LL(1)')
7
     parser = argparse.ArgumentParser(description='Compilador para uma linguagem do tipo LL(1)')
12
 
16
 
13
 #executa a funcao main()
17
 #executa a funcao main()
14
 if __name__ == "__main__":
18
 if __name__ == "__main__":
15
-    import sys
16
-    import argparse
17
-    from selection import opction
18
     main()
19
     main()

+ 4
- 5
selection.py View File

1
+from lexical import tokenize
2
+from beuty import initsintatico
3
+from semantico import semantico
4
+from  Geracaodecodigo import gerarcodigo
1
 def opction(args):
5
 def opction(args):
2
     token = []
6
     token = []
3
     erro = []
7
     erro = []
21
         lgc(token, args)
25
         lgc(token, args)
22
 
26
 
23
 def vlt(filename,token,args, erro):
27
 def vlt(filename,token,args, erro):
24
-    from lexical import tokenize
25
     print ('#' * 80)
28
     print ('#' * 80)
26
     file = open(filename, "r")
29
     file = open(filename, "r")
27
     arquivo = file.read()
30
     arquivo = file.read()
34
               '{:10}'.format(token[i][3]))
37
               '{:10}'.format(token[i][3]))
35
         i += 1
38
         i += 1
36
 def lt(filename, token, args, erro):
39
 def lt(filename, token, args, erro):
37
-    from lexical import tokenize
38
     file = open(filename, "r")
40
     file = open(filename, "r")
39
     arquivo = file.read()
41
     arquivo = file.read()
40
     file.close()
42
     file.close()
41
     for tok in tokenize(arquivo,args,erro):
43
     for tok in tokenize(arquivo,args,erro):
42
         token.append(tok)
44
         token.append(tok)
43
 def ls(token,args,erro):
45
 def ls(token,args,erro):
44
-    from beuty import initsintatico
45
     initsintatico(token,args,erro)
46
     initsintatico(token,args,erro)
46
 def lse(token,args,erro):
47
 def lse(token,args,erro):
47
-    from semantico import semantico
48
     semantico(token,args,erro)
48
     semantico(token,args,erro)
49
 def lgc(token,args):
49
 def lgc(token,args):
50
-    from  Geracaodecodigo import gerarcodigo
51
     gerarcodigo(token,args)
50
     gerarcodigo(token,args)

+ 2
- 1
semantico.py View File

1
+import re
2
+
1
 def semantico(token, args, erro):
3
 def semantico(token, args, erro):
2
     Avariaveis(token, args,erro)
4
     Avariaveis(token, args,erro)
3
 def divisao(token, args, lista,erro):
5
 def divisao(token, args, lista,erro):
45
     return 0
47
     return 0
46
 
48
 
47
 def trocandoValores(lista,a,key):
49
 def trocandoValores(lista,a,key):
48
-    import re
49
     for exp in lista.keys():
50
     for exp in lista.keys():
50
         if exp in a:
51
         if exp in a:
51
             a=re.sub(r''+exp, (''.join(lista[exp])),''.join(a))
52
             a=re.sub(r''+exp, (''.join(lista[exp])),''.join(a))

Loading…
Cancel
Save