Changed "||" -> "or" and "&&" -> "and" to be more Pascal-like.
This commit is contained in:
parent
589b62a30c
commit
e8443937fd
26
LexToken.mli
26
LexToken.mli
@ -50,8 +50,6 @@ type t =
|
|||||||
| ASS of Region.t (* ":=" *)
|
| ASS of Region.t (* ":=" *)
|
||||||
| EQUAL of Region.t (* "=" *)
|
| EQUAL of Region.t (* "=" *)
|
||||||
| COLON of Region.t (* ":" *)
|
| COLON of Region.t (* ":" *)
|
||||||
| OR of Region.t (* "||" *)
|
|
||||||
| AND of Region.t (* "&&" *)
|
|
||||||
| LT of Region.t (* "<" *)
|
| LT of Region.t (* "<" *)
|
||||||
| LEQ of Region.t (* "<=" *)
|
| LEQ of Region.t (* "<=" *)
|
||||||
| GT of Region.t (* ">" *)
|
| GT of Region.t (* ">" *)
|
||||||
@ -67,33 +65,35 @@ type t =
|
|||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
|
| And of Region.t (* "and" *)
|
||||||
| Begin of Region.t (* "begin" *)
|
| Begin of Region.t (* "begin" *)
|
||||||
| Case of Region.t (* "case" *)
|
| Case of Region.t (* "case" *)
|
||||||
| Const of Region.t (* "const" *)
|
| Const of Region.t (* "const" *)
|
||||||
| Down of Region.t (* "down" *)
|
| Down of Region.t (* "down" *)
|
||||||
|
| Else of Region.t (* "else" *)
|
||||||
|
| End of Region.t (* "end" *)
|
||||||
|
| Entrypoint of Region.t (* "entrypoint" *)
|
||||||
| Fail of Region.t (* "fail" *)
|
| Fail of Region.t (* "fail" *)
|
||||||
|
| For of Region.t (* "for" *)
|
||||||
|
| Function of Region.t (* "function" *)
|
||||||
| If of Region.t (* "if" *)
|
| If of Region.t (* "if" *)
|
||||||
| In of Region.t (* "in" *)
|
| In of Region.t (* "in" *)
|
||||||
| Is of Region.t (* "is" *)
|
| Is of Region.t (* "is" *)
|
||||||
| Entrypoint of Region.t (* "entrypoint" *)
|
|
||||||
| For of Region.t (* "for" *)
|
|
||||||
| Function of Region.t (* "function" *)
|
|
||||||
| Type of Region.t (* "type" *)
|
|
||||||
| Of of Region.t (* "of" *)
|
|
||||||
| Var of Region.t (* "var" *)
|
|
||||||
| End of Region.t (* "end" *)
|
|
||||||
| Then of Region.t (* "then" *)
|
|
||||||
| Else of Region.t (* "else" *)
|
|
||||||
| Map of Region.t (* "map" *)
|
| Map of Region.t (* "map" *)
|
||||||
|
| Mod of Region.t (* "mod" *)
|
||||||
|
| Not of Region.t (* "not" *)
|
||||||
|
| Of of Region.t (* "of" *)
|
||||||
|
| Or of Region.t (* "or" *)
|
||||||
| Patch of Region.t (* "patch" *)
|
| Patch of Region.t (* "patch" *)
|
||||||
| Procedure of Region.t (* "procedure" *)
|
| Procedure of Region.t (* "procedure" *)
|
||||||
| Record of Region.t (* "record" *)
|
| Record of Region.t (* "record" *)
|
||||||
| Skip of Region.t (* "skip" *)
|
| Skip of Region.t (* "skip" *)
|
||||||
| Step of Region.t (* "step" *)
|
| Step of Region.t (* "step" *)
|
||||||
| Storage of Region.t (* "storage" *)
|
| Storage of Region.t (* "storage" *)
|
||||||
|
| Then of Region.t (* "then" *)
|
||||||
| To of Region.t (* "to" *)
|
| To of Region.t (* "to" *)
|
||||||
| Mod of Region.t (* "mod" *)
|
| Type of Region.t (* "type" *)
|
||||||
| Not of Region.t (* "not" *)
|
| Var of Region.t (* "var" *)
|
||||||
| While of Region.t (* "while" *)
|
| While of Region.t (* "while" *)
|
||||||
| With of Region.t (* "with" *)
|
| With of Region.t (* "with" *)
|
||||||
|
|
||||||
|
106
LexToken.mll
106
LexToken.mll
@ -49,8 +49,6 @@ type t =
|
|||||||
| ASS of Region.t
|
| ASS of Region.t
|
||||||
| EQUAL of Region.t
|
| EQUAL of Region.t
|
||||||
| COLON of Region.t
|
| COLON of Region.t
|
||||||
| OR of Region.t
|
|
||||||
| AND of Region.t
|
|
||||||
| LT of Region.t
|
| LT of Region.t
|
||||||
| LEQ of Region.t
|
| LEQ of Region.t
|
||||||
| GT of Region.t
|
| GT of Region.t
|
||||||
@ -66,35 +64,37 @@ type t =
|
|||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
| Begin of Region.t
|
| And of Region.t (* "and" *)
|
||||||
| Case of Region.t
|
| Begin of Region.t (* "begin" *)
|
||||||
| Const of Region.t
|
| Case of Region.t (* "case" *)
|
||||||
| Down of Region.t
|
| Const of Region.t (* "const" *)
|
||||||
| Fail of Region.t
|
| Down of Region.t (* "down" *)
|
||||||
| If of Region.t
|
| Else of Region.t (* "else" *)
|
||||||
| In of Region.t
|
| End of Region.t (* "end" *)
|
||||||
| Is of Region.t
|
| Entrypoint of Region.t (* "entrypoint" *)
|
||||||
| Entrypoint of Region.t
|
| Fail of Region.t (* "fail" *)
|
||||||
| For of Region.t
|
| For of Region.t (* "for" *)
|
||||||
| Function of Region.t
|
| Function of Region.t (* "function" *)
|
||||||
| Type of Region.t
|
| If of Region.t (* "if" *)
|
||||||
| Of of Region.t
|
| In of Region.t (* "in" *)
|
||||||
| Var of Region.t
|
| Is of Region.t (* "is" *)
|
||||||
| End of Region.t
|
| Map of Region.t (* "map" *)
|
||||||
| Then of Region.t
|
| Mod of Region.t (* "mod" *)
|
||||||
| Else of Region.t
|
| Not of Region.t (* "not" *)
|
||||||
| Map of Region.t
|
| Of of Region.t (* "of" *)
|
||||||
| Patch of Region.t
|
| Or of Region.t (* "or" *)
|
||||||
| Procedure of Region.t
|
| Patch of Region.t (* "patch" *)
|
||||||
| Record of Region.t
|
| Procedure of Region.t (* "procedure" *)
|
||||||
| Skip of Region.t
|
| Record of Region.t (* "record" *)
|
||||||
| Step of Region.t
|
| Skip of Region.t (* "skip" *)
|
||||||
| Storage of Region.t
|
| Step of Region.t (* "step" *)
|
||||||
| To of Region.t
|
| Storage of Region.t (* "storage" *)
|
||||||
| Mod of Region.t
|
| Then of Region.t (* "then" *)
|
||||||
| Not of Region.t
|
| To of Region.t (* "to" *)
|
||||||
| While of Region.t
|
| Type of Region.t (* "type" *)
|
||||||
| With of Region.t
|
| Var of Region.t (* "var" *)
|
||||||
|
| While of Region.t (* "while" *)
|
||||||
|
| With of Region.t (* "with" *)
|
||||||
|
|
||||||
(* Types *)
|
(* Types *)
|
||||||
(*
|
(*
|
||||||
@ -169,8 +169,6 @@ let proj_token = function
|
|||||||
| ASS region -> region, "ASS"
|
| ASS region -> region, "ASS"
|
||||||
| EQUAL region -> region, "EQUAL"
|
| EQUAL region -> region, "EQUAL"
|
||||||
| COLON region -> region, "COLON"
|
| COLON region -> region, "COLON"
|
||||||
| OR region -> region, "OR"
|
|
||||||
| AND region -> region, "AND"
|
|
||||||
| LT region -> region, "LT"
|
| LT region -> region, "LT"
|
||||||
| LEQ region -> region, "LEQ"
|
| LEQ region -> region, "LEQ"
|
||||||
| GT region -> region, "GT"
|
| GT region -> region, "GT"
|
||||||
@ -186,33 +184,35 @@ let proj_token = function
|
|||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
|
| And region -> region, "And"
|
||||||
| Begin region -> region, "Begin"
|
| Begin region -> region, "Begin"
|
||||||
| Case region -> region, "Case"
|
| Case region -> region, "Case"
|
||||||
| Const region -> region, "Const"
|
| Const region -> region, "Const"
|
||||||
| Down region -> region, "Down"
|
| Down region -> region, "Down"
|
||||||
|
| Else region -> region, "Else"
|
||||||
|
| End region -> region, "End"
|
||||||
|
| Entrypoint region -> region, "Entrypoint"
|
||||||
| Fail region -> region, "Fail"
|
| Fail region -> region, "Fail"
|
||||||
|
| For region -> region, "For"
|
||||||
|
| Function region -> region, "Function"
|
||||||
| If region -> region, "If"
|
| If region -> region, "If"
|
||||||
| In region -> region, "In"
|
| In region -> region, "In"
|
||||||
| Is region -> region, "Is"
|
| Is region -> region, "Is"
|
||||||
| Entrypoint region -> region, "Entrypoint"
|
|
||||||
| For region -> region, "For"
|
|
||||||
| Function region -> region, "Function"
|
|
||||||
| Type region -> region, "Type"
|
|
||||||
| Of region -> region, "Of"
|
|
||||||
| Var region -> region, "Var"
|
|
||||||
| End region -> region, "End"
|
|
||||||
| Then region -> region, "Then"
|
|
||||||
| Else region -> region, "Else"
|
|
||||||
| Map region -> region, "Map"
|
| Map region -> region, "Map"
|
||||||
|
| Mod region -> region, "Mod"
|
||||||
|
| Not region -> region, "Not"
|
||||||
|
| Of region -> region, "Of"
|
||||||
|
| Or region -> region, "Or"
|
||||||
| Patch region -> region, "Patch"
|
| Patch region -> region, "Patch"
|
||||||
| Procedure region -> region, "Procedure"
|
| Procedure region -> region, "Procedure"
|
||||||
| Record region -> region, "Record"
|
| Record region -> region, "Record"
|
||||||
| Skip region -> region, "Skip"
|
| Skip region -> region, "Skip"
|
||||||
| Step region -> region, "Step"
|
| Step region -> region, "Step"
|
||||||
| Storage region -> region, "Storage"
|
| Storage region -> region, "Storage"
|
||||||
|
| Then region -> region, "Then"
|
||||||
| To region -> region, "To"
|
| To region -> region, "To"
|
||||||
| Mod region -> region, "Mod"
|
| Type region -> region, "Type"
|
||||||
| Not region -> region, "Not"
|
| Var region -> region, "Var"
|
||||||
| While region -> region, "While"
|
| While region -> region, "While"
|
||||||
| With region -> region, "With"
|
| With region -> region, "With"
|
||||||
|
|
||||||
@ -254,8 +254,6 @@ let to_lexeme = function
|
|||||||
| ASS _ -> ":="
|
| ASS _ -> ":="
|
||||||
| EQUAL _ -> "="
|
| EQUAL _ -> "="
|
||||||
| COLON _ -> ":"
|
| COLON _ -> ":"
|
||||||
| OR _ -> "||"
|
|
||||||
| AND _ -> "&&"
|
|
||||||
| LT _ -> "<"
|
| LT _ -> "<"
|
||||||
| LEQ _ -> "<="
|
| LEQ _ -> "<="
|
||||||
| GT _ -> ">"
|
| GT _ -> ">"
|
||||||
@ -271,6 +269,7 @@ let to_lexeme = function
|
|||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
|
| And _ -> "and"
|
||||||
| Begin _ -> "begin"
|
| Begin _ -> "begin"
|
||||||
| Case _ -> "case"
|
| Case _ -> "case"
|
||||||
| Const _ -> "const"
|
| Const _ -> "const"
|
||||||
@ -284,6 +283,7 @@ let to_lexeme = function
|
|||||||
| Function _ -> "function"
|
| Function _ -> "function"
|
||||||
| Type _ -> "type"
|
| Type _ -> "type"
|
||||||
| Of _ -> "of"
|
| Of _ -> "of"
|
||||||
|
| Or _ -> "or"
|
||||||
| Var _ -> "var"
|
| Var _ -> "var"
|
||||||
| End _ -> "end"
|
| End _ -> "end"
|
||||||
| Then _ -> "then"
|
| Then _ -> "then"
|
||||||
@ -324,6 +324,7 @@ let to_region token = proj_token token |> fst
|
|||||||
(* LEXIS *)
|
(* LEXIS *)
|
||||||
|
|
||||||
let keywords = [
|
let keywords = [
|
||||||
|
(fun reg -> And reg);
|
||||||
(fun reg -> Begin reg);
|
(fun reg -> Begin reg);
|
||||||
(fun reg -> Case reg);
|
(fun reg -> Case reg);
|
||||||
(fun reg -> Const reg);
|
(fun reg -> Const reg);
|
||||||
@ -337,6 +338,7 @@ let keywords = [
|
|||||||
(fun reg -> Function reg);
|
(fun reg -> Function reg);
|
||||||
(fun reg -> Type reg);
|
(fun reg -> Type reg);
|
||||||
(fun reg -> Of reg);
|
(fun reg -> Of reg);
|
||||||
|
(fun reg -> Or reg);
|
||||||
(fun reg -> Var reg);
|
(fun reg -> Var reg);
|
||||||
(fun reg -> End reg);
|
(fun reg -> End reg);
|
||||||
(fun reg -> Then reg);
|
(fun reg -> Then reg);
|
||||||
@ -357,8 +359,7 @@ let keywords = [
|
|||||||
|
|
||||||
let reserved =
|
let reserved =
|
||||||
let open SSet in
|
let open SSet in
|
||||||
empty |> add "and"
|
empty |> add "as"
|
||||||
|> add "as"
|
|
||||||
|> add "asr"
|
|> add "asr"
|
||||||
|> add "assert"
|
|> add "assert"
|
||||||
|> add "class"
|
|> add "class"
|
||||||
@ -388,7 +389,6 @@ let reserved =
|
|||||||
|> add "nonrec"
|
|> add "nonrec"
|
||||||
|> add "object"
|
|> add "object"
|
||||||
|> add "open"
|
|> add "open"
|
||||||
|> add "or"
|
|
||||||
|> add "private"
|
|> add "private"
|
||||||
|> add "rec"
|
|> add "rec"
|
||||||
|> add "sig"
|
|> add "sig"
|
||||||
@ -500,8 +500,6 @@ let mk_sym lexeme region =
|
|||||||
| ":=" -> ASS region
|
| ":=" -> ASS region
|
||||||
| "=" -> EQUAL region
|
| "=" -> EQUAL region
|
||||||
| ":" -> COLON region
|
| ":" -> COLON region
|
||||||
| "||" -> OR region
|
|
||||||
| "&&" -> AND region
|
|
||||||
| "<" -> LT region
|
| "<" -> LT region
|
||||||
| "<=" -> LEQ region
|
| "<=" -> LEQ region
|
||||||
| ">" -> GT region
|
| ">" -> GT region
|
||||||
@ -549,7 +547,8 @@ let is_ident = function
|
|||||||
| _ -> false
|
| _ -> false
|
||||||
|
|
||||||
let is_kwd = function
|
let is_kwd = function
|
||||||
Begin _
|
And _
|
||||||
|
| Begin _
|
||||||
| Case _
|
| Case _
|
||||||
| Const _
|
| Const _
|
||||||
| Down _
|
| Down _
|
||||||
@ -562,6 +561,7 @@ let is_kwd = function
|
|||||||
| Function _
|
| Function _
|
||||||
| Type _
|
| Type _
|
||||||
| Of _
|
| Of _
|
||||||
|
| Or _
|
||||||
| Var _
|
| Var _
|
||||||
| End _
|
| End _
|
||||||
| Then _
|
| Then _
|
||||||
@ -604,8 +604,6 @@ let is_sym = function
|
|||||||
| ASS _
|
| ASS _
|
||||||
| EQUAL _
|
| EQUAL _
|
||||||
| COLON _
|
| COLON _
|
||||||
| OR _
|
|
||||||
| AND _
|
|
||||||
| LT _
|
| LT _
|
||||||
| LEQ _
|
| LEQ _
|
||||||
| GT _
|
| GT _
|
||||||
|
@ -462,7 +462,7 @@ let esc = "\\n" | "\\\"" | "\\\\" | "\\b"
|
|||||||
let symbol = ';' | ','
|
let symbol = ';' | ','
|
||||||
| '(' | ')' | '{' | '}' | '[' | ']'
|
| '(' | ')' | '{' | '}' | '[' | ']'
|
||||||
| '#' | '|' | "->" | ":=" | '=' | ':'
|
| '#' | '|' | "->" | ":=" | '=' | ':'
|
||||||
| "||" | "&&" | '<' | "<=" | '>' | ">=" | "=/="
|
| '<' | "<=" | '>' | ">=" | "=/="
|
||||||
| '+' | '-' | '*' | '.' | '_' | '^'
|
| '+' | '-' | '*' | '.' | '_' | '^'
|
||||||
let string = [^'"' '\\' '\n']* (* For strings of #include *)
|
let string = [^'"' '\\' '\n']* (* For strings of #include *)
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
%token <Region.t> ASS (* ":=" *)
|
%token <Region.t> ASS (* ":=" *)
|
||||||
%token <Region.t> EQUAL (* "=" *)
|
%token <Region.t> EQUAL (* "=" *)
|
||||||
%token <Region.t> COLON (* ":" *)
|
%token <Region.t> COLON (* ":" *)
|
||||||
%token <Region.t> OR (* "||" *)
|
|
||||||
%token <Region.t> AND (* "&&" *)
|
|
||||||
%token <Region.t> LT (* "<" *)
|
%token <Region.t> LT (* "<" *)
|
||||||
%token <Region.t> LEQ (* "<=" *)
|
%token <Region.t> LEQ (* "<=" *)
|
||||||
%token <Region.t> GT (* ">" *)
|
%token <Region.t> GT (* ">" *)
|
||||||
@ -44,6 +42,7 @@
|
|||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
|
%token <Region.t> And (* "and" *)
|
||||||
%token <Region.t> Begin (* "begin" *)
|
%token <Region.t> Begin (* "begin" *)
|
||||||
%token <Region.t> Case (* "case" *)
|
%token <Region.t> Case (* "case" *)
|
||||||
%token <Region.t> Const (* "const" *)
|
%token <Region.t> Const (* "const" *)
|
||||||
@ -57,6 +56,7 @@
|
|||||||
%token <Region.t> Function (* "function" *)
|
%token <Region.t> Function (* "function" *)
|
||||||
%token <Region.t> Type (* "type" *)
|
%token <Region.t> Type (* "type" *)
|
||||||
%token <Region.t> Of (* "of" *)
|
%token <Region.t> Of (* "of" *)
|
||||||
|
%token <Region.t> Or (* "or" *)
|
||||||
%token <Region.t> Var (* "var" *)
|
%token <Region.t> Var (* "var" *)
|
||||||
%token <Region.t> End (* "end" *)
|
%token <Region.t> End (* "end" *)
|
||||||
%token <Region.t> Then (* "then" *)
|
%token <Region.t> Then (* "then" *)
|
||||||
|
@ -603,7 +603,7 @@ interactive_expr:
|
|||||||
expr EOF { $1 }
|
expr EOF { $1 }
|
||||||
|
|
||||||
expr:
|
expr:
|
||||||
expr OR conj_expr {
|
expr Or conj_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
@ -613,7 +613,7 @@ expr:
|
|||||||
| conj_expr { $1 }
|
| conj_expr { $1 }
|
||||||
|
|
||||||
conj_expr:
|
conj_expr:
|
||||||
conj_expr AND comp_expr {
|
conj_expr And comp_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
|
@ -18,7 +18,8 @@ entrypoint contribute (storage store : store;
|
|||||||
fail "Deadline passed"
|
fail "Deadline passed"
|
||||||
else
|
else
|
||||||
case store.backers[sender] of
|
case store.backers[sender] of
|
||||||
None -> //store.backers[sender] := amount
|
None ->
|
||||||
|
// store.backers[sender] := Some (amount)
|
||||||
patch store.backers with map sender -> amount end
|
patch store.backers with map sender -> amount end
|
||||||
| _ -> skip
|
| _ -> skip
|
||||||
end
|
end
|
||||||
@ -33,7 +34,6 @@ entrypoint withdraw (storage store : store; const sender : address)
|
|||||||
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;
|
||||||
// patch store.funded with True end;
|
|
||||||
// store.funded := True;
|
// store.funded := True;
|
||||||
operations := [Transfer (owner, balance)]
|
operations := [Transfer (owner, balance)]
|
||||||
end
|
end
|
||||||
@ -54,12 +54,12 @@ entrypoint claim (storage store : store; const sender : address)
|
|||||||
None ->
|
None ->
|
||||||
fail "Not a backer"
|
fail "Not a backer"
|
||||||
| Some (amount) ->
|
| Some (amount) ->
|
||||||
if balance >= store.goal || store.funded then
|
if balance >= store.goal or store.funded then
|
||||||
fail "Cannot refund"
|
fail "Cannot refund"
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
operations := [Transfer (sender, amount)];
|
operations := [Transfer (sender, amount)];
|
||||||
// patch store.backers without key sender;
|
// store.backers[sender] := None
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end with (store, operations)
|
end with (store, operations)
|
||||||
|
Loading…
Reference in New Issue
Block a user