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.

пре 7 месеци
пре 7 месеци
пре 7 месеци
пре 7 месеци
пре 7 месеци
пре 7 месеци
пре 7 месеци
пре 7 месеци
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from Type import *
  2. class Function:
  3. def __init__(self):
  4. self.isBody = False
  5. self.isComplete = False
  6. self.isSignature = False
  7. self.name = None
  8. self.parameters = []
  9. self.returnType = None
  10. self.statements = []
  11. def parseLine(self, ln):
  12. parts = ln.split(" ")
  13. count = len(parts)
  14. lastPart = parts[count - 1]
  15. # Beginning of signature.
  16. if (
  17. self.returnType is None and
  18. self.name is None
  19. and lastPart.endswith("(")
  20. ):
  21. self.isSignature = True
  22. # End of parameters.
  23. if (
  24. self.isSignature and
  25. ln.endswith(") {")
  26. ):
  27. self.isSignature = False
  28. isBody = True
  29. # # Parameter.
  30. # if (
  31. # isSignature and
  32. # not ln.endswith(") {")
  33. # ):
  34. # print(f"TODO argument: '{ln}'")
  35. # Return type and name.
  36. if (
  37. self.isSignature and
  38. lastPart.endswith("(")
  39. ):
  40. self.name = lastPart[:-1]
  41. rawReturnType = ln[:-len(lastPart) - 1] # -1 for space before function name
  42. self.returnType = Type(rawReturnType)
  43. def __repr__(self):
  44. return self.__str__()
  45. def __str__(self):
  46. return f"Function(n/rt: '{self.name}'/'{self.returnType}')"