@@ -28,18 +28,22 @@ let process_implementation_file ppf name =
28
28
(output_prefix name)
29
29
30
30
31
- let setup_reason_error_printer () =
32
- Config. syntax_kind := `reason ;
33
- Lazy. force Super_main. setup;
34
- Lazy. force Reason_outcome_printer_main. setup
31
+ let setup_error_printer (syntax_kind : [ `ml | `reason | `rescript ] )=
32
+ Config. syntax_kind := syntax_kind ;
33
+ if syntax_kind = `reason then begin
34
+ Lazy. force Super_main. setup;
35
+ Lazy. force Reason_outcome_printer_main. setup
36
+ end else if ! Config. syntax_kind = `rescript then begin
37
+ Lazy. force Super_main. setup;
38
+ Lazy. force Res_outcome_printer. setup
39
+ end
35
40
36
- let setup_napkin_error_printer () =
37
- Config. syntax_kind := `rescript ;
38
- Lazy. force Super_main. setup;
39
- Lazy. force Res_outcome_printer. setup
41
+
42
+
43
+
40
44
41
45
let handle_reason (type a ) (kind : a Ml_binary.kind ) sourcefile ppf opref =
42
- setup_reason_error_printer () ;
46
+ setup_error_printer `reason ;
43
47
let tmpfile = Ast_reason_pp. pp sourcefile in
44
48
(match kind with
45
49
| Ml_binary. Ml ->
@@ -62,60 +66,10 @@ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
62
66
Ast_reason_pp. clean tmpfile
63
67
64
68
65
- type valid_input =
66
- | Ml
67
- | Mli
68
- | Re
69
- | Rei
70
- | Res
71
- | Resi
72
- | Resast
73
- | Resiast
74
- | Mlast
75
- | Mliast
76
- | Reast
77
- | Reiast
78
- | Mlmap
79
- | Cmi
80
- | Unknown
81
-
82
-
83
-
84
- (* * This is per-file based,
85
- when [ocamlc] [-c -o another_dir/xx.cmi]
86
- it will return (another_dir/xx)
87
- *)
88
-
89
- let classify_input ext =
90
-
91
- match () with
92
- | _ when ext = Literals. suffix_ml ->
93
- Ml
94
- | _ when ext = Literals. suffix_re ->
95
- Re
96
- | _ when ext = ! Config. interface_suffix ->
97
- Mli
98
- | _ when ext = Literals. suffix_rei ->
99
- Rei
100
- | _ when ext = Literals. suffix_mlast ->
101
- Mlast
102
- | _ when ext = Literals. suffix_mliast ->
103
- Mliast
104
- | _ when ext = Literals. suffix_reast ->
105
- Reast
106
- | _ when ext = Literals. suffix_reiast ->
107
- Reiast
108
- | _ when ext = Literals. suffix_mlmap ->
109
- Mlmap
110
- | _ when ext = Literals. suffix_cmi ->
111
- Cmi
112
- | _ when ext = Literals. suffix_res ->
113
- Res
114
- | _ when ext = Literals. suffix_resi ->
115
- Resi
116
- | _ when ext = Literals. suffix_resast -> Resast
117
- | _ when ext = Literals. suffix_resiast -> Resiast
118
- | _ -> Unknown
69
+
70
+
71
+
72
+
119
73
120
74
let process_file ppf sourcefile =
121
75
(* This is a better default then "", it will be changed later
@@ -124,50 +78,38 @@ let process_file ppf sourcefile =
124
78
*)
125
79
Location. set_input_name sourcefile;
126
80
let ext = Ext_filename. get_extension_maybe sourcefile in
127
- let input = classify_input ext in
81
+ let input = Ext_file_extensions. classify_input ext in
128
82
let opref = output_prefix sourcefile in
129
83
match input with
130
84
| Re -> handle_reason Ml sourcefile ppf opref
131
85
| Rei ->
132
86
handle_reason Mli sourcefile ppf opref
133
- | Reiast
134
- ->
135
- setup_reason_error_printer () ;
136
- Js_implementation. interface_mliast ppf sourcefile opref
137
- | Reast
138
- ->
139
- setup_reason_error_printer () ;
140
- Js_implementation. implementation_mlast ppf sourcefile opref
87
+ | Ml ->
88
+ Js_implementation. implementation
89
+ ~parser: Pparse_driver. parse_implementation
90
+ ppf sourcefile opref
91
+ | Mli ->
92
+ Js_implementation. interface
93
+ ~parser: Pparse_driver. parse_interface
94
+ ppf sourcefile opref
141
95
| Res ->
142
- setup_napkin_error_printer () ;
96
+ setup_error_printer `rescript ;
143
97
Js_implementation. implementation
144
98
~parser: Res_driver. parse_implementation
145
99
ppf sourcefile opref
146
100
| Resi ->
147
- setup_napkin_error_printer () ;
101
+ setup_error_printer `rescript ;
148
102
Js_implementation. interface
149
103
~parser: Res_driver. parse_interface
150
- ppf sourcefile opref
151
- | Ml ->
152
- Js_implementation. implementation
153
- ~parser: Pparse_driver. parse_implementation
154
- ppf sourcefile opref
155
- | Mli ->
156
- Js_implementation. interface
157
- ~parser: Pparse_driver. parse_interface
158
- ppf sourcefile opref
159
- | Resiast
160
- ->
161
- setup_napkin_error_printer () ;
162
- Js_implementation. interface_mliast ppf sourcefile opref
163
- | Mliast
164
- -> Js_implementation. interface_mliast ppf sourcefile opref
165
- | Resast
166
- ->
167
- setup_napkin_error_printer () ;
104
+ ppf sourcefile opref
105
+ | Intf_ast
106
+ ->
107
+ Js_implementation. interface_mliast ppf sourcefile opref
108
+ setup_error_printer ;
109
+ | Impl_ast
110
+ ->
168
111
Js_implementation. implementation_mlast ppf sourcefile opref
169
- | Mlast
170
- -> Js_implementation. implementation_mlast ppf sourcefile opref
112
+ setup_error_printer;
171
113
| Mlmap
172
114
-> Js_implementation. implementation_map ppf sourcefile opref
173
115
| Cmi
@@ -213,7 +155,7 @@ let intf filename =
213
155
214
156
215
157
let format_file input =
216
- let ext = classify_input (Ext_filename. get_extension_maybe input) in
158
+ let ext = Ext_file_extensions. classify_input (Ext_filename. get_extension_maybe input) in
217
159
let syntax =
218
160
match ext with
219
161
| Ml | Mli -> `ml
0 commit comments