Research portable Memory game | Исследовать портируемую игру Память
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.

process.py 753B

8 months ago
12345678910111213141516171819202122232425262728293031323334353637
  1. from CPP import *
  2. from Function import *
  3. def process(FILE_IN):
  4. # Read file.
  5. lines_in = []
  6. with open(FILE_IN) as file:
  7. for line in file:
  8. lines_in.append(line.rstrip())
  9. f = Function()
  10. out = includes()
  11. # Parse.
  12. for ln in lines_in:
  13. ln = ln.rstrip()
  14. # Empty line.
  15. if ln == "":
  16. out += "\n"
  17. # Comment.
  18. elif (
  19. ln.startswith("#") and
  20. not f.isBody
  21. ):
  22. out += replaceComment(ln) + "\n"
  23. # Function.
  24. else:
  25. f.parseLine(ln)
  26. if f.isComplete:
  27. cpp = CPP(f)
  28. out += cpp.translate()
  29. # Create new function instance.
  30. f = Function()
  31. return out