I added qualified names (paths) as left-hand sides of assignments.

For example:

store.funded := True;
This commit is contained in:
Christian Rinderknecht 2019-03-20 13:27:55 +01:00
parent e8443937fd
commit dc70df99f9
No known key found for this signature in database
GPG Key ID: 9446816CFD267040
4 changed files with 22 additions and 24 deletions

16
AST.ml
View File

@ -388,7 +388,7 @@ and case = {
}
and assignment = {
var : variable;
path : path;
assign : assign;
expr : expr
}
@ -1014,8 +1014,8 @@ and print_case {value; _} =
print_instruction instr
and print_assignment {value; _} =
let {var; assign; expr} = value in
print_var var;
let {path; assign; expr} = value in
print_path path;
print_token assign ":=";
print_expr expr
@ -1089,10 +1089,10 @@ and print_map_expr = function
MapLookUp {value; _} ->
let {path; index} = value in
let {lbracket; inside; rbracket} = index.value in
print_path path;
print_token lbracket "[";
print_expr inside;
print_token rbracket "]"
print_path path;
print_token lbracket "[";
print_expr inside;
print_token rbracket "]"
| MapInj inj ->
print_map_injection inj
@ -1192,7 +1192,7 @@ and print_field_path sequence =
and print_record_patch node =
let {kwd_patch; path; kwd_with; record_inj} = node in
print_token kwd_patch "patch";
print_path path;
print_path path;
print_token kwd_with "with";
print_record_injection record_inj

View File

@ -372,7 +372,7 @@ and case = {
}
and assignment = {
var : variable;
path : path;
assign : assign;
expr : expr
}

View File

@ -543,9 +543,9 @@ case:
}
assignment:
var ASS expr {
let region = cover $1.region (expr_to_region $3)
and value = {var = $1; assign = $2; expr = $3}
path ASS expr {
let region = cover (path_to_region $1) (expr_to_region $3)
and value = {path = $1; assign = $2; expr = $3}
in {region; value}
}
@ -566,16 +566,14 @@ while_loop:
for_loop:
For assignment Down? To expr option(step_clause) block {
let region = cover $1 $7.region in
let value =
{
kwd_for = $1;
assign = $2;
down = $3;
kwd_to = $4;
bound = $5;
step = $6;
block = $7;
}
let value = {
kwd_for = $1;
assign = $2;
down = $3;
kwd_to = $4;
bound = $5;
step = $6;
block = $7}
in For (ForInt {region; value})
}

View File

@ -33,8 +33,8 @@ entrypoint withdraw (storage store : store; const sender : address)
if now >= store.deadline then
if balance >= store.goal then
begin
patch store with record funded = True end;
// store.funded := True;
// patch store with record funded = True end;
store.funded := True;
operations := [Transfer (owner, balance)]
end
else fail "Below target"