Minor refactoring of the parser.
Added local subdirectory containing an OCaml stub to build with my own system (not dune).
This commit is contained in:
parent
c2ac9ab361
commit
561073ca54
@ -1,2 +1,7 @@
|
||||
$HOME/git/OCaml-build/Makefile
|
||||
$HOME/git/OCaml-build/Makefile.cfg
|
||||
$HOME/git/tezos/src/lib_utils/pos.mli
|
||||
$HOME/git/tezos/src/lib_utils/pos.ml
|
||||
$HOME/git/tezos/src/lib_utils/region.mli
|
||||
$HOME/git/tezos/src/lib_utils/region.ml
|
||||
Stubs/Tezos_utils.ml
|
||||
|
@ -109,6 +109,13 @@ sepseq(X,Sep):
|
||||
(**) { None }
|
||||
| nsepseq(X,Sep) { Some $1 }
|
||||
|
||||
(* TODO *)
|
||||
(*
|
||||
sequence(Item,TERM):
|
||||
nsepseq(Item,TERM) {}
|
||||
| nseq(Item TERM {$1,$2}) {}
|
||||
*)
|
||||
|
||||
(* Inlines *)
|
||||
|
||||
%inline var : Ident { $1 }
|
||||
@ -157,11 +164,13 @@ cartesian:
|
||||
in {region; value=$1}}
|
||||
|
||||
function_type:
|
||||
core_type { $1 }
|
||||
| core_type ARROW function_type {
|
||||
let region = cover (type_expr_to_region $1) (type_expr_to_region $3)
|
||||
in TFun {region; value = ($1, $2, $3)}
|
||||
core_type {
|
||||
$1
|
||||
}
|
||||
| core_type ARROW function_type {
|
||||
let region = cover (type_expr_to_region $1)
|
||||
(type_expr_to_region $3)
|
||||
in TFun {region; value = ($1, $2, $3)} }
|
||||
|
||||
core_type:
|
||||
type_name {
|
||||
@ -216,7 +225,8 @@ record_type:
|
||||
elements = Some (first, others);
|
||||
terminator;
|
||||
closing = End closing}
|
||||
in {region; value}}
|
||||
in {region; value}
|
||||
}
|
||||
| Record LBRACKET series(field_decl,RBRACKET) {
|
||||
let first, (others, terminator, closing) = $3 in
|
||||
let region = cover $1 closing
|
||||
@ -353,19 +363,10 @@ entry_param_decl:
|
||||
in EntryStore {region; value}}
|
||||
|
||||
param_type:
|
||||
nsepseq(function_type,TIMES) {
|
||||
let region = nsepseq_to_region type_expr_to_region $1
|
||||
in TProd {region; value=$1}}
|
||||
|
||||
/* core_param_type: */
|
||||
/* type_name { */
|
||||
/* TAlias $1 */
|
||||
/* } */
|
||||
/* | type_name type_tuple { */
|
||||
/* let region = cover $1.region $2.region */
|
||||
/* in TApp {region; value = $1,$2}} */
|
||||
cartesian { TProd $1 }
|
||||
|
||||
block:
|
||||
(* Begin sequence(statement,SEMI) End { failwith "TODO" } *)
|
||||
Begin series(statement,End) {
|
||||
let first, (others, terminator, closing) = $2 in
|
||||
let region = cover $1 closing
|
||||
@ -457,34 +458,16 @@ unqualified_decl(OP):
|
||||
in $1, $2, $3, $4, init, region}
|
||||
|
||||
const_decl:
|
||||
Const unqualified_decl(EQUAL) SEMI {
|
||||
let name, colon, const_type, equal, init, _ = $2 in
|
||||
let region = cover $1 $3
|
||||
and value = {
|
||||
kwd_const = $1;
|
||||
name;
|
||||
colon;
|
||||
const_type;
|
||||
equal;
|
||||
init;
|
||||
terminator = Some $3}
|
||||
in {region; value}
|
||||
open_const_decl SEMI {
|
||||
let const_decl : AST.const_decl = $1.value in
|
||||
{$1 with value = {const_decl with terminator = Some $2}}
|
||||
}
|
||||
| open_const_decl { $1 }
|
||||
|
||||
var_decl:
|
||||
Var unqualified_decl(ASS) SEMI {
|
||||
let name, colon, var_type, assign, init, _ = $2 in
|
||||
let region = cover $1 $3
|
||||
and value = {
|
||||
kwd_var = $1;
|
||||
name;
|
||||
colon;
|
||||
var_type;
|
||||
assign;
|
||||
init;
|
||||
terminator = Some $3}
|
||||
in {region; value}
|
||||
open_var_decl SEMI {
|
||||
let var_decl : AST.var_decl = $1.value in
|
||||
{$1 with value = {var_decl with terminator = Some $2}}
|
||||
}
|
||||
| open_var_decl { $1 }
|
||||
|
||||
|
2
src/ligo/ligo_parser/Stubs/Tezos_utils.ml
Normal file
2
src/ligo/ligo_parser/Stubs/Tezos_utils.ml
Normal file
@ -0,0 +1,2 @@
|
||||
module Region = Region
|
||||
module Pos = Pos
|
@ -11,18 +11,18 @@ entrypoint contribute (storage store : store;
|
||||
const amount : mutez)
|
||||
: store * list (operation) is
|
||||
var operations : list (operation) := nil
|
||||
const s : list (int) = list [1; 2; 3]
|
||||
const t : set (int) = set []
|
||||
block {
|
||||
// const s : list (int) = list [1; 2; 3]
|
||||
//const t : set (int) = set []
|
||||
begin
|
||||
if now > store.deadline then
|
||||
fail "Deadline passed";
|
||||
else
|
||||
case store.backers[sender] of [
|
||||
None -> store.backers[sender] := Some (amount)
|
||||
None -> store.backers[sender] := Some (amount);
|
||||
// None -> patch store.backers with map sender -> amount end
|
||||
| _ -> skip
|
||||
]
|
||||
} with (store, operations)
|
||||
end with (store, operations)
|
||||
|
||||
entrypoint withdraw (storage store : store; const sender : address)
|
||||
: store * list (operation) is
|
||||
@ -37,7 +37,7 @@ entrypoint withdraw (storage store : store; const sender : address)
|
||||
operations := list [Transfer (owner, balance)];
|
||||
};
|
||||
else fail "Below target"
|
||||
else { fail "Too soon"; }
|
||||
else block { fail "Too soon"; }
|
||||
else skip
|
||||
end with (store, operations)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user