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

+ 3
- 3
main.py View File

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

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

+ 1
- 1
semantico.py View File

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

Loading…
Cancel
Save