basic bin
This commit is contained in:
parent
9ac9fdd562
commit
df84763eb2
@ -1 +1,24 @@
|
||||
let () = ()
|
||||
open Trace
|
||||
|
||||
let () =
|
||||
let l = Array.length Sys.argv in
|
||||
if l < 2
|
||||
then raise (Failure "Pass a command") ;
|
||||
Format.printf "Toto %d\n%!" (Array.length Sys.argv) ;
|
||||
let command = Sys.argv.(1) in
|
||||
let _ =
|
||||
match command with
|
||||
| "compile" -> (
|
||||
let%bind () =
|
||||
if l <> 4
|
||||
then simple_fail "Bad number of argument to compile"
|
||||
else ok () in
|
||||
let source = Sys.argv.(2) in
|
||||
let entry_point = Sys.argv.(3) in
|
||||
let%bind michelson = Ligo.compile_file source entry_point in
|
||||
Format.printf "%a" Micheline.Michelson.pp michelson ;
|
||||
ok ()
|
||||
)
|
||||
| _ -> simple_fail "Bad command"
|
||||
in
|
||||
()
|
||||
|
@ -3,6 +3,7 @@
|
||||
(public_name ligo)
|
||||
(libraries
|
||||
tezos-utils
|
||||
ligo
|
||||
)
|
||||
(package ligo)
|
||||
(preprocess
|
||||
|
@ -128,6 +128,8 @@ let transpile_value
|
||||
let untranspile_value (v : Mini_c.value) (e:AST_Typed.type_value) : AST_Typed.annotated_expression result =
|
||||
Transpiler.untranspile v e
|
||||
|
||||
let compile : Mini_c.program -> string -> Mini_c.Compiler.compiled_program result = Mini_c.Compiler.translate_program
|
||||
|
||||
let type_file ?(debug_simplify = false) ?(debug_typed = false)
|
||||
(path:string) : AST_Typed.program result =
|
||||
let%bind raw = parse_file path in
|
||||
@ -194,3 +196,21 @@ let easy_run_main (path:string) (input:string) : AST_Typed.annotated_expression
|
||||
let%bind simpl_expr = simplify_expr raw_expr in
|
||||
let%bind typed_expr = type_expression simpl_expr in
|
||||
easy_run_main_typed typed typed_expr
|
||||
|
||||
let compile_file (source: string) (entry_point:string) : Micheline.Michelson.t result =
|
||||
let%bind raw =
|
||||
trace (simple_error "parsing") @@
|
||||
parse_file source in
|
||||
let%bind simplified =
|
||||
trace (simple_error "simplifying") @@
|
||||
simplify raw in
|
||||
let%bind typed =
|
||||
trace (simple_error "typing") @@
|
||||
type_ simplified in
|
||||
let%bind mini_c =
|
||||
trace (simple_error "transpiling") @@
|
||||
transpile typed in
|
||||
let%bind {body = michelson} =
|
||||
trace (simple_error "compiling") @@
|
||||
compile mini_c entry_point in
|
||||
ok michelson
|
||||
|
@ -12,7 +12,6 @@ depends: [
|
||||
"menhir"
|
||||
"ppx_let"
|
||||
"tezos-utils"
|
||||
"meta-michelson"
|
||||
]
|
||||
build: [
|
||||
[ "dune" "build" "-p" name "-j" jobs ]
|
||||
|
@ -126,9 +126,9 @@ let tokens = [
|
||||
keyword "then" ;
|
||||
keyword "else" ;
|
||||
keyword "list" ;
|
||||
keyword "block" ;
|
||||
keyword "for" ;
|
||||
keyword "const" ;
|
||||
(* keyword "block" ;
|
||||
* keyword "for" ;
|
||||
* keyword "const" ; *)
|
||||
keyword "fun" ;
|
||||
keyword "match" ;
|
||||
keyword "with" ;
|
||||
|
@ -20,6 +20,6 @@ let integration () : unit result =
|
||||
|
||||
let main = "Multifix", [
|
||||
test "basic" basic ;
|
||||
test "simplfiy" simplify ;
|
||||
test "simplify" simplify ;
|
||||
test "integration" integration ;
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user