Added construct remove k from map m
.
This commit is contained in:
parent
285be32729
commit
1e65c63d99
21
AST.ml
21
AST.ml
@ -49,6 +49,7 @@ type kwd_end = Region.t
|
|||||||
type kwd_entrypoint = Region.t
|
type kwd_entrypoint = Region.t
|
||||||
type kwd_fail = Region.t
|
type kwd_fail = Region.t
|
||||||
type kwd_for = Region.t
|
type kwd_for = Region.t
|
||||||
|
type kwd_from = Region.t
|
||||||
type kwd_function = Region.t
|
type kwd_function = Region.t
|
||||||
type kwd_if = Region.t
|
type kwd_if = Region.t
|
||||||
type kwd_in = Region.t
|
type kwd_in = Region.t
|
||||||
@ -61,6 +62,7 @@ type kwd_or = Region.t
|
|||||||
type kwd_patch = Region.t
|
type kwd_patch = Region.t
|
||||||
type kwd_procedure = Region.t
|
type kwd_procedure = Region.t
|
||||||
type kwd_record = Region.t
|
type kwd_record = Region.t
|
||||||
|
type kwd_remove = Region.t
|
||||||
type kwd_skip = Region.t
|
type kwd_skip = Region.t
|
||||||
type kwd_step = Region.t
|
type kwd_step = Region.t
|
||||||
type kwd_storage = Region.t
|
type kwd_storage = Region.t
|
||||||
@ -329,6 +331,15 @@ and single_instr =
|
|||||||
| Skip of kwd_skip
|
| Skip of kwd_skip
|
||||||
| RecordPatch of record_patch reg
|
| RecordPatch of record_patch reg
|
||||||
| MapPatch of map_patch reg
|
| MapPatch of map_patch reg
|
||||||
|
| MapRemove of map_remove reg
|
||||||
|
|
||||||
|
and map_remove = {
|
||||||
|
kwd_remove : kwd_remove;
|
||||||
|
key : expr;
|
||||||
|
kwd_from : kwd_from;
|
||||||
|
kwd_map : kwd_map;
|
||||||
|
map : path
|
||||||
|
}
|
||||||
|
|
||||||
and map_patch = {
|
and map_patch = {
|
||||||
kwd_patch : kwd_patch;
|
kwd_patch : kwd_patch;
|
||||||
@ -703,6 +714,7 @@ let instr_to_region = function
|
|||||||
| Single Fail {region; _}
|
| Single Fail {region; _}
|
||||||
| Single RecordPatch {region; _}
|
| Single RecordPatch {region; _}
|
||||||
| Single MapPatch {region; _}
|
| Single MapPatch {region; _}
|
||||||
|
| Single MapRemove {region; _}
|
||||||
| Block {region; _} -> region
|
| Block {region; _} -> region
|
||||||
|
|
||||||
let pattern_to_region = function
|
let pattern_to_region = function
|
||||||
@ -999,6 +1011,7 @@ and print_single_instr = function
|
|||||||
| Skip kwd_skip -> print_token kwd_skip "skip"
|
| Skip kwd_skip -> print_token kwd_skip "skip"
|
||||||
| RecordPatch {value; _} -> print_record_patch value
|
| RecordPatch {value; _} -> print_record_patch value
|
||||||
| MapPatch {value; _} -> print_map_patch value
|
| MapPatch {value; _} -> print_map_patch value
|
||||||
|
| MapRemove {value; _} -> print_map_remove value
|
||||||
|
|
||||||
and print_fail {kwd_fail; fail_expr} =
|
and print_fail {kwd_fail; fail_expr} =
|
||||||
print_token kwd_fail "fail";
|
print_token kwd_fail "fail";
|
||||||
@ -1242,6 +1255,14 @@ and print_map_patch node =
|
|||||||
print_token kwd_with "with";
|
print_token kwd_with "with";
|
||||||
print_map_injection map_inj
|
print_map_injection map_inj
|
||||||
|
|
||||||
|
and print_map_remove node =
|
||||||
|
let {kwd_remove; key; kwd_from; kwd_map; map} = node in
|
||||||
|
print_token kwd_remove "remove";
|
||||||
|
print_expr key;
|
||||||
|
print_token kwd_from "from";
|
||||||
|
print_token kwd_map "map";
|
||||||
|
print_path map
|
||||||
|
|
||||||
and print_map_injection {value; _} =
|
and print_map_injection {value; _} =
|
||||||
let {opening; bindings; terminator; close} = value in
|
let {opening; bindings; terminator; close} = value in
|
||||||
print_token opening "record";
|
print_token opening "record";
|
||||||
|
11
AST.mli
11
AST.mli
@ -33,6 +33,7 @@ type kwd_end = Region.t
|
|||||||
type kwd_entrypoint = Region.t
|
type kwd_entrypoint = Region.t
|
||||||
type kwd_fail = Region.t
|
type kwd_fail = Region.t
|
||||||
type kwd_for = Region.t
|
type kwd_for = Region.t
|
||||||
|
type kwd_from = Region.t
|
||||||
type kwd_function = Region.t
|
type kwd_function = Region.t
|
||||||
type kwd_if = Region.t
|
type kwd_if = Region.t
|
||||||
type kwd_in = Region.t
|
type kwd_in = Region.t
|
||||||
@ -45,6 +46,7 @@ type kwd_or = Region.t
|
|||||||
type kwd_patch = Region.t
|
type kwd_patch = Region.t
|
||||||
type kwd_procedure = Region.t
|
type kwd_procedure = Region.t
|
||||||
type kwd_record = Region.t
|
type kwd_record = Region.t
|
||||||
|
type kwd_remove = Region.t
|
||||||
type kwd_skip = Region.t
|
type kwd_skip = Region.t
|
||||||
type kwd_step = Region.t
|
type kwd_step = Region.t
|
||||||
type kwd_storage = Region.t
|
type kwd_storage = Region.t
|
||||||
@ -313,6 +315,15 @@ and single_instr =
|
|||||||
| Skip of kwd_skip
|
| Skip of kwd_skip
|
||||||
| RecordPatch of record_patch reg
|
| RecordPatch of record_patch reg
|
||||||
| MapPatch of map_patch reg
|
| MapPatch of map_patch reg
|
||||||
|
| MapRemove of map_remove reg
|
||||||
|
|
||||||
|
and map_remove = {
|
||||||
|
kwd_remove : kwd_remove;
|
||||||
|
key : expr;
|
||||||
|
kwd_from : kwd_from;
|
||||||
|
kwd_map : kwd_map;
|
||||||
|
map : path
|
||||||
|
}
|
||||||
|
|
||||||
and map_patch = {
|
and map_patch = {
|
||||||
kwd_patch : kwd_patch;
|
kwd_patch : kwd_patch;
|
||||||
|
@ -75,6 +75,7 @@ type t =
|
|||||||
| Entrypoint of Region.t (* "entrypoint" *)
|
| Entrypoint of Region.t (* "entrypoint" *)
|
||||||
| Fail of Region.t (* "fail" *)
|
| Fail of Region.t (* "fail" *)
|
||||||
| For of Region.t (* "for" *)
|
| For of Region.t (* "for" *)
|
||||||
|
| From of Region.t (* "from" *)
|
||||||
| Function of Region.t (* "function" *)
|
| Function of Region.t (* "function" *)
|
||||||
| If of Region.t (* "if" *)
|
| If of Region.t (* "if" *)
|
||||||
| In of Region.t (* "in" *)
|
| In of Region.t (* "in" *)
|
||||||
@ -87,6 +88,7 @@ type t =
|
|||||||
| Patch of Region.t (* "patch" *)
|
| Patch of Region.t (* "patch" *)
|
||||||
| Procedure of Region.t (* "procedure" *)
|
| Procedure of Region.t (* "procedure" *)
|
||||||
| Record of Region.t (* "record" *)
|
| Record of Region.t (* "record" *)
|
||||||
|
| Remove of Region.t (* "remove" *)
|
||||||
| Skip of Region.t (* "skip" *)
|
| Skip of Region.t (* "skip" *)
|
||||||
| Step of Region.t (* "step" *)
|
| Step of Region.t (* "step" *)
|
||||||
| Storage of Region.t (* "storage" *)
|
| Storage of Region.t (* "storage" *)
|
||||||
|
10
LexToken.mll
10
LexToken.mll
@ -74,6 +74,7 @@ type t =
|
|||||||
| Entrypoint of Region.t (* "entrypoint" *)
|
| Entrypoint of Region.t (* "entrypoint" *)
|
||||||
| Fail of Region.t (* "fail" *)
|
| Fail of Region.t (* "fail" *)
|
||||||
| For of Region.t (* "for" *)
|
| For of Region.t (* "for" *)
|
||||||
|
| From of Region.t (* "from" *)
|
||||||
| Function of Region.t (* "function" *)
|
| Function of Region.t (* "function" *)
|
||||||
| If of Region.t (* "if" *)
|
| If of Region.t (* "if" *)
|
||||||
| In of Region.t (* "in" *)
|
| In of Region.t (* "in" *)
|
||||||
@ -86,6 +87,7 @@ type t =
|
|||||||
| Patch of Region.t (* "patch" *)
|
| Patch of Region.t (* "patch" *)
|
||||||
| Procedure of Region.t (* "procedure" *)
|
| Procedure of Region.t (* "procedure" *)
|
||||||
| Record of Region.t (* "record" *)
|
| Record of Region.t (* "record" *)
|
||||||
|
| Remove of Region.t (* "remove" *)
|
||||||
| Skip of Region.t (* "skip" *)
|
| Skip of Region.t (* "skip" *)
|
||||||
| Step of Region.t (* "step" *)
|
| Step of Region.t (* "step" *)
|
||||||
| Storage of Region.t (* "storage" *)
|
| Storage of Region.t (* "storage" *)
|
||||||
@ -194,6 +196,7 @@ let proj_token = function
|
|||||||
| Entrypoint region -> region, "Entrypoint"
|
| Entrypoint region -> region, "Entrypoint"
|
||||||
| Fail region -> region, "Fail"
|
| Fail region -> region, "Fail"
|
||||||
| For region -> region, "For"
|
| For region -> region, "For"
|
||||||
|
| From region -> region, "From"
|
||||||
| Function region -> region, "Function"
|
| Function region -> region, "Function"
|
||||||
| If region -> region, "If"
|
| If region -> region, "If"
|
||||||
| In region -> region, "In"
|
| In region -> region, "In"
|
||||||
@ -206,6 +209,7 @@ let proj_token = function
|
|||||||
| Patch region -> region, "Patch"
|
| Patch region -> region, "Patch"
|
||||||
| Procedure region -> region, "Procedure"
|
| Procedure region -> region, "Procedure"
|
||||||
| Record region -> region, "Record"
|
| Record region -> region, "Record"
|
||||||
|
| Remove region -> region, "Remove"
|
||||||
| Skip region -> region, "Skip"
|
| Skip region -> region, "Skip"
|
||||||
| Step region -> region, "Step"
|
| Step region -> region, "Step"
|
||||||
| Storage region -> region, "Storage"
|
| Storage region -> region, "Storage"
|
||||||
@ -280,6 +284,7 @@ let to_lexeme = function
|
|||||||
| Is _ -> "is"
|
| Is _ -> "is"
|
||||||
| Entrypoint _ -> "entrypoint"
|
| Entrypoint _ -> "entrypoint"
|
||||||
| For _ -> "for"
|
| For _ -> "for"
|
||||||
|
| From _ -> "from"
|
||||||
| Function _ -> "function"
|
| Function _ -> "function"
|
||||||
| Type _ -> "type"
|
| Type _ -> "type"
|
||||||
| Of _ -> "of"
|
| Of _ -> "of"
|
||||||
@ -292,6 +297,7 @@ let to_lexeme = function
|
|||||||
| Patch _ -> "patch"
|
| Patch _ -> "patch"
|
||||||
| Procedure _ -> "procedure"
|
| Procedure _ -> "procedure"
|
||||||
| Record _ -> "record"
|
| Record _ -> "record"
|
||||||
|
| Remove _ -> "remove"
|
||||||
| Skip _ -> "skip"
|
| Skip _ -> "skip"
|
||||||
| Step _ -> "step"
|
| Step _ -> "step"
|
||||||
| Storage _ -> "storage"
|
| Storage _ -> "storage"
|
||||||
@ -335,6 +341,7 @@ let keywords = [
|
|||||||
(fun reg -> Is reg);
|
(fun reg -> Is reg);
|
||||||
(fun reg -> Entrypoint reg);
|
(fun reg -> Entrypoint reg);
|
||||||
(fun reg -> For reg);
|
(fun reg -> For reg);
|
||||||
|
(fun reg -> From reg);
|
||||||
(fun reg -> Function reg);
|
(fun reg -> Function reg);
|
||||||
(fun reg -> Type reg);
|
(fun reg -> Type reg);
|
||||||
(fun reg -> Of reg);
|
(fun reg -> Of reg);
|
||||||
@ -347,6 +354,7 @@ let keywords = [
|
|||||||
(fun reg -> Patch reg);
|
(fun reg -> Patch reg);
|
||||||
(fun reg -> Procedure reg);
|
(fun reg -> Procedure reg);
|
||||||
(fun reg -> Record reg);
|
(fun reg -> Record reg);
|
||||||
|
(fun reg -> Remove reg);
|
||||||
(fun reg -> Skip reg);
|
(fun reg -> Skip reg);
|
||||||
(fun reg -> Step reg);
|
(fun reg -> Step reg);
|
||||||
(fun reg -> Storage reg);
|
(fun reg -> Storage reg);
|
||||||
@ -558,6 +566,7 @@ let is_kwd = function
|
|||||||
| Is _
|
| Is _
|
||||||
| Entrypoint _
|
| Entrypoint _
|
||||||
| For _
|
| For _
|
||||||
|
| From _
|
||||||
| Function _
|
| Function _
|
||||||
| Type _
|
| Type _
|
||||||
| Of _
|
| Of _
|
||||||
@ -570,6 +579,7 @@ let is_kwd = function
|
|||||||
| Patch _
|
| Patch _
|
||||||
| Procedure _
|
| Procedure _
|
||||||
| Record _
|
| Record _
|
||||||
|
| Remove _
|
||||||
| Skip _
|
| Skip _
|
||||||
| Step _
|
| Step _
|
||||||
| Storage _
|
| Storage _
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
%token <Region.t> Const (* "const" *)
|
%token <Region.t> Const (* "const" *)
|
||||||
%token <Region.t> Down (* "down" *)
|
%token <Region.t> Down (* "down" *)
|
||||||
%token <Region.t> Fail (* "fail" *)
|
%token <Region.t> Fail (* "fail" *)
|
||||||
|
%token <Region.t> From (* "from" *)
|
||||||
%token <Region.t> If (* "if" *)
|
%token <Region.t> If (* "if" *)
|
||||||
%token <Region.t> In (* "in" *)
|
%token <Region.t> In (* "in" *)
|
||||||
%token <Region.t> Is (* "is" *)
|
%token <Region.t> Is (* "is" *)
|
||||||
@ -65,6 +66,7 @@
|
|||||||
%token <Region.t> Patch (* "patch" *)
|
%token <Region.t> Patch (* "patch" *)
|
||||||
%token <Region.t> Procedure (* "procedure" *)
|
%token <Region.t> Procedure (* "procedure" *)
|
||||||
%token <Region.t> Record (* "record" *)
|
%token <Region.t> Record (* "record" *)
|
||||||
|
%token <Region.t> Remove (* "remove" *)
|
||||||
%token <Region.t> Skip (* "skip" *)
|
%token <Region.t> Skip (* "skip" *)
|
||||||
%token <Region.t> Step (* "step" *)
|
%token <Region.t> Step (* "step" *)
|
||||||
%token <Region.t> Storage (* "storage" *)
|
%token <Region.t> Storage (* "storage" *)
|
||||||
|
13
Parser.mly
13
Parser.mly
@ -464,6 +464,19 @@ single_instr:
|
|||||||
| Skip { Skip $1 }
|
| Skip { Skip $1 }
|
||||||
| record_patch { RecordPatch $1 }
|
| record_patch { RecordPatch $1 }
|
||||||
| map_patch { MapPatch $1 }
|
| map_patch { MapPatch $1 }
|
||||||
|
| map_remove { MapRemove $1 }
|
||||||
|
|
||||||
|
map_remove:
|
||||||
|
Remove expr From Map path {
|
||||||
|
let region = cover $1 (path_to_region $5) in
|
||||||
|
let value = {
|
||||||
|
kwd_remove = $1;
|
||||||
|
key = $2;
|
||||||
|
kwd_from = $3;
|
||||||
|
kwd_map = $4;
|
||||||
|
map = $5}
|
||||||
|
in {region; value}
|
||||||
|
}
|
||||||
|
|
||||||
map_patch:
|
map_patch:
|
||||||
Patch path With map_injection {
|
Patch path With map_injection {
|
||||||
|
@ -58,7 +58,7 @@ entrypoint claim (storage store : store; const sender : address)
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
operations := [Transfer (sender, amount)];
|
operations := [Transfer (sender, amount)];
|
||||||
store.backers[sender] := None
|
remove sender from map store.backers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end with (store, operations)
|
end with (store, operations)
|
||||||
|
Loading…
Reference in New Issue
Block a user