open Syntax ;; let rec cout_mem_character = function | [] -> 0 | a::l -> cout_mem_rule a + cout_mem_character l and cout_mem_rule = function Rule (sl, st) -> cout_mem_st st and cout_mem_st = function If (c, st, el, st') -> cout_mem_cond c + cout_mem_st st +cout_mem_el el + cout_mem_st st' | Decision (ns, st) -> ( match ns with None -> 3 | _ -> 4) | Case (s, al, st) -> 10 + cout_mem_size_arm al + cout_mem_span_arm al + cout_mem_st st and cout_mem_cond = function Equals _ -> 6 | And cl -> List.fold_left (fun x y -> x + (cout_mem_cond y)) 0 cl | Or cl -> List.fold_left (fun x y -> x + (cout_mem_cond y)) 0 cl and cout_mem_el el = List.fold_left (fun x y -> x + (cout_mem_elsif y)) 0 el and cout_mem_elsif = function Elseif (c, s) -> cout_mem_cond c + cout_mem_st s and min_and_max l neutre = List.fold_left (fun x y -> (min (fst x) y,max (snd x) y)) neutre l and cout_mem_span_arm al = let p = List.fold_left (fun x y -> min_and_max (match y with Arm(il, st) -> il) x) (max_int, min_int) al in let tmpmin = fst p in if (tmpmin = max_int) then 0 else ((snd p) - tmpmin + 1) and cout_mem_size_arm al = List.fold_left (fun x y -> x + cout_mem_st (match y with Arm(il, st) -> st)) 0 al