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

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