1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
11 (***********************************************************************)
20 let rec flat accu
= function
22 | Ldot
(lid
, s
) -> flat (s
:: accu
) lid
23 | Lapply
(l1
, l2
) -> Misc.fatal_error
"Longident.flat"
25 let flatten lid
= flat [] lid
27 let rec split_at_dots s pos
=
29 let dot = String.index_from s pos '
.'
in
30 String.sub s pos
(dot - pos
) :: split_at_dots s
(dot + 1)
32 [String.sub s pos
(String.length s
- pos
)]
35 match split_at_dots s
0 with
36 [] -> Lident
"" (* should not happen, but don't put assert false
37 so as not to crash the toplevel (see Genprintval) *)
38 | hd
:: tl
-> List.fold_left
(fun p s
-> Ldot
(p
, s
)) (Lident hd
) tl