From 8055935bd63d7d0e4ffbae00f187d4232c1a56ea Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 3 Jul 2024 11:02:38 +0200 Subject: [PATCH 1/5] Remove `.ml` parsing tests. --- jscomp/syntax/cli/res_cli.ml | 8 ++- .../destructiveSubstitutionSubModules.ml | 51 -------------- .../tests/conversion/reason/docComments.ml | 40 ----------- .../tests/conversion/reason/docComments.mli | 70 ------------------- .../destructiveSubstitutionSubModules.ml.txt | 60 ---------------- .../reason/expected/docComments.ml.txt | 40 ----------- .../reason/expected/docComments.mli.txt | 69 ------------------ .../conversion/reason/expected/object.ml.txt | 4 -- .../reason/expected/recursiveType.ml.txt | 3 - .../reason/expected/refSugar.ml.txt | 1 - .../syntax/tests/conversion/reason/object.ml | 4 -- .../tests/conversion/reason/recursiveType.ml | 4 -- .../tests/conversion/reason/refSugar.ml | 1 - 13 files changed, 5 insertions(+), 350 deletions(-) delete mode 100644 jscomp/syntax/tests/conversion/reason/destructiveSubstitutionSubModules.ml delete mode 100644 jscomp/syntax/tests/conversion/reason/docComments.ml delete mode 100644 jscomp/syntax/tests/conversion/reason/docComments.mli delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/destructiveSubstitutionSubModules.ml.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/docComments.ml.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/docComments.mli.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/object.ml.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/recursiveType.ml.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/expected/refSugar.ml.txt delete mode 100644 jscomp/syntax/tests/conversion/reason/object.ml delete mode 100644 jscomp/syntax/tests/conversion/reason/recursiveType.ml delete mode 100644 jscomp/syntax/tests/conversion/reason/refSugar.ml diff --git a/jscomp/syntax/cli/res_cli.ml b/jscomp/syntax/cli/res_cli.ml index d5fca5d132..a8bbb5616f 100644 --- a/jscomp/syntax/cli/res_cli.ml +++ b/jscomp/syntax/cli/res_cli.ml @@ -195,7 +195,9 @@ end = struct [ ("-recover", Arg.Unit (fun () -> recover := true), "Emit partial ast"); ( "-parse", - Arg.String (fun txt -> origin := txt), + Arg.String (fun txt -> + let _ = assert (txt <> "ml") in + origin := txt), "Parse ml or res. Default: res" ); ( "-print", Arg.String (fun txt -> print := txt), @@ -238,11 +240,11 @@ module CliArgProcessor = struct in let parsing_engine = match origin with - | "ml" -> Parser Res_driver_ml_parser.parsing_engine + | "ml" -> assert false | "res" -> Parser Res_driver.parsing_engine | "" -> ( match Filename.extension filename with - | ".ml" | ".mli" -> Parser Res_driver_ml_parser.parsing_engine + | ".ml" | ".mli" -> assert false | _ -> Parser Res_driver.parsing_engine) | origin -> print_endline diff --git a/jscomp/syntax/tests/conversion/reason/destructiveSubstitutionSubModules.ml b/jscomp/syntax/tests/conversion/reason/destructiveSubstitutionSubModules.ml deleted file mode 100644 index f6060c1743..0000000000 --- a/jscomp/syntax/tests/conversion/reason/destructiveSubstitutionSubModules.ml +++ /dev/null @@ -1,51 +0,0 @@ -module type Id = - sig type t val toString : t -> string val ofString : string -> t option end -module type A = sig module Id : Id type name = string val name : name end -module type B = sig module A : A val fullName : A.Id.t -> string end -module MakeB(A:A): B with module A.Id := A.Id = - (struct - module A = A - let fullName id = A.name ^ ("-" ^ (A.Id.toString id)) - end) -module StringId : Id = - struct - type t = string - external toString : t -> string = "%identity" - external ofString : string -> t = "%identity" - let ofString id = ((Some ((id |> ofString)))[@explicit_arity ]) - end -module A = struct module Id = StringId - type name = string - let name = "A" end -module B = (MakeB)(A) -let test = - match "someId" |> StringId.ofString with - | ((Some (id))[@explicit_arity ]) -> ((Some ((id |> B.fullName))) - [@explicit_arity ]) - | None as none -> none - -module type Printable = sig - type t - val print : Format.formatter -> t -> unit -end - -module type Comparable = sig - type t - val compare : t -> t -> int -end - -module type PrintableComparable = sig - include Printable - include Comparable with type t := t -end - -module type S = Comparable with type t := int - -module type S = sig - type u - include Comparable with type t := u -end - -module type ComparableInt = Comparable with type t = int - -module type CompareInt = ComparableInt with type t := int diff --git a/jscomp/syntax/tests/conversion/reason/docComments.ml b/jscomp/syntax/tests/conversion/reason/docComments.ml deleted file mode 100644 index 4a6a782133..0000000000 --- a/jscomp/syntax/tests/conversion/reason/docComments.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** The first special comment of the file is the comment associated - to the whole module. *) - - (** The comment for function f *) - let f x y = x + y - - (** This comment is not attached to any element since there is another - special comment just before the next element. *) - - (** Comment for exception My_exception, even with a simple comment - between the special comment and the exception.*) - (* A simple comment. *) - exception My_exception of (int -> int) * int - - (** Comment for type weather *) - type weather = - | Rain of int (** The comment for constructor Rain *) - | Sun (** The comment for constructor Sun *) - - (** The comment for type my_record *) - type my_record = { - foo : int ; (** Comment for field foo *) - bar : string ; (** Comment for field bar *) - } - - (** The comment for module Foo *) - module Foo = - struct - (** The comment for x *) - let x = 0 - (** A special comment in the class, but not associated to any element. *) - end - - (** The comment for module type my_module_type. *) - module type my_module_type = - sig - (* Comment for value x. *) - val x : int - (* ... *) - end diff --git a/jscomp/syntax/tests/conversion/reason/docComments.mli b/jscomp/syntax/tests/conversion/reason/docComments.mli deleted file mode 100644 index bfde148836..0000000000 --- a/jscomp/syntax/tests/conversion/reason/docComments.mli +++ /dev/null @@ -1,70 +0,0 @@ -(** The first special comment of the file is the comment associated - with the whole module.*) - - - (** Special comments can be placed between elements and are kept - by the OCamldoc tool, but are not associated to any element. - @-tags in these comments are ignored.*) - - (*******************************************************************) - (** Comments like the one above, with more than two asterisks, - are ignored. *) - - (** The comment for function f. *) - val f : int -> int -> int - (** The continuation of the comment for function f. *) - - (** Comment for exception My_exception, even with a simple comment - between the special comment and the exception.*) - (* Hello, I'm a simple comment :-) *) - exception My_exception of (int -> int) * int - - (** Comment for type weather *) - type weather = - | Rain of int (** The comment for constructor Rain *) - | Sun (** The comment for constructor Sun *) - - (** Comment for type weather2 *) - type weather2 = - | Rain of int (** The comment for constructor Rain *) - | Sun (** The comment for constructor Sun *) - (** I can continue the comment for type weather2 here - because there is already a comment associated to the last constructor.*) - - (** The comment for type my_record *) - type my_record = { - foo : int ; (** Comment for field foo *) - bar : string ; (** Comment for field bar *) - } - (** Continuation of comment for type my_record *) - - (** Comment for foo *) - val foo : string - (** This comment is associated to foo and not to bar. *) - val bar : string - (** This comment is associated to bar. *) - - (** The comment for module Foo *) - module Foo : - sig - (** The comment for x *) - val x : int - - (** A special comment that is kept but not associated to any element *) - end - - (** The comment for module type my_module_type. *) - module type my_module_type = - sig - (** The comment for value x. *) - val x : int - - (** The comment for module M. *) - module M : - sig - (** The comment for value y. *) - val y : int - - (* ... *) - end - end diff --git a/jscomp/syntax/tests/conversion/reason/expected/destructiveSubstitutionSubModules.ml.txt b/jscomp/syntax/tests/conversion/reason/expected/destructiveSubstitutionSubModules.ml.txt deleted file mode 100644 index 81c1f50060..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/destructiveSubstitutionSubModules.ml.txt +++ /dev/null @@ -1,60 +0,0 @@ -module type Id = { - type t - let toString: t => string - let ofString: string => option -} -module type A = { - module Id: Id - type name = string - let name: name -} -module type B = { - module A: A - let fullName: A.Id.t => string -} -module MakeB = (A: A): (B with module A.Id := A.Id) => { - module A = A - let fullName = id => A.name ++ ("-" ++ A.Id.toString(id)) -} -module StringId: Id = { - type t = string - external toString: t => string = "%identity" - external ofString: string => t = "%identity" - let ofString = id => Some(id |> ofString) -} -module A = { - module Id = StringId - type name = string - let name = "A" -} -module B = MakeB(A) -let test = switch "someId" |> StringId.ofString { -| Some(id) => Some(id |> B.fullName) -| None as none => none -} - -module type Printable = { - type t - let print: (Format.formatter, t) => unit -} - -module type Comparable = { - type t - let compare: (t, t) => int -} - -module type PrintableComparable = { - include Printable - include Comparable with type t := t -} - -module type S = Comparable with type t := int - -module type S = { - type u - include Comparable with type t := u -} - -module type ComparableInt = Comparable with type t = int - -module type CompareInt = ComparableInt with type t := int diff --git a/jscomp/syntax/tests/conversion/reason/expected/docComments.ml.txt b/jscomp/syntax/tests/conversion/reason/expected/docComments.ml.txt deleted file mode 100644 index 7b31e47a32..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/docComments.ml.txt +++ /dev/null @@ -1,40 +0,0 @@ -@@ocaml.text(" The first special comment of the file is the comment associated - to the whole module. ") - -@ocaml.doc(" The comment for function f ") -let f = (x, y) => x + y - -@@ocaml.text(" This comment is not attached to any element since there is another - special comment just before the next element. ") - -/* A simple comment. */ -@ocaml.doc(" Comment for exception My_exception, even with a simple comment - between the special comment and the exception.") -exception My_exception(int => int, int) - -@ocaml.doc(" Comment for type weather ") -type weather = - | @ocaml.doc(" The comment for constructor Rain ") Rain(int) - | @ocaml.doc(" The comment for constructor Sun ") Sun - -@ocaml.doc(" The comment for type my_record ") -type my_record = { - @ocaml.doc(" Comment for field foo ") - foo: int, - @ocaml.doc(" Comment for field bar ") - bar: string, -} - -@ocaml.doc(" The comment for module Foo ") -module Foo = { - @ocaml.doc(" The comment for x ") - @ocaml.doc(" A special comment in the class, but not associated to any element. ") - let x = 0 -} - -@ocaml.doc(" The comment for module type my_module_type. ") -module type my_module_type = { - /* Comment for value x. */ - let x: int - /* ... */ -} diff --git a/jscomp/syntax/tests/conversion/reason/expected/docComments.mli.txt b/jscomp/syntax/tests/conversion/reason/expected/docComments.mli.txt deleted file mode 100644 index 1ca939e048..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/docComments.mli.txt +++ /dev/null @@ -1,69 +0,0 @@ -@@ocaml.text(" The first special comment of the file is the comment associated - with the whole module.") - -@@ocaml.text(" Special comments can be placed between elements and are kept - by the OCamldoc tool, but are not associated to any element. - @-tags in these comments are ignored.") - -@@ocaml.text(/* ***************************************************************** */ -" Comments like the one above, with more than two asterisks, - are ignored. ") - -@ocaml.doc(" The comment for function f. ") -@ocaml.doc(" The continuation of the comment for function f. ") -let f: (int, int) => int - -/* Hello, I'm a simple comment :-) */ -@ocaml.doc(" Comment for exception My_exception, even with a simple comment - between the special comment and the exception.") -exception My_exception(int => int, int) - -@ocaml.doc(" Comment for type weather ") -type weather = - | @ocaml.doc(" The comment for constructor Rain ") Rain(int) - | @ocaml.doc(" The comment for constructor Sun ") Sun - -@ocaml.doc(" Comment for type weather2 ") -@ocaml.doc(" I can continue the comment for type weather2 here - because there is already a comment associated to the last constructor.") -type weather2 = - | @ocaml.doc(" The comment for constructor Rain ") Rain(int) - | @ocaml.doc(" The comment for constructor Sun ") Sun - -@ocaml.doc(" The comment for type my_record ") -@ocaml.doc(" Continuation of comment for type my_record ") -type my_record = { - @ocaml.doc(" Comment for field foo ") - foo: int, - @ocaml.doc(" Comment for field bar ") - bar: string, -} - -@ocaml.doc(" Comment for foo ") @ocaml.doc(" This comment is associated to foo and not to bar. ") -let foo: string - -@ocaml.doc(" This comment is associated to foo and not to bar. ") -@ocaml.doc(" This comment is associated to bar. ") -let bar: string - -@ocaml.doc(" The comment for module Foo ") -module Foo: { - @ocaml.doc(" The comment for x ") - let x: int - - @@ocaml.text(" A special comment that is kept but not associated to any element ") -} - -@ocaml.doc(" The comment for module type my_module_type. ") -module type my_module_type = { - @ocaml.doc(" The comment for value x. ") - let x: int - - @ocaml.doc(" The comment for module M. ") - module M: { - @ocaml.doc(" The comment for value y. ") - let y: int - - /* ... */ - } -} diff --git a/jscomp/syntax/tests/conversion/reason/expected/object.ml.txt b/jscomp/syntax/tests/conversion/reason/expected/object.ml.txt deleted file mode 100644 index 3afee67da6..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/object.ml.txt +++ /dev/null @@ -1,4 +0,0 @@ -type hi = {"z": int} -type u<'a> = {.. ...hi, "x": int, "y": int} as 'a -type u1<'a> = {.. ...hi} as 'a -type u2<'a> = {.. ...hi, ...hi, "y": int, ...hi} as 'a diff --git a/jscomp/syntax/tests/conversion/reason/expected/recursiveType.ml.txt b/jscomp/syntax/tests/conversion/reason/expected/recursiveType.ml.txt deleted file mode 100644 index b77962fb8e..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/recursiveType.ml.txt +++ /dev/null @@ -1,3 +0,0 @@ -type rec tree = {"label": string, "left": option, "right": option} - -type t = t diff --git a/jscomp/syntax/tests/conversion/reason/expected/refSugar.ml.txt b/jscomp/syntax/tests/conversion/reason/expected/refSugar.ml.txt deleted file mode 100644 index 96255e4a4c..0000000000 --- a/jscomp/syntax/tests/conversion/reason/expected/refSugar.ml.txt +++ /dev/null @@ -1 +0,0 @@ -let x = foo.contents diff --git a/jscomp/syntax/tests/conversion/reason/object.ml b/jscomp/syntax/tests/conversion/reason/object.ml deleted file mode 100644 index 62099596f6..0000000000 --- a/jscomp/syntax/tests/conversion/reason/object.ml +++ /dev/null @@ -1,4 +0,0 @@ -type hi = < z : int > -type 'a u = < hi ; x : int ; y : int; .. > as 'a -type 'a u1 = < hi; .. > as 'a -type 'a u2 = < hi ; hi; y : int ; hi; .. > as 'a diff --git a/jscomp/syntax/tests/conversion/reason/recursiveType.ml b/jscomp/syntax/tests/conversion/reason/recursiveType.ml deleted file mode 100644 index 6a378eea08..0000000000 --- a/jscomp/syntax/tests/conversion/reason/recursiveType.ml +++ /dev/null @@ -1,4 +0,0 @@ -type tree = - < label: string ;left: tree option ;right: tree option > Js.t - -type nonrec t = t diff --git a/jscomp/syntax/tests/conversion/reason/refSugar.ml b/jscomp/syntax/tests/conversion/reason/refSugar.ml deleted file mode 100644 index 6aa9cea6bd..0000000000 --- a/jscomp/syntax/tests/conversion/reason/refSugar.ml +++ /dev/null @@ -1 +0,0 @@ -let x = !foo From 640467f38d20c81223dfce05eefcd770adda4a56 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 3 Jul 2024 11:41:14 +0200 Subject: [PATCH 2/5] Remove `.ml` conversion. --- jscomp/bsc/rescript_compiler_main.ml | 1 - jscomp/syntax/cli/res_cli.ml | 7 +- jscomp/syntax/src/res_ast_conversion.ml | 596 --------------------- jscomp/syntax/src/res_ast_conversion.mli | 18 - jscomp/syntax/src/res_driver_ml_parser.ml | 49 -- jscomp/syntax/src/res_driver_ml_parser.mli | 2 - jscomp/syntax/src/res_multi_printer.ml | 18 - jscomp/syntax/src/res_multi_printer.mli | 2 +- jscomp/syntax/testrunner/res_test.ml | 29 - 9 files changed, 5 insertions(+), 717 deletions(-) delete mode 100644 jscomp/syntax/src/res_ast_conversion.ml delete mode 100644 jscomp/syntax/src/res_ast_conversion.mli diff --git a/jscomp/bsc/rescript_compiler_main.ml b/jscomp/bsc/rescript_compiler_main.ml index 5914aec7a1..6ff19ca230 100644 --- a/jscomp/bsc/rescript_compiler_main.ml +++ b/jscomp/bsc/rescript_compiler_main.ml @@ -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 diff --git a/jscomp/syntax/cli/res_cli.ml b/jscomp/syntax/cli/res_cli.ml index a8bbb5616f..dfb3a3d80b 100644 --- a/jscomp/syntax/cli/res_cli.ml +++ b/jscomp/syntax/cli/res_cli.ml @@ -195,9 +195,10 @@ end = struct [ ("-recover", Arg.Unit (fun () -> recover := true), "Emit partial ast"); ( "-parse", - Arg.String (fun txt -> - let _ = assert (txt <> "ml") in - origin := txt), + Arg.String + (fun txt -> + let _ = assert (txt <> "ml") in + origin := txt), "Parse ml or res. Default: res" ); ( "-print", Arg.String (fun txt -> print := txt), diff --git a/jscomp/syntax/src/res_ast_conversion.ml b/jscomp/syntax/src/res_ast_conversion.ml deleted file mode 100644 index 910d7e731b..0000000000 --- a/jscomp/syntax/src/res_ast_conversion.ml +++ /dev/null @@ -1,596 +0,0 @@ -let concat_longidents l1 l2 = - let parts1 = Longident.flatten l1 in - let parts2 = Longident.flatten l2 in - match List.concat [parts1; parts2] |> Longident.unflatten with - | Some longident -> longident - | None -> l2 - -(* TODO: support nested open's ? *) -let rec rewrite_ppat_open longident_open pat = - match pat.Parsetree.ppat_desc with - | Ppat_array (first :: rest) -> - (* Color.[Red, Blue, Green] -> [Color.Red, Blue, Green] *) - { - pat with - ppat_desc = Ppat_array (rewrite_ppat_open longident_open first :: rest); - } - | Ppat_tuple (first :: rest) -> - (* Color.(Red, Blue, Green) -> (Color.Red, Blue, Green) *) - { - pat with - ppat_desc = Ppat_tuple (rewrite_ppat_open longident_open first :: rest); - } - | Ppat_construct - ( ({txt = Longident.Lident "::"} as list_constructor), - Some ({ppat_desc = Ppat_tuple (pat :: rest)} as element) ) -> - (* Color.(list[Red, Blue, Green]) -> list[Color.Red, Blue, Green] *) - { - pat with - ppat_desc = - Ppat_construct - ( list_constructor, - Some - { - element with - ppat_desc = - Ppat_tuple (rewrite_ppat_open longident_open pat :: rest); - } ); - } - | Ppat_construct (({txt = constructor} as longident_loc), opt_pattern) -> - (* Foo.(Bar(a)) -> Foo.Bar(a) *) - { - pat with - ppat_desc = - Ppat_construct - ( { - longident_loc with - txt = concat_longidents longident_open constructor; - }, - opt_pattern ); - } - | Ppat_record ((({txt = lbl} as longident_loc), first_pat) :: rest, flag) -> - (* Foo.{x} -> {Foo.x: x} *) - let first_row = - ( {longident_loc with txt = concat_longidents longident_open lbl}, - first_pat ) - in - {pat with ppat_desc = Ppat_record (first_row :: rest, flag)} - | Ppat_or (pat1, pat2) -> - { - pat with - ppat_desc = - Ppat_or - ( rewrite_ppat_open longident_open pat1, - rewrite_ppat_open longident_open pat2 ); - } - | Ppat_constraint (pattern, typ) -> - { - pat with - ppat_desc = Ppat_constraint (rewrite_ppat_open longident_open pattern, typ); - } - | Ppat_type ({txt = constructor} as longident_loc) -> - { - pat with - ppat_desc = - Ppat_type - { - longident_loc with - txt = concat_longidents longident_open constructor; - }; - } - | Ppat_lazy p -> - {pat with ppat_desc = Ppat_lazy (rewrite_ppat_open longident_open p)} - | Ppat_exception p -> - {pat with ppat_desc = Ppat_exception (rewrite_ppat_open longident_open p)} - | _ -> pat - -let escape_template_literal s = - let len = String.length s in - let b = Buffer.create len in - let i = ref 0 in - while !i < len do - let c = (String.get [@doesNotRaise]) s !i in - if c = '`' then ( - Buffer.add_char b '\\'; - Buffer.add_char b '`'; - incr i) - else if c = '$' then - if !i + 1 < len then ( - let c2 = (String.get [@doesNotRaise]) s (!i + 1) in - if c2 = '{' then ( - Buffer.add_char b '\\'; - Buffer.add_char b '$'; - Buffer.add_char b '{') - else ( - Buffer.add_char b c; - Buffer.add_char b c2); - i := !i + 2) - else ( - Buffer.add_char b c; - incr i) - else if c = '\\' then ( - Buffer.add_char b '\\'; - Buffer.add_char b '\\'; - incr i) - else ( - Buffer.add_char b c; - incr i) - done; - Buffer.contents b - -let escape_string_contents s = - let len = String.length s in - let b = Buffer.create len in - - let i = ref 0 in - - while !i < len do - let c = String.unsafe_get s !i in - if c = '\\' then ( - incr i; - Buffer.add_char b c; - let c = String.unsafe_get s !i in - if !i < len then - let () = Buffer.add_char b c in - incr i - else ()) - else if c = '"' then ( - Buffer.add_char b '\\'; - Buffer.add_char b c; - incr i) - else ( - Buffer.add_char b c; - incr i) - done; - Buffer.contents b - -let looks_like_recursive_type_declaration type_declaration = - let open Parsetree in - let name = type_declaration.ptype_name.txt in - let rec check_kind kind = - match kind with - | Ptype_abstract | Ptype_open -> false - | Ptype_variant constructor_declarations -> - List.exists check_constructor_declaration constructor_declarations - | Ptype_record label_declarations -> - List.exists check_label_declaration label_declarations - and check_constructor_declaration constr_decl = - check_constructor_arguments constr_decl.pcd_args - || - match constr_decl.pcd_res with - | Some typexpr -> check_typ_expr typexpr - | None -> false - and check_label_declaration label_declaration = - check_typ_expr label_declaration.pld_type - and check_constructor_arguments constr_arg = - match constr_arg with - | Pcstr_tuple types -> List.exists check_typ_expr types - | Pcstr_record label_declarations -> - List.exists check_label_declaration label_declarations - and check_typ_expr typ = - match typ.ptyp_desc with - | Ptyp_any -> false - | Ptyp_var _ -> false - | Ptyp_object (fields, _) -> List.exists check_object_field fields - | Ptyp_class _ -> false - | Ptyp_package _ -> false - | Ptyp_extension _ -> false - | Ptyp_arrow (_lbl, typ1, typ2) -> - check_typ_expr typ1 || check_typ_expr typ2 - | Ptyp_tuple types -> List.exists check_typ_expr types - | Ptyp_constr ({txt = longident}, types) -> - (match longident with - | Lident ident -> ident = name - | _ -> false) - || List.exists check_typ_expr types - | Ptyp_alias (typ, _) -> check_typ_expr typ - | Ptyp_variant (row_fields, _, _) -> List.exists check_row_fields row_fields - | Ptyp_poly (_, typ) -> check_typ_expr typ - and check_object_field field = - match field with - | Otag (_label, _attrs, typ) -> check_typ_expr typ - | Oinherit typ -> check_typ_expr typ - and check_row_fields row_field = - match row_field with - | Rtag (_, _, _, types) -> List.exists check_typ_expr types - | Rinherit typexpr -> check_typ_expr typexpr - and check_manifest manifest = - match manifest with - | Some typ -> check_typ_expr typ - | None -> false - in - check_kind type_declaration.ptype_kind - || check_manifest type_declaration.ptype_manifest - -let filter_reason_raw_literal attrs = - List.filter - (fun attr -> - match attr with - | {Location.txt = "reason.raw_literal"}, _ -> false - | _ -> true) - attrs - -let string_literal_mapper string_data = - let is_same_location l1 l2 = - let open Location in - l1.loc_start.pos_cnum == l2.loc_start.pos_cnum - in - let remaining_string_data = string_data in - let open Ast_mapper in - { - default_mapper with - expr = - (fun mapper expr -> - match expr.pexp_desc with - | Pexp_constant (Pconst_string (_txt, None)) -> ( - match - List.find_opt - (fun (_stringData, string_loc) -> - is_same_location string_loc expr.pexp_loc) - remaining_string_data - with - | Some (string_data, _) -> - let string_data = - let attr = - List.find_opt - (fun attr -> - match attr with - | {Location.txt = "reason.raw_literal"}, _ -> true - | _ -> false) - expr.pexp_attributes - in - match attr with - | Some - ( _, - PStr - [ - { - pstr_desc = - Pstr_eval - ( { - pexp_desc = - Pexp_constant (Pconst_string (raw, _)); - }, - _ ); - }; - ] ) -> - raw - | _ -> - (String.sub [@doesNotRaise]) string_data 1 - (String.length string_data - 2) - in - { - expr with - pexp_attributes = filter_reason_raw_literal expr.pexp_attributes; - pexp_desc = Pexp_constant (Pconst_string (string_data, None)); - } - | None -> default_mapper.expr mapper expr) - | _ -> default_mapper.expr mapper expr); - } - -let has_uncurried_attribute attrs = - List.exists - (fun attr -> - match attr with - | {Asttypes.txt = "bs"}, Parsetree.PStr [] -> true - | _ -> false) - attrs - -let template_literal_attr = (Location.mknoloc "res.template", Parsetree.PStr []) - -let normalize = - let open Ast_mapper in - { - default_mapper with - attributes = - (fun mapper attrs -> - attrs - |> List.filter (fun attr -> - match attr with - | ( { - Location.txt = - ( "reason.preserve_braces" | "explicit_arity" - | "implicity_arity" ); - }, - _ ) -> - false - | _ -> true) - |> default_mapper.attributes mapper); - pat = - (fun mapper p -> - match p.ppat_desc with - | Ppat_open ({txt = longident_open}, pattern) -> - let p = rewrite_ppat_open longident_open pattern in - default_mapper.pat mapper p - | Ppat_constant (Pconst_string (txt, tag)) -> - let new_tag = - match tag with - (* transform {|abc|} into {js|abc|js}, because `template string` is interpreted as {js||js} *) - | Some "" -> Some "js" - | tag -> tag - in - let s = - Parsetree.Pconst_string (escape_template_literal txt, new_tag) - in - { - p with - ppat_attributes = - template_literal_attr - :: mapper.attributes mapper p.ppat_attributes; - ppat_desc = Ppat_constant s; - } - | _ -> default_mapper.pat mapper p); - typ = - (fun mapper typ -> - match typ.ptyp_desc with - | Ptyp_constr - ({txt = Longident.Ldot (Longident.Lident "Js", "t")}, [arg]) -> - (* Js.t({"a": b}) -> {"a": b} - Since compiler >9.0.1 objects don't need Js.t wrapping anymore *) - mapper.typ mapper arg - | _ -> default_mapper.typ mapper typ); - expr = - (fun mapper expr -> - match expr.pexp_desc with - | Pexp_constant (Pconst_string (txt, None)) -> - let raw = escape_string_contents txt in - let s = Parsetree.Pconst_string (raw, None) in - {expr with pexp_desc = Pexp_constant s} - | Pexp_constant (Pconst_string (txt, tag)) -> - let new_tag = - match tag with - (* transform {|abc|} into {js|abc|js}, we want to preserve unicode by default *) - | Some "" -> Some "js" - | tag -> tag - in - let s = - Parsetree.Pconst_string (escape_template_literal txt, new_tag) - in - { - expr with - pexp_attributes = - template_literal_attr - :: mapper.attributes mapper expr.pexp_attributes; - pexp_desc = Pexp_constant s; - } - | Pexp_apply - ( call_expr, - [ - ( Nolabel, - ({ - pexp_desc = - Pexp_construct ({txt = Longident.Lident "()"}, None); - pexp_attributes = []; - } as unit_expr) ); - ] ) - when has_uncurried_attribute expr.pexp_attributes -> - { - expr with - pexp_attributes = mapper.attributes mapper expr.pexp_attributes; - pexp_desc = - Pexp_apply - ( call_expr, - [ - ( Nolabel, - { - unit_expr with - pexp_loc = {unit_expr.pexp_loc with loc_ghost = true}; - } ); - ] ); - } - | Pexp_function cases -> - let loc = - match (cases, List.rev cases) with - | first :: _, last :: _ -> - { - first.pc_lhs.ppat_loc with - loc_end = last.pc_rhs.pexp_loc.loc_end; - } - | _ -> Location.none - in - let var = - { - Parsetree.ppat_loc = Location.none; - ppat_attributes = []; - ppat_desc = Ppat_var (Location.mknoloc "x"); - } - in - { - pexp_loc = loc; - pexp_attributes = []; - pexp_desc = - Pexp_fun - ( Asttypes.Nolabel, - None, - var, - { - pexp_loc = loc; - pexp_attributes = []; - pexp_desc = - Pexp_match - ( { - pexp_loc = Location.none; - pexp_attributes = []; - pexp_desc = - Pexp_ident - (Location.mknoloc (Longident.Lident "x")); - }, - mapper.cases mapper cases ); - } ); - } - | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "!"}}, - [(Asttypes.Nolabel, operand)] ) -> - (* turn `!foo` into `foo.contents` *) - { - pexp_loc = expr.pexp_loc; - pexp_attributes = expr.pexp_attributes; - pexp_desc = - Pexp_field - ( mapper.expr mapper operand, - Location.mknoloc (Longident.Lident "contents") ); - } - | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "##"}}, - [ - (Asttypes.Nolabel, lhs); - ( Nolabel, - { - pexp_desc = - ( Pexp_constant (Pconst_string (txt, None)) - | Pexp_ident {txt = Longident.Lident txt} ); - pexp_loc = label_loc; - } ); - ] ) -> - let label = Location.mkloc txt label_loc in - { - pexp_loc = expr.pexp_loc; - pexp_attributes = expr.pexp_attributes; - pexp_desc = Pexp_send (mapper.expr mapper lhs, label); - } - | Pexp_match - ( condition, - [ - { - pc_lhs = - { - ppat_desc = - Ppat_construct ({txt = Longident.Lident "true"}, None); - }; - pc_rhs = then_expr; - }; - { - pc_lhs = - { - ppat_desc = - Ppat_construct ({txt = Longident.Lident "false"}, None); - }; - pc_rhs = else_expr; - }; - ] ) -> - let ternary_marker = - (Location.mknoloc "res.ternary", Parsetree.PStr []) - in - { - Parsetree.pexp_loc = expr.pexp_loc; - pexp_desc = - Pexp_ifthenelse - ( mapper.expr mapper condition, - mapper.expr mapper then_expr, - Some (mapper.expr mapper else_expr) ); - pexp_attributes = ternary_marker :: expr.pexp_attributes; - } - | _ -> default_mapper.expr mapper expr); - structure_item = - (fun mapper structure_item -> - match structure_item.pstr_desc with - (* heuristic: if we have multiple type declarations, mark them recursive *) - | Pstr_type ((Recursive as rec_flag), type_declarations) -> - let flag = - match type_declarations with - | [td] -> - if looks_like_recursive_type_declaration td then - Asttypes.Recursive - else Asttypes.Nonrecursive - | _ -> rec_flag - in - { - structure_item with - pstr_desc = - Pstr_type - ( flag, - List.map - (fun type_declaration -> - default_mapper.type_declaration mapper type_declaration) - type_declarations ); - } - | _ -> default_mapper.structure_item mapper structure_item); - signature_item = - (fun mapper signature_item -> - match signature_item.psig_desc with - (* heuristic: if we have multiple type declarations, mark them recursive *) - | Psig_type ((Recursive as rec_flag), type_declarations) -> - let flag = - match type_declarations with - | [td] -> - if looks_like_recursive_type_declaration td then - Asttypes.Recursive - else Asttypes.Nonrecursive - | _ -> rec_flag - in - { - signature_item with - psig_desc = - Psig_type - ( flag, - List.map - (fun type_declaration -> - default_mapper.type_declaration mapper type_declaration) - type_declarations ); - } - | _ -> default_mapper.signature_item mapper signature_item); - value_binding = - (fun mapper vb -> - match vb with - | { - pvb_pat = {ppat_desc = Ppat_var _} as pat; - pvb_expr = - {pexp_loc = expr_loc; pexp_desc = Pexp_constraint (expr, typ)}; - } - when expr_loc.loc_ghost -> - (* let t: t = (expr : t) -> let t: t = expr *) - let typ = default_mapper.typ mapper typ in - let pat = default_mapper.pat mapper pat in - let expr = mapper.expr mapper expr in - let new_pattern = - { - Parsetree.ppat_loc = - {pat.ppat_loc with loc_end = typ.ptyp_loc.loc_end}; - ppat_attributes = []; - ppat_desc = Ppat_constraint (pat, typ); - } - in - { - vb with - pvb_pat = new_pattern; - pvb_expr = expr; - pvb_attributes = default_mapper.attributes mapper vb.pvb_attributes; - } - | { - pvb_pat = - {ppat_desc = Ppat_constraint (pat, {ptyp_desc = Ptyp_poly ([], _)})}; - pvb_expr = - {pexp_loc = expr_loc; pexp_desc = Pexp_constraint (expr, typ)}; - } - when expr_loc.loc_ghost -> - (* let t: . t = (expr : t) -> let t: t = expr *) - let typ = default_mapper.typ mapper typ in - let pat = default_mapper.pat mapper pat in - let expr = mapper.expr mapper expr in - let new_pattern = - { - Parsetree.ppat_loc = - {pat.ppat_loc with loc_end = typ.ptyp_loc.loc_end}; - ppat_attributes = []; - ppat_desc = Ppat_constraint (pat, typ); - } - in - { - vb with - pvb_pat = new_pattern; - pvb_expr = expr; - pvb_attributes = default_mapper.attributes mapper vb.pvb_attributes; - } - | _ -> default_mapper.value_binding mapper vb); - } - -let structure s = normalize.Ast_mapper.structure normalize s -let signature s = normalize.Ast_mapper.signature normalize s - -let replace_string_literal_structure string_data structure = - let mapper = string_literal_mapper string_data in - mapper.Ast_mapper.structure mapper structure - -let replace_string_literal_signature string_data signature = - let mapper = string_literal_mapper string_data in - mapper.Ast_mapper.signature mapper signature diff --git a/jscomp/syntax/src/res_ast_conversion.mli b/jscomp/syntax/src/res_ast_conversion.mli deleted file mode 100644 index 745b7cc84a..0000000000 --- a/jscomp/syntax/src/res_ast_conversion.mli +++ /dev/null @@ -1,18 +0,0 @@ -(* The purpose of this module is to convert a parsetree coming from the reason - * or ocaml parser, into something consumable by the rescript printer. *) - -(* Ocaml/Reason parser interprets string literals: i.e. escape sequences and unicode. - * For printing purposes you want to preserve the original string. - * Example: "😎" is interpreted as "\240\159\152\142" - * The purpose of this routine is to place the original string back in - * the parsetree for printing purposes. Unicode and escape sequences - * shouldn't be mangled when *) -val replace_string_literal_structure : - (string * Location.t) list -> Parsetree.structure -> Parsetree.structure -val replace_string_literal_signature : - (string * Location.t) list -> Parsetree.signature -> Parsetree.signature - -(* transform parts of the parsetree into a suitable parsetree suitable - * for printing. Example: convert reason ternaries into rescript ternaries *) -val structure : Parsetree.structure -> Parsetree.structure -val signature : Parsetree.signature -> Parsetree.signature diff --git a/jscomp/syntax/src/res_driver_ml_parser.ml b/jscomp/syntax/src/res_driver_ml_parser.ml index b910d49fac..6eced790f4 100644 --- a/jscomp/syntax/src/res_driver_ml_parser.ml +++ b/jscomp/syntax/src/res_driver_ml_parser.ml @@ -1,12 +1,6 @@ module OcamlParser = Parser module IO = Res_io -let setup ~filename = - if String.length filename > 0 then ( - Location.input_name := filename; - IO.read_file ~filename |> Lexing.from_string) - else Lexing.from_channel stdin - let extract_ocaml_concrete_syntax filename = let lexbuf = if String.length filename > 0 then @@ -47,49 +41,6 @@ let extract_ocaml_concrete_syntax filename = next lexbuf.Lexing.lex_start_p (); (List.rev !string_locs, List.rev !comment_data) -let parsing_engine = - { - Res_driver.parse_implementation = - (fun ~for_printer:_ ~filename -> - let lexbuf = setup ~filename in - let string_data, comments = - extract_ocaml_concrete_syntax !Location.input_name - in - let structure = - Parse.implementation lexbuf - |> Res_ast_conversion.replace_string_literal_structure string_data - |> Res_ast_conversion.structure - in - { - filename = !Location.input_name; - source = Bytes.to_string lexbuf.lex_buffer; - parsetree = structure; - diagnostics = (); - invalid = false; - comments; - }); - parse_interface = - (fun ~for_printer:_ ~filename -> - let lexbuf = setup ~filename in - let string_data, comments = - extract_ocaml_concrete_syntax !Location.input_name - in - let signature = - Parse.interface lexbuf - |> Res_ast_conversion.replace_string_literal_signature string_data - |> Res_ast_conversion.signature - in - { - filename = !Location.input_name; - source = Bytes.to_string lexbuf.lex_buffer; - parsetree = signature; - diagnostics = (); - invalid = false; - comments; - }); - string_of_diagnostics = (fun ~source:_ ~filename:_ _diagnostics -> ()); - } - let print_engine = Res_driver. { diff --git a/jscomp/syntax/src/res_driver_ml_parser.mli b/jscomp/syntax/src/res_driver_ml_parser.mli index e104f6e637..53d298c99f 100644 --- a/jscomp/syntax/src/res_driver_ml_parser.mli +++ b/jscomp/syntax/src/res_driver_ml_parser.mli @@ -5,6 +5,4 @@ val extract_ocaml_concrete_syntax : string -> (string * Location.t) list * Res_comment.t list [@@live] -val parsing_engine : unit Res_driver.parsing_engine - val print_engine : Res_driver.print_engine diff --git a/jscomp/syntax/src/res_multi_printer.ml b/jscomp/syntax/src/res_multi_printer.ml index fd212eb453..5f04aa065c 100644 --- a/jscomp/syntax/src/res_multi_printer.ml +++ b/jscomp/syntax/src/res_multi_printer.ml @@ -87,23 +87,6 @@ let print_res ~ignore_parse_errors ~is_interface ~filename = ~comments:parse_result.comments parse_result.parsetree [@@raises exit] -(* print ocaml files to res syntax *) -let print_ml ~is_interface ~filename = - if is_interface then - let parse_result = - Res_driver_ml_parser.parsing_engine.parse_interface ~for_printer:true - ~filename - in - Res_printer.print_interface ~width:default_print_width - ~comments:parse_result.comments parse_result.parsetree - else - let parse_result = - Res_driver_ml_parser.parsing_engine.parse_implementation ~for_printer:true - ~filename - in - Res_printer.print_implementation ~width:default_print_width - ~comments:parse_result.comments parse_result.parsetree - (* print the given file named input to from "language" to res, general interface exposed by the compiler *) let print ?(ignore_parse_errors = false) language ~input = let is_interface = @@ -112,7 +95,6 @@ let print ?(ignore_parse_errors = false) language ~input = in match language with | `res -> print_res ~ignore_parse_errors ~is_interface ~filename:input - | `ml -> print_ml ~is_interface ~filename:input [@@raises exit] (* suppress unused optional arg *) diff --git a/jscomp/syntax/src/res_multi_printer.mli b/jscomp/syntax/src/res_multi_printer.mli index ff3da3b3aa..178e799d5b 100644 --- a/jscomp/syntax/src/res_multi_printer.mli +++ b/jscomp/syntax/src/res_multi_printer.mli @@ -1,3 +1,3 @@ (* Interface to print source code from different languages to res. * Takes a filename called "input" and returns the corresponding formatted res syntax *) -val print : ?ignore_parse_errors:bool -> [`ml | `res] -> input:string -> string +val print : ?ignore_parse_errors:bool -> [`res] -> input:string -> string diff --git a/jscomp/syntax/testrunner/res_test.ml b/jscomp/syntax/testrunner/res_test.ml index 8dd38b1fcc..e800b5666b 100644 --- a/jscomp/syntax/testrunner/res_test.ml +++ b/jscomp/syntax/testrunner/res_test.ml @@ -26,35 +26,6 @@ let () = let x: int |}) -(* test printing of ocaml .ml file *) -let () = - let filename = Filename.concat data_dir "api/mlSyntax.ml" in - let pretty_source = Res_multi_printer.print `ml ~input:filename in - assert ( - pretty_source - = {|/* test ml file */ - -let () = print_endline("hello world") - -let unicode = "πŸ™ˆ πŸ˜… πŸ™Œ" - -let d = `Sehr SchΓΆn` -|}) - -(* test printing of ocaml .mli file *) -let () = - let filename = Filename.concat data_dir "api/mliSyntax.mli" in - let pretty_source = Res_multi_printer.print `ml ~input:filename in - assert ( - pretty_source - = {|/* test mli file */ - -let x: int - -/* comment */ -let y: float -|}) - let () = print_endline "βœ… multi printer api tests" module OutcomePrinterTests = struct From 66d5bce880433fb7b18e01f4ddc8d5144a9b65d1 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 3 Jul 2024 19:39:40 +0200 Subject: [PATCH 3/5] cleanup --- cli/rescript_format.js | 4 ++-- jscomp/syntax/cli/res_cli.ml | 31 +++++-------------------------- scripts/test_syntax.sh | 12 +++++------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/cli/rescript_format.js b/cli/rescript_format.js index 550384e6dc..51037f2580 100644 --- a/cli/rescript_format.js +++ b/cli/rescript_format.js @@ -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`, ], [ @@ -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"]; /** diff --git a/jscomp/syntax/cli/res_cli.ml b/jscomp/syntax/cli/res_cli.ml index dfb3a3d80b..7f981f22f5 100644 --- a/jscomp/syntax/cli/res_cli.ml +++ b/jscomp/syntax/cli/res_cli.ml @@ -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 @@ -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" @@ -194,12 +192,6 @@ end = struct let spec = [ ("-recover", Arg.Unit (fun () -> recover := true), "Emit partial ast"); - ( "-parse", - Arg.String - (fun txt -> - let _ = assert (txt <> "ml") in - 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" ); @@ -232,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" -> assert false - | "res" -> Parser Res_driver.parsing_engine - | "" -> ( - match Filename.extension filename with - | ".ml" | ".mli" -> assert false - | _ -> 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 @@ -316,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] diff --git a/scripts/test_syntax.sh b/scripts/test_syntax.sh index 6502044417..1fd42ecfe9 100755 --- a/scripts/test_syntax.sh +++ b/scripts/test_syntax.sh @@ -72,7 +72,7 @@ if [[ $ROUNDTRIP_TEST = 1 ]]; then roundtripTestsResult="temp/result.txt" touch $roundtripTestsResult - find tests/{idempotency,printer} -name "*.res" -o -name "*.resi" -o -name "*.ml" -o -name "*.mli" >temp/files.txt + find tests/{idempotency,printer} -name "*.res" -o -name "*.resi" >temp/files.txt while read file; do { mkdir -p temp/$(dirname $file) sexpAst1=temp/$file.sexp @@ -81,14 +81,12 @@ if [[ $ROUNDTRIP_TEST = 1 ]]; then rescript2=temp/$file.2.res case $file in - *.ml ) class="ml" ; resIntf="" ;; - *.mli ) class="ml" ; resIntf=-interface ;; - *.res ) class="res"; resIntf="" ;; - *.resi ) class="res"; resIntf=-interface ;; + *.res ) resIntf="" ;; + *.resi ) resIntf=-interface ;; esac - $DUNE_BIN_DIR/res_parser $resIntf -parse $class -print sexp $file > $sexpAst1 - $DUNE_BIN_DIR/res_parser $resIntf -parse $class -print res $file > $rescript1 + $DUNE_BIN_DIR/res_parser $resIntf -print sexp $file > $sexpAst1 + $DUNE_BIN_DIR/res_parser $resIntf -print res $file > $rescript1 $DUNE_BIN_DIR/res_parser $resIntf -print sexp $rescript1 > $sexpAst2 $DUNE_BIN_DIR/res_parser $resIntf -print res $rescript1 > $rescript2 From 1167a040d6f95ee446d55893903b1257ee1daca8 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 3 Jul 2024 19:41:06 +0200 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21032f6d57..8887ed37f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 371d5a4998cb601b429c961c5f94c48117b1a282 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 3 Jul 2024 20:23:15 +0200 Subject: [PATCH 5/5] Update input.js --- jscomp/build_tests/cli_help/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jscomp/build_tests/cli_help/input.js b/jscomp/build_tests/cli_help/input.js index 4909e3e32f..8b2cbffcbf 100755 --- a/jscomp/build_tests/cli_help/input.js +++ b/jscomp/build_tests/cli_help/input.js @@ -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";