@@ -415736,7 +415736,7 @@ module Js_implementation : sig
415736415736 it will be useful if we don't care about bytecode output(generating js only).
415737415737 *)
415738415738val interface :
415739- parser:(Format.formatter -> string -> Parsetree.signature) ->
415739+ parser:(string -> Parsetree.signature) ->
415740415740 Format.formatter ->
415741415741 string ->
415742415742 string ->
@@ -415757,7 +415757,7 @@ val interface_mliast : Format.formatter -> string -> string -> unit
415757415757*)
415758415758
415759415759val implementation :
415760- parser:(Format.formatter -> string -> Parsetree.structure) ->
415760+ parser:(string -> Parsetree.structure) ->
415761415761 Format.formatter ->
415762415762 string ->
415763415763 string ->
@@ -415874,7 +415874,7 @@ let after_parsing_sig ppf outputprefix ast =
415874415874
415875415875let interface ~parser ppf fname outputprefix =
415876415876 Compmisc.init_path false;
415877- parser ppf fname
415877+ parser fname
415878415878 |> Cmd_ppx_apply.apply_rewriters ~restore:false ~tool_name:Js_config.tool_name Mli
415879415879 |> Ppx_entry.rewrite_signature
415880415880 |> print_if_pipe ppf Clflags.dump_parsetree Printast.interface
@@ -415973,7 +415973,7 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) =
415973415973 end
415974415974let implementation ~parser ppf fname outputprefix =
415975415975 Compmisc.init_path false;
415976- parser ppf fname
415976+ parser fname
415977415977 |> Cmd_ppx_apply.apply_rewriters ~restore:false ~tool_name:Js_config.tool_name Ml
415978415978 |> Ppx_entry.rewrite_implementation
415979415979 |> print_if_pipe ppf Clflags.dump_parsetree Printast.implementation
@@ -416531,14 +416531,11 @@ module Pparse_driver : sig
416531416531#1 "pparse_driver.mli"
416532416532
416533416533
416534- val parse_implementation:
416535- Format.formatter ->
416534+ val parse_implementation:
416536416535 string -> Parsetree.structure
416537416536
416538416537
416539416538val parse_interface:
416540- Format.formatter ->
416541-
416542416539 string -> Parsetree.signature
416543416540
416544416541end = struct
@@ -416577,12 +416574,12 @@ let remove_preprocessed inputfile =
416577416574
416578416575(* Parse a file or get a dumped syntax tree from it *)
416579416576
416580- let parse (type a) (kind : a Ml_binary.kind) lexbuf : a =
416577+ let parse (type a) (kind : a Ml_binary.kind) : _ -> a =
416581416578 match kind with
416582- | Ml_binary.Ml -> Parse.implementation lexbuf
416583- | Ml_binary.Mli -> Parse.interface lexbuf
416579+ | Ml_binary.Ml -> Parse.implementation
416580+ | Ml_binary.Mli -> Parse.interface
416584416581
416585- let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416582+ let file_aux inputfile (type a) (parse_fun : _ -> a)
416586416583 (kind : a Ml_binary.kind) : a =
416587416584 let ast_magic = Ml_binary.magic_of_kind kind in
416588416585 let ic = open_in_bin inputfile in
@@ -416597,10 +416594,6 @@ let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416597416594 let ast =
416598416595 try
416599416596 if is_ast_file then begin
416600- if !Clflags.fast then
416601- (* FIXME make this a proper warning *)
416602- Format.fprintf ppf "@[Warning: %s@]@."
416603- "option -unsafe used with a preprocessor returning a syntax tree";
416604416597 Location.set_input_name (input_value ic : string);
416605416598 (input_value ic : a)
416606416599 end else begin
@@ -416617,12 +416610,12 @@ let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416617416610
416618416611
416619416612
416620- let parse_file (type a) (kind : a Ml_binary.kind) (ppf : Format.formatter) ( sourcefile : string) : a =
416613+ let parse_file (type a) (kind : a Ml_binary.kind) (sourcefile : string) : a =
416621416614 Location.set_input_name sourcefile;
416622416615 let inputfile = preprocess sourcefile in
416623416616 let ast =
416624416617 try
416625- (file_aux ppf inputfile (parse kind) kind)
416618+ (file_aux inputfile (parse kind) kind)
416626416619 with exn ->
416627416620 remove_preprocessed inputfile;
416628416621 raise exn
@@ -416632,11 +416625,11 @@ let parse_file (type a) (kind : a Ml_binary.kind) (ppf : Format.formatter) (sou
416632416625
416633416626
416634416627
416635- let parse_implementation ppf sourcefile =
416636- parse_file Ml ppf sourcefile
416628+ let parse_implementation sourcefile =
416629+ parse_file Ml sourcefile
416637416630
416638- let parse_interface ppf sourcefile =
416639- parse_file Mli ppf sourcefile
416631+ let parse_interface sourcefile =
416632+ parse_file Mli sourcefile
416640416633
416641416634end
416642416635module Ppx_apply
@@ -418961,10 +418954,31 @@ let setup_reason_context () =
418961418954 Lazy.force Super_main.setup;
418962418955 Lazy.force Reason_outcome_printer_main.setup
418963418956
418964- let reason_pp ~sourcefile =
418957+
418958+ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
418965418959 setup_reason_context ();
418966- Ast_reason_pp.pp sourcefile
418960+ let tmpfile = Ast_reason_pp.pp sourcefile in
418961+ (match kind with
418962+ | Ml_binary.Ml ->
418963+ Js_implementation.implementation
418964+ ~parser:(fun file_in ->
418965+ let in_chan = open_in_bin file_in in
418966+ let ast = Ml_binary.read_ast Ml in_chan in
418967+ close_in in_chan; ast
418968+ )
418969+ ppf tmpfile opref
418970+
418971+ | Ml_binary.Mli ->
418972+ Js_implementation.interface
418973+ ~parser:(fun file_in ->
418974+ let in_chan = open_in_bin file_in in
418975+ let ast = Ml_binary.read_ast Mli in_chan in
418976+ close_in in_chan; ast
418977+ )
418978+ ppf tmpfile opref ; );
418979+ Ast_reason_pp.clean tmpfile
418967418980
418981+
418968418982type valid_input =
418969418983 | Ml
418970418984 | Mli
@@ -419015,28 +419029,9 @@ let process_file ppf sourcefile =
419015419029 | _ -> raise(Arg.Bad("don't know what to do with " ^ sourcefile)) in
419016419030 let opref = Compenv.output_prefix sourcefile in
419017419031 match input with
419018- | Re ->
419019- setup_reason_context ();
419020- let tmpfile = reason_pp ~sourcefile in
419021- Js_implementation.implementation
419022- ~parser:(fun _ file_in ->
419023- let in_chan = open_in_bin file_in in
419024- let ast = Ml_binary.read_ast Ml in_chan in
419025- close_in in_chan; ast
419026- )
419027- ppf tmpfile opref ;
419028- Ast_reason_pp.clean tmpfile
419032+ | Re -> handle_reason Ml sourcefile ppf opref
419029419033 | Rei ->
419030- setup_reason_context ();
419031- let tmpfile = reason_pp ~sourcefile in
419032- Js_implementation.interface
419033- ~parser:(fun _ file_in ->
419034- let in_chan = open_in_bin file_in in
419035- let ast = Ml_binary.read_ast Mli in_chan in
419036- close_in in_chan; ast
419037- )
419038- ppf tmpfile opref ;
419039- Ast_reason_pp.clean tmpfile
419034+ handle_reason Mli sourcefile ppf opref
419040419035 | Reiast
419041419036 ->
419042419037 setup_reason_context ();
0 commit comments