ocaml/typing/path.ml

31 lines
1.1 KiB
OCaml
Raw Normal View History

(***********************************************************************)
(* *)
(* Caml Special Light *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1995 Institut National de Recherche en Informatique et *)
(* Automatique. Distributed only by permission. *)
(* *)
(***********************************************************************)
(* $Id$ *)
type t =
Pident of Ident.t
| Pdot of t * string * int
let nopos = -1
let rec same p1 p2 =
match (p1, p2) with
(Pident id1, Pident id2) -> Ident.same id1 id2
| (Pdot(p1, s1, pos1), Pdot(p2, s2, pos2)) -> s1 = s2 & same p1 p2
| (_, _) -> false
let rec root = function
Pident id -> id
| Pdot(p, s, pos) -> root p
let isfree id p = Ident.same id (root p)