Skip to content

Commit f552500

Browse files
committed
Remove .ml support from the compiler and clean up.
1 parent f2e240b commit f552500

15 files changed

+26
-161
lines changed

jscomp/bsc/rescript_compiler_main.ml

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,8 @@ let set_abs_input_name sourcefile =
1818
else sourcefile in
1919
Location.set_input_name sourcefile;
2020
sourcefile
21-
22-
type syntax_kind = [`ml | `rescript]
23-
let setup_compiler_printer (syntax_kind : [ syntax_kind | `default])=
24-
(match syntax_kind with
25-
| `default -> ()
26-
| #syntax_kind as k -> Config.syntax_kind := k);
27-
let syntax_kind = !Config.syntax_kind in
28-
if syntax_kind = `rescript then begin
29-
Lazy.force Res_outcome_printer.setup
30-
end
31-
32-
21+
let setup_outcome_printer () =
22+
Lazy.force Res_outcome_printer.setup
3323

3424
let setup_runtime_path path =
3525
let u0 = Filename.dirname path in
@@ -51,53 +41,37 @@ let process_file sourcefile ?(kind ) ppf =
5141
properly
5242
*)
5343
let uncurried = !Config.uncurried in
44+
setup_outcome_printer ();
5445
let kind =
5546
match kind with
5647
| None -> Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile)
5748
| Some kind -> kind in
5849
let res = match kind with
59-
| Ml ->
60-
let sourcefile = set_abs_input_name sourcefile in
61-
setup_compiler_printer `ml;
62-
Js_implementation.implementation
63-
~parser:Pparse_driver.parse_implementation
64-
ppf sourcefile
65-
| Mli ->
66-
let sourcefile = set_abs_input_name sourcefile in
67-
setup_compiler_printer `ml;
68-
Js_implementation.interface
69-
~parser:Pparse_driver.parse_interface
70-
ppf sourcefile
7150
| Res ->
7251
let sourcefile = set_abs_input_name sourcefile in
73-
setup_compiler_printer `rescript;
7452
Js_implementation.implementation
7553
~parser:(Res_driver.parse_implementation ~ignore_parse_errors:!Clflags.ignore_parse_errors)
7654
ppf sourcefile
7755
| Resi ->
7856
let sourcefile = set_abs_input_name sourcefile in
79-
setup_compiler_printer `rescript;
8057
Js_implementation.interface
8158
~parser:(Res_driver.parse_interface ~ignore_parse_errors:!Clflags.ignore_parse_errors)
8259
ppf sourcefile
8360
| Intf_ast
8461
->
8562
Js_implementation.interface_mliast ppf sourcefile
86-
setup_compiler_printer
8763
(* The printer setup is done in the runtime depends on
8864
the content of ast
8965
*)
9066
| Impl_ast
9167
->
92-
Js_implementation.implementation_mlast ppf sourcefile
93-
setup_compiler_printer
68+
Js_implementation.implementation_mlast ppf sourcefile
9469
| Mlmap
9570
->
9671
Location.set_input_name sourcefile;
9772
Js_implementation.implementation_map ppf sourcefile
9873
| Cmi
9974
->
100-
setup_compiler_printer `default;
10175
let cmi_sign = (Cmi_format.read_cmi sourcefile).cmi_sign in
10276
Printtyp.signature Format.std_formatter cmi_sign ;
10377
Format.pp_print_newline Format.std_formatter ()
@@ -182,22 +156,12 @@ let anonymous ~(rev_args : string list) =
182156
Bsc_args.bad_arg "can not handle multiple files"
183157
end
184158

185-
(** used by -impl -intf *)
186-
let impl filename =
187-
Js_config.js_stdout := false;
188-
process_file filename ~kind:Ml ppf ;;
189-
let intf filename =
190-
Js_config.js_stdout := false ;
191-
process_file filename ~kind:Mli ppf;;
192-
193-
194159
let format_file input =
195160
let ext = Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe input) in
196-
let syntax =
197-
match ext with
198-
| Res | Resi -> `res
199-
| _ -> Bsc_args.bad_arg ("don't know what to do with " ^ input) in
200-
let formatted = Res_multi_printer.print ~ignore_parse_errors:!Clflags.ignore_parse_errors syntax ~input in
161+
( match ext with
162+
| Res | Resi -> ()
163+
| _ -> Bsc_args.bad_arg ("don't know what to do with " ^ input) );
164+
let formatted = Res_multi_printer.print ~ignore_parse_errors:!Clflags.ignore_parse_errors input in
201165
match !Clflags.output_name with
202166
| None ->
203167
output_string stdout formatted
@@ -407,12 +371,6 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
407371
"-bs-loc", set Clflags.dump_location,
408372
"*internal* dont display location with -dtypedtree, -dparsetree";
409373

410-
"-impl", string_call impl,
411-
"*internal* <file> Compile <file> as a .ml file";
412-
413-
"-intf", string_call intf,
414-
"*internal* <file> Compile <file> as a .mli file";
415-
416374
"-dtypedtree", set Clflags.dump_typedtree,
417375
"*internal* debug typedtree";
418376

jscomp/core/bs_conditional_initial.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ let setup_env () =
3232
Matching.call_switcher_variant_constr := Polyvar_pattern_match.call_switcher_variant_constr;
3333
Ctype.variant_is_subtype := Matching_polyfill.variant_is_subtype;
3434
Clflags.dump_location := false;
35-
Config.syntax_kind := `rescript;
3635
Parmatch.print_res_pat := Pattern_printer.print_pattern;
3736
(* default true
3837
otherwise [bsc -I sc src/hello.ml ] will include current directory to search path

jscomp/core/js_implementation.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ let interface ~parser ppf ?outputprefix fname =
9696
|> print_if_pipe ppf Clflags.dump_source Pprintast.signature
9797
|> after_parsing_sig ppf outputprefix
9898

99-
let interface_mliast ppf fname setup =
99+
let interface_mliast ppf fname =
100100
Res_compmisc.init_path ();
101-
Binary_ast.read_ast_exn ~fname Mli setup
101+
Binary_ast.read_ast_exn ~fname Mli
102102
|> print_if_pipe ppf Clflags.dump_parsetree Printast.interface
103103
|> print_if_pipe ppf Clflags.dump_source Pprintast.signature
104104
|> after_parsing_sig ppf (Config_util.output_prefix fname)
@@ -187,9 +187,9 @@ let implementation ~parser ppf ?outputprefix fname =
187187
|> print_if_pipe ppf Clflags.dump_source Pprintast.structure
188188
|> after_parsing_impl ppf outputprefix
189189

190-
let implementation_mlast ppf fname setup =
190+
let implementation_mlast ppf fname =
191191
Res_compmisc.init_path ();
192-
Binary_ast.read_ast_exn ~fname Ml setup
192+
Binary_ast.read_ast_exn ~fname Ml
193193
|> print_if_pipe ppf Clflags.dump_parsetree Printast.implementation
194194
|> print_if_pipe ppf Clflags.dump_source Pprintast.structure
195195
|> after_parsing_impl ppf (Config_util.output_prefix fname)

jscomp/core/js_implementation.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ val interface :
3636
*)
3737

3838
val interface_mliast :
39-
Format.formatter -> string -> ([ `ml | `rescript | `default ] -> unit) -> unit
39+
Format.formatter -> string -> unit
4040

4141
(* val after_parsing_impl :
4242
Format.formatter ->
@@ -57,6 +57,6 @@ val implementation :
5757
(** [implementation ppf sourcefile outprefix] compiles to JS directly *)
5858

5959
val implementation_mlast :
60-
Format.formatter -> string -> ([ `ml | `rescript | `default ] -> unit) -> unit
60+
Format.formatter -> string -> unit
6161

6262
val implementation_map : Format.formatter -> string -> unit

jscomp/core/pparse_driver.ml

Lines changed: 0 additions & 72 deletions
This file was deleted.

jscomp/core/pparse_driver.mli

Lines changed: 0 additions & 3 deletions
This file was deleted.

jscomp/depends/binary_ast.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,14 @@ type 'a kind = 'a Ml_binary.kind =
2929
| Ml : Parsetree.structure kind
3030
| Mli : Parsetree.signature kind
3131

32-
let read_ast_exn (type t) ~fname (_ : t kind) setup : t =
32+
let read_ast_exn (type t) ~fname (_ : t kind) : t =
3333
let ic = open_in_bin fname in
3434
let dep_size = input_binary_int ic in
3535
seek_in ic (pos_in ic + dep_size);
3636
let sourcefile = input_line ic in
3737
Location.set_input_name sourcefile;
3838
let ast = input_value ic in
3939
close_in ic;
40-
(match
41-
Ext_file_extensions.classify_input
42-
(Ext_filename.get_extension_maybe sourcefile)
43-
with
44-
| Res | Resi -> setup `rescript
45-
| _ -> ());
4640
ast
4741

4842
let magic_sep_char = '\n'

jscomp/depends/binary_ast.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
type _ kind = Ml : Parsetree.structure kind | Mli : Parsetree.signature kind
2626

2727
val read_ast_exn :
28-
fname:string -> 'a kind -> ([ `ml | `rescript | `default ] -> unit) -> 'a
28+
fname:string -> 'a kind -> 'a
2929

3030
val magic_sep_char : char
3131

jscomp/ext/ext_file_extensions.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
type valid_input =
2-
| Ml
3-
| Mli
42
| Res
53
| Resi
64
| Intf_ast
@@ -16,8 +14,6 @@ type valid_input =
1614

1715
let classify_input ext =
1816
match () with
19-
| _ when ext = Literals.suffix_ml -> Ml
20-
| _ when ext = Literals.suffix_mli -> Mli
2117
| _ when ext = Literals.suffix_ast -> Impl_ast
2218
| _ when ext = Literals.suffix_iast -> Intf_ast
2319
| _ when ext = Literals.suffix_mlmap -> Mlmap

jscomp/ext/warnings.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,8 @@ let message = function
367367
"this statement never returns (or has an unsound type.)"
368368
| Preprocessor s -> s
369369
| Useless_record_with -> (
370-
match !Config.syntax_kind with
371-
| `ml ->
372-
"all the fields are explicitly listed in this record:\n\
373-
the 'with' clause is useless."
374-
| `rescript ->
375-
"All the fields are already explicitly listed in this record. You \
376-
can remove the `...` spread.")
370+
"All the fields are already explicitly listed in this record. You \
371+
can remove the `...` spread.")
377372
| Bad_module_name modname ->
378373
"This file's name is potentially invalid. The build systems \
379374
conventionally turn a file name into a module name by upper-casing the \

jscomp/frontend/bs_ast_invariant.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ let emit_external_warnings : iterator =
8484
match str_item.pstr_desc with
8585
| Pstr_type
8686
( Nonrecursive,
87-
[{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] )
88-
when !Config.syntax_kind = `rescript ->
87+
[{ptype_kind = Ptype_variant ({pcd_res = Some _} :: _)}] ) ->
8988
Location.raise_errorf ~loc:str_item.pstr_loc
9089
"GADT has to be recursive types, please try `type rec'"
9190
| Pstr_class _ ->

jscomp/ml/typetexp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ let report_error env ppf = function
785785
(* modified *)
786786
Format.fprintf ppf "@[<v>This type constructor, `%a`, can't be found.@ " Printtyp.longident lid;
787787
let has_candidate = super_spellcheck ppf Env.fold_types env lid in
788-
if !Config.syntax_kind = `rescript && not has_candidate then
788+
if not has_candidate then
789789
Format.fprintf ppf "If you wanted to write a recursive type, don't forget the `rec` in `type rec`@]"
790790
| Unbound_type_constructor_2 p ->
791791
fprintf ppf "The type constructor@ %a@ is not yet completely defined"

jscomp/syntax/src/res_multi_printer.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ let print_res ~ignore_parse_errors ~is_interface ~filename =
8888
[@@raises exit]
8989

9090
(* print the given file named input to from "language" to res, general interface exposed by the compiler *)
91-
let print ?(ignore_parse_errors = false) language ~input =
91+
let print ?(ignore_parse_errors = false) input =
9292
let is_interface =
9393
let len = String.length input in
9494
len > 0 && String.unsafe_get input (len - 1) = 'i'
9595
in
96-
match language with
97-
| `res -> print_res ~ignore_parse_errors ~is_interface ~filename:input
96+
print_res ~ignore_parse_errors ~is_interface ~filename:input
9897
[@@raises exit]
9998

10099
(* suppress unused optional arg *)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
(* Interface to print source code from different languages to res.
1+
(* Interface to print source code to res.
22
* Takes a filename called "input" and returns the corresponding formatted res syntax *)
3-
val print : ?ignore_parse_errors:bool -> [`res] -> input:string -> string
3+
val print : ?ignore_parse_errors:bool -> string -> string

jscomp/syntax/testrunner/res_test.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let data_dir = "jscomp/syntax/tests"
55
(* test printing of .res file*)
66
let () =
77
let filename = Filename.concat data_dir "api/resSyntax.res" in
8-
let pretty_source = Res_multi_printer.print `res ~input:filename in
8+
let pretty_source = Res_multi_printer.print filename in
99
assert (
1010
pretty_source
1111
= {|// test file
@@ -20,7 +20,7 @@ if true {
2020
(* test printing of .resi file*)
2121
let () =
2222
let filename = Filename.concat data_dir "api/resiSyntax.resi" in
23-
let pretty_source = Res_multi_printer.print `res ~input:filename in
23+
let pretty_source = Res_multi_printer.print filename in
2424
assert (pretty_source = {|// test interface file
2525

2626
let x: int

0 commit comments

Comments
 (0)