def p_bool_expressions_not(p): """bool_expressions : NOT expressions""" arg = p[2] if "t_list" not in arg: code_array.create_simple_if_check(arg) p[0] = {"t_list": arg["f_list"], "f_list": arg["t_list"], "type": "bool"} return
def p_bool_expressions_or(p): """bool_expressions : OR pair""" first_arg = p[2]["first_arg"] second_arg = p[2]["second_arg"] if "t_list" not in first_arg: code_array.create_simple_if_check(first_arg) if "t_list" not in second_arg: p[2]["second_quad_index"] = code_array.create_simple_if_check( second_arg) temp_var = symbol_table.get_new_temp_variable("bool") code_array.emit('=', temp_var, {"value": 1, "type": "bool"}, None) code_array.backpatch_e_list(first_arg["t_list"], code_array.get_current_quad_index()) code_array.emit('goto', None, p[2]["second_quad_index"], None) code_array.emit('=', temp_var, {"value": 0, "type": "bool"}, None) code_array.backpatch_e_list(first_arg["f_list"], code_array.get_current_quad_index()) code_array.emit('goto', None, p[2]["second_quad_index"], None) code_array.create_simple_if_check(temp_var) code_array.backpatch_e_list(second_arg["f_list"], code_array.get_current_quad_index() - 2) p[0] = { "t_list": code_array.merge_e_lists(temp_var["t_list"], second_arg["t_list"]), "f_list": temp_var["f_list"], "type": "bool" } return
def p_bool_expressions_or_else(p): """bool_expressions : OR ELSE pair""" first_arg = p[3]["first_arg"] second_arg = p[3]["second_arg"] if "t_list" not in first_arg: code_array.create_simple_if_check(first_arg) if "t_list" not in second_arg: p[3]["second_quad_index"] = code_array.create_simple_if_check( second_arg) code_array.backpatch_e_list(first_arg["f_list"], p[3]["second_quad_index"]) p[0] = { "f_list": second_arg["f_list"], "t_list": code_array.merge_e_lists(first_arg["t_list"], second_arg["t_list"]), "type": "bool" } return