MCPcopy Create free account
hub / github.com/IENT/YUView / ContainerDo

Class ContainerDo

tools/standardTextToCode/parseTables.py:327–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 return f"{spaces}while({self.condition})"
326
327class ContainerDo(Container):
328 def __init__(self, parent):
329 super().__init__(parent)
330 self.condition = None
331 def fromText(self, text : str):
332 if (not text.startswith("do")):
333 raise SyntaxError("Do container does not start with do")
334 def parseClosingWhile(self, table, tableIndex : int):
335 t0_full = table.cell(0, tableIndex).text
336 text = t0_full.strip()
337 if (not text.startswith("} while")):
338 raise SyntaxError("do does not end with while")
339 start = text.find("(")
340 end = text.rfind(")")
341 if (start == -1 or end == -1):
342 raise SyntaxError("Do ... while loop does not contain brackets")
343 self.condition = cleanCondition(text[start+1:end])
344 t1 = table.cell(0, tableIndex+1).text.strip()
345 try:
346 t2 = table.cell(0, tableIndex+2).text.strip()
347 if (t2 == t1):
348 # Skip identical entries. This may be the aforementioned glitch.
349 tableIndex += 1
350 except IndexError:
351 # No more data
352 pass
353 tableIndex += 2
354 return tableIndex
355 def getDoText(self):
356 spaces = ""
357 for _ in range(self.parent.depth):
358 spaces += " "
359 return f"{spaces}do"
360 def __str__(self):
361 spaces = ""
362 for _ in range(self.parent.depth):
363 spaces += " "
364 return f"{spaces}while ({self.condition})"
365
366class ContainerFor(Container):
367 def __init__(self, parent):

Callers 1

parseChildrenMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected