1 (*CSC codice cut & paste da cicPp e xmlcommand *)
3 exception ImpossiblePossible;;
4 exception NotImplemented;;
5 exception BinderNotSpecified;;
7 let dtdname = "http://localhost:8081/getdtd?url=annotations.dtd";;
9 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
14 let module U = UriManager in
16 C.ARel (id,ann,_,_) ->
19 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
21 | C.AVar (id,ann,_) ->
24 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
26 | C.AMeta (id,ann,_) ->
29 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
31 | C.ASort (id,ann,_) ->
34 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
36 | C.AImplicit _ -> raise NotImplemented
37 | C.AProd (id,ann,_,s,t) ->
41 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
46 | C.ACast (id,ann,v,t) ->
50 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
55 | C.ALambda (id,ann,_,s,t) ->
59 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
64 | C.ALetIn (id,ann,_,s,t) ->
68 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
73 | C.AAppl (id,ann,li) ->
77 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
79 List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>]
81 | C.AConst (id,ann,_,_) ->
84 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
86 | C.AAbst (id,ann,_) -> raise NotImplemented
87 | C.AMutInd (id,ann,_,_,_) ->
90 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
92 | C.AMutConstruct (id,ann,_,_,_,_) ->
95 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
97 | C.AMutCase (id,ann,_,_,_,ty,te,patterns) ->
101 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
106 (fun x i -> [< aux x ; i>])
109 | C.AFix (id, ann, _, funs) ->
113 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
116 (fun (_,_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
118 | C.ACoFix (id, ann,no,funs) ->
122 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
125 (fun (_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
131 let print_mutual_inductive_type (_,_,arity,constructors) =
132 [< print_term arity ;
134 (fun (name,ty,_) i -> [< print_term ty ; i >]) constructors [<>]
138 let target_uri_of_annotation_uri uri =
139 Str.replace_first (Str.regexp "\.ann$") "" (UriManager.string_of_uri uri)
142 let pp_annotation obj curi =
143 let module C = Cic in
144 let module X = Xml in
145 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
146 X.xml_cdata ("<!DOCTYPE Annotations SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
147 X.xml_nempty "Annotations" ["of", target_uri_of_annotation_uri curi]
150 C.ADefinition (xid, ann, _, te, ty, _) ->
154 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
159 | C.AAxiom (xid, ann, _, ty, _) ->
163 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
167 | C.AVariable (xid, ann, _, bo, ty) ->
171 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
175 | Some bo -> print_term bo
179 | C.ACurrentProof (xid, ann, _, conjs, bo, ty) ->
183 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
186 (fun (_,t) i -> [< print_term t ; i >])
191 | C.AInductiveDefinition (xid, ann, tys, params, paramsno) ->
195 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
198 (fun x i -> [< print_mutual_inductive_type x ; i >])