def preprocess_code(code, cpp_file_path=COMPILE_TMP_PATH, tokenize_fn=None): if not compile_c_code_by_gcc(code, cpp_file_path): return None, None, None, None, None code = init_code(code) if not compile_c_code_by_gcc(code, cpp_file_path): return None, None, None, None, None before_code = code after_code = before_code error_count_range = (1, 9) if tokenize_fn is None: tokenize_fn = tokenize_by_clex_fn() count = 0 action_maplist = [] error_character_maplist = [] error_count = -1 while compile_c_code_by_gcc(after_code, cpp_file_path): cod = before_code # cod = remove_blank(cod) # cod = remove_comments(cod) # cod = remove_blank_line(cod) count += 1 # before_code = cod before_code, after_code, action_maplist, error_character_maplist, error_count = create_error_code( cod, error_count_range=error_count_range, tokenize_fn=tokenize_fn) if before_code is None: return None, None, None, None, None if count > compile_max_count: return None, None, None, None, None return before_code, after_code, action_maplist, error_character_maplist, error_count
def do_c_compile(one, file_path): code = one['code'] if code is None or code == '': return False res = compile_c_code_by_gcc(code, file_path) return res
def single_compile(t, t2, t3): file_path = '/dev/shm/main.c' target_file_path = '/dev/shm/main.out' file_path = add_pid_to_file_path(file_path) target_file_path = add_pid_to_file_path(target_file_path) res = compile_c_code_by_gcc(code, file_path, target_file_path)