Skip to content

Remove ml parsing tests and conversion .ml to .res. #6848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Drop Node.js version <18 support, due to it reaching End-of-Life. https://github.com/rescript-lang/rescript-compiler/pull/6429
- Remove deprecated -bs-super-errors option. https://github.com/rescript-lang/rescript-compiler/pull/6814
- Some global names and old keywords are no longer prefixed. https://github.com/rescript-lang/rescript-compiler/pull/6831
- Remove ml parsing tests and conversion from `.ml` to `.res` via format. https://github.com/rescript-lang/rescript-compiler/pull/6848

#### :bug: Bug Fix

Expand Down
4 changes: 2 additions & 2 deletions cli/rescript_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var specs = [
[
"-stdin",
{ kind: "String", data: { kind: "String_set", data: stdin } },
`[.res|.resi|.ml|.mli] Read the code from stdin and print
`[.res|.resi] Read the code from stdin and print
the formatted code to stdout in ReScript syntax`,
],
[
Expand All @@ -46,7 +46,7 @@ the formatted code to stdout in ReScript syntax`,
"Check formatting for file or the whole project. Use `-all` to check the whole project",
],
];
var formattedStdExtensions = [".res", ".resi", ".ml", ".mli"];
var formattedStdExtensions = [".res", ".resi"];
var formattedFileExtensions = [".res", ".resi"];

/**
Expand Down
1 change: 0 additions & 1 deletion jscomp/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ let format_file input =
let ext = Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe input) in
let syntax =
match ext with
| Ml | Mli -> `ml
| Res | Resi -> `res
| _ -> Bsc_args.bad_arg ("don't know what to do with " ^ input) in
let formatted = Res_multi_printer.print ~ignore_parse_errors:!Clflags.ignore_parse_errors syntax ~input in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/cli_help/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const formatHelp =
"`rescript format` formats the current directory\n" +
"\n" +
"Options:\n" +
" -stdin [.res|.resi|.ml|.mli] Read the code from stdin and print\n" +
" -stdin [.res|.resi] Read the code from stdin and print\n" +
" the formatted code to stdout in ReScript syntax\n" +
" -all Format the whole project \n" +
" -check Check formatting for file or the whole project. Use `-all` to check the whole project\n";
Expand Down
28 changes: 5 additions & 23 deletions jscomp/syntax/cli/res_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ module ResClflags : sig
val recover : bool ref
val print : string ref
val width : int ref
val origin : string ref
val file : string ref
val interface : bool ref
val jsx_version : int ref
Expand All @@ -173,7 +172,6 @@ end = struct
let width = ref 100

let print = ref "res"
let origin = ref ""
let interface = ref false
let jsx_version = ref (-1)
let jsx_module = ref "react"
Expand All @@ -194,9 +192,6 @@ end = struct
let spec =
[
("-recover", Arg.Unit (fun () -> recover := true), "Emit partial ast");
( "-parse",
Arg.String (fun txt -> origin := txt),
"Parse ml or res. Default: res" );
( "-print",
Arg.String (fun txt -> print := txt),
"Print either binary, ml, ast, sexp, comments or res. Default: res" );
Expand Down Expand Up @@ -229,26 +224,14 @@ module CliArgProcessor = struct
type backend = Parser : 'diagnostics Res_driver.parsing_engine -> backend
[@@unboxed]

let process_file ~is_interface ~width ~recover ~origin ~target ~jsx_version
let process_file ~is_interface ~width ~recover ~target ~jsx_version
~jsx_module ~jsx_mode ~typechecker filename =
let len = String.length filename in
let process_interface =
is_interface
|| (len > 0 && (String.get [@doesNotRaise]) filename (len - 1) = 'i')
in
let parsing_engine =
match origin with
| "ml" -> Parser Res_driver_ml_parser.parsing_engine
| "res" -> Parser Res_driver.parsing_engine
| "" -> (
match Filename.extension filename with
| ".ml" | ".mli" -> Parser Res_driver_ml_parser.parsing_engine
| _ -> Parser Res_driver.parsing_engine)
| origin ->
print_endline
("-parse needs to be either ml or res. You provided " ^ origin);
exit 1
in
let parsing_engine = Parser Res_driver.parsing_engine in
let print_engine =
match target with
| "binary" -> Res_driver_binary.print_engine
Expand Down Expand Up @@ -313,8 +296,7 @@ let () =
ResClflags.parse ();
CliArgProcessor.process_file ~is_interface:!ResClflags.interface
~width:!ResClflags.width ~recover:!ResClflags.recover
~target:!ResClflags.print ~origin:!ResClflags.origin
~jsx_version:!ResClflags.jsx_version ~jsx_module:!ResClflags.jsx_module
~jsx_mode:!ResClflags.jsx_mode ~typechecker:!ResClflags.typechecker
!ResClflags.file)
~target:!ResClflags.print ~jsx_version:!ResClflags.jsx_version
~jsx_module:!ResClflags.jsx_module ~jsx_mode:!ResClflags.jsx_mode
~typechecker:!ResClflags.typechecker !ResClflags.file)
[@@raises exit]
Loading