Implement -ppx option (fixes #63).
This commit is contained in:
parent
b0795906e5
commit
72a7e7bfbe
|
@ -508,12 +508,15 @@ let rewrite_str_item pstr_item tstr_item =
|
||||||
let rewrite phrase =
|
let rewrite phrase =
|
||||||
match phrase with
|
match phrase with
|
||||||
| Parsetree.Ptop_def pstr ->
|
| 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
|
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, _, _ = Typemod.type_structure !Toploop.toplevel_env pstr Location.none in
|
||||||
let tstr = str_items_of_typed_structure tstr in
|
let tstr = str_items_of_typed_structure tstr in
|
||||||
Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr)
|
Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr)
|
||||||
else
|
else
|
||||||
phrase
|
Parsetree.Ptop_def pstr
|
||||||
| Parsetree.Ptop_dir _ ->
|
| Parsetree.Ptop_dir _ ->
|
||||||
phrase
|
phrase
|
||||||
|
|
||||||
|
@ -1126,6 +1129,9 @@ let args = Arg.align [
|
||||||
"-noassert", Arg.Set Clflags.noassert, " Do not compile assertion checks";
|
"-noassert", Arg.Set Clflags.noassert, " Do not compile assertion checks";
|
||||||
"-nolabels", Arg.Set Clflags.classic, " Ignore non-optional labels in types";
|
"-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";
|
"-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";
|
"-principal", Arg.Set Clflags.principal, " Check principality of type inference";
|
||||||
#if ocaml_version >= (4, 01, 0)
|
#if ocaml_version >= (4, 01, 0)
|
||||||
"-short-paths", Arg.Clear Clflags.real_paths, " Shorten paths in types (the default)";
|
"-short-paths", Arg.Clear Clflags.real_paths, " Shorten paths in types (the default)";
|
||||||
|
|
Loading…
Reference in New Issue