Skip to content

Commit

Permalink
Add OCaml 5.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pitag-ha committed Jun 17, 2022
1 parent f3306f5 commit 8724242
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
--------------------------

- Add support for 5.0 (#122, @pitag-ha)

v2.3.0 2021-12-07 Valencia
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion ocaml-migrate-parsetree.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
14 changes: 14 additions & 0 deletions src/ast_500.ml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/cinaps_helpers/cinaps_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let supported_versions = [
("412", "4.12");
("413", "4.13");
("414", "4.14");
("500", "5.0" );
]

let foreach_version f =
Expand Down
1 change: 1 addition & 0 deletions src/config/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
40 changes: 40 additions & 0 deletions src/migrate_414_500.ml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions src/migrate_500_414.ml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions src/migrate_parsetree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down Expand Up @@ -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 *)
Expand Down

0 comments on commit 8724242

Please sign in to comment.