I added qualified names (paths) as left-hand sides of assignments.
For example: store.funded := True;
This commit is contained in:
parent
e8443937fd
commit
dc70df99f9
16
AST.ml
16
AST.ml
@ -388,7 +388,7 @@ and case = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and assignment = {
|
and assignment = {
|
||||||
var : variable;
|
path : path;
|
||||||
assign : assign;
|
assign : assign;
|
||||||
expr : expr
|
expr : expr
|
||||||
}
|
}
|
||||||
@ -1014,8 +1014,8 @@ and print_case {value; _} =
|
|||||||
print_instruction instr
|
print_instruction instr
|
||||||
|
|
||||||
and print_assignment {value; _} =
|
and print_assignment {value; _} =
|
||||||
let {var; assign; expr} = value in
|
let {path; assign; expr} = value in
|
||||||
print_var var;
|
print_path path;
|
||||||
print_token assign ":=";
|
print_token assign ":=";
|
||||||
print_expr expr
|
print_expr expr
|
||||||
|
|
||||||
@ -1089,10 +1089,10 @@ and print_map_expr = function
|
|||||||
MapLookUp {value; _} ->
|
MapLookUp {value; _} ->
|
||||||
let {path; index} = value in
|
let {path; index} = value in
|
||||||
let {lbracket; inside; rbracket} = index.value in
|
let {lbracket; inside; rbracket} = index.value in
|
||||||
print_path path;
|
print_path path;
|
||||||
print_token lbracket "[";
|
print_token lbracket "[";
|
||||||
print_expr inside;
|
print_expr inside;
|
||||||
print_token rbracket "]"
|
print_token rbracket "]"
|
||||||
| MapInj inj ->
|
| MapInj inj ->
|
||||||
print_map_injection inj
|
print_map_injection inj
|
||||||
|
|
||||||
@ -1192,7 +1192,7 @@ and print_field_path sequence =
|
|||||||
and print_record_patch node =
|
and print_record_patch node =
|
||||||
let {kwd_patch; path; kwd_with; record_inj} = node in
|
let {kwd_patch; path; kwd_with; record_inj} = node in
|
||||||
print_token kwd_patch "patch";
|
print_token kwd_patch "patch";
|
||||||
print_path path;
|
print_path path;
|
||||||
print_token kwd_with "with";
|
print_token kwd_with "with";
|
||||||
print_record_injection record_inj
|
print_record_injection record_inj
|
||||||
|
|
||||||
|
2
AST.mli
2
AST.mli
@ -372,7 +372,7 @@ and case = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and assignment = {
|
and assignment = {
|
||||||
var : variable;
|
path : path;
|
||||||
assign : assign;
|
assign : assign;
|
||||||
expr : expr
|
expr : expr
|
||||||
}
|
}
|
||||||
|
24
Parser.mly
24
Parser.mly
@ -543,9 +543,9 @@ case:
|
|||||||
}
|
}
|
||||||
|
|
||||||
assignment:
|
assignment:
|
||||||
var ASS expr {
|
path ASS expr {
|
||||||
let region = cover $1.region (expr_to_region $3)
|
let region = cover (path_to_region $1) (expr_to_region $3)
|
||||||
and value = {var = $1; assign = $2; expr = $3}
|
and value = {path = $1; assign = $2; expr = $3}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,16 +566,14 @@ while_loop:
|
|||||||
for_loop:
|
for_loop:
|
||||||
For assignment Down? To expr option(step_clause) block {
|
For assignment Down? To expr option(step_clause) block {
|
||||||
let region = cover $1 $7.region in
|
let region = cover $1 $7.region in
|
||||||
let value =
|
let value = {
|
||||||
{
|
kwd_for = $1;
|
||||||
kwd_for = $1;
|
assign = $2;
|
||||||
assign = $2;
|
down = $3;
|
||||||
down = $3;
|
kwd_to = $4;
|
||||||
kwd_to = $4;
|
bound = $5;
|
||||||
bound = $5;
|
step = $6;
|
||||||
step = $6;
|
block = $7}
|
||||||
block = $7;
|
|
||||||
}
|
|
||||||
in For (ForInt {region; value})
|
in For (ForInt {region; value})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ entrypoint withdraw (storage store : store; const sender : address)
|
|||||||
if now >= store.deadline then
|
if now >= store.deadline then
|
||||||
if balance >= store.goal then
|
if balance >= store.goal then
|
||||||
begin
|
begin
|
||||||
patch store with record funded = True end;
|
// patch store with record funded = True end;
|
||||||
// store.funded := True;
|
store.funded := True;
|
||||||
operations := [Transfer (owner, balance)]
|
operations := [Transfer (owner, balance)]
|
||||||
end
|
end
|
||||||
else fail "Below target"
|
else fail "Below target"
|
||||||
|
Loading…
Reference in New Issue
Block a user