add last expressions in mini_c
This commit is contained in:
parent
32ecf8cfca
commit
4e76b5344d
@ -338,6 +338,18 @@ and translate_expression ?(first=false) (expr:expression) (env:environment) : (m
|
|||||||
set_code ;
|
set_code ;
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
| E_while (expr, block) -> (
|
||||||
|
let%bind (expr' , env') = translate_expression expr env in
|
||||||
|
let%bind (block' , env'') = translate_expression block env' in
|
||||||
|
let%bind restrict_block = Compiler_environment.select_env env'' env' in
|
||||||
|
return @@ seq [
|
||||||
|
expr' ;
|
||||||
|
prim ~children:[seq [
|
||||||
|
block' ;
|
||||||
|
restrict_block ;
|
||||||
|
expr']] I_LOOP ;
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
and translate_statement ((s', w_env) as s:statement) : michelson result =
|
and translate_statement ((s', w_env) as s:statement) : michelson result =
|
||||||
let error_message () = Format.asprintf "%a" PP.statement s in
|
let error_message () = Format.asprintf "%a" PP.statement s in
|
||||||
|
@ -80,6 +80,8 @@ and expression' ppf (e:expression') = match e with
|
|||||||
fprintf ppf "let %s = %a in %a" name expression expr expression body
|
fprintf ppf "let %s = %a in %a" name expression expr expression body
|
||||||
| E_assignment (r , path , e) ->
|
| E_assignment (r , path , e) ->
|
||||||
fprintf ppf "%s.%a := %a" r (list_sep lr (const ".")) path expression e
|
fprintf ppf "%s.%a := %a" r (list_sep lr (const ".")) path expression e
|
||||||
|
| E_while (e , b) ->
|
||||||
|
fprintf ppf "while (%a) %a" expression e expression b
|
||||||
|
|
||||||
and expression : _ -> expression -> _ = fun ppf e ->
|
and expression : _ -> expression -> _ = fun ppf e ->
|
||||||
expression' ppf e.content
|
expression' ppf e.content
|
||||||
|
@ -68,6 +68,7 @@ and expression' =
|
|||||||
| E_let_in of ((var_name * type_value) * expression * expression)
|
| E_let_in of ((var_name * type_value) * expression * expression)
|
||||||
| E_sequence of (expression * expression)
|
| E_sequence of (expression * expression)
|
||||||
| E_assignment of (string * [`Left | `Right] list * expression)
|
| E_assignment of (string * [`Left | `Right] list * expression)
|
||||||
|
| E_while of expression * expression
|
||||||
|
|
||||||
and expression = {
|
and expression = {
|
||||||
content : expression' ;
|
content : expression' ;
|
||||||
|
Loading…
Reference in New Issue
Block a user