def __str__(self) -> str: parameters = "" if self.pragma_parameters: parameters = ", ".join(self.pragma_parameters) parameters = " (" + indent_next( str(parameters), len(str(self.identifier)) + 9) + ")" return f"pragma {self.identifier}{parameters};"
def definition(self) -> str: def input_values(values: Sequence[StrID]) -> str: if len(values) == 0: return "null" if len(values) == 1: return str(values[0]) return "(" + ", ".join(str(p) for p in values) + ")" dependencies = indent_next( ", ".join(f"{o} => {input_values(i)}" for o, i in self.dependencies.items()), 1) return f"({dependencies})"
def __str__(self) -> str: if not self.terms: return str(TRUE) result = "" for i, t in reversed(list(enumerate(self.terms))): if i == 0: result = self.parenthesized(t) + result else: result = ( "\n" + str(self.symbol)[1:] + indent_next(self.parenthesized(t), len(self.symbol) - 1) + result ) return result
def __str__(self) -> str: if isinstance(self.expression, Case): return "return (" + indent_next(str(self.expression), 8) + ");" return "return " + indent_next(str(self.expression), 7) + ";"
def definition(self) -> str: cases = indent_next( ",\n".join(f"{p} =>\n{indent(str(q), 3)}" for p, q in self.cases), 1) return f"({cases})"
def __repr__(self) -> str: prefixed_str = ( ("\n".join(f"# {l}" for l in str(self).split("\n")) + "\n") if self.__errors else "" ) return indent_next(f"\nRecordFluxError({self.__errors})\n{prefixed_str}", 4)
def parenthesized(self, expr: "Expr") -> str: if expr.precedence.value <= self.precedence.value: return "(" + indent_next(str(expr), 1) + ")" return str(expr)
def __str__(self) -> str: if not self.terms: return str(TRUE) return indent_next( f"\n{self.symbol}".join(map(self.parenthesized, self.terms)), 2)