File tree Expand file tree Collapse file tree 6 files changed +44
-1
lines changed
Expand file tree Collapse file tree 6 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ unreleased
77
88### Other Changes
99
10+ - Add ` Longident.to/of_compiler ` to astlib to simplify maintenance
11+ of ppx-es that interacts with other parts of the compiler-libs such
12+ as the type checker. (#603 , @NathanReb )
13+
1014- Fix a bug where some infix operators such as ` mod ` would be printed as
1115 raw identifiers by our ` Pprintast ` . (#601 , @NathanReb )
1216
Original file line number Diff line number Diff line change 11module Longident = struct
2- type t (*IF_CURRENT = Ocaml_common.Longident .t * ) =
2+ type t = Longident_504 .t =
33 | Lident of string
44 | Ldot of t Location .loc * string Location .loc
55 | Lapply of t Location .loc * t Location .loc
Original file line number Diff line number Diff line change @@ -29,3 +29,28 @@ let parse s =
2929 (* should not happen, but don't put assert false
3030 so as not to crash the toplevel (see Genprintval) *)
3131 | Some v -> v
32+
33+ let rec to_504_plus lid =
34+ let loc = Location. none in
35+ match lid with
36+ | Lident s -> Longident_504. Lident s
37+ | Ldot (lid , s ) ->
38+ Longident_504. Ldot ({txt = to_504_plus lid; loc}, { txt = s; loc})
39+ | Lapply (lid , lid2 ) ->
40+ Longident_504. Lapply
41+ ({txt = to_504_plus lid; loc}, {txt= to_504_plus lid2; loc})
42+
43+ let rec from_504_plus lid =
44+ match lid with
45+ | Longident_504. Lident s -> Lident s
46+ | Longident_504. Ldot (lid , s ) -> Ldot (from_504_plus lid.txt, s.txt)
47+ | Longident_504. Lapply (lid , lid2 ) ->
48+ Lapply (from_504_plus lid.txt, from_504_plus lid2.txt)
49+
50+ let to_compiler lid =
51+ (* IF_NOT_AT_LEAST 504 lid *)
52+ (* IF_AT_LEAST 504 to_504_plus lid *)
53+
54+ let from_compiler lid =
55+ (* IF_NOT_AT_LEAST 504 lid *)
56+ (* IF_AT_LEAST 504 from_504_plus lid *)
Original file line number Diff line number Diff line change @@ -13,3 +13,7 @@ val flatten : t -> string list
1313
1414val parse : string -> t
1515(* * Parse a string into a long identifier built upon [Lident] and [Ldot]. *)
16+
17+ val to_compiler : t -> Ocaml_common.Longident .t
18+
19+ val from_compiler : Ocaml_common.Longident .t -> t
Original file line number Diff line number Diff line change 1+ type t =
2+ (* IF_AT_LEAST 504 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
Original file line number Diff line number Diff line change 1+ type t =
2+ (* IF_AT_LEAST 504 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
You can’t perform that action at this time.
0 commit comments