open Misc open Syntax open Lexer open Opt_tmp open Cout let character_control_gather d = let d5 = ref d in for i=1 to 10 do try while true do d5 := Optimize_local.main_controle_gather i !d5 done; with Optimize_local.No_one_state_case_rule | Optimize_local.No_progress_done -> () done; !d5 let character_remove_case_with_only_default = Optimize_local.apply_map_on_rules Remove_case.remove_case_with_only_default let character_remove_case_with_many_arm = Optimize_local.apply_map_on_rules Remove_case.remove_case_with_many_arm (* once bitten twice shy *) (* let safe_wrapper f x = ( try f x with _ -> x ) *) let safe_wrapper f x = f x let main init = try let curr = ref init in for i=1 to 5 do let d0 = safe_wrapper character_optimize_ifs !curr in let d' = safe_wrapper Optimize_local.optimize d0 in let d1 = safe_wrapper character_remove_case_with_only_default d' in let d'' = safe_wrapper gather_rules d1 in let d3 = safe_wrapper character_substitute_underscore d'' in let d4 = safe_wrapper gather_rules d3 in let d5 = safe_wrapper character_control_gather d4 in let d6 = safe_wrapper (Optimize_local.apply_map_on_rules Optimize_local.optimize_same_if) d5 in let d7 = safe_wrapper character_optimize_ifs d6 in let d8 = safe_wrapper character_remove_case_with_many_arm d7 in curr := d8 done; Results.record_attempt (Syntax.to_ast !curr) with Timeout -> raise Timeout | x -> ()