def execute(self): print(self.expression.__class__.__name__) if self.expression.__class__.__name__ == "VariablesExpression": if var.get(self.expression.name) == "array": writer.w(f"cout << {self.expression.name} << endl;") return if var.get(self.expression.name) == "function": writer.w(f"cout << {self.expression.name}().value << endl;") return elif self.expression.__class__.__name__ == "MethodCallExpression": writer.w(f"{self.expression.eval()};") writer.w(f"cout << {self.expression.var}.value << endl;") else: writer.w(f"cout << {self.expression.eval()}.value << endl;")
def execute(self): var = self.initialization.var result = self.initialization.expression.eval writer.w( f"for(double {var} = {result}; {self.termination.expr1} {self.termination.getOperator()} {self.termination.expr2}; {self.increment.var}{self.increment.op}){'{'}" ) try: self.block.execute() except BreakStatement: writer.w("break;") except ContinueStatement: writer.w("continue;") writer.w("}")
def execute(self): var.set(self.var, "") writer.w(f"{self.type} {self.var};")
def execute(self): writer.w(f"{self.func.eval()};")
def execute(self): writer.w("continue;")
def execute(self): writer.w(f'cout << "{self.tag}";')
def execute(self): writer.w(f"{self.var}.value {self.op}= {self.expression.eval()};")
def execute(self): if self.type != "": if self.expression != None: if self.expression.__class__.__name__ == "ArrayExpression": var.set(self.var, "array") if self.expression.autofill: writer.w(f"vector<INT> {self.var}_v;") writer.w( f"for(int i = {self.expression.start.eval()}; i <= {self.expression.stop.eval()}; i += {self.expression.step.eval()}){'{'}" ) writer.w(f"{self.var}_v.push_back(i);") writer.w("}") writer.w( f"{self.type} {self.var} = INT_ARR({self.var}_v);") else: result = self.expression.eval() writer.w( f"INT {self.var}_arr[{result[1]}] = {'{'}{result[0]}{'}'};" ) writer.w( f"vector<INT> {self.var}_v({self.var}_arr,{self.var}_arr+{result[1]});" ) writer.w( f"{self.type} {self.var} = INT_ARR({self.var}_v);") else: result = self.expression.eval() writer.w(f"{self.type} {self.var} = {result};") else: writer.w(f"{self.type} {self.var};") else: result = self.expression.eval() writer.w(f"{self.var} = {result};")
def execute(self): value = var.getType(self.var) if value not in ['str', 'bool']: writer.w(f"{self.var}.value++;") else: raise RuntimeError("This type don't support the ++ operator")
def execute(self): writer.w("break;")
def execute(self): if self.expression.__class__.__name__ == "VariablesExpression": writer.w(f"cin >> {self.expression.eval()};") else: writer.w(f"cin >> {self.expression.eval()};")
def execute(self): self.result = "" if self.expression.__class__.__name__ == "NoneExpression" else self.expression.eval( ) writer.w(f"return {self.result};")