Skip to content

Commit 028e123

Browse files
committed
Simplify Longident versioning for 5.4.0 support
Signed-off-by: Patrick Ferris <[email protected]>
1 parent dbb5f50 commit 028e123

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+68
-187
lines changed

ast/ast.ml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -663,25 +663,30 @@ and type_exception = Parsetree.type_exception = {
663663

664664
and extension_constructor_kind = Parsetree.extension_constructor_kind =
665665
| Pext_decl of string loc list * constructor_arguments * core_type option
666-
(** [Pext_decl(existentials, c_args, t_opt)]
667-
describes a new extension constructor. It can be:
668-
- [C of T1 * ... * Tn] when:
669-
{ul {- [existentials] is [[]],}
670-
{- [c_args] is [[T1; ...; Tn]],}
671-
{- [t_opt] is [None]}.}
672-
- [C: T0] when
673-
{ul {- [existentials] is [[]],}
674-
{- [c_args] is [[]],}
675-
{- [t_opt] is [Some T0].}}
676-
- [C: T1 * ... * Tn -> T0] when
677-
{ul {- [existentials] is [[]],}
678-
{- [c_args] is [[T1; ...; Tn]],}
679-
{- [t_opt] is [Some T0].}}
680-
- [C: 'a... . T1 * ... * Tn -> T0] when
681-
{ul {- [existentials] is [['a;...]],}
682-
{- [c_args] is [[T1; ... ; Tn]],}
683-
{- [t_opt] is [Some T0].}}
684-
*)
666+
(** [Pext_decl(existentials, c_args, t_opt)] describes a new extension
667+
constructor. It can be:
668+
{ul
669+
{- [C of T1 * ... * Tn] when:
670+
- [existentials] is [[]],
671+
- [c_args] is [[T1; ...; Tn]],
672+
- [t_opt] is [None]
673+
}
674+
{- [C: T0] when
675+
- [existentials] is [[]],
676+
- [c_args] is [[]],
677+
- [t_opt] is [Some T0].
678+
}
679+
{- [C: T1 * ... * Tn -> T0] when
680+
- [existentials] is [[]],
681+
- [c_args] is [[T1; ...; Tn]],
682+
- [t_opt] is [Some T0].
683+
}
684+
{- [C: 'a... . T1 * ... * Tn -> T0] when
685+
- [existentials] is [['a;...]],
686+
- [c_args] is [[T1; ... ; Tn]],
687+
- [t_opt] is [Some T0].
688+
}
689+
} *)
685690
| Pext_rebind of longident_loc
686691
(** [Pext_rebind(D)] re-export the constructor [D] with the new name [C]
687692
*)

ast/ast_helper_lite.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(* TODO: remove this open *)
1717
open Stdlib0
1818
module Location = Astlib.Location
19-
module Longident = Astlib.Legacy_longident
19+
module Longident = Astlib.Longident
2020
open Astlib.Ast_503
2121

2222
[@@@warning "-9"]

ast/ast_helper_lite.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open Parsetree
2121

2222
type 'a with_loc = 'a Astlib.Location.loc
2323
type loc = Astlib.Location.t
24-
type lid = Astlib.Legacy_longident.t with_loc
24+
type lid = Astlib.Longident.t with_loc
2525
type str = string with_loc
2626
type str_opt = string option with_loc
2727
type attrs = attribute list

ast/import.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ module Asttypes = Selected_ast.Ast.Asttypes
193193

194194
(* Other Astlib modules *)
195195
module Location = Astlib.Location
196-
module Longident = Astlib.Legacy_longident
196+
module Longident = Astlib.Longident
197197

198198
module Parse = struct
199199
include Astlib.Parse

astlib/ast_407.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
2626
change VERSION for 4.07.0+beta2
2727
*)
28-
module Longident = Legacy_longident
29-
3028
module Asttypes = struct
3129
(** Auxiliary AST types used by parsetree and typedtree. *)
3230

astlib/ast_408.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
2828
Actually run all lib-unix tests [4.08]
2929
*)
30-
module Longident = Legacy_longident
31-
3230
module Asttypes = struct
3331

3432
type constant (*IF_CURRENT = Asttypes.constant *) =

astlib/ast_409.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220

2321
type constant (*IF_CURRENT = Asttypes.constant *) =

astlib/ast_410.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220
type constant (*IF_CURRENT = Asttypes.constant *) =
2321
Const_int of int

astlib/ast_411.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220
type constant (*IF_CURRENT = Asttypes.constant *) =
2321
Const_int of int

astlib/ast_412.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220
type constant (*IF_CURRENT = Asttypes.constant *) =
2321
Const_int of int

astlib/ast_413.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220
type constant (*IF_CURRENT = Asttypes.constant *) =
2321
Const_int of int

astlib/ast_414.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
(* special exception on linking described in the file LICENSE. *)
1717
(* *)
1818
(**************************************************************************)
19-
module Longident = Legacy_longident
20-
2119
module Asttypes = struct
2220
type constant (*IF_CURRENT = Asttypes.constant *) =
2321
Const_int of int

astlib/ast_501.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module Longident = Legacy_longident
2-
31
module Asttypes = struct
42
type constant (*IF_CURRENT = Asttypes.constant *) =
53
Const_int of int

astlib/ast_502.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
module Longident = Legacy_longident
21
module Asttypes = struct
32
type constant (*IF_CURRENT = Asttypes.constant *) =
43
Const_int of int

astlib/ast_503.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
module Longident = Legacy_longident
21
module Asttypes = struct
32
type constant (*IF_CURRENT = Asttypes.constant *) =
43
Const_int of int

astlib/ast_504.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module Longident = struct
2+
type t (*IF_CURRENT = Ocaml_common.Longident.t *) =
3+
| Lident of string
4+
| Ldot of t Location.loc * string Location.loc
5+
| Lapply of t Location.loc * t Location.loc
6+
end
7+
18
module Asttypes = struct
29
type constant (*IF_CURRENT = Asttypes.constant *) =
310
Const_int of int

astlib/astlib.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ module Ast_metadata = Ast_metadata
7171
module Config = Config
7272
module Keyword = Keyword
7373
module Location = Location
74-
module Legacy_longident = Legacy_longident
7574
module Longident = Longident
7675
module Parse = Parse
7776
module Pprintast = Pprintast

astlib/legacy_longident.ml

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

astlib/legacy_longident.mli

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

astlib/longident.ml

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,31 @@
1-
(**************************************************************************)
2-
(* *)
3-
(* OCaml *)
4-
(* *)
5-
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6-
(* *)
7-
(* Copyright 1996 Institut National de Recherche en Informatique et *)
8-
(* en Automatique. *)
9-
(* *)
10-
(* All rights reserved. This file is distributed under the terms of *)
11-
(* the GNU Lesser General Public License version 2.1, with the *)
12-
(* special exception on linking described in the file LICENSE. *)
13-
(* *)
14-
(**************************************************************************)
15-
open Location
16-
17-
type t = (*IF_AT_LEAST 504 Ocaml_common.Longident.t = *)
18-
Lident of string
19-
| Ldot of t loc * string loc
20-
| Lapply of t loc * t loc
21-
22-
23-
let rec same t t' =
24-
t == t'
25-
|| match t, t' with
26-
| Lident s, Lident s' ->
27-
String.equal s s'
28-
| Ldot ({ txt = t; _ }, { txt = s; _ }),
29-
Ldot ({ txt = t'; _ }, { txt = s'; _ }) ->
30-
if String.equal s s' then
31-
same t t'
32-
else
33-
false
34-
| Lapply ({ txt = tl; _ }, { txt = tr; _ }),
35-
Lapply ({ txt = tl'; _ }, { txt = tr'; _ }) ->
36-
same tl tl' && same tr tr'
37-
| _, _ -> false
38-
1+
type t =
2+
(*IF_NOT_AT_LEAST 504 Ocaml_common.Longident.t = *)
3+
| Lident of string
4+
| Ldot of t * string
5+
| Lapply of t * t
396

407
let rec flat accu = function
41-
Lident s -> s :: accu
42-
| Ldot({ txt = lid; _ }, { txt = s; _ }) -> flat (s :: accu) lid
43-
| Lapply(_, _) -> Misc.fatal_error "Longident.flat"
8+
| Lident s -> s :: accu
9+
| Ldot (lid, s) -> flat (s :: accu) lid
10+
| Lapply (_, _) -> Misc.fatal_error "Longident.flat"
4411

4512
let flatten lid = flat [] lid
4613

47-
let last = function
48-
Lident s -> s
49-
| Ldot(_, s) -> s.txt
50-
| Lapply(_, _) -> Misc.fatal_error "Longident.last"
51-
52-
5314
let rec split_at_dots s pos =
5415
try
5516
let dot = String.index_from s pos '.' in
5617
String.sub s pos (dot - pos) :: split_at_dots s (dot + 1)
57-
with Not_found ->
58-
[String.sub s pos (String.length s - pos)]
59-
60-
let mknoloc txt = { txt; loc = Location.none }
18+
with Not_found -> [ String.sub s pos (String.length s - pos) ]
6119

6220
let unflatten l =
6321
match l with
6422
| [] -> None
65-
| hd :: tl ->
66-
Some (List.fold_left (fun p s -> Ldot(mknoloc p, mknoloc s))
67-
(Lident hd) tl)
23+
| hd :: tl -> Some (List.fold_left (fun p s -> Ldot (p, s)) (Lident hd) tl)
6824

6925
let parse s =
7026
match unflatten (split_at_dots s 0) with
71-
| None -> Lident "" (* should not happen, but don't put assert false
27+
| None ->
28+
Lident ""
29+
(* should not happen, but don't put assert false
7230
so as not to crash the toplevel (see Genprintval) *)
7331
| Some v -> v

astlib/longident.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(** Long identifiers, used in parsetrees. *)
2-
open Location
32

43
(** The long identifier type *)
5-
type t = (*IF_AT_LEAST 504 Ocaml_common.Longident.t = *)
4+
type t =
5+
(*IF_NOT_AT_LEAST 504 Ocaml_common.Longident.t = *)
66
| Lident of string
7-
| Ldot of t loc * string loc
8-
| Lapply of t loc * t loc
7+
| Ldot of t * string
8+
| Lapply of t * t
99

1010
val flatten : t -> string list
1111
(** Flatten a long identifier built upon [Lident] and [Ldot]. Raise when hitting

astlib/migrate_408_409.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_408
43
module To = Ast_409
54

astlib/migrate_409_408.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_409
43
module To = Ast_408
54

astlib/migrate_409_410.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
module Longident = Legacy_longident
21
module From = Ast_409
32
module To = Ast_410
43

astlib/migrate_410_409.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
module Longident = Legacy_longident
21
module From = Ast_410
32
module To = Ast_409
43

astlib/migrate_410_411.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_410
43
module To = Ast_411
54

astlib/migrate_411_410.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_411
43
module To = Ast_410
54

astlib/migrate_411_412.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_411
43
module To = Ast_412
54

astlib/migrate_412_411.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_412
43
module To = Ast_411
54

astlib/migrate_412_413.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_412
43
module To = Ast_413
54

astlib/migrate_413_412.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_413
43
module To = Ast_412
54

astlib/migrate_413_414.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
open Stdlib0
2-
module Longident = Legacy_longident
32
module From = Ast_413
43
module To = Ast_414
54

0 commit comments

Comments
 (0)