Merge branch 'dev' into feature/more-operators
This commit is contained in:
commit
07f7af5286
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
/dune-project
|
||||
*~
|
||||
cache/*
|
||||
Version.ml
|
||||
|
@ -41,28 +41,28 @@ let main =
|
||||
let term = Term.(const print_endline $ const "Ligo needs a command. Do ligo --help") in
|
||||
(term , Term.info "ligo")
|
||||
|
||||
let source =
|
||||
let source n =
|
||||
let open Arg in
|
||||
let info =
|
||||
let docv = "SOURCE_FILE" in
|
||||
let doc = "$(docv) is the path to the .ligo file of the contract." in
|
||||
info ~docv ~doc [] in
|
||||
required @@ pos 0 (some string) None info
|
||||
required @@ pos n (some string) None info
|
||||
|
||||
let entry_point =
|
||||
let entry_point n =
|
||||
let open Arg in
|
||||
let info =
|
||||
let docv = "ENTRY_POINT" in
|
||||
let doc = "$(docv) is entry-point that will be compiled." in
|
||||
info ~docv ~doc [] in
|
||||
required @@ pos 1 (some string) (Some "main") info
|
||||
required @@ pos n (some string) (Some "main") info
|
||||
|
||||
let expression =
|
||||
let expression n =
|
||||
let open Arg in
|
||||
let docv = "EXPRESSION" in
|
||||
let doc = "$(docv) is the expression that will be compiled." in
|
||||
let info = info ~docv ~doc [] in
|
||||
required @@ pos 2 (some string) None info
|
||||
required @@ pos n (some string) None info
|
||||
|
||||
let syntax =
|
||||
let open Arg in
|
||||
@ -82,7 +82,7 @@ let compile_file =
|
||||
ok ()
|
||||
in
|
||||
let term =
|
||||
Term.(const f $ source $ entry_point $ syntax) in
|
||||
Term.(const f $ source 0 $ entry_point 1 $ syntax) in
|
||||
let cmdname = "compile-contract" in
|
||||
let docs = "Subcommand: compile a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in
|
||||
(term , Term.info ~docs cmdname)
|
||||
@ -97,7 +97,7 @@ let compile_parameter =
|
||||
ok ()
|
||||
in
|
||||
let term =
|
||||
Term.(const f $ source $ entry_point $ expression $ syntax) in
|
||||
Term.(const f $ source 0 $ entry_point 1 $ expression 2 $ syntax) in
|
||||
let cmdname = "compile-parameter" in
|
||||
let docs = "Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which calls a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in
|
||||
(term , Term.info ~docs cmdname)
|
||||
@ -112,10 +112,23 @@ let compile_storage =
|
||||
ok ()
|
||||
in
|
||||
let term =
|
||||
Term.(const f $ source $ entry_point $ expression $ syntax) in
|
||||
Term.(const f $ source 0 $ entry_point 1 $ expression 2 $ syntax) in
|
||||
let cmdname = "compile-storage" in
|
||||
let docs = "Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in
|
||||
(term , Term.info ~docs cmdname)
|
||||
|
||||
let dry_run =
|
||||
let f source entry_point storage input syntax =
|
||||
toplevel @@
|
||||
let%bind output =
|
||||
Ligo.Run.run_contract source entry_point storage input syntax in
|
||||
Format.printf "%a\n" Ast_simplified.PP.expression output ;
|
||||
ok ()
|
||||
in
|
||||
let term =
|
||||
Term.(const f $ source 0 $ entry_point 1 $ expression 2 $ expression 3 $ syntax) in
|
||||
let cmdname = "dry-run" in
|
||||
let docs = "Subcommand: run a smart-contract with the given storage and input." in
|
||||
(term , Term.info ~docs cmdname)
|
||||
|
||||
let () = Term.exit @@ Term.eval_choice main [compile_file ; compile_parameter ; compile_storage]
|
||||
let () = Term.exit @@ Term.eval_choice main [compile_file ; compile_parameter ; compile_storage ; dry_run ]
|
||||
|
@ -216,3 +216,13 @@ let type_file ?(debug_simplify = false) ?(debug_typed = false)
|
||||
Format.(printf "Typed : %a\n%!" Ast_typed.PP.program typed)
|
||||
)) ;
|
||||
ok typed
|
||||
|
||||
|
||||
let run_contract source entry_point storage input syntax =
|
||||
let%bind typed =
|
||||
type_file source entry_point in
|
||||
let%bind storage_simpl =
|
||||
parsify_expression storage syntax in
|
||||
let%bind input_simpl =
|
||||
parsify_expression input syntax in
|
||||
Run_simplified.run_simplityped typed entry_point (Ast_simplified.e_pair storage_simpl input_simpl)
|
||||
|
@ -104,7 +104,7 @@ let keywords = Token.[
|
||||
"and", None;
|
||||
"as", None;
|
||||
"asr", None;
|
||||
(* "assert", None; *)
|
||||
(* "assert", None;*)
|
||||
"class", None;
|
||||
"constraint", None;
|
||||
"do", None;
|
||||
|
@ -179,11 +179,18 @@ tuple(item):
|
||||
(* Possibly empty semicolon-separated values between brackets *)
|
||||
|
||||
list_of(item):
|
||||
lbracket sepseq(item,semi) rbracket {
|
||||
{opening = LBracket $1;
|
||||
elements = $2;
|
||||
terminator = None;
|
||||
closing = RBracket $3} }
|
||||
lbracket sep_or_term_list(item,semi) rbracket {
|
||||
let elements, terminator = $2 in {
|
||||
opening = LBracket $1;
|
||||
elements = Some elements;
|
||||
terminator;
|
||||
closing = RBracket $3}
|
||||
}
|
||||
| lbracket rbracket {
|
||||
{opening = LBracket $1;
|
||||
elements = None;
|
||||
terminator = None;
|
||||
closing = RBracket $2} }
|
||||
|
||||
(* Main *)
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
let version = "UNKNOWN"
|
Loading…
Reference in New Issue
Block a user