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.AAppl (id,ann,li) ->
68 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
70 List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>]
72 | C.AConst (id,ann,_,_) ->
75 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
77 | C.AAbst (id,ann,_) -> raise NotImplemented
78 | C.AMutInd (id,ann,_,_,_) ->
81 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
83 | C.AMutConstruct (id,ann,_,_,_,_) ->
86 | Some ann -> (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
88 | C.AMutCase (id,ann,_,_,_,ty,te,patterns) ->
92 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
97 (fun x i -> [< aux x ; i>])
100 | C.AFix (id, ann, _, funs) ->
104 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
107 (fun (_,_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
109 | C.ACoFix (id, ann,no,funs) ->
113 (X.xml_nempty "Annotation" ["of", id] (X.xml_cdata ann))
116 (fun (_,ti,bi) i -> [< aux ti ; aux bi ; i >]) funs [<>]
122 let print_mutual_inductive_type (_,_,arity,constructors) =
123 [< print_term arity ;
125 (fun (name,ty,_) i -> [< print_term ty ; i >]) constructors [<>]
129 let target_uri_of_annotation_uri uri =
130 Str.replace_first (Str.regexp "\.ann$") "" (UriManager.string_of_uri uri)
133 let pp_annotation obj curi =
134 let module C = Cic in
135 let module X = Xml in
136 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
137 X.xml_cdata ("<!DOCTYPE Annotations SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
138 X.xml_nempty "Annotations" ["of", target_uri_of_annotation_uri curi]
141 C.ADefinition (xid, ann, _, te, ty, _) ->
145 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
150 | C.AAxiom (xid, ann, _, ty, _) ->
154 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
158 | C.AVariable (xid, ann, _, ty) ->
162 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
166 | C.ACurrentProof (xid, ann, _, conjs, bo, ty) ->
170 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
173 (fun (_,t) i -> [< print_term t ; i >])
178 | C.AInductiveDefinition (xid, ann, tys, params, paramsno) ->
182 X.xml_nempty "Annotation" ["of", xid] (X.xml_cdata ann)
185 (fun x i -> [< print_mutual_inductive_type x ; i >])