def compile(self): cs = CompiledSegment() line = self.child.compile() if self.comment is not None: if line == "": line = self.comment.compile() else: line = "{} {}".format(line, self.comment.compile()) cs.append(line) return cs
def compile(self) -> CompiledSegment: cs = CompiledSegment() cs.indent() for c in self: cs.append(c.compile()) cs.dedent() return cs
def compile(self): cs = CompiledSegment() cs.append("try:") cs.append(self.block.compile()) for c in self.catches: cs.append(c.compile()) return cs
def compile(self): cs = CompiledSegment() cs.append("if {}:".format(self.condition.compile())) cs.append(self.block.compile()) for e in self.elses: cs.append(e.compile()) return cs
def compile(self): cs = CompiledSegment() cs.append("class {}({}):".format(self.value, self.parent.compile())) cs.indent() # TODO: Move as appropriate to __init__ cs.append(self.body.compile()) return cs
def compile(self): cs = CompiledSegment() if len(self.exceptions) > 1: exceptions = "({})".format(", ".join([e.compile() for e in self.exceptions])) else: exceptions = self.exceptions[0].compile() if self.exc_name is None: cs.append("except {}:".format(exceptions)) else: cs.append("except {} as {}:".format(exceptions, self.exc_name.compile())) cs.append(self.block.compile()) return cs
def compile(self) -> CompiledSegment: cs = CompiledSegment() cs.append("_app_.write({})".format(repr(self.value))) return cs
def compile(self): cs = CompiledSegment() cs.append("for {} in {}:".format(self.thing.compile(), self.items.compile())) cs.append(self.block.compile()) return cs
def compile(self): cs = CompiledSegment() cs.append("while {}:".format(self.condition.compile())) cs.append(self.block.compile()) return cs
def compile(self): cs = CompiledSegment() cs.append("else:") cs.append(self.block.compile()) return cs
def compile(self): cs = CompiledSegment() cs.append("return {}".format(self.child.compile())) # TODO: Comments return cs
def compile(self): cs = CompiledSegment() args = ", ".join([a.compile() for a in self.args]) cs.append("def {}({}):".format(self.value, args)) cs.append(self.body.compile()) return cs