2019-11-06 17:33:00 +01:00
|
|
|
type t is timestamp * nat -> map (string, address)
|
|
|
|
type u is A | B of t * int | C of int -> (string -> int)
|
|
|
|
type v is record a : t; b : record c : string end end
|
|
|
|
|
|
|
|
function back (var store : store) : list (operation) * store is
|
|
|
|
begin
|
Refactoring of comments (for [dune build @doc]).
Refactoring of parsing command-line arguments
* The type [options] is now abstract and implemented as an
object type to avoid struggling with scoping and type
inference when record types share some common field names.
Refactoring of ParserLog for PascaLIGO and CameLIGO
* The immediate motivation behind that refactoring was to
remove the use of a couple of global references. A
consequence is that we have a nicer and more compact code, by
threading a state. The files [pascaligo/Tests/pp.ligo] and
[ligodity/Tests/pp.mligo].
* Another consequence is that the choice of making strings from
AST nodes depends on the CLI (offsets? mode?). After this
refactoring, that choice is hardcoded in the simplifiers in a
few places (TODO), waiting for a general solution that would
have all CL options flow through the compiler.
* I removed the use of vendors [x_option.ml], [x_map.ml] and
[x_list.ml] when handling optional values. (Less dependencies
this way.)
Refactoring of the ASTs
* I removed the node [local_decl], which was set to [[]]
already in a previous commit (which removed local
declarations as being redundant, as statements could already
be instructions or declarations).
* I changed [StrLit] to [String] in the AST of CameLIGO and
ReasonLIGO.
* I also changed the type [fun_expr] so now either a block is
present, and therefore followed by the [with] keyword, or it
is not. (Before, the presence of a block was not enforced in
the type with the presence of the keyword.)
Notes
* [LexerMain.ml] and [ParserMain.ml] for CameLIGO and PascaLIGO
are almost identical and differ in the same way (language
name and file extension), which suggests that they should be
in the [shared] folder and instanciated as a functor in the
future (TODO).
* I removed the blank characters at the end of many lines in
the parser of ReasonLIGO.
2019-12-13 12:21:52 +01:00
|
|
|
var operations : list (operation) := list [];
|
2019-11-06 17:33:00 +01:00
|
|
|
const a : nat = 0n;
|
|
|
|
x0 := record foo = "1"; bar = 4n end;
|
|
|
|
x1 := nil;
|
|
|
|
x2 := list end;
|
|
|
|
x3 := 3#4# list [5; 6];
|
|
|
|
case foo of
|
|
|
|
10n -> skip
|
|
|
|
end;
|
|
|
|
if s contains x then skip else skip;
|
|
|
|
s := set [3_000mutez; -2; 1n];
|
|
|
|
a := A;
|
|
|
|
b := B (a);
|
|
|
|
c := C (a, B (a));
|
|
|
|
d := None;
|
|
|
|
e := Some (a, B (b));
|
|
|
|
z := z.1.2;
|
|
|
|
x := map [1 -> "1"; 2 -> "2"];
|
|
|
|
y := a.b.c[3];
|
|
|
|
a := "hello " ^ "world" ^ "!";
|
2020-01-10 16:41:47 +01:00
|
|
|
r := record a = 0 end;
|
|
|
|
r := r with record a = 42 end;
|
2019-11-06 17:33:00 +01:00
|
|
|
patch store.backers with set [(1); f(2*3)];
|
|
|
|
remove (1,2,3) from set foo.bar;
|
|
|
|
remove 3 from map foo.bar;
|
|
|
|
patch store.backers with map [sender -> amount];
|
|
|
|
if now > store.deadline and (not True) then
|
|
|
|
begin
|
|
|
|
f (x,1);
|
Refactoring of comments (for [dune build @doc]).
Refactoring of parsing command-line arguments
* The type [options] is now abstract and implemented as an
object type to avoid struggling with scoping and type
inference when record types share some common field names.
Refactoring of ParserLog for PascaLIGO and CameLIGO
* The immediate motivation behind that refactoring was to
remove the use of a couple of global references. A
consequence is that we have a nicer and more compact code, by
threading a state. The files [pascaligo/Tests/pp.ligo] and
[ligodity/Tests/pp.mligo].
* Another consequence is that the choice of making strings from
AST nodes depends on the CLI (offsets? mode?). After this
refactoring, that choice is hardcoded in the simplifiers in a
few places (TODO), waiting for a general solution that would
have all CL options flow through the compiler.
* I removed the use of vendors [x_option.ml], [x_map.ml] and
[x_list.ml] when handling optional values. (Less dependencies
this way.)
Refactoring of the ASTs
* I removed the node [local_decl], which was set to [[]]
already in a previous commit (which removed local
declarations as being redundant, as statements could already
be instructions or declarations).
* I changed [StrLit] to [String] in the AST of CameLIGO and
ReasonLIGO.
* I also changed the type [fun_expr] so now either a block is
present, and therefore followed by the [with] keyword, or it
is not. (Before, the presence of a block was not enforced in
the type with the presence of the keyword.)
Notes
* [LexerMain.ml] and [ParserMain.ml] for CameLIGO and PascaLIGO
are almost identical and differ in the same way (language
name and file extension), which suggests that they should be
in the [shared] folder and instanciated as a functor in the
future (TODO).
* I removed the blank characters at the end of many lines in
the parser of ReasonLIGO.
2019-12-13 12:21:52 +01:00
|
|
|
for k -> d in map m block { skip };
|
|
|
|
for x in set s block { skip };
|
2019-11-06 17:33:00 +01:00
|
|
|
while i < 10n
|
|
|
|
begin
|
|
|
|
acc := 2 - (if toggle then f(x) else Unit);
|
|
|
|
end;
|
|
|
|
for i := 1n to 10n
|
|
|
|
begin
|
|
|
|
acc := acc + i;
|
|
|
|
end;
|
|
|
|
failwith ("Deadline passed");
|
|
|
|
end
|
|
|
|
else
|
|
|
|
case store.backers[sender] of [
|
|
|
|
None -> store.0.backers[sender] := amount
|
|
|
|
| Some (_) -> skip
|
|
|
|
| B (x, C (y,z)) -> skip
|
|
|
|
| False#True#Unit#0xAA#"hi"#4#nil -> skip
|
|
|
|
]
|
|
|
|
end with (operations, store)
|
|
|
|
|
|
|
|
function claim (var store : store) : list (operation) * store is
|
|
|
|
begin
|
Refactoring of comments (for [dune build @doc]).
Refactoring of parsing command-line arguments
* The type [options] is now abstract and implemented as an
object type to avoid struggling with scoping and type
inference when record types share some common field names.
Refactoring of ParserLog for PascaLIGO and CameLIGO
* The immediate motivation behind that refactoring was to
remove the use of a couple of global references. A
consequence is that we have a nicer and more compact code, by
threading a state. The files [pascaligo/Tests/pp.ligo] and
[ligodity/Tests/pp.mligo].
* Another consequence is that the choice of making strings from
AST nodes depends on the CLI (offsets? mode?). After this
refactoring, that choice is hardcoded in the simplifiers in a
few places (TODO), waiting for a general solution that would
have all CL options flow through the compiler.
* I removed the use of vendors [x_option.ml], [x_map.ml] and
[x_list.ml] when handling optional values. (Less dependencies
this way.)
Refactoring of the ASTs
* I removed the node [local_decl], which was set to [[]]
already in a previous commit (which removed local
declarations as being redundant, as statements could already
be instructions or declarations).
* I changed [StrLit] to [String] in the AST of CameLIGO and
ReasonLIGO.
* I also changed the type [fun_expr] so now either a block is
present, and therefore followed by the [with] keyword, or it
is not. (Before, the presence of a block was not enforced in
the type with the presence of the keyword.)
Notes
* [LexerMain.ml] and [ParserMain.ml] for CameLIGO and PascaLIGO
are almost identical and differ in the same way (language
name and file extension), which suggests that they should be
in the [shared] folder and instanciated as a functor in the
future (TODO).
* I removed the blank characters at the end of many lines in
the parser of ReasonLIGO.
2019-12-13 12:21:52 +01:00
|
|
|
var operations : list (operation) := nil;
|
2019-11-06 17:33:00 +01:00
|
|
|
if now <= store.deadline then
|
|
|
|
failwith ("Too soon.")
|
|
|
|
else
|
|
|
|
case store.backers[sender] of
|
|
|
|
None ->
|
|
|
|
failwith ("Not a backer.")
|
2020-01-14 01:27:35 +01:00
|
|
|
| Some (quantity) ->
|
2019-11-06 17:33:00 +01:00
|
|
|
if balance >= store.goal or store.funded then
|
|
|
|
failwith ("Goal reached: no refund.")
|
|
|
|
else
|
|
|
|
begin
|
2020-01-14 01:27:35 +01:00
|
|
|
operations.0.foo := list [transaction (unit, sender, quantity)];
|
2019-11-06 17:33:00 +01:00
|
|
|
remove sender from map store.backers
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end with (operations, store)
|
|
|
|
|
|
|
|
function withdraw (var store : store) : list (operation) * store is
|
|
|
|
begin
|
Refactoring of comments (for [dune build @doc]).
Refactoring of parsing command-line arguments
* The type [options] is now abstract and implemented as an
object type to avoid struggling with scoping and type
inference when record types share some common field names.
Refactoring of ParserLog for PascaLIGO and CameLIGO
* The immediate motivation behind that refactoring was to
remove the use of a couple of global references. A
consequence is that we have a nicer and more compact code, by
threading a state. The files [pascaligo/Tests/pp.ligo] and
[ligodity/Tests/pp.mligo].
* Another consequence is that the choice of making strings from
AST nodes depends on the CLI (offsets? mode?). After this
refactoring, that choice is hardcoded in the simplifiers in a
few places (TODO), waiting for a general solution that would
have all CL options flow through the compiler.
* I removed the use of vendors [x_option.ml], [x_map.ml] and
[x_list.ml] when handling optional values. (Less dependencies
this way.)
Refactoring of the ASTs
* I removed the node [local_decl], which was set to [[]]
already in a previous commit (which removed local
declarations as being redundant, as statements could already
be instructions or declarations).
* I changed [StrLit] to [String] in the AST of CameLIGO and
ReasonLIGO.
* I also changed the type [fun_expr] so now either a block is
present, and therefore followed by the [with] keyword, or it
is not. (Before, the presence of a block was not enforced in
the type with the presence of the keyword.)
Notes
* [LexerMain.ml] and [ParserMain.ml] for CameLIGO and PascaLIGO
are almost identical and differ in the same way (language
name and file extension), which suggests that they should be
in the [shared] folder and instanciated as a functor in the
future (TODO).
* I removed the blank characters at the end of many lines in
the parser of ReasonLIGO.
2019-12-13 12:21:52 +01:00
|
|
|
var operations : list (operation) := list end;
|
2019-11-06 17:33:00 +01:00
|
|
|
if sender = owner then
|
|
|
|
if now >= store.deadline then
|
|
|
|
if balance >= store.goal then {
|
|
|
|
// store.funded := True;
|
|
|
|
patch store with record funded = True; a = b end;
|
|
|
|
operations := list [Transfer (owner, balance)];
|
|
|
|
};
|
|
|
|
else failwith ("Below target.")
|
|
|
|
else failwith ("Too soon.");
|
|
|
|
else skip
|
|
|
|
end with case (foo: bar) of
|
|
|
|
nil -> (operations, (store : store))
|
|
|
|
| _ -> (operations, store)
|
|
|
|
end
|