Research portable Memory game | Исследовать портируемую игру Память
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
843B

  1. class Type:
  2. def __init__(self, s):
  3. # Currently no recursion is allowed,
  4. # so you can't have a dictionary in dictionary.
  5. self.name = None
  6. self.first = None
  7. self.second = None
  8. # Dictionary.
  9. if s.startswith("std::map"):
  10. self.name = "map"
  11. # Remove prefix and suffix.
  12. prefix = "std::map<"
  13. s = s[len(prefix):]
  14. suffix = ">"
  15. s = s[:-len(suffix)]
  16. # Get map types.
  17. parts = s.split(", ")
  18. self.first = parts[0]
  19. self.second = parts[1]
  20. # By default we treat the type as is.
  21. else:
  22. self.name = s
  23. def __repr__(self):
  24. return self.__str__()
  25. def __str__(self):
  26. return f"Type(n/f/s: '{self.name}'/'{self.first}'/'{self.second}')"