diff --git a/src/compiler/compiler_program.ml b/src/compiler/compiler_program.ml index 311095250..f5d808df5 100644 --- a/src/compiler/compiler_program.ml +++ b/src/compiler/compiler_program.ml @@ -117,7 +117,7 @@ and translate_expression ?(first=false) (expr:expression) (env:environment) : (m trace (error (thunk "compiling expression") error_message) @@ match expr' with - | E_capture_environment c -> + | E_environment_capture c -> let%bind code = Compiler_environment.pack_select env c in return @@ code | E_literal v -> @@ -173,8 +173,15 @@ and translate_expression ?(first=false) (expr:expression) (env:environment) : (m | _ -> simple_fail "E_applicationing something not appliable" ) | E_variable x -> - let%bind code = Compiler_environment.get env x in - return code + let%bind code = Compiler_environment.get env x in + return code + | E_sequence (a , b) -> + let%bind (a' , env_a) = translate_expression a env in + let%bind (b' , env_b) = translate_expression b env_a in + return ~env':env_b @@ seq [ + a' ; + b' ; + ] | E_constant(str, lst) -> let module L = Logger.Stateful() in let%bind lst' = diff --git a/src/mini_c/PP.ml b/src/mini_c/PP.ml index a12804f1c..f3506d97d 100644 --- a/src/mini_c/PP.ml +++ b/src/mini_c/PP.ml @@ -61,7 +61,7 @@ and value_assoc ppf : (value * value) -> unit = fun (a, b) -> fprintf ppf "%a -> %a" value a value b and expression' ppf (e:expression') = match e with - | E_capture_environment s -> fprintf ppf "capture(%a)" (list_sep string (const " ; ")) s + | E_environment_capture s -> fprintf ppf "capture(%a)" (list_sep string (const " ; ")) s | E_variable v -> fprintf ppf "%s" v | 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 @@ -73,6 +73,7 @@ and expression' ppf (e:expression') = match e with | 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 + | E_sequence (a , b) -> fprintf ppf "%a ; %a" expression a expression b | E_let_in ((name , _) , expr , body) -> fprintf ppf "let %s = %a in %a" name expression expr expression body diff --git a/src/mini_c/types.ml b/src/mini_c/types.ml index d6c631a04..fd1b820ce 100644 --- a/src/mini_c/types.ml +++ b/src/mini_c/types.ml @@ -53,7 +53,7 @@ and selector = var_name list and expression' = | E_literal of value - | E_capture_environment of selector + | E_environment_capture of selector | E_constant of string * expression list | E_application of expression * expression | E_variable of var_name @@ -64,6 +64,7 @@ and 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) + | E_sequence of (expression * expression) and expression = { content : expression' ; diff --git a/src/transpiler/transpiler.ml b/src/transpiler/transpiler.ml index 92046c2db..96192c01b 100644 --- a/src/transpiler/transpiler.ml +++ b/src/transpiler/transpiler.ml @@ -448,7 +448,7 @@ and translate_lambda_deep : Mini_c.Environment.t -> AST.lambda -> Mini_c.express let expr = Expression.make_tpl (E_literal f_literal , tv) in ok (expr , raw_input , output) in let%bind c_expr = - ok @@ Expression.make_tpl (E_capture_environment fv , c_tv) in + ok @@ Expression.make_tpl (E_environment_capture fv , c_tv) in let expr = Expression.pair f_expr c_expr in let tv = Mini_c.t_deep_closure c_env input_tv output_tv in ok @@ Expression.make_tpl (expr , tv)