Bora vê
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

selection.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. def opction(args):
  2. token = []
  3. erro = []
  4. if args.tudo:
  5. args.lt=True
  6. args.ls=True
  7. args.lse=True
  8. args.lgc=True
  9. if args.lt:
  10. vlt(args.filename,token,args,erro)
  11. else:
  12. lt(args.filename,token,args,erro)
  13. ls(token,args,erro)
  14. lse(token,args,erro)
  15. if len(erro)>0:
  16. for e in erro:
  17. print(e)
  18. if (args.lgc):
  19. print ("Não foi possivel iniciar a geração de código por causa de erro no código fonte.")
  20. else:
  21. lgc(token, args)
  22. def vlt(filename,token,args, erro):
  23. from lexical import tokenize
  24. print ('#' * 80)
  25. file = open(filename, "r")
  26. arquivo = file.read()
  27. file.close()
  28. print('{:15}'.format('Token'), '{:29}'.format('Lexema'), '{:10}'.format('Linha'), '{:10}'.format('Coluna'))
  29. i = 0
  30. for tok in tokenize(arquivo,args, erro):
  31. token.append(tok)
  32. print('{:15}'.format(token[i][0]), '{:20.11}'.format(token[i][1]), '{:10}'.format(token[i][2]),
  33. '{:10}'.format(token[i][3]))
  34. i += 1
  35. def lt(filename, token, args, erro):
  36. from lexical import tokenize
  37. file = open(filename, "r")
  38. arquivo = file.read()
  39. file.close()
  40. for tok in tokenize(arquivo,args,erro):
  41. token.append(tok)
  42. def ls(token,args,erro):
  43. from beuty import initsintatico
  44. initsintatico(token,args,erro)
  45. def lse(token,args,erro):
  46. from semantico import semantico
  47. semantico(token,args,erro)
  48. def lgc(token,args):
  49. from Geracaodecodigo import gerarcodigo
  50. gerarcodigo(token,args)