Browse Source

fixando importações

Nicolas T 3 years ago
parent
commit
a2eb0f7b8f
4 changed files with 12 additions and 14 deletions
  1. 3
    5
      beuty.py
  2. 3
    3
      main.py
  3. 5
    5
      selection.py
  4. 1
    1
      semantico.py

+ 3
- 5
beuty.py View File

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

+ 3
- 3
main.py View File

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

+ 5
- 5
selection.py View File

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

+ 1
- 1
semantico.py View File

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

Loading…
Cancel
Save