From dc70df99f901a1d67a2a877d6b90639cbed57da2 Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Wed, 20 Mar 2019 13:27:55 +0100 Subject: [PATCH] I added qualified names (paths) as left-hand sides of assignments. For example: store.funded := True; --- AST.ml | 16 ++++++++-------- AST.mli | 2 +- Parser.mly | 24 +++++++++++------------- Tests/crowdfunding.ligo | 4 ++-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/AST.ml b/AST.ml index f156992a9..26c5d9f6d 100644 --- a/AST.ml +++ b/AST.ml @@ -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 diff --git a/AST.mli b/AST.mli index 825d0f63e..9b617322f 100644 --- a/AST.mli +++ b/AST.mli @@ -372,7 +372,7 @@ and case = { } and assignment = { - var : variable; + path : path; assign : assign; expr : expr } diff --git a/Parser.mly b/Parser.mly index f9d5b2003..d61bffdbb 100644 --- a/Parser.mly +++ b/Parser.mly @@ -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}) } diff --git a/Tests/crowdfunding.ligo b/Tests/crowdfunding.ligo index ff43397b3..e3fff9e67 100644 --- a/Tests/crowdfunding.ligo +++ b/Tests/crowdfunding.ligo @@ -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"