(* Copyright (C) 2000, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://cs.unibo.it/helm/. *) type spec = | Decl | Def | Fix of int * int (* fixno, recparamno *) | CoFix of int | Ind of int | IConstr of int * int (* indtyno, constrno *) type uri = Uri of int * string * spec let eq = (==);; let string_of_uri (Uri (_,s,_)) = s ;; module OrderedStrings = struct type t = string let compare (s1 : t) (s2 : t) = compare s1 s2 end ;; module MapStringsToUri = Map.Make(OrderedStrings);; let set_of_uri = ref MapStringsToUri.empty;; (* '.' not allowed in path and foo * * Decl cic:/path/foo.decl * Def cic:/path/foo.def * Fix of int * int cic:/path/foo.fix(i,j) * CoFix of int cic:/path/foo.cofix(i) * Ind of int cic:/path/foo.ind(i) * Constr of int * int cic:/path/foo.constr(i,j) *) let uri_of_string_aux = let counter = ref 0 in fun s -> incr counter; try let sharp = String.rindex s '#' in let pre = String.sub s 0 sharp in let ind = String.sub s (sharp+12) (String.length s - (sharp+13)) in try let slash = String.rindex ind '/' in let indno = String.sub ind 0 slash in let constr = String.sub ind (slash+1) (String.length ind - (slash+1)) in Uri(!counter,pre,Some(int_of_string indno-1,Some(int_of_string constr-1))) with Not_found -> Uri (!counter,pre,Some (int_of_string ind-1, None)) with Not_found -> Uri (!counter,s,None) ;; let uri_of_string s = try MapStringsToUri.find s !set_of_uri with Not_found -> let new_uri = uri_of_string_aux s in set_of_uri := MapStringsToUri.add s new_uri !set_of_uri; new_uri ;; let nuri_of_ouri u indinfo = uri_of_string (string_of_uri (Uri(0,UriManager.string_of_uri u,indinfo))) ;; let ouri_of_nuri u = UriManager.uri_of_string (string_of_uri u) ;;