visit_t f r t
in
try visit_t (fun x -> x) () t; false with Exit -> true
+
+let xpointer_RE = Str.regexp "[^#]+#xpointer(\\(.*\\))"
+let slash_RE = Str.regexp "/"
+
+let term_of_uri s =
+ let uri = UriManager.uri_of_string s in
+ try
+ (if String.sub s (String.length s - 4) 4 = ".con" then
+ Cic.Const (uri, [])
+ else if String.sub s (String.length s - 4) 4 = ".var" then
+ Cic.Var (uri, [])
+ else if not (Str.string_match xpointer_RE s 0) then
+ raise (UriManager.IllFormedUri s)
+ else
+ (match Str.split slash_RE (Str.matched_group 1 s) with
+ | [_; tyno] -> Cic.MutInd (uri, int_of_string tyno - 1, [])
+ | [_; tyno; consno] ->
+ Cic.MutConstruct
+ (uri, int_of_string tyno - 1, int_of_string consno, [])
+ | _ -> raise Exit))
+ with
+ | Exit
+ | Failure _
+ | Not_found -> raise (UriManager.IllFormedUri s)
+