Merge branch 'master' of gitlab.com:gabriel.alfour/tezos
This commit is contained in:
commit
4485cb3b61
@ -391,7 +391,7 @@ and record_patch = {
|
||||
kwd_patch : kwd_patch;
|
||||
path : path;
|
||||
kwd_with : kwd_with;
|
||||
record_inj : record_injection reg
|
||||
record_inj : record_expr
|
||||
}
|
||||
|
||||
and fail_instr = {
|
||||
@ -599,15 +599,7 @@ and constr_expr =
|
||||
| NoneExpr of none_expr reg
|
||||
| ConstrApp of (constr * arguments) reg
|
||||
|
||||
and record_expr =
|
||||
RecordInj of record_injection reg
|
||||
|
||||
and record_injection = {
|
||||
opening : kwd_record;
|
||||
fields : (field_assign reg, semi) nsepseq;
|
||||
terminator : semi option;
|
||||
closing : kwd_end
|
||||
}
|
||||
and record_expr = field_assign reg injection reg
|
||||
|
||||
and field_assign = {
|
||||
field_name : field_name;
|
||||
@ -750,8 +742,7 @@ and constr_expr_to_region = function
|
||||
| ConstrApp {region; _}
|
||||
| SomeApp {region; _} -> region
|
||||
|
||||
and record_expr_to_region = function
|
||||
RecordInj {region; _} -> region
|
||||
and record_expr_to_region {region; _} = region
|
||||
|
||||
let path_to_region = function
|
||||
Name var -> var.region
|
||||
|
@ -375,7 +375,7 @@ and record_patch = {
|
||||
kwd_patch : kwd_patch;
|
||||
path : path;
|
||||
kwd_with : kwd_with;
|
||||
record_inj : record_injection reg
|
||||
record_inj : field_assign reg injection reg
|
||||
}
|
||||
|
||||
and fail_instr = {
|
||||
@ -583,15 +583,7 @@ and constr_expr =
|
||||
| NoneExpr of none_expr reg
|
||||
| ConstrApp of (constr * arguments) reg
|
||||
|
||||
and record_expr =
|
||||
RecordInj of record_injection reg
|
||||
|
||||
and record_injection = {
|
||||
opening : kwd_record;
|
||||
fields : (field_assign reg, semi) nsepseq;
|
||||
terminator : semi option;
|
||||
closing : kwd_end
|
||||
}
|
||||
and record_expr = field_assign reg injection reg
|
||||
|
||||
and field_assign = {
|
||||
field_name : field_name;
|
||||
|
@ -626,7 +626,7 @@ binding:
|
||||
in {region; value}}
|
||||
|
||||
record_patch:
|
||||
Patch path With record_injection {
|
||||
Patch path With record_expr {
|
||||
let region = cover $1 $4.region in
|
||||
let value = {
|
||||
kwd_patch = $1;
|
||||
@ -984,9 +984,6 @@ path:
|
||||
var { Name $1 }
|
||||
| projection { Path $1 }
|
||||
|
||||
record_expr:
|
||||
record_injection { RecordInj $1 }
|
||||
|
||||
projection:
|
||||
struct_name DOT nsepseq(selection,DOT) {
|
||||
let stop = nsepseq_to_region selection_to_region $3 in
|
||||
@ -1001,16 +998,26 @@ selection:
|
||||
field_name { FieldName $1 }
|
||||
| Int { Component $1 }
|
||||
|
||||
record_injection:
|
||||
record_expr:
|
||||
Record series(field_assignment,End) {
|
||||
let first, (others, terminator, closing) = $2 in
|
||||
let region = cover $1 closing
|
||||
and value = {
|
||||
opening = $1;
|
||||
fields = first, others;
|
||||
opening = Kwd $1;
|
||||
elements = Some (first, others);
|
||||
terminator;
|
||||
closing}
|
||||
in {region; value}}
|
||||
closing = End closing}
|
||||
in {region; value}
|
||||
}
|
||||
| Record LBRACKET series(field_assignment,RBRACKET) {
|
||||
let first, (others, terminator, closing) = $3 in
|
||||
let region = cover $1 closing
|
||||
and value = {
|
||||
opening = KwdBracket ($1,$2);
|
||||
elements = Some (first, others);
|
||||
terminator;
|
||||
closing = RBracket closing}
|
||||
in {region; value} }
|
||||
|
||||
field_assignment:
|
||||
field_name EQUAL expr {
|
||||
|
@ -1,3 +1,5 @@
|
||||
[@@@warning "-42"]
|
||||
|
||||
open Utils
|
||||
open AST
|
||||
open! Region
|
||||
@ -529,15 +531,8 @@ and print_constr_expr = function
|
||||
| NoneExpr e -> print_none_expr e
|
||||
| ConstrApp e -> print_constr_app e
|
||||
|
||||
and print_record_expr = function
|
||||
RecordInj e -> print_record_injection e
|
||||
|
||||
and print_record_injection {value; _} =
|
||||
let {opening; fields; terminator; closing} = value in
|
||||
print_token opening "record";
|
||||
print_nsepseq ";" print_field_assign fields;
|
||||
print_terminator terminator;
|
||||
print_token closing "end"
|
||||
and print_record_expr e =
|
||||
print_injection "record" print_field_assign e
|
||||
|
||||
and print_field_assign {value; _} =
|
||||
let {field_name; equal; field_expr} = value in
|
||||
@ -563,7 +558,7 @@ and print_record_patch node =
|
||||
print_token kwd_patch "patch";
|
||||
print_path path;
|
||||
print_token kwd_with "with";
|
||||
print_record_injection record_inj
|
||||
print_record_expr record_inj
|
||||
|
||||
and print_set_patch node =
|
||||
let {kwd_patch; path; kwd_with; set_inj} = node in
|
||||
|
@ -128,11 +128,11 @@ let rec simpl_expression (t:Raw.expr) : ae result =
|
||||
let (Raw.TupleInj tpl') = tpl in
|
||||
simpl_tuple_expression
|
||||
@@ npseq_to_list tpl'.value.inside
|
||||
| ERecord (RecordInj r) ->
|
||||
| ERecord r ->
|
||||
let%bind fields = bind_list
|
||||
@@ List.map (fun ((k : _ Raw.reg), v) -> let%bind v = simpl_expression v in ok (k.value, v))
|
||||
@@ List.map (fun (x:Raw.field_assign Raw.reg) -> (x.value.field_name, x.value.field_expr))
|
||||
@@ npseq_to_list r.value.fields in
|
||||
@@ pseq_to_list r.value.elements in
|
||||
let aux prev (k, v) = SMap.add k v prev in
|
||||
ok @@ make_e_a @@ E_record (List.fold_left aux SMap.empty fields)
|
||||
| EProj p' -> (
|
||||
@ -476,7 +476,7 @@ and simpl_single_instruction : Raw.single_instr -> instruction result = fun t ->
|
||||
let%bind inj = bind_list
|
||||
@@ List.map (fun (x:Raw.field_assign) -> let%bind e = simpl_expression x.field_expr in ok (x.field_name.value, e))
|
||||
@@ List.map (fun (x:_ Raw.reg) -> x.value)
|
||||
@@ npseq_to_list r.record_inj.value.fields in
|
||||
@@ pseq_to_list r.record_inj.value.elements in
|
||||
ok @@ I_record_patch (name, access_path, inj)
|
||||
)
|
||||
| MapPatch _ -> simple_fail "no map patch yet"
|
||||
|
Loading…
Reference in New Issue
Block a user