def p_seen_call_end(p): """Seen_Call_End : """ state.func_parsing = False expr.pop_operator() func_name = p[-6] func.generate_gosub(func_name, sem.get_function(func_name)[3]) state.reset_call()
def p_generate_dir(p): """Generate_Dir : """ var = sem.get_variable(p[-3]) state.arr_parsing = False # If size is zero variable is unresolved if var[1][2][0] <= 0: state.unresolved_vars[sem.scope][var[0]].append(len(state.quads)) arr.generate_dir(var[1][1], var[1][3]) # Starting address, scope state.assign_list.append(var[1][0][: -2 * state.arr_current_dim]) state.arr_dim_stack.append(state.arr_current_dim) expr.pop_operator()
def p_update_offset(p): """Update_Offset : """ var = sem.get_variable(p[-2]) type = var[1][0] expr.add_operator("#") for x in range(state.arr_current_dim - 1): expr.add_operator("+") expr.generate_quad(2) # Generates quads to sum all the indices if type[0] == "i" or type[0] == "f": sem.fill_symbol_table_constant(4, "int", 4) expr.add_operand(sem.get_variable(4)) expr.add_operator("*") expr.generate_quad(1) expr.pop_operator()