ast_core
This commit is contained in:
parent
2b09906a37
commit
bc7df6a5b4
@ -68,7 +68,7 @@ and idle_type_operator : I.type_operator -> O.type_operator result =
|
||||
|
||||
let rec compile_expression : I.expression -> O.expression result =
|
||||
fun e ->
|
||||
let return expr = ok @@ O.make_expr ~loc:e.location expr in
|
||||
let return expr = ok @@ O.make_e ~loc:e.location expr in
|
||||
match e.expression_content with
|
||||
| I.E_literal literal -> return @@ O.E_literal literal
|
||||
| I.E_constant {cons_name;arguments} ->
|
||||
|
@ -367,7 +367,7 @@ and type_expression : environment -> Solver.state -> ?tv_opt:O.type_expression -
|
||||
let%bind new_state = aggregate_constraints state constraints in
|
||||
let tv = t_variable type_name () in
|
||||
let location = ae.location in
|
||||
let expr' = make_a_e ~location expr tv e in
|
||||
let expr' = make_e ~location expr tv e in
|
||||
ok @@ (expr' , new_state) in
|
||||
let return_wrapped expr state (constraints , expr_type) = return expr state constraints expr_type in
|
||||
let main_error =
|
||||
@ -912,11 +912,9 @@ let rec untype_expression (e:O.expression) : (I.expression) result =
|
||||
let Constructor n = constructor in
|
||||
return (e_constructor n p')
|
||||
| E_record r ->
|
||||
let aux ( Label k ,v) = (k, v) in
|
||||
let r = Map.String.of_list @@ List.map aux (LMap.to_kv_list r) in
|
||||
let%bind r' = bind_smap
|
||||
@@ Map.String.map untype_expression r in
|
||||
return (e_record r')
|
||||
let r = LMap.to_kv_list r in
|
||||
let%bind r' = bind_map_list (fun (k,e) -> let%bind e = untype_expression e in ok (k,e)) r in
|
||||
return (e_record @@ LMap.of_list r')
|
||||
| E_record_accessor {record; path} ->
|
||||
let%bind r' = untype_expression record in
|
||||
let Label s = path in
|
||||
@ -924,8 +922,7 @@ let rec untype_expression (e:O.expression) : (I.expression) result =
|
||||
| E_record_update {record; path; update} ->
|
||||
let%bind r' = untype_expression record in
|
||||
let%bind e = untype_expression update in
|
||||
let Label l = path in
|
||||
return (e_record_update r' l e)
|
||||
return (e_record_update r' path e)
|
||||
| E_matching {matchee;cases} ->
|
||||
let%bind ae' = untype_expression matchee in
|
||||
let%bind m' = untype_matching untype_expression cases in
|
||||
|
@ -407,7 +407,7 @@ and type_expression' : environment -> ?tv_opt:O.type_expression -> I.expression
|
||||
| None -> ok ()
|
||||
| Some tv' -> O.assert_type_expression_eq (tv' , tv) in
|
||||
let location = ae.location in
|
||||
ok @@ make_a_e ~location expr tv e in
|
||||
ok @@ make_e ~location expr tv e in
|
||||
let main_error =
|
||||
let title () = "typing expression" in
|
||||
let content () = "" in
|
||||
@ -463,7 +463,7 @@ and type_expression' : environment -> ?tv_opt:O.type_expression -> I.expression
|
||||
generic_try (bad_record_access property ae prev.type_expression ae.location)
|
||||
@@ (fun () -> I.LMap.find property r_tv) in
|
||||
let location = ae.location in
|
||||
ok @@ make_a_e ~location (E_record_accessor {record=prev; path=property}) tv e
|
||||
ok @@ make_e ~location (E_record_accessor {record=prev; path=property}) tv e
|
||||
in
|
||||
let%bind ae =
|
||||
trace (simple_info "accessing") @@ aux e' path in
|
||||
@ -544,7 +544,7 @@ and type_expression' : environment -> ?tv_opt:O.type_expression -> I.expression
|
||||
let e' = Environment.add_ez_binder lname input_type e in
|
||||
let%bind body = type_expression' ?tv_opt:(Some tv_out) e' result in
|
||||
let output_type = body.type_expression in
|
||||
let lambda' = make_a_e (E_lambda {binder = lname ; result=body}) (t_function input_type output_type ()) e' in
|
||||
let lambda' = make_e (E_lambda {binder = lname ; result=body}) (t_function input_type output_type ()) e' in
|
||||
let lst' = [lambda'; v_col; v_initr] in
|
||||
let tv_lst = List.map get_type_expression lst' in
|
||||
let%bind (opname', tv) =
|
||||
@ -565,7 +565,7 @@ and type_expression' : environment -> ?tv_opt:O.type_expression -> I.expression
|
||||
let e' = Environment.add_ez_binder lname input_type e in
|
||||
let%bind body = type_expression' e' result in
|
||||
let output_type = body.type_expression in
|
||||
let lambda' = make_a_e (E_lambda {binder = lname ; result=body}) (t_function input_type output_type ()) e' in
|
||||
let lambda' = make_e (E_lambda {binder = lname ; result=body}) (t_function input_type output_type ()) e' in
|
||||
let lst' = [lambda';v_initr] in
|
||||
let tv_lst = List.map get_type_expression lst' in
|
||||
let%bind (opname',tv) = type_constant opname tv_lst tv_opt in
|
||||
@ -782,11 +782,9 @@ let rec untype_expression (e:O.expression) : (I.expression) result =
|
||||
let Constructor n = constructor in
|
||||
return (e_constructor n p')
|
||||
| E_record r ->
|
||||
let aux ( Label k ,v) = (k, v) in
|
||||
let r = Map.String.of_list @@ List.map aux (LMap.to_kv_list r) in
|
||||
let%bind r' = bind_smap
|
||||
@@ Map.String.map untype_expression r in
|
||||
return (e_record r')
|
||||
let r = LMap.to_kv_list r in
|
||||
let%bind r' = bind_map_list (fun (k,e) -> let%bind e = untype_expression e in ok (k,e)) r in
|
||||
return (e_record @@ LMap.of_list r')
|
||||
| E_record_accessor {record; path} ->
|
||||
let%bind r' = untype_expression record in
|
||||
let Label s = path in
|
||||
@ -794,7 +792,6 @@ let rec untype_expression (e:O.expression) : (I.expression) result =
|
||||
| E_record_update {record=r; path=l; update=e} ->
|
||||
let%bind r' = untype_expression r in
|
||||
let%bind e = untype_expression e in
|
||||
let Label l = l in
|
||||
return (e_record_update r' l e)
|
||||
| E_matching {matchee;cases} ->
|
||||
let%bind ae' = untype_expression matchee in
|
||||
|
@ -79,112 +79,64 @@ let t_operator op lst: type_expression result =
|
||||
| TC_contract _ , [t] -> ok @@ t_contract t
|
||||
| _ , _ -> fail @@ bad_type_operator op
|
||||
|
||||
let make_expr ?(loc = Location.generated) expression_content =
|
||||
let location = loc in
|
||||
{ expression_content; location }
|
||||
let make_e ?(loc = Location.generated) expression_content = { expression_content; location=loc }
|
||||
|
||||
let e_var ?loc (n: string) : expression = make_expr ?loc @@ E_variable (Var.of_name n)
|
||||
let e_literal ?loc l : expression = make_expr ?loc @@ E_literal l
|
||||
let e_unit ?loc () : expression = make_expr ?loc @@ E_literal (Literal_unit)
|
||||
let e_int ?loc n : expression = make_expr ?loc @@ E_literal (Literal_int n)
|
||||
let e_nat ?loc n : expression = make_expr ?loc @@ E_literal (Literal_nat n)
|
||||
let e_timestamp ?loc n : expression = make_expr ?loc @@ E_literal (Literal_timestamp n)
|
||||
let e_bool ?loc b : expression = make_expr ?loc @@ E_literal (Literal_bool b)
|
||||
let e_string ?loc s : expression = make_expr ?loc @@ E_literal (Literal_string s)
|
||||
let e_address ?loc s : expression = make_expr ?loc @@ E_literal (Literal_address s)
|
||||
let e_mutez ?loc s : expression = make_expr ?loc @@ E_literal (Literal_mutez s)
|
||||
let e_signature ?loc s : expression = make_expr ?loc @@ E_literal (Literal_signature s)
|
||||
let e_key ?loc s : expression = make_expr ?loc @@ E_literal (Literal_key s)
|
||||
let e_key_hash ?loc s : expression = make_expr ?loc @@ E_literal (Literal_key_hash s)
|
||||
let e_chain_id ?loc s : expression = make_expr ?loc @@ E_literal (Literal_chain_id s)
|
||||
let e_var ?loc (n: string) : expression = make_e ?loc @@ E_variable (Var.of_name n)
|
||||
let e_literal ?loc l : expression = make_e ?loc @@ E_literal l
|
||||
let e_unit ?loc () : expression = make_e ?loc @@ E_literal (Literal_unit)
|
||||
let e_int ?loc n : expression = make_e ?loc @@ E_literal (Literal_int n)
|
||||
let e_nat ?loc n : expression = make_e ?loc @@ E_literal (Literal_nat n)
|
||||
let e_timestamp ?loc n : expression = make_e ?loc @@ E_literal (Literal_timestamp n)
|
||||
let e_bool ?loc b : expression = make_e ?loc @@ E_literal (Literal_bool b)
|
||||
let e_string ?loc s : expression = make_e ?loc @@ E_literal (Literal_string s)
|
||||
let e_address ?loc s : expression = make_e ?loc @@ E_literal (Literal_address s)
|
||||
let e_mutez ?loc s : expression = make_e ?loc @@ E_literal (Literal_mutez s)
|
||||
let e_signature ?loc s : expression = make_e ?loc @@ E_literal (Literal_signature s)
|
||||
let e_key ?loc s : expression = make_e ?loc @@ E_literal (Literal_key s)
|
||||
let e_key_hash ?loc s : expression = make_e ?loc @@ E_literal (Literal_key_hash s)
|
||||
let e_chain_id ?loc s : expression = make_e ?loc @@ E_literal (Literal_chain_id s)
|
||||
let e'_bytes b : expression_content result =
|
||||
let%bind bytes = generic_try (simple_error "bad hex to bytes") (fun () -> Hex.to_bytes (`Hex b)) in
|
||||
ok @@ E_literal (Literal_bytes bytes)
|
||||
let e_bytes_hex ?loc b : expression result =
|
||||
let%bind e' = e'_bytes b in
|
||||
ok @@ make_expr ?loc e'
|
||||
ok @@ make_e ?loc e'
|
||||
let e_bytes_raw ?loc (b: bytes) : expression =
|
||||
make_expr ?loc @@ E_literal (Literal_bytes b)
|
||||
make_e ?loc @@ E_literal (Literal_bytes b)
|
||||
let e_bytes_string ?loc (s: string) : expression =
|
||||
make_expr ?loc @@ E_literal (Literal_bytes (Hex.to_bytes (Hex.of_string s)))
|
||||
let e_some ?loc s : expression = make_expr ?loc @@ E_constant {cons_name = C_SOME; arguments = [s]}
|
||||
let e_none ?loc () : expression = make_expr ?loc @@ E_constant {cons_name = C_NONE; arguments = []}
|
||||
let e_string_cat ?loc sl sr : expression = make_expr ?loc @@ E_constant {cons_name = C_CONCAT; arguments = [sl ; sr ]}
|
||||
let e_map_add ?loc k v old : expression = make_expr ?loc @@ E_constant {cons_name = C_MAP_ADD; arguments = [k ; v ; old]}
|
||||
let e_constructor ?loc s a : expression = make_expr ?loc @@ E_constructor { constructor = Constructor s; element = a}
|
||||
let e_matching ?loc a b : expression = make_expr ?loc @@ E_matching {matchee=a;cases=b}
|
||||
let e_matching_bool ?loc a b c : expression = e_matching ?loc a (Match_bool {match_true = b ; match_false = c})
|
||||
let e_record_accessor ?loc a b = make_expr ?loc @@ E_record_accessor {record = a; path = Label b}
|
||||
let e_record_accessor_list ?loc a b = List.fold_left (fun a b -> e_record_accessor ?loc a b) a b
|
||||
let e_variable ?loc v = make_expr ?loc @@ E_variable v
|
||||
let e_let_in ?loc (binder, ascr) inline rhs let_result =
|
||||
make_expr ?loc @@ E_let_in { let_binder = (binder,ascr) ; rhs ; let_result; inline }
|
||||
let e_annotation ?loc anno_expr ty = make_expr ?loc @@ E_ascription {anno_expr; type_annotation = ty}
|
||||
let e_application ?loc a b = make_expr ?loc @@ E_application {lamb=a ; args=b}
|
||||
let e_binop ?loc name a b = make_expr ?loc @@ E_constant {cons_name = name ; arguments = [a ; b]}
|
||||
let e_constant ?loc name lst = make_expr ?loc @@ E_constant {cons_name=name ; arguments = lst}
|
||||
let e_cond ?loc expr match_true match_false = e_matching expr ?loc (Match_bool {match_true; match_false})
|
||||
(*
|
||||
let e_assign ?loc a b c = location_wrap ?loc @@ E_assign (Var.of_name a , b , c) (* TODO handlethat*)
|
||||
*)
|
||||
let ez_match_variant (lst : ((string * string) * 'a) list) =
|
||||
let lst = List.map (fun ((c,n),a) -> ((Constructor c, Var.of_name n), a) ) lst in
|
||||
Match_variant (lst,())
|
||||
let e_matching_variant ?loc a (lst : ((string * string)* 'a) list) =
|
||||
e_matching ?loc a (ez_match_variant lst)
|
||||
let e_record_ez ?loc (lst : (string * expr) list) : expression =
|
||||
let map = List.fold_left (fun m (x, y) -> LMap.add (Label x) y m) LMap.empty lst in
|
||||
make_expr ?loc @@ E_record map
|
||||
let e_record ?loc map =
|
||||
let lst = Map.String.to_kv_list map in
|
||||
e_record_ez ?loc lst
|
||||
make_e ?loc @@ E_literal (Literal_bytes (Hex.to_bytes (Hex.of_string s)))
|
||||
let e_some ?loc s : expression = make_e ?loc @@ E_constant {cons_name = C_SOME; arguments = [s]}
|
||||
let e_none ?loc () : expression = make_e ?loc @@ E_constant {cons_name = C_NONE; arguments = []}
|
||||
let e_string_cat ?loc sl sr : expression = make_e ?loc @@ E_constant {cons_name = C_CONCAT; arguments = [sl ; sr ]}
|
||||
let e_map_add ?loc k v old : expression = make_e ?loc @@ E_constant {cons_name = C_MAP_ADD; arguments = [k ; v ; old]}
|
||||
|
||||
let e_record_update ?loc record path update =
|
||||
let path = Label path in
|
||||
make_expr ?loc @@ E_record_update {record; path; update}
|
||||
let e_constant ?loc name lst = make_e ?loc @@ E_constant {cons_name=name ; arguments = lst}
|
||||
let e_variable ?loc v = make_e ?loc @@ E_variable v
|
||||
let e_application ?loc a b = make_e ?loc @@ E_application {lamb=a ; args=b}
|
||||
let e_lambda ?loc binder input_type output_type result = make_e ?loc @@ E_lambda {binder; input_type; output_type; result ; }
|
||||
let e_recursive ?loc fun_name fun_type lambda = make_e ?loc @@ E_recursive {fun_name; fun_type; lambda}
|
||||
let e_let_in ?loc (binder, ascr) inline rhs let_result = make_e ?loc @@ E_let_in { let_binder = (binder,ascr) ; rhs ; let_result; inline }
|
||||
|
||||
let e_tuple ?loc lst : expression = e_record_ez ?loc (tuple_to_record lst)
|
||||
let e_pair ?loc a b : expression = e_tuple ?loc [a;b]
|
||||
let e_constructor ?loc s a : expression = make_e ?loc @@ E_constructor { constructor = Constructor s; element = a}
|
||||
let e_matching ?loc a b : expression = make_e ?loc @@ E_matching {matchee=a;cases=b}
|
||||
|
||||
let e_record ?loc map = make_e ?loc @@ E_record map
|
||||
let e_record_accessor ?loc a b = make_e ?loc @@ E_record_accessor {record = a; path = Label b}
|
||||
let e_record_update ?loc record path update = make_e ?loc @@ E_record_update {record; path; update}
|
||||
|
||||
let e_annotation ?loc anno_expr ty = make_e ?loc @@ E_ascription {anno_expr; type_annotation = ty}
|
||||
|
||||
let make_option_typed ?loc e t_opt =
|
||||
match t_opt with
|
||||
| None -> e
|
||||
| Some t -> e_annotation ?loc e t
|
||||
|
||||
|
||||
let e_typed_none ?loc t_opt =
|
||||
let type_annotation = t_option t_opt in
|
||||
e_annotation ?loc (e_none ?loc ()) type_annotation
|
||||
|
||||
let e_lambda ?loc (binder : expression_variable)
|
||||
(input_type : type_expression option)
|
||||
(output_type : type_expression option)
|
||||
(result : expression)
|
||||
: expression =
|
||||
make_expr ?loc @@ E_lambda {
|
||||
binder = binder ;
|
||||
input_type = input_type ;
|
||||
output_type = output_type ;
|
||||
result ;
|
||||
}
|
||||
let e_recursive ?loc fun_name fun_type lambda = make_expr ?loc @@ E_recursive {fun_name; fun_type; lambda}
|
||||
|
||||
|
||||
let e_assign_with_let ?loc var access_path expr =
|
||||
let var = Var.of_name (var) in
|
||||
match access_path with
|
||||
| [] -> (var, None), true, expr, false
|
||||
|
||||
| lst ->
|
||||
let rec aux path record= match path with
|
||||
| [] -> failwith "acces_path cannot be empty"
|
||||
| [e] -> e_record_update ?loc record e expr
|
||||
| elem::tail ->
|
||||
let next_record = e_record_accessor record elem in
|
||||
e_record_update ?loc record elem (aux tail next_record )
|
||||
in
|
||||
(var, None), true, (aux lst (e_variable var)), false
|
||||
|
||||
let get_e_record_accessor = fun t ->
|
||||
match t with
|
||||
| E_record_accessor {record; path} -> ok (record, path)
|
||||
|
@ -46,7 +46,7 @@ val t_map : type_expression -> type_expression -> type_expression
|
||||
val t_operator : type_operator -> type_expression list -> type_expression result
|
||||
val t_set : type_expression -> type_expression
|
||||
|
||||
val make_expr : ?loc:Location.t -> expression_content -> expression
|
||||
val make_e : ?loc:Location.t -> expression_content -> expression
|
||||
val e_var : ?loc:Location.t -> string -> expression
|
||||
val e_literal : ?loc:Location.t -> literal -> expression
|
||||
val e_unit : ?loc:Location.t -> unit -> expression
|
||||
@ -66,27 +66,18 @@ val e_bytes_hex : ?loc:Location.t -> string -> expression result
|
||||
val e_bytes_raw : ?loc:Location.t -> bytes -> expression
|
||||
val e_bytes_string : ?loc:Location.t -> string -> expression
|
||||
|
||||
val e_record_ez : ?loc:Location.t -> ( string * expr ) list -> expression
|
||||
val e_tuple : ?loc:Location.t -> expression list -> expression
|
||||
val e_some : ?loc:Location.t -> expression -> expression
|
||||
val e_none : ?loc:Location.t -> unit -> expression
|
||||
val e_string_cat : ?loc:Location.t -> expression -> expression -> expression
|
||||
val e_map_add : ?loc:Location.t -> expression -> expression -> expression -> expression
|
||||
val e_pair : ?loc:Location.t -> expression -> expression -> expression
|
||||
val e_constructor : ?loc:Location.t -> string -> expression -> expression
|
||||
val e_matching : ?loc:Location.t -> expression -> matching_expr -> expression
|
||||
val e_matching_bool : ?loc:Location.t -> expression -> expression -> expression -> expression
|
||||
val e_record_accessor : ?loc:Location.t -> expression -> string -> expression
|
||||
val e_record_accessor_list : ?loc:Location.t -> expression -> string list -> expression
|
||||
val e_variable : ?loc:Location.t -> expression_variable -> expression
|
||||
val e_cond: ?loc:Location.t -> expression -> expression -> expression -> expression
|
||||
val e_let_in : ?loc:Location.t -> ( expression_variable * type_expression option ) -> bool -> expression -> expression -> expression
|
||||
val e_annotation : ?loc:Location.t -> expression -> type_expression -> expression
|
||||
val e_application : ?loc:Location.t -> expression -> expression -> expression
|
||||
val e_binop : ?loc:Location.t -> constant' -> expression -> expression -> expression
|
||||
val e_constant : ?loc:Location.t -> constant' -> expression list -> expression
|
||||
val ez_match_variant : ((string * string ) * 'a ) list -> ('a,unit) matching_content
|
||||
val e_matching_variant : ?loc:Location.t -> expression -> ((string * string) * expression) list -> expression
|
||||
|
||||
val make_option_typed : ?loc:Location.t -> expression -> type_expression option -> expression
|
||||
|
||||
@ -94,9 +85,8 @@ val e_typed_none : ?loc:Location.t -> type_expression -> expression
|
||||
|
||||
val e_lambda : ?loc:Location.t -> expression_variable -> type_expression option -> type_expression option -> expression -> expression
|
||||
val e_recursive : ?loc:Location.t -> expression_variable -> type_expression -> lambda -> expression
|
||||
val e_record : ?loc:Location.t -> expr Map.String.t -> expression
|
||||
val e_record_update : ?loc:Location.t -> expression -> string -> expression -> expression
|
||||
val e_assign_with_let : ?loc:Location.t -> string -> string list -> expression -> ((expression_variable*type_expression option)*bool*expression*bool)
|
||||
val e_record : ?loc:Location.t -> expr label_map-> expression
|
||||
val e_record_update : ?loc:Location.t -> expression -> label -> expression -> expression
|
||||
|
||||
(*
|
||||
val get_e_accessor : expression' -> ( expression * access_path ) result
|
||||
|
@ -24,7 +24,7 @@ module Errors = struct
|
||||
end
|
||||
|
||||
let make_t type_content core = { type_content ; type_meta=core }
|
||||
let make_a_e ?(location = Location.generated) expression_content type_expression environment = {
|
||||
let make_e ?(location = Location.generated) expression_content type_expression environment = {
|
||||
expression_content ;
|
||||
type_expression ;
|
||||
environment ;
|
||||
@ -299,22 +299,22 @@ let e_application lamb args : expression_content = E_application {lamb;args}
|
||||
let e_variable v : expression_content = E_variable v
|
||||
let e_let_in let_binder inline rhs let_result = E_let_in { let_binder ; rhs ; let_result; inline }
|
||||
|
||||
let e_a_unit = make_a_e (e_unit ()) (t_unit ())
|
||||
let e_a_int n = make_a_e (e_int n) (t_int ())
|
||||
let e_a_nat n = make_a_e (e_nat n) (t_nat ())
|
||||
let e_a_mutez n = make_a_e (e_mutez n) (t_mutez ())
|
||||
let e_a_bool b = make_a_e (e_bool b) (t_bool ())
|
||||
let e_a_string s = make_a_e (e_string s) (t_string ())
|
||||
let e_a_address s = make_a_e (e_address s) (t_address ())
|
||||
let e_a_pair a b = make_a_e (e_pair a b) (t_pair a.type_expression b.type_expression ())
|
||||
let e_a_some s = make_a_e (e_some s) (t_option s.type_expression ())
|
||||
let e_a_lambda l in_ty out_ty = make_a_e (e_lambda l) (t_function in_ty out_ty ())
|
||||
let e_a_none t = make_a_e (e_none ()) (t_option t ())
|
||||
let e_a_record r = make_a_e (e_record r) (t_record (LMap.map get_type_expression r) ())
|
||||
let e_a_application a b = make_a_e (e_application a b) (get_type_expression b)
|
||||
let e_a_variable v ty = make_a_e (e_variable v) ty
|
||||
let ez_e_a_record r = make_a_e (ez_e_record r) (ez_t_record (List.map (fun (x, y) -> x, y.type_expression) r) ())
|
||||
let e_a_let_in binder expr body attributes = make_a_e (e_let_in binder expr body attributes) (get_type_expression body)
|
||||
let e_a_unit = make_e (e_unit ()) (t_unit ())
|
||||
let e_a_int n = make_e (e_int n) (t_int ())
|
||||
let e_a_nat n = make_e (e_nat n) (t_nat ())
|
||||
let e_a_mutez n = make_e (e_mutez n) (t_mutez ())
|
||||
let e_a_bool b = make_e (e_bool b) (t_bool ())
|
||||
let e_a_string s = make_e (e_string s) (t_string ())
|
||||
let e_a_address s = make_e (e_address s) (t_address ())
|
||||
let e_a_pair a b = make_e (e_pair a b) (t_pair a.type_expression b.type_expression ())
|
||||
let e_a_some s = make_e (e_some s) (t_option s.type_expression ())
|
||||
let e_a_lambda l in_ty out_ty = make_e (e_lambda l) (t_function in_ty out_ty ())
|
||||
let e_a_none t = make_e (e_none ()) (t_option t ())
|
||||
let e_a_record r = make_e (e_record r) (t_record (LMap.map get_type_expression r) ())
|
||||
let e_a_application a b = make_e (e_application a b) (get_type_expression b)
|
||||
let e_a_variable v ty = make_e (e_variable v) ty
|
||||
let ez_e_a_record r = make_e (ez_e_record r) (ez_t_record (List.map (fun (x, y) -> x, y.type_expression) r) ())
|
||||
let e_a_let_in binder expr body attributes = make_e (e_let_in binder expr body attributes) (get_type_expression body)
|
||||
|
||||
|
||||
let get_a_int (t:expression) =
|
||||
|
@ -3,7 +3,7 @@ open Types
|
||||
|
||||
val make_n_t : type_variable -> type_expression -> named_type_content
|
||||
val make_t : type_content -> S.type_expression option -> type_expression
|
||||
val make_a_e : ?location:Location.t -> expression_content -> type_expression -> full_environment -> expression
|
||||
val make_e : ?location:Location.t -> expression_content -> type_expression -> full_environment -> expression
|
||||
|
||||
val t_bool : ?s:S.type_expression -> unit -> type_expression
|
||||
val t_string : ?s:S.type_expression -> unit -> type_expression
|
||||
|
@ -1,7 +1,7 @@
|
||||
open Types
|
||||
open Combinators
|
||||
|
||||
let make_a_e_empty expression type_annotation = make_a_e expression type_annotation Environment.full_empty
|
||||
let make_a_e_empty expression type_annotation = make_e expression type_annotation Environment.full_empty
|
||||
|
||||
let e_a_empty_unit = e_a_unit Environment.full_empty
|
||||
let e_a_empty_int n = e_a_int n Environment.full_empty
|
||||
|
@ -51,7 +51,7 @@ module TestExpressions = struct
|
||||
|
||||
let tuple () : unit result =
|
||||
test_expression
|
||||
I.(e_tuple [e_int 32; e_string "foo"])
|
||||
I.(e_record @@ LMap.of_list [(Label "0",e_int 32); (Label "1",e_string "foo")])
|
||||
O.(make_t_ez_record [("0",t_int ()); ("1",t_string ())])
|
||||
|
||||
let constructor () : unit result =
|
||||
@ -64,7 +64,7 @@ module TestExpressions = struct
|
||||
|
||||
let record () : unit result =
|
||||
test_expression
|
||||
I.(e_record_ez [("foo", e_int 32); ("bar", e_string "foo")])
|
||||
I.(e_record @@ LMap.of_list [(Label "foo", e_int 32); (Label "bar", e_string "foo")])
|
||||
O.(make_t_ez_record [("foo", t_int ()); ("bar", t_string ())])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user