I extended the right-hand side of assignments to accept "None"
without type annotation. This is meant to enable specify the removal of a map binding. Note: The index assignments in loops are not concerned.
This commit is contained in:
parent
24c0a33c99
commit
495686bbd4
18
AST.ml
18
AST.ml
@ -390,13 +390,17 @@ and case = {
|
|||||||
and assignment = {
|
and assignment = {
|
||||||
lhs : lhs;
|
lhs : lhs;
|
||||||
assign : assign;
|
assign : assign;
|
||||||
expr : expr
|
rhs : rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
and lhs =
|
and lhs =
|
||||||
Path of path
|
Path of path
|
||||||
| MapPath of map_lookup reg
|
| MapPath of map_lookup reg
|
||||||
|
|
||||||
|
and rhs =
|
||||||
|
Expr of expr
|
||||||
|
| NoneExpr of c_None
|
||||||
|
|
||||||
and loop =
|
and loop =
|
||||||
While of while_loop reg
|
While of while_loop reg
|
||||||
| For of for_loop
|
| For of for_loop
|
||||||
@ -727,6 +731,10 @@ let lhs_to_region = function
|
|||||||
Path path -> path_to_region path
|
Path path -> path_to_region path
|
||||||
| MapPath {region; _} -> region
|
| MapPath {region; _} -> region
|
||||||
|
|
||||||
|
let rhs_to_region = function
|
||||||
|
Expr e -> expr_to_region e
|
||||||
|
| NoneExpr r -> r
|
||||||
|
|
||||||
(* Printing the tokens with their source regions *)
|
(* Printing the tokens with their source regions *)
|
||||||
|
|
||||||
let printf = Printf.printf
|
let printf = Printf.printf
|
||||||
@ -1028,10 +1036,14 @@ and print_case {value; _} =
|
|||||||
print_instruction instr
|
print_instruction instr
|
||||||
|
|
||||||
and print_assignment {value; _} =
|
and print_assignment {value; _} =
|
||||||
let {lhs; assign; expr} = value in
|
let {lhs; assign; rhs} = value in
|
||||||
print_lhs lhs;
|
print_lhs lhs;
|
||||||
print_token assign ":=";
|
print_token assign ":=";
|
||||||
print_expr expr
|
print_rhs rhs
|
||||||
|
|
||||||
|
and print_rhs = function
|
||||||
|
Expr e -> print_expr e
|
||||||
|
| NoneExpr r -> print_token r "None"
|
||||||
|
|
||||||
and print_lhs = function
|
and print_lhs = function
|
||||||
Path path -> print_path path
|
Path path -> print_path path
|
||||||
|
7
AST.mli
7
AST.mli
@ -374,13 +374,17 @@ and case = {
|
|||||||
and assignment = {
|
and assignment = {
|
||||||
lhs : lhs;
|
lhs : lhs;
|
||||||
assign : assign;
|
assign : assign;
|
||||||
expr : expr
|
rhs : rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
and lhs =
|
and lhs =
|
||||||
Path of path
|
Path of path
|
||||||
| MapPath of map_lookup reg
|
| MapPath of map_lookup reg
|
||||||
|
|
||||||
|
and rhs =
|
||||||
|
Expr of expr
|
||||||
|
| NoneExpr of c_None
|
||||||
|
|
||||||
and loop =
|
and loop =
|
||||||
While of while_loop reg
|
While of while_loop reg
|
||||||
| For of for_loop
|
| For of for_loop
|
||||||
@ -593,6 +597,7 @@ val pattern_to_region : pattern -> Region.t
|
|||||||
val local_decl_to_region : local_decl -> Region.t
|
val local_decl_to_region : local_decl -> Region.t
|
||||||
val path_to_region : path -> Region.t
|
val path_to_region : path -> Region.t
|
||||||
val lhs_to_region : lhs -> Region.t
|
val lhs_to_region : lhs -> Region.t
|
||||||
|
val rhs_to_region : rhs -> Region.t
|
||||||
|
|
||||||
(* Printing *)
|
(* Printing *)
|
||||||
|
|
||||||
|
12
Parser.mly
12
Parser.mly
@ -543,12 +543,17 @@ case:
|
|||||||
}
|
}
|
||||||
|
|
||||||
assignment:
|
assignment:
|
||||||
lhs ASS expr {
|
lhs ASS rhs {
|
||||||
let region = cover (lhs_to_region $1) (expr_to_region $3)
|
let stop = rhs_to_region $3 in
|
||||||
and value = {lhs = $1; assign = $2; expr = $3}
|
let region = cover (lhs_to_region $1) stop
|
||||||
|
and value = {lhs = $1; assign = $2; rhs = $3}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rhs:
|
||||||
|
expr { Expr $1 }
|
||||||
|
| C_None { NoneExpr $1 : rhs }
|
||||||
|
|
||||||
lhs:
|
lhs:
|
||||||
path { Path $1 }
|
path { Path $1 }
|
||||||
| map_lookup { MapPath $1 }
|
| map_lookup { MapPath $1 }
|
||||||
@ -580,7 +585,6 @@ for_loop:
|
|||||||
block = $7}
|
block = $7}
|
||||||
in For (ForInt {region; value})
|
in For (ForInt {region; value})
|
||||||
}
|
}
|
||||||
|
|
||||||
| For var option(arrow_clause) In expr block {
|
| For var option(arrow_clause) In expr block {
|
||||||
let region = cover $1 $6.region in
|
let region = cover $1 $6.region in
|
||||||
let value = {
|
let value = {
|
||||||
|
@ -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 : option (nat))
|
store.backers[sender] := None
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end with (store, operations)
|
end with (store, operations)
|
||||||
|
Loading…
Reference in New Issue
Block a user