def render(self, indent: int = 0) -> Iterable[Line]: for index, statements in enumerate(self.items): yield Line("or" if index else "either", indent) for statement in statements: yield from statement.render(indent + 2) yield Line("end either;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: args = ", ".join(str(arg) for arg in self.args) yield Line(f"procedure {str(self.name)}({args})", indent) if self.variables is not None: yield Line(str(self.variables), indent) yield from self.body.render(indent) yield Line("end procedure;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line() yield Line("define", indent) yield from ( Line(line, indent + 2) for item in self.items for line in item.splitlines() ) yield Line("end define;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: declarations = ", ".join( str(declaration) for declaration in self.declarations) yield Line(f"with {declarations}", indent) yield Line("do", indent) for statement in self.statements: yield from statement.render(indent + 2) yield Line("end with;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield from self.if_clause.render(indent) for elsif_clause in self.elsif_clauses: yield from elsif_clause.render(indent) if self.else_: yield Line("else", indent) for statement in self.else_: yield from statement.render(indent + 2) yield Line(f"end if;", indent)
def test_line(): line = Line("foo", 2) assert_that( str(line), is_(equal_to(" foo")), )
def render(self, indent: int = 0) -> Iterable[Line]: if self.label is not None: yield Line(f"{str(self.label)}:", indent) extra_indent = 2 else: extra_indent = 0 yield from self.value.render(indent=indent + extra_indent)
def render(self, indent: int = 0) -> Iterable[Line]: algorithm = "fair algorithm" if self.fair else "algorithm" yield Line(f"--{algorithm} {str(self.name)}", indent) if self.variables: yield from self.variables.render(indent) if self.definitions: yield from self.definitions.render(indent) if self.macros: yield from self.macros.render(indent) if self.procedures: yield from self.procedures.render(indent) if isinstance(self.body, AlgorithmBody): yield Line() yield from self.body.render(indent) yield Line("end algorithm", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(f"call {self.value}", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(f"print {str(self.value)};", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line("return;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line("skip;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(f"{self.clause_type} {str(self.condition)} then", indent) for statement in self.statements: yield from statement.render(indent + 2)
def render(self, indent: int = 0) -> Iterable[Line]: values = ", ".join(str(item) for item in self.items) variable = "variables" if len(self.items) > 1 else "variable" yield Line(f"{variable} {values};", indent)
def render(self, indent: int = 0) -> Iterable[Line]: args = ", ".join(str(arg) for arg in self.args) yield Line(f"macro {str(self.name)}({args})", indent) yield from self.body.render(indent) yield Line("end macro;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line("begin", indent) for item in self.items: yield from item.render(indent + 2)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(" || ".join(str(item) for item in self.items) + ";", indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(self.value, indent)
def render(self, indent: int = 0) -> Iterable[Line]: yield Line(f"while {str(self.condition)} do", indent) for statement in self.statements: yield from statement.render(indent + 2) yield Line("end while;", indent)
def render(self, indent: int = 0) -> Iterable[Line]: for item in self.items: yield Line() yield from item.render(indent)