This commit is contained in:
Pierre-Emmanuel Wulfman 2020-03-23 16:07:40 +01:00
parent 2182054c1c
commit 9b192d8ba2
2 changed files with 55 additions and 13 deletions

View File

@ -167,8 +167,8 @@ let print_cst =
let print_ast = let print_ast =
let f source_file syntax display_format = ( let f source_file syntax display_format = (
toplevel ~display_format @@ toplevel ~display_format @@
let%bind core = Compile.Utils.to_core source_file syntax in let%bind imperative = Compile.Utils.to_imperatve source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_core.pretty_print core ok @@ Format.asprintf "%a\n" Compile.Of_imperative.pretty_print imperative
) )
in in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
@ -176,7 +176,31 @@ let print_ast =
let doc = "Subcommand: Print the AST.\n Warning: Intended for development of LIGO and can break at any time." in let doc = "Subcommand: Print the AST.\n Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname) (Term.ret term, Term.info ~doc cmdname)
let print_typed_ast = let print_ast_sugar =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind sugar = Compile.Utils.to_sugar source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_sugar.pretty_print sugar
)
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast-sugar" in
let doc = "Subcommand: Print the AST.\n Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname)
let print_ast_core =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind core = Compile.Utils.to_core source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_core.pretty_print core
)
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast-core" in
let doc = "Subcommand: Print the AST.\n Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname)
let print_ast_typed =
let f source_file syntax display_format = ( let f source_file syntax display_format = (
toplevel ~display_format @@ toplevel ~display_format @@
let%bind typed,_ = Compile.Utils.type_file source_file syntax Env in let%bind typed,_ = Compile.Utils.type_file source_file syntax Env in
@ -184,7 +208,7 @@ let print_typed_ast =
) )
in in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-typed-ast" in let cmdname = "print-ast-typed" in
let doc = "Subcommand: Print the typed AST.\n Warning: Intended for development of LIGO and can break at any time." in let doc = "Subcommand: Print the typed AST.\n Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname) (Term.ret term, Term.info ~doc cmdname)
@ -441,7 +465,9 @@ let run ?argv () =
dump_changelog ; dump_changelog ;
print_cst ; print_cst ;
print_ast ; print_ast ;
print_typed_ast ; print_ast_sugar ;
print_ast_core ;
print_ast_typed ;
print_mini_c ; print_mini_c ;
list_declarations ; list_declarations ;
] ]

View File

@ -57,6 +57,18 @@ let%expect_test _ =
Subcommand: Print the AST. Warning: Intended for development of Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
print-ast-core
Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time.
print-ast-sugar
Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time.
print-ast-typed
Subcommand: Print the typed AST. Warning: Intended for development
of LIGO and can break at any time.
print-cst print-cst
Subcommand: Print the CST. Warning: Intended for development of Subcommand: Print the CST. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
@ -65,10 +77,6 @@ let%expect_test _ =
Subcommand: Print Mini-C. Warning: Intended for development of Subcommand: Print Mini-C. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
print-typed-ast
Subcommand: Print the typed AST. Warning: Intended for development
of LIGO and can break at any time.
run-function run-function
Subcommand: Run a function with the given parameter. Subcommand: Run a function with the given parameter.
@ -136,6 +144,18 @@ let%expect_test _ =
Subcommand: Print the AST. Warning: Intended for development of Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
print-ast-core
Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time.
print-ast-sugar
Subcommand: Print the AST. Warning: Intended for development of
LIGO and can break at any time.
print-ast-typed
Subcommand: Print the typed AST. Warning: Intended for development
of LIGO and can break at any time.
print-cst print-cst
Subcommand: Print the CST. Warning: Intended for development of Subcommand: Print the CST. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
@ -144,10 +164,6 @@ let%expect_test _ =
Subcommand: Print Mini-C. Warning: Intended for development of Subcommand: Print Mini-C. Warning: Intended for development of
LIGO and can break at any time. LIGO and can break at any time.
print-typed-ast
Subcommand: Print the typed AST. Warning: Intended for development
of LIGO and can break at any time.
run-function run-function
Subcommand: Run a function with the given parameter. Subcommand: Run a function with the given parameter.