def represent_cc(self, presenter: CcScriptPresenter): presenter.write_line(f'while ({self.condition.reference_cc})') self.condition.represent_cc(presenter) presenter.shift_indent(True) self.statement.represent_cc(presenter) presenter.shift_indent(False)
def represent_py_output(self, presenter: CcScriptPresenter): presenter.write_line(f'while {self.condition.reference_py}:') self.condition.represent_py_output(presenter) presenter.shift_indent(True) self.statement.represent_py_output(presenter) presenter.shift_indent(False)
def represent_cc(self, presenter: CcScriptPresenter): presenter.write_line( f'for {self.var.reference_cc} in {self.iterable.reference_cc}') presenter.shift_indent(True) self.statement.represent_cc(presenter) presenter.shift_indent(False)
def represent_py_output(self, presenter: CcScriptPresenter): if self.l_expr.l_expr.value_type.identifier == 'string': var_name = self.l_expr.l_expr.reference_py func_name = property_set_name(self.l_expr.indicator) argument = f'{{CcObject.value_of({self.r_expr.reference_py})}}' presenter.write_line(f'if {self.r_expr.reference_py}:') presenter.shift_indent(True) presenter.write_line( f'presenter.write_line({var_name}, f\'->{func_name}({argument});\')' ) presenter.shift_indent(False) else: presenter.write_line( f'{self.l_expr.reference_py} = {self.r_expr.reference_py}')
def represent_cc(self, presenter: CcScriptPresenter): presenter.shift_indent(False) presenter.write_line('{') presenter.shift_indent(True) super().represent_cc(presenter) presenter.shift_indent(False) presenter.write_line('}') presenter.shift_indent(True)
def represent_cc(self, presenter: CcScriptPresenter): presenter.write_line(f'{self.operator} {{') if self.operator == '>': presenter.shift_indent(True) elif self.operator == '<': presenter.shift_indent(False) if self.statement: self.statement.represent_cc(presenter) if self.operator == '>': presenter.shift_indent(False) elif self.operator == '<': presenter.shift_indent(True) presenter.write_line(f'}}')
def represent_cc(self, presenter: CcScriptPresenter): if presenter.follow_if: presenter.write_line(f'else if ({self.condition.reference_cc})') else: presenter.write_line(f'if ({self.condition.reference_cc})') presenter.shift_indent(True) self.if_statement.represent_cc(presenter) presenter.shift_indent(False) if self.else_statement: if isinstance(self.else_statement, CcIfStatement): presenter.follow_if = True self.else_statement.represent_cc(presenter) else: presenter.follow_if = False presenter.write_line('else') presenter.shift_indent(True) self.else_statement.represent_cc(presenter) presenter.shift_indent(False)