X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Furimanager%2FuriManager.ml;h=6dad8ddef6c4095e4764497f21150d53c4e649e2;hb=5325734bc2e4927ed7ec146e35a6f0f2b49f50c1;hp=0fa24cfcdc8504bffff1a0be2bb8099507403e8c;hpb=5a92117eeff70048d29e91ba24e113155d956e1b;p=helm.git diff --git a/helm/ocaml/urimanager/uriManager.ml b/helm/ocaml/urimanager/uriManager.ml index 0fa24cfcd..6dad8ddef 100644 --- a/helm/ocaml/urimanager/uriManager.ml +++ b/helm/ocaml/urimanager/uriManager.ml @@ -35,26 +35,6 @@ let name_of_uri uri = uri.(Array.length uri - 1);; let buri_of_uri uri = uri.(Array.length uri - 3);; let depth_of_uri uri = Array.length uri - 2;; -(*CSC: ora e' diventato poco efficiente, migliorare *) -let relative_depth curi uri cookingsno = - let rec length_of_current_prefix l1 l2 = - match (l1, l2) with - (he1::tl1, he2::tl2) when he1 == he2 -> - 1 + length_of_current_prefix tl1 tl2 - | (_,_) -> 0 - in - depth_of_uri uri - - length_of_current_prefix - (Array.to_list (Array.sub curi 0 (Array.length curi - (2 + cookingsno)))) - (Array.to_list (Array.sub uri 0 (Array.length uri - 2))) - (*CSC: vecchio codice da eliminare - if eq curi uri then 0 - else - depth_of_uri uri - - length_of_current_prefix (Array.to_list curi) (Array.to_list uri) - *) -;; - module OrderedStrings = struct type t = string @@ -96,7 +76,11 @@ let mk_prefixes str = in let tokens = (Str.split (Str.regexp "/") str) in (* ty = "cic:" *) - let (ty, sp) = (List.hd tokens, List.tl tokens) in + let (ty, sp) = + (try (List.hd tokens, List.tl tokens) + with Failure "hd" | Failure "tl" -> + raise (IllFormedUri str)) + in aux ty sp ;; @@ -137,3 +121,20 @@ let annuri_of_uri uri = let uri_is_annuri uri = Str.string_match (Str.regexp ".*\.ann$") (string_of_uri uri) 0 ;; + +let bodyuri_of_uri uri = + let struri = string_of_uri uri in + if Str.string_match (Str.regexp ".*\.con$") (string_of_uri uri) 0 then + let newuri = Array.copy uri in + newuri.(Array.length uri - 2) <- struri ^ ".body" ; + Some newuri + else + None +;; + +let innertypesuri_of_uri uri = + let cicuri = cicuri_of_uri uri in + let newuri = Array.copy cicuri in + newuri.(Array.length cicuri - 2) <- (string_of_uri cicuri) ^ ".types" ; + newuri +;;