]> matita.cs.unibo.it Git - helm.git/blob - helm/interface/cicXPath.ml
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / interface / cicXPath.ml
1 (* Copyright (C) 2000, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 (******************************************************************************)
27 (*                                                                            *)
28 (*                               PROJECT HELM                                 *)
29 (*                                                                            *)
30 (*                Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>               *)
31 (*                                 14/06/2000                                 *)
32 (*                                                                            *)
33 (*                                                                            *)
34 (******************************************************************************)
35
36 let get_annotation_from_term annterm =
37  let module C = Cic in
38   match annterm with
39      C.ARel (_,ann,_,_)             -> ann
40    | C.AVar (_,ann,_)               -> ann
41    | C.AMeta (_,ann,_)              -> ann
42    | C.ASort (_,ann,_)              -> ann
43    | C.AImplicit (_,ann)            -> ann
44    | C.ACast (_,ann,_,_)            -> ann
45    | C.AProd (_,ann,_,_,_)          -> ann
46    | C.ALambda (_,ann,_,_,_)        -> ann
47    | C.ALetIn (_,ann,_,_,_)         -> ann
48    | C.AAppl (_,ann,_)              -> ann
49    | C.AConst (_,ann,_,_)           -> ann
50    | C.AAbst (_,ann,_)              -> ann
51    | C.AMutInd (_,ann,_,_,_)        -> ann
52    | C.AMutConstruct (_,ann,_,_,_,_)-> ann
53    | C.AMutCase (_,ann,_,_,_,_,_,_) -> ann
54    | C.AFix (_,ann,_,_)             -> ann
55    | C.ACoFix (_,ann,_,_)           -> ann
56 ;;
57
58 let get_annotation_from_obj annobj =
59  let module C = Cic in
60   match annobj with
61      C.ADefinition (_,ann,_,_,_,_)        -> ann
62    | C.AAxiom (_,ann,_,_,_)               -> ann
63    | C.AVariable (_,ann,_,_,_)            -> ann
64    | C.ACurrentProof (_,ann,_,_,_,_)      -> ann
65    | C.AInductiveDefinition (_,ann,_,_,_) -> ann
66 ;;
67
68 exception IdUnknown of string;;
69
70 let get_annotation (annobj,ids_to_targets) xpath =
71  try
72   match Hashtbl.find ids_to_targets xpath with
73      Cic.Object annobj -> get_annotation_from_obj annobj
74    | Cic.Term annterm -> get_annotation_from_term annterm
75  with
76   Not_found -> raise (IdUnknown xpath)
77 ;;