@@ -415736,7 +415736,7 @@ module Js_implementation : sig
415736
415736
it will be useful if we don't care about bytecode output(generating js only).
415737
415737
*)
415738
415738
val interface :
415739
- parser:(Format.formatter -> string -> Parsetree.signature) ->
415739
+ parser:(string -> Parsetree.signature) ->
415740
415740
Format.formatter ->
415741
415741
string ->
415742
415742
string ->
@@ -415757,7 +415757,7 @@ val interface_mliast : Format.formatter -> string -> string -> unit
415757
415757
*)
415758
415758
415759
415759
val implementation :
415760
- parser:(Format.formatter -> string -> Parsetree.structure) ->
415760
+ parser:(string -> Parsetree.structure) ->
415761
415761
Format.formatter ->
415762
415762
string ->
415763
415763
string ->
@@ -415874,7 +415874,7 @@ let after_parsing_sig ppf outputprefix ast =
415874
415874
415875
415875
let interface ~parser ppf fname outputprefix =
415876
415876
Compmisc.init_path false;
415877
- parser ppf fname
415877
+ parser fname
415878
415878
|> Cmd_ppx_apply.apply_rewriters ~restore:false ~tool_name:Js_config.tool_name Mli
415879
415879
|> Ppx_entry.rewrite_signature
415880
415880
|> print_if_pipe ppf Clflags.dump_parsetree Printast.interface
@@ -415973,7 +415973,7 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) =
415973
415973
end
415974
415974
let implementation ~parser ppf fname outputprefix =
415975
415975
Compmisc.init_path false;
415976
- parser ppf fname
415976
+ parser fname
415977
415977
|> Cmd_ppx_apply.apply_rewriters ~restore:false ~tool_name:Js_config.tool_name Ml
415978
415978
|> Ppx_entry.rewrite_implementation
415979
415979
|> print_if_pipe ppf Clflags.dump_parsetree Printast.implementation
@@ -416531,14 +416531,11 @@ module Pparse_driver : sig
416531
416531
#1 "pparse_driver.mli"
416532
416532
416533
416533
416534
- val parse_implementation:
416535
- Format.formatter ->
416534
+ val parse_implementation:
416536
416535
string -> Parsetree.structure
416537
416536
416538
416537
416539
416538
val parse_interface:
416540
- Format.formatter ->
416541
-
416542
416539
string -> Parsetree.signature
416543
416540
416544
416541
end = struct
@@ -416577,12 +416574,12 @@ let remove_preprocessed inputfile =
416577
416574
416578
416575
(* Parse a file or get a dumped syntax tree from it *)
416579
416576
416580
- let parse (type a) (kind : a Ml_binary.kind) lexbuf : a =
416577
+ let parse (type a) (kind : a Ml_binary.kind) : _ -> a =
416581
416578
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
416584
416581
416585
- let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416582
+ let file_aux inputfile (type a) (parse_fun : _ -> a)
416586
416583
(kind : a Ml_binary.kind) : a =
416587
416584
let ast_magic = Ml_binary.magic_of_kind kind in
416588
416585
let ic = open_in_bin inputfile in
@@ -416597,10 +416594,6 @@ let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416597
416594
let ast =
416598
416595
try
416599
416596
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";
416604
416597
Location.set_input_name (input_value ic : string);
416605
416598
(input_value ic : a)
416606
416599
end else begin
@@ -416617,12 +416610,12 @@ let file_aux ppf inputfile (type a) (parse_fun : _ -> a)
416617
416610
416618
416611
416619
416612
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 =
416621
416614
Location.set_input_name sourcefile;
416622
416615
let inputfile = preprocess sourcefile in
416623
416616
let ast =
416624
416617
try
416625
- (file_aux ppf inputfile (parse kind) kind)
416618
+ (file_aux inputfile (parse kind) kind)
416626
416619
with exn ->
416627
416620
remove_preprocessed inputfile;
416628
416621
raise exn
@@ -416632,11 +416625,11 @@ let parse_file (type a) (kind : a Ml_binary.kind) (ppf : Format.formatter) (sou
416632
416625
416633
416626
416634
416627
416635
- let parse_implementation ppf sourcefile =
416636
- parse_file Ml ppf sourcefile
416628
+ let parse_implementation sourcefile =
416629
+ parse_file Ml sourcefile
416637
416630
416638
- let parse_interface ppf sourcefile =
416639
- parse_file Mli ppf sourcefile
416631
+ let parse_interface sourcefile =
416632
+ parse_file Mli sourcefile
416640
416633
416641
416634
end
416642
416635
module Ppx_apply
@@ -418961,10 +418954,31 @@ let setup_reason_context () =
418961
418954
Lazy.force Super_main.setup;
418962
418955
Lazy.force Reason_outcome_printer_main.setup
418963
418956
418964
- let reason_pp ~sourcefile =
418957
+
418958
+ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
418965
418959
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
418967
418980
418981
+
418968
418982
type valid_input =
418969
418983
| Ml
418970
418984
| Mli
@@ -419015,28 +419029,9 @@ let process_file ppf sourcefile =
419015
419029
| _ -> raise(Arg.Bad("don't know what to do with " ^ sourcefile)) in
419016
419030
let opref = Compenv.output_prefix sourcefile in
419017
419031
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
419029
419033
| 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
419040
419035
| Reiast
419041
419036
->
419042
419037
setup_reason_context ();
0 commit comments