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 NotImplemented;;
30 let dtdname = "http://www.cs.unibo.it/helm/dtd/annotations.dtd";;
32 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
37 let module U = UriManager in
39 C.ARel (id,ann,_,_) ->
42 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
44 | C.AVar (id,ann,_) ->
47 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
49 | C.AMeta (id,ann,_) ->
52 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
54 | C.ASort (id,ann,_) ->
57 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
59 | C.AImplicit _ -> raise NotImplemented
60 | C.AProd (id,ann,_,s,t) ->
64 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
69 | C.ACast (id,ann,v,t) ->
73 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
78 | C.ALambda (id,ann,_,s,t) ->
82 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
87 | C.ALetIn (id,ann,_,s,t) ->
91 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
96 | C.AAppl (id,ann,li) ->
100 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
102 List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>]
104 | C.AConst (id,ann,_,_) ->
107 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
109 | C.AAbst (id,ann,_) -> raise NotImplemented
110 | C.AMutInd (id,ann,_,_,_) ->
113 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
115 | C.AMutConstruct (id,ann,_,_,_,_) ->
118 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
120 | C.AMutCase (id,ann,_,_,_,ty,te,patterns) ->
124 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
129 (fun x i -> [< aux x ; i>])
132 | C.AFix (id, ann, _, funs) ->
136 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
139 (fun (_,_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
141 | C.ACoFix (id, ann,no,funs) ->
145 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
148 (fun (_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
154 let print_mutual_inductive_type (_,_,arity,constructors) =
155 [< print_term arity ;
157 (fun (name,ty,_) i -> [< print_term ty ; i >]) constructors [<>]
161 let pp_annotation obj curi =
162 let module C = Cic in
163 let module X = Xml in
164 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
165 X.xml_cdata ("<!DOCTYPE Annotations SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
166 X.xml_nempty "Annotations"
167 ["of", UriManager.string_of_uri (UriManager.cicuri_of_uri curi)]
170 C.ADefinition (xid, ann, _, te, ty, _) ->
174 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
179 | C.AAxiom (xid, ann, _, ty, _) ->
183 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
187 | C.AVariable (xid, ann, _, bo, ty) ->
191 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
195 | Some bo -> print_term bo
199 | C.ACurrentProof (xid, ann, _, conjs, bo, ty) ->
203 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
206 (fun (_,t) i -> [< print_term t ; i >])
211 | C.AInductiveDefinition (xid, ann, tys, params, paramsno) ->
215 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
218 (fun x i -> [< print_mutual_inductive_type x ; i >])