Research portable Memory game | Исследовать портируемую игру Память
25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- from Type import *
-
- class Function:
- def __init__(self):
- self.isBody = False
- self.isComplete = False
- self.isSignature = False
- self.name = None
- self.parameters = []
- self.returnType = None
- self.statements = []
-
- def parseLine(self, ln):
- parts = ln.split(" ")
- count = len(parts)
- lastPart = parts[count - 1]
-
- # Beginning of signature.
- if (
- self.returnType is None and
- self.name is None
- and lastPart.endswith("(")
- ):
- self.isSignature = True
-
- # End of parameters.
- if (
- self.isSignature and
- ln.endswith(") {")
- ):
- self.isSignature = False
- isBody = True
-
- # # Parameter.
- # if (
- # isSignature and
- # not ln.endswith(") {")
- # ):
- # print(f"TODO argument: '{ln}'")
-
- # Return type and name.
- if (
- self.isSignature and
- lastPart.endswith("(")
- ):
- self.name = lastPart[:-1]
- rawReturnType = ln[:-len(lastPart) - 1] # -1 for space before function name
- self.returnType = Type(rawReturnType)
-
- def __repr__(self):
- return self.__str__()
- def __str__(self):
- return f"Function(n/rt: '{self.name}'/'{self.returnType}')"
|