| 307 | return f"{spaces}if({self.condition})" |
| 308 | |
| 309 | class ContainerWhile(Container): |
| 310 | def __init__(self, parent): |
| 311 | super().__init__(parent) |
| 312 | self.condition = None |
| 313 | def fromText(self, text : str): |
| 314 | if (not text.startswith("while")): |
| 315 | raise SyntaxError("While container does not start with while") |
| 316 | start = text.find("(") |
| 317 | end = text.rfind(")") |
| 318 | if (start == -1 or end == -1): |
| 319 | raise SyntaxError("While loop does not contain brackets") |
| 320 | self.condition = cleanCondition(text[start+1:end]) |
| 321 | def __str__(self): |
| 322 | spaces = "" |
| 323 | for _ in range(self.parent.depth): |
| 324 | spaces += " " |
| 325 | return f"{spaces}while({self.condition})" |
| 326 | |
| 327 | class ContainerDo(Container): |
| 328 | def __init__(self, parent): |