From 87242426f18c0c5622f58b07e44e46f3ff0b035d Mon Sep 17 00:00:00 2001 From: Sonja Heinze Date: Fri, 17 Jun 2022 12:35:01 +0200 Subject: [PATCH] Add OCaml 5.0 support --- CHANGES.md | 5 ++++ ocaml-migrate-parsetree.opam | 2 +- src/ast_500.ml | 14 ++++++++++ src/cinaps_helpers/cinaps_helpers.ml | 1 + src/config/gen.ml | 1 + src/migrate_414_500.ml | 40 ++++++++++++++++++++++++++++ src/migrate_500_414.ml | 40 ++++++++++++++++++++++++++++ src/migrate_parsetree.ml | 3 +++ 8 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/ast_500.ml create mode 100644 src/migrate_414_500.ml create mode 100644 src/migrate_500_414.ml diff --git a/CHANGES.md b/CHANGES.md index 2650a736..7d38cd09 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +unreleased +-------------------------- + +- Add support for 5.0 (#122, @pitag-ha) + v2.3.0 2021-12-07 Valencia -------------------------- diff --git a/ocaml-migrate-parsetree.opam b/ocaml-migrate-parsetree.opam index 278f3350..0de0e756 100644 --- a/ocaml-migrate-parsetree.opam +++ b/ocaml-migrate-parsetree.opam @@ -14,7 +14,7 @@ build: ["dune" "build" "-p" name "-j" jobs] run-test: ["dune" "runtest" "-p" name "-j" jobs] depends: [ "dune" {>= "2.3"} - "ocaml" {>= "4.02.3" & < "4.15"} + "ocaml" {>= "4.02.3" & < "5.2"} "cinaps" {with-test & >= "v0.13.0"} ] conflicts: [ diff --git a/src/ast_500.ml b/src/ast_500.ml new file mode 100644 index 00000000..36e769e4 --- /dev/null +++ b/src/ast_500.ml @@ -0,0 +1,14 @@ +(* The only difference between 4.14 and 5.0 from a Parsetree point of view are the magic numbers *) + +module Asttypes = struct + include Ast_414.Asttypes +end + +module Parsetree = struct + include Ast_414.Parsetree +end + +module Config = struct + let ast_impl_magic_number = "Caml1999M032" + let ast_intf_magic_number = "Caml1999N032" +end diff --git a/src/cinaps_helpers/cinaps_helpers.ml b/src/cinaps_helpers/cinaps_helpers.ml index 241e6146..e6559d23 100644 --- a/src/cinaps_helpers/cinaps_helpers.ml +++ b/src/cinaps_helpers/cinaps_helpers.ml @@ -19,6 +19,7 @@ let supported_versions = [ ("412", "4.12"); ("413", "4.13"); ("414", "4.14"); + ("500", "5.0" ); ] let foreach_version f = diff --git a/src/config/gen.ml b/src/config/gen.ml index 1764a418..22e652e4 100644 --- a/src/config/gen.ml +++ b/src/config/gen.ml @@ -23,6 +23,7 @@ let () = | (4, 12) -> "412" | (4, 13) -> "413" | (4, 14) -> "414" + | (5, 0) -> "500" | _ -> Printf.eprintf "Unknown OCaml version %s\n" ocaml_version_str; exit 1) diff --git a/src/migrate_414_500.ml b/src/migrate_414_500.ml new file mode 100644 index 00000000..6a81b073 --- /dev/null +++ b/src/migrate_414_500.ml @@ -0,0 +1,40 @@ +module From = Ast_414 +module To = Ast_500 + +let copy_structure : Ast_414.Parsetree.structure -> Ast_500.Parsetree.structure + = + fun x -> x + +let copy_signature : Ast_414.Parsetree.signature -> Ast_500.Parsetree.signature + = + fun x -> x + +let copy_toplevel_phrase : + Ast_414.Parsetree.toplevel_phrase -> Ast_500.Parsetree.toplevel_phrase = + fun x -> x + +let copy_core_type : Ast_414.Parsetree.core_type -> Ast_500.Parsetree.core_type + = + fun x -> x + +let copy_expression : + Ast_414.Parsetree.expression -> Ast_500.Parsetree.expression = + fun x -> x + +let copy_pattern : Ast_414.Parsetree.pattern -> Ast_500.Parsetree.pattern = + fun x -> x + +let copy_case : Ast_414.Parsetree.case -> Ast_500.Parsetree.case = fun x -> x + +let copy_type_declaration : + Ast_414.Parsetree.type_declaration -> Ast_500.Parsetree.type_declaration = + fun x -> x + +let copy_type_extension : + Ast_414.Parsetree.type_extension -> Ast_500.Parsetree.type_extension = + fun x -> x + +let copy_extension_constructor : + Ast_414.Parsetree.extension_constructor -> + Ast_500.Parsetree.extension_constructor = + fun x -> x diff --git a/src/migrate_500_414.ml b/src/migrate_500_414.ml new file mode 100644 index 00000000..ac0f27bd --- /dev/null +++ b/src/migrate_500_414.ml @@ -0,0 +1,40 @@ +module From = Ast_500 +module To = Ast_414 + +let copy_structure : Ast_500.Parsetree.structure -> Ast_414.Parsetree.structure + = + fun x -> x + +let copy_signature : Ast_500.Parsetree.signature -> Ast_414.Parsetree.signature + = + fun x -> x + +let copy_toplevel_phrase : + Ast_500.Parsetree.toplevel_phrase -> Ast_414.Parsetree.toplevel_phrase = + fun x -> x + +let copy_core_type : Ast_500.Parsetree.core_type -> Ast_414.Parsetree.core_type + = + fun x -> x + +let copy_expression : + Ast_500.Parsetree.expression -> Ast_414.Parsetree.expression = + fun x -> x + +let copy_pattern : Ast_500.Parsetree.pattern -> Ast_414.Parsetree.pattern = + fun x -> x + +let copy_case : Ast_500.Parsetree.case -> Ast_414.Parsetree.case = fun x -> x + +let copy_type_declaration : + Ast_500.Parsetree.type_declaration -> Ast_414.Parsetree.type_declaration = + fun x -> x + +let copy_type_extension : + Ast_500.Parsetree.type_extension -> Ast_414.Parsetree.type_extension = + fun x -> x + +let copy_extension_constructor : + Ast_500.Parsetree.extension_constructor -> + Ast_414.Parsetree.extension_constructor = + fun x -> x diff --git a/src/migrate_parsetree.ml b/src/migrate_parsetree.ml index 2a4712be..a73e0dde 100644 --- a/src/migrate_parsetree.ml +++ b/src/migrate_parsetree.ml @@ -39,6 +39,7 @@ module Ast_411 = Ast_411 module Ast_412 = Ast_412 module Ast_413 = Ast_413 module Ast_414 = Ast_414 +module Ast_500 = Ast_500 (*$*) (* Manual migration between versions *) @@ -70,6 +71,8 @@ module Migrate_412_413 = Migrate_412_413 module Migrate_413_412 = Migrate_413_412 module Migrate_413_414 = Migrate_413_414 module Migrate_414_413 = Migrate_414_413 +module Migrate_414_500 = Migrate_414_500 +module Migrate_500_414 = Migrate_500_414 (*$*) (* Aliases for compiler-libs modules that might be shadowed *)