From 0c745bcef5d14e215ce58b47a23366a7c7fa1f15 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Fri, 2 May 2014 19:43:30 +0400 Subject: [PATCH] Implement -dparsetree and -dsource options (refs #51). --- src/lib/uTop_main.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index cc8e637..2444492 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -585,6 +585,8 @@ let rec loop term = #if ocaml_version > (4, 00, 1) Env.reset_cache_toplevel (); #endif + if !Clflags.dump_parsetree then Printast.top_phrase pp phrase; + if !Clflags.dump_source then Pprintast.top_phrase pp phrase; ignore (Toploop.execute_phrase true pp phrase); (* Flush everything. *) Format.pp_print_flush Format.std_formatter (); @@ -1169,6 +1171,8 @@ let args = Arg.align [ " Disable autoloading of files in $OCAML_TOPLEVEL_PATH/autoload"; "-require", Arg.String (fun s -> preload := `Packages (UTop.split_words s) :: !preload), " Load this package"; + "-dparsetree", Arg.Set Clflags.dump_parsetree, " Dump OCaml AST after rewriting"; + "-dsource", Arg.Set Clflags.dump_source, " Dump OCaml source after rewriting"; ] #if ocaml_version >= (4, 01, 0)