Implement -ppx option (fixes #63).

This commit is contained in:
Peter Zotov 2014-05-02 19:38:57 +04:00
parent b0795906e5
commit 72a7e7bfbe
1 changed files with 7 additions and 1 deletions

View File

@ -508,12 +508,15 @@ let rewrite_str_item pstr_item tstr_item =
let rewrite phrase =
match phrase with
| Parsetree.Ptop_def pstr ->
#if ocaml_version >= (4, 02, 0)
let pstr = Pparse.apply_rewriters Config.ast_impl_magic_number pstr in
#endif
if (UTop.get_auto_run_lwt () || UTop.get_auto_run_async ()) && List.exists is_eval pstr then
let tstr, _, _ = Typemod.type_structure !Toploop.toplevel_env pstr Location.none in
let tstr = str_items_of_typed_structure tstr in
Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr)
else
phrase
Parsetree.Ptop_def pstr
| Parsetree.Ptop_dir _ ->
phrase
@ -1126,6 +1129,9 @@ let args = Arg.align [
"-noassert", Arg.Set Clflags.noassert, " Do not compile assertion checks";
"-nolabels", Arg.Set Clflags.classic, " Ignore non-optional labels in types";
"-nostdlib", Arg.Set Clflags.no_std_include, " Do not add default directory to the list of include directories";
#if ocaml_version >= (4, 02, 0)
"-ppx", Arg.String (fun ppx -> Clflags.all_ppx := ppx :: !Clflags.all_ppx), "<command> Pipe abstract syntax trees through preprocessor <command>";
#endif
"-principal", Arg.Set Clflags.principal, " Check principality of type inference";
#if ocaml_version >= (4, 01, 0)
"-short-paths", Arg.Clear Clflags.real_paths, " Shorten paths in types (the default)";