1 (* Copyright (C) 2000, 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 (*CSC codice cut & paste da cicPp e xmlcommand *)
28 exception ImpossiblePossible;;
29 exception NotImplemented;;
30 exception BinderNotSpecified;;
32 let dtdname = "http://localhost:8081/getdtd?url=annotations.dtd";;
34 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
39 let module U = UriManager in
41 C.ARel (id,ann,_,_) ->
44 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
46 | C.AVar (id,ann,_) ->
49 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
51 | C.AMeta (id,ann,_) ->
54 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
56 | C.ASort (id,ann,_) ->
59 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
61 | C.AImplicit _ -> raise NotImplemented
62 | C.AProd (id,ann,_,s,t) ->
66 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
71 | C.ACast (id,ann,v,t) ->
75 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
80 | C.ALambda (id,ann,_,s,t) ->
84 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
89 | C.ALetIn (id,ann,_,s,t) ->
93 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
98 | C.AAppl (id,ann,li) ->
102 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
104 List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>]
106 | C.AConst (id,ann,_,_) ->
109 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
111 | C.AAbst (id,ann,_) -> raise NotImplemented
112 | C.AMutInd (id,ann,_,_,_) ->
115 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
117 | C.AMutConstruct (id,ann,_,_,_,_) ->
120 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
122 | C.AMutCase (id,ann,_,_,_,ty,te,patterns) ->
126 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
131 (fun x i -> [< aux x ; i>])
134 | C.AFix (id, ann, _, funs) ->
138 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
141 (fun (_,_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
143 | C.ACoFix (id, ann,no,funs) ->
147 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
150 (fun (_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
156 let print_mutual_inductive_type (_,_,arity,constructors) =
157 [< print_term arity ;
159 (fun (name,ty,_) i -> [< print_term ty ; i >]) constructors [<>]
163 let target_uri_of_annotation_uri uri =
164 Str.replace_first (Str.regexp "\.ann$") "" (UriManager.string_of_uri uri)
167 let pp_annotation obj curi =
168 let module C = Cic in
169 let module X = Xml in
170 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
171 X.xml_cdata ("<!DOCTYPE Annotations SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
172 X.xml_nempty "Annotations" ["of", target_uri_of_annotation_uri curi]
175 C.ADefinition (xid, ann, _, te, ty, _) ->
179 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
184 | C.AAxiom (xid, ann, _, ty, _) ->
188 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
192 | C.AVariable (xid, ann, _, bo, ty) ->
196 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
200 | Some bo -> print_term bo
204 | C.ACurrentProof (xid, ann, _, conjs, bo, ty) ->
208 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
211 (fun (_,t) i -> [< print_term t ; i >])
216 | C.AInductiveDefinition (xid, ann, tys, params, paramsno) ->
220 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
223 (fun x i -> [< print_mutual_inductive_type x ; i >])