diff --git a/src/compiler/compiler_program.ml b/src/compiler/compiler_program.ml index f7b66b3b7..311095250 100644 --- a/src/compiler/compiler_program.ml +++ b/src/compiler/compiler_program.ml @@ -214,16 +214,16 @@ and translate_expression ?(first=false) (expr:expression) (env:environment) : (m error title content in trace error @@ return code - | E_empty_map sd -> + | E_make_empty_map sd -> let%bind (src, dst) = bind_map_pair Compiler_type.type_ sd in return @@ i_empty_map src dst - | E_empty_list t -> + | E_make_empty_list t -> let%bind t' = Compiler_type.type_ t in return @@ i_nil t' | E_make_none o -> let%bind o' = Compiler_type.type_ o in return @@ i_none o' - | E_Cond (c, a, b) -> ( + | E_if_bool (c, a, b) -> ( let%bind (c' , env') = translate_expression c env in let%bind (a' , _) = translate_expression a env' in let%bind (b' , _) = translate_expression b env' in diff --git a/src/mini_c/PP.ml b/src/mini_c/PP.ml index 6dfa90e4a..a12804f1c 100644 --- a/src/mini_c/PP.ml +++ b/src/mini_c/PP.ml @@ -66,10 +66,10 @@ and expression' ppf (e:expression') = match e with | E_application(a, b) -> fprintf ppf "(%a)@(%a)" expression a expression b | E_constant(p, lst) -> fprintf ppf "%s %a" p (pp_print_list ~pp_sep:space_sep expression) lst | E_literal v -> fprintf ppf "%a" value v - | E_empty_map _ -> fprintf ppf "map[]" - | E_empty_list _ -> fprintf ppf "list[]" + | E_make_empty_map _ -> fprintf ppf "map[]" + | E_make_empty_list _ -> fprintf ppf "list[]" | E_make_none _ -> fprintf ppf "none" - | E_Cond (c, a, b) -> fprintf ppf "%a ? %a : %a" expression c expression a expression b + | E_if_bool (c, a, b) -> fprintf ppf "%a ? %a : %a" expression c expression a expression b | E_if_none (c, n, ((name, _) , s)) -> fprintf ppf "%a ?? %a : %s -> %a" expression c expression n name expression s | E_if_left (c, ((name_l, _) , l), ((name_r, _) , r)) -> fprintf ppf "%a ?? %s -> %a : %s -> %a" expression c name_l expression l name_r expression r diff --git a/src/mini_c/types.ml b/src/mini_c/types.ml index d8971c9ca..d6c631a04 100644 --- a/src/mini_c/types.ml +++ b/src/mini_c/types.ml @@ -57,10 +57,10 @@ and expression' = | E_constant of string * expression list | E_application of expression * expression | E_variable of var_name - | E_empty_map of (type_value * type_value) - | E_empty_list of type_value + | E_make_empty_map of (type_value * type_value) + | E_make_empty_list of type_value | E_make_none of type_value - | E_Cond of expression * expression * expression + | E_if_bool of expression * expression * expression | E_if_none of expression * expression * ((var_name * type_value) * expression) | E_if_left of expression * ((var_name * type_value) * expression) * ((var_name * type_value) * expression) | E_let_in of ((var_name * type_value) * expression * expression) diff --git a/src/transpiler/transpiler.ml b/src/transpiler/transpiler.ml index 658b4da9c..92046c2db 100644 --- a/src/transpiler/transpiler.ml +++ b/src/transpiler/transpiler.ml @@ -339,7 +339,7 @@ and translate_annotated_expression (env:Environment.t) (ae:AST.annotated_express let%bind lst' = bind_map_list (translate_annotated_expression env) lst in let aux : expression -> expression -> expression result = fun prev cur -> return @@ E_constant ("CONS", [cur ; prev]) in - let%bind (init : expression) = return @@ E_empty_list t in + let%bind (init : expression) = return @@ E_make_empty_list t in bind_fold_list aux init lst' | E_map m -> let%bind (src, dst) = Mini_c.Combinators.get_t_map tv in @@ -350,7 +350,7 @@ and translate_annotated_expression (env:Environment.t) (ae:AST.annotated_express bind_map_pair (translate_annotated_expression env) (k, v') in return @@ E_constant ("UPDATE", [k' ; v' ; prev']) in - let init = return @@ E_empty_map (src, dst) in + let init = return @@ E_make_empty_map (src, dst) in List.fold_left aux init m | E_look_up dsi -> let%bind (ds', i') = bind_map_pair f dsi in @@ -360,7 +360,7 @@ and translate_annotated_expression (env:Environment.t) (ae:AST.annotated_express match m with | Match_bool {match_true ; match_false} -> let%bind (t , f) = bind_map_pair (translate_annotated_expression env) (match_true, match_false) in - return @@ E_Cond (expr', t, f) + return @@ E_if_bool (expr', t, f) | Match_option { match_none; match_some = ((name, tv), s) } -> let%bind n = translate_annotated_expression env match_none in let%bind (tv' , s') =