1 (* Copyright (C) 2000-2002, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 exception IllFormedUri of string;;
28 let string_of_cic_textual_parser_uri uri =
30 let module CTP = CicTextualParser0 in
33 CTP.ConUri uri -> UriManager.string_of_uri uri
34 | CTP.VarUri uri -> UriManager.string_of_uri uri
35 | CTP.IndTyUri (uri,tyno) ->
36 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
37 | CTP.IndConUri (uri,tyno,consno) ->
38 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
41 (* 4 = String.length "cic:" *)
42 String.sub uri' 4 (String.length uri' - 4)
45 let cic_textual_parser_uri_of_string uri' =
46 prerr_endline ("cic_textual_parser_uri_of_string INPUT = " ^ uri');
49 if String.sub uri' (String.length uri' - 4) 4 = ".con" then
50 CicTextualParser0.ConUri (UriManager.uri_of_string uri')
52 if String.sub uri' (String.length uri' - 4) 4 = ".var" then
53 CicTextualParser0.VarUri (UriManager.uri_of_string uri')
57 let uri'',typeno = CicTextualLexer.indtyuri_of_uri uri' in
58 CicTextualParser0.IndTyUri (uri'',typeno)
60 UriManager.IllFormedUri _
61 | CicTextualParser0.LexerFailure _
62 | Invalid_argument _ ->
63 (* Constructor of an Inductive Type *)
64 let uri'',typeno,consno =
65 CicTextualLexer.indconuri_of_uri uri'
67 CicTextualParser0.IndConUri (uri'',typeno,consno)
70 UriManager.IllFormedUri _
71 | CicTextualParser0.LexerFailure _
72 | Invalid_argument _ ->
73 raise (IllFormedUri uri')
75 let cic_textual_parser_uri_of_string uri' =
76 let res = cic_textual_parser_uri_of_string uri' in
77 prerr_endline ("RESULT: " ^ (string_of_cic_textual_parser_uri res));
80 (* CSC: quick fix: a function from [uri#xpointer(path)] to [uri#path] *)
81 let wrong_xpointer_format_from_wrong_xpointer_format' uri =
83 let index_sharp = String.index uri '#' in
84 let index_rest = index_sharp + 10 in
85 let baseuri = String.sub uri 0 index_sharp in
87 String.sub uri index_rest (String.length uri - index_rest - 1)
93 let term_of_cic_textual_parser_uri uri =
95 let module CTP = CicTextualParser0 in
97 CTP.ConUri uri -> C.Const (uri,[])
98 | CTP.VarUri uri -> C.Var (uri,[])
99 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
100 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
103 (* time handling ***********************************************************)
105 type time = float * float
108 (Sys.time (), Unix.time ())
110 let stop_time (s0, u0) =
111 let s1 = Sys.time () in
112 let u1 = Unix.time () in
113 Printf.sprintf "%.2fs,%.2fs" (s1 -. s0) (u1 -. u0)