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
|
||||||
$HOME/git/OCaml-build/Makefile.cfg
|
$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 }
|
(**) { None }
|
||||||
| nsepseq(X,Sep) { Some $1 }
|
| nsepseq(X,Sep) { Some $1 }
|
||||||
|
|
||||||
|
(* TODO *)
|
||||||
|
(*
|
||||||
|
sequence(Item,TERM):
|
||||||
|
nsepseq(Item,TERM) {}
|
||||||
|
| nseq(Item TERM {$1,$2}) {}
|
||||||
|
*)
|
||||||
|
|
||||||
(* Inlines *)
|
(* Inlines *)
|
||||||
|
|
||||||
%inline var : Ident { $1 }
|
%inline var : Ident { $1 }
|
||||||
@ -157,11 +164,13 @@ cartesian:
|
|||||||
in {region; value=$1}}
|
in {region; value=$1}}
|
||||||
|
|
||||||
function_type:
|
function_type:
|
||||||
core_type { $1 }
|
core_type {
|
||||||
|
$1
|
||||||
|
}
|
||||||
| core_type ARROW function_type {
|
| core_type ARROW function_type {
|
||||||
let region = cover (type_expr_to_region $1) (type_expr_to_region $3)
|
let region = cover (type_expr_to_region $1)
|
||||||
in TFun {region; value = ($1, $2, $3)}
|
(type_expr_to_region $3)
|
||||||
}
|
in TFun {region; value = ($1, $2, $3)} }
|
||||||
|
|
||||||
core_type:
|
core_type:
|
||||||
type_name {
|
type_name {
|
||||||
@ -199,13 +208,13 @@ type_tuple:
|
|||||||
sum_type:
|
sum_type:
|
||||||
nsepseq(variant,VBAR) {
|
nsepseq(variant,VBAR) {
|
||||||
let region = nsepseq_to_region (fun x -> x.region) $1
|
let region = nsepseq_to_region (fun x -> x.region) $1
|
||||||
in {region; value = $1}}
|
in {region; value = $1} }
|
||||||
|
|
||||||
variant:
|
variant:
|
||||||
Constr Of cartesian {
|
Constr Of cartesian {
|
||||||
let region = cover $1.region $3.region
|
let region = cover $1.region $3.region
|
||||||
and value = {constr = $1; kwd_of = $2; product = $3}
|
and value = {constr = $1; kwd_of = $2; product = $3}
|
||||||
in {region; value}}
|
in {region; value} }
|
||||||
|
|
||||||
record_type:
|
record_type:
|
||||||
Record series(field_decl,End) {
|
Record series(field_decl,End) {
|
||||||
@ -216,7 +225,8 @@ record_type:
|
|||||||
elements = Some (first, others);
|
elements = Some (first, others);
|
||||||
terminator;
|
terminator;
|
||||||
closing = End closing}
|
closing = End closing}
|
||||||
in {region; value}}
|
in {region; value}
|
||||||
|
}
|
||||||
| Record LBRACKET series(field_decl,RBRACKET) {
|
| Record LBRACKET series(field_decl,RBRACKET) {
|
||||||
let first, (others, terminator, closing) = $3 in
|
let first, (others, terminator, closing) = $3 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
@ -225,14 +235,14 @@ record_type:
|
|||||||
elements = Some (first, others);
|
elements = Some (first, others);
|
||||||
terminator;
|
terminator;
|
||||||
closing = RBracket closing}
|
closing = RBracket closing}
|
||||||
in {region; value}}
|
in {region; value} }
|
||||||
|
|
||||||
field_decl:
|
field_decl:
|
||||||
field_name COLON type_expr {
|
field_name COLON type_expr {
|
||||||
let stop = type_expr_to_region $3 in
|
let stop = type_expr_to_region $3 in
|
||||||
let region = cover $1.region stop
|
let region = cover $1.region stop
|
||||||
and value = {field_name = $1; colon = $2; field_type = $3}
|
and value = {field_name = $1; colon = $2; field_type = $3}
|
||||||
in {region; value}}
|
in {region; value} }
|
||||||
|
|
||||||
(* Function and procedure declarations *)
|
(* Function and procedure declarations *)
|
||||||
|
|
||||||
@ -353,19 +363,10 @@ entry_param_decl:
|
|||||||
in EntryStore {region; value}}
|
in EntryStore {region; value}}
|
||||||
|
|
||||||
param_type:
|
param_type:
|
||||||
nsepseq(function_type,TIMES) {
|
cartesian { TProd $1 }
|
||||||
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}} */
|
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
(* Begin sequence(statement,SEMI) End { failwith "TODO" } *)
|
||||||
Begin series(statement,End) {
|
Begin series(statement,End) {
|
||||||
let first, (others, terminator, closing) = $2 in
|
let first, (others, terminator, closing) = $2 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
@ -457,34 +458,16 @@ unqualified_decl(OP):
|
|||||||
in $1, $2, $3, $4, init, region}
|
in $1, $2, $3, $4, init, region}
|
||||||
|
|
||||||
const_decl:
|
const_decl:
|
||||||
Const unqualified_decl(EQUAL) SEMI {
|
open_const_decl SEMI {
|
||||||
let name, colon, const_type, equal, init, _ = $2 in
|
let const_decl : AST.const_decl = $1.value in
|
||||||
let region = cover $1 $3
|
{$1 with value = {const_decl with terminator = Some $2}}
|
||||||
and value = {
|
|
||||||
kwd_const = $1;
|
|
||||||
name;
|
|
||||||
colon;
|
|
||||||
const_type;
|
|
||||||
equal;
|
|
||||||
init;
|
|
||||||
terminator = Some $3}
|
|
||||||
in {region; value}
|
|
||||||
}
|
}
|
||||||
| open_const_decl { $1 }
|
| open_const_decl { $1 }
|
||||||
|
|
||||||
var_decl:
|
var_decl:
|
||||||
Var unqualified_decl(ASS) SEMI {
|
open_var_decl SEMI {
|
||||||
let name, colon, var_type, assign, init, _ = $2 in
|
let var_decl : AST.var_decl = $1.value in
|
||||||
let region = cover $1 $3
|
{$1 with value = {var_decl with terminator = Some $2}}
|
||||||
and value = {
|
|
||||||
kwd_var = $1;
|
|
||||||
name;
|
|
||||||
colon;
|
|
||||||
var_type;
|
|
||||||
assign;
|
|
||||||
init;
|
|
||||||
terminator = Some $3}
|
|
||||||
in {region; value}
|
|
||||||
}
|
}
|
||||||
| open_var_decl { $1 }
|
| 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)
|
const amount : mutez)
|
||||||
: store * list (operation) is
|
: store * list (operation) is
|
||||||
var operations : list (operation) := nil
|
var operations : list (operation) := nil
|
||||||
const s : list (int) = list [1; 2; 3]
|
// const s : list (int) = list [1; 2; 3]
|
||||||
const t : set (int) = set []
|
//const t : set (int) = set []
|
||||||
block {
|
begin
|
||||||
if now > store.deadline then
|
if now > store.deadline then
|
||||||
fail "Deadline passed";
|
fail "Deadline passed";
|
||||||
else
|
else
|
||||||
case store.backers[sender] of [
|
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
|
// None -> patch store.backers with map sender -> amount end
|
||||||
| _ -> skip
|
| _ -> skip
|
||||||
]
|
]
|
||||||
} with (store, operations)
|
end with (store, operations)
|
||||||
|
|
||||||
entrypoint withdraw (storage store : store; const sender : address)
|
entrypoint withdraw (storage store : store; const sender : address)
|
||||||
: store * list (operation) is
|
: store * list (operation) is
|
||||||
@ -37,7 +37,7 @@ entrypoint withdraw (storage store : store; const sender : address)
|
|||||||
operations := list [Transfer (owner, balance)];
|
operations := list [Transfer (owner, balance)];
|
||||||
};
|
};
|
||||||
else fail "Below target"
|
else fail "Below target"
|
||||||
else { fail "Too soon"; }
|
else block { fail "Too soon"; }
|
||||||
else skip
|
else skip
|
||||||
end with (store, operations)
|
end with (store, operations)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user