def rule_18(self, rhs): """ statement: "CALL" IDENT """ code_set = CodeSet() l, a = backend.get_procedure(rhs[1].content) code_set.add_code("CALL", l, a) statement = Statement(code_set) return statement
def rule_3(self, rhs): """ block: const_declaration var_declaration statement """ block = Block(backend.get_current_pos()) code_set = CodeSet() code_set.add_code("INT", 0, backend.get_var_count()) code_set.append(rhs[2].code_set) code_set.add_code("OPR", 0, 0) backend.generate_code(code_set) backend.pop_var_stack() backend.pop_procedure_table_stack() # print "" return block
def rule_46(self, rhs): """ factor: IDENT """ code_set = CodeSet() l, a, t = backend.get_var(rhs[0].content) if t == 1: code_set.add_code("LOD", l, a) else: code_set.add_code("LIT", 0, a) factor = Factor(code_set) return factor
def rule_23(self, rhs): """ statement: "READ" IDENT """ code_set = CodeSet() code_set.add_code("OPR", 0, 16) l, a, t = backend.get_var(rhs[1].content) if t == 1: code_set.add_code("STO", l, a) else: backend.trigger_error(rhs[1], AssignmentError, "Const Is Not Assignable") statement = Statement(code_set) return statement
def rule_47(self, rhs): """ factor: CONST """ code_set = CodeSet() code_set.add_code("LIT", 0, int(rhs[0].content)) factor = Factor(code_set) return factor
def rule_15(self, rhs): """ statemente: /* empty */ """ code_set = CodeSet() statemente = Statemente(code_set) return statemente