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 let get_ann ids_to_annotations =
33 CicXPath.get_annotation ids_to_annotations
36 let print_ann i2a id =
38 let ann = get_ann i2a id in
41 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
44 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
49 let module U = UriManager in
51 C.ARel (id,_,_) -> print_ann i2a id
52 | C.AVar (id,_) -> print_ann i2a id
53 | C.AMeta (id,_) -> print_ann i2a id
54 | C.ASort (id,_) -> print_ann i2a id
55 | C.AImplicit _ -> raise NotImplemented
56 | C.AProd (id,_,s,t) -> [< print_ann i2a id ; aux s ; aux t >]
57 | C.ACast (id,v,t) -> [< print_ann i2a id ; aux v ; aux t >]
58 | C.ALambda (id,_,s,t) -> [< print_ann i2a id ; aux s ; aux t >]
59 | C.ALetIn (id,_,s,t) -> [< print_ann i2a id ; aux s ; aux t >]
62 List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>]
64 | C.AConst (id,_,_) -> print_ann i2a id
65 | C.AAbst (id,_) -> raise NotImplemented
66 | C.AMutInd (id,_,_,_) -> print_ann i2a id
67 | C.AMutConstruct (id,_,_,_,_) -> print_ann i2a id
68 | C.AMutCase (id,_,_,_,ty,te,patterns) ->
73 (fun x i -> [< aux x ; i>])
76 | C.AFix (id,_,funs) ->
79 (fun (_,_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
81 | C.ACoFix (id,no,funs) ->
84 (fun (_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
90 let print_mutual_inductive_type i2a (_,_,arity,constructors) =
91 [< print_term i2a arity ;
93 (fun (name,ty,_) i -> [< print_term i2a ty ; i >]) constructors [<>]
97 let pp_annotation obj i2a curi =
100 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
101 X.xml_cdata ("<!DOCTYPE Annotations SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
102 X.xml_nempty "Annotations"
103 ["of", UriManager.string_of_uri (UriManager.cicuri_of_uri curi)]
106 C.ADefinition (xid, _, te, ty, _) ->
107 [< print_ann i2a xid ; print_term i2a te ; print_term i2a ty >]
108 | C.AAxiom (xid, _, ty, _) -> [< print_ann i2a xid ; print_term i2a ty >]
109 | C.AVariable (xid, _, bo, ty) ->
110 [< print_ann i2a xid ;
113 | Some bo -> print_term i2a bo
117 | C.ACurrentProof (xid, _, conjs, bo, ty) ->
118 [< print_ann i2a xid ;
120 (fun (_,t) i -> [< print_term i2a t ; i >])
125 | C.AInductiveDefinition (xid, tys, params, paramsno) ->
126 [< print_ann i2a xid ;
128 (fun x i -> [< print_mutual_inductive_type i2a x ; i >])