From 46d6df21464b0983724ea34ce20450d5e8953e4c Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Mon, 18 Mar 2019 18:09:15 +0100 Subject: [PATCH] Changed "do nothing" to "skip". --- AST.ml | 7 ++++--- AST.mli | 3 ++- LexToken.mli | 3 +-- LexToken.mll | 16 ++++++---------- ParToken.mly | 3 +-- Parser.mly | 14 +++++++------- Tests/crowdfunding.ligo | 4 ++-- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/AST.ml b/AST.ml index 0d9fdeee5..b8a3172b6 100644 --- a/AST.ml +++ b/AST.ml @@ -58,6 +58,7 @@ type kwd_not = Region.t type kwd_of = Region.t type kwd_procedure = Region.t type kwd_record = Region.t +type kwd_skip = Region.t type kwd_step = Region.t type kwd_storage = Region.t type kwd_then = Region.t @@ -323,7 +324,7 @@ and single_instr = | Loop of loop | ProcCall of fun_call | Fail of fail_instr reg -| DoNothing of Region.t +| Skip of kwd_skip and fail_instr = { kwd_fail : kwd_fail; @@ -650,7 +651,7 @@ let instr_to_region = function | Single Loop For ForInt {region; _} | Single Loop For ForCollect {region; _} | Single ProcCall {region; _} -| Single DoNothing region +| Single Skip region | Single Fail {region; _} | Block {region; _} -> region @@ -936,7 +937,7 @@ and print_single_instr = function | Loop loop -> print_loop loop | ProcCall fun_call -> print_fun_call fun_call | Fail {value; _} -> print_fail value -| DoNothing region -> print_token region "do nothing" +| Skip kwd_skip -> print_token kwd_skip "skip" and print_fail {kwd_fail; fail_expr} = print_token kwd_fail "fail"; diff --git a/AST.mli b/AST.mli index 305640a75..5cd0e9587 100644 --- a/AST.mli +++ b/AST.mli @@ -42,6 +42,7 @@ type kwd_not = Region.t type kwd_of = Region.t type kwd_procedure = Region.t type kwd_record = Region.t +type kwd_skip = Region.t type kwd_step = Region.t type kwd_storage = Region.t type kwd_then = Region.t @@ -307,7 +308,7 @@ and single_instr = | Loop of loop | ProcCall of fun_call | Fail of fail_instr reg -| DoNothing of Region.t +| Skip of kwd_skip and fail_instr = { kwd_fail : kwd_fail; diff --git a/LexToken.mli b/LexToken.mli index 5c9c1725f..f72c0e41e 100644 --- a/LexToken.mli +++ b/LexToken.mli @@ -70,7 +70,6 @@ type t = | Begin of Region.t (* "begin" *) | Const of Region.t (* "const" *) | Copy of Region.t (* "copy" *) -| Do of Region.t (* "do" *) | Down of Region.t (* "down" *) | Fail of Region.t (* "fail" *) | If of Region.t (* "if" *) @@ -86,9 +85,9 @@ type t = | Then of Region.t (* "then" *) | Else of Region.t (* "else" *) | Match of Region.t (* "match" *) -| Nothing of Region.t (* "nothing" *) | Procedure of Region.t (* "procedure" *) | Record of Region.t (* "record" *) +| Skip of Region.t (* "skip" *) | Step of Region.t (* "step" *) | Storage of Region.t (* "storage" *) | To of Region.t (* "to" *) diff --git a/LexToken.mll b/LexToken.mll index 3d311078d..741426209 100644 --- a/LexToken.mll +++ b/LexToken.mll @@ -69,7 +69,6 @@ type t = | Begin of Region.t | Const of Region.t | Copy of Region.t -| Do of Region.t | Down of Region.t | Fail of Region.t | If of Region.t @@ -85,9 +84,9 @@ type t = | Then of Region.t | Else of Region.t | Match of Region.t -| Nothing of Region.t | Procedure of Region.t | Record of Region.t +| Skip of Region.t | Step of Region.t | Storage of Region.t | To of Region.t @@ -189,7 +188,6 @@ let proj_token = function | Begin region -> region, "Begin" | Const region -> region, "Const" | Copy region -> region, "Copy" -| Do region -> region, "Do" | Down region -> region, "Down" | Fail region -> region, "Fail" | If region -> region, "If" @@ -205,9 +203,9 @@ let proj_token = function | Then region -> region, "Then" | Else region -> region, "Else" | Match region -> region, "Match" -| Nothing region -> region, "Nothing" | Procedure region -> region, "Procedure" | Record region -> region, "Record" +| Skip region -> region, "Skip" | Step region -> region, "Step" | Storage region -> region, "Storage" | To region -> region, "To" @@ -274,7 +272,6 @@ let to_lexeme = function | Begin _ -> "begin" | Const _ -> "const" | Copy _ -> "copy" -| Do _ -> "do" | Down _ -> "down" | Fail _ -> "fail" | If _ -> "if" @@ -290,9 +287,9 @@ let to_lexeme = function | Then _ -> "then" | Else _ -> "else" | Match _ -> "match" -| Nothing _ -> "nothing" | Procedure _ -> "procedure" | Record _ -> "record" +| Skip _ -> "skip" | Step _ -> "step" | Storage _ -> "storage" | To _ -> "to" @@ -327,7 +324,6 @@ let keywords = [ (fun reg -> Begin reg); (fun reg -> Const reg); (fun reg -> Copy reg); - (fun reg -> Do reg); (fun reg -> Down reg); (fun reg -> Fail reg); (fun reg -> If reg); @@ -343,9 +339,9 @@ let keywords = [ (fun reg -> Then reg); (fun reg -> Else reg); (fun reg -> Match reg); - (fun reg -> Nothing reg); (fun reg -> Procedure reg); (fun reg -> Record reg); + (fun reg -> Skip reg); (fun reg -> Step reg); (fun reg -> Storage reg); (fun reg -> To reg); @@ -363,6 +359,7 @@ let reserved = |> add "assert" |> add "class" |> add "constraint" + |> add "do" |> add "done" |> add "downto" |> add "exception" @@ -551,7 +548,6 @@ let is_kwd = function Begin _ | Const _ | Copy _ -| Do _ | Down _ | Fail _ | If _ @@ -567,9 +563,9 @@ let is_kwd = function | Then _ | Else _ | Match _ -| Nothing _ | Procedure _ | Record _ +| Skip _ | Step _ | Storage _ | To _ diff --git a/ParToken.mly b/ParToken.mly index 188505a5f..2611aae22 100644 --- a/ParToken.mly +++ b/ParToken.mly @@ -47,7 +47,6 @@ %token Begin (* "begin" *) %token Const (* "const" *) %token Copy (* "copy" *) -%token Do (* "do" *) %token Down (* "down" *) %token Fail (* "fail" *) %token If (* "if" *) @@ -63,9 +62,9 @@ %token Then (* "then" *) %token Else (* "else" *) %token Match (* "match" *) -%token Nothing (* "nothing" *) %token Procedure (* "procedure" *) %token Record (* "record" *) +%token Skip (* "skip" *) %token Step (* "step" *) %token Storage (* "storage" *) %token To (* "to" *) diff --git a/Parser.mly b/Parser.mly index fc9b471ee..7e4b3daf2 100644 --- a/Parser.mly +++ b/Parser.mly @@ -413,13 +413,13 @@ instruction: | block { Block $1 } single_instr: - conditional { Cond $1 } -| match_instr { Match $1 } -| assignment { Assign $1 } -| loop { Loop $1 } -| proc_call { ProcCall $1 } -| fail_instr { Fail $1 } -| Do Nothing { let region = cover $1 $2 in DoNothing region } + conditional { Cond $1 } +| match_instr { Match $1 } +| assignment { Assign $1 } +| loop { Loop $1 } +| proc_call { ProcCall $1 } +| fail_instr { Fail $1 } +| Skip { Skip $1 } fail_instr: Fail expr { diff --git a/Tests/crowdfunding.ligo b/Tests/crowdfunding.ligo index b60caa704..24fe9161a 100644 --- a/Tests/crowdfunding.ligo +++ b/Tests/crowdfunding.ligo @@ -22,7 +22,7 @@ entrypoint contribute (storage store : state; record backers = add_binding ((sender, amount), store.backers) end - | _ -> do nothing + | _ -> skip end end with (store, operations) @@ -39,7 +39,7 @@ entrypoint get_funds (storage store : state; const sender : address) end else fail "Below target" else fail "Too soon" - else do nothing + else skip end with (store, operations) entrypoint claim (storage store : state; const sender : address)