]> matita.cs.unibo.it Git - helm.git/blob - matitaB/components/content/notationEnv.mli
Matitaweb:
[helm.git] / matitaB / components / content / notationEnv.mli
1 (* Copyright (C) 2004-2005, 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://helm.cs.unibo.it/
24  *)
25
26 (** {2 Types} *)
27
28 type ident_or_var =
29    Ident of string
30  | Var of string
31
32 type value =
33   | TermValue of NotationPt.term
34   | StringValue of ident_or_var
35   | NumValue of string
36   | OptValue of value option
37   | ListValue of value list
38   | DisambiguationValue of (string option * Stdpp.location * string option * string option)
39
40 type value_type =
41   | TermType of int (* the level of the expected term *)
42   | StringType
43   | NumType
44   | OptType of value_type
45   | ListType of value_type
46   | NoType
47
48   (** looked up value not found in environment *)
49 exception Value_not_found of string
50
51   (** looked up value has the wrong type
52    * parameters are value name and value type in environment *)
53 exception Type_mismatch of string * value_type
54
55 type declaration = string * value_type
56 type binding = string * (value_type * value)
57 type t = binding list
58
59 val declaration_of_var: NotationPt.pattern_variable -> declaration
60 val value_of_term: NotationPt.term -> value
61 val term_of_value: value -> NotationPt.term
62 val well_typed: value_type -> value -> bool
63
64 val declarations_of_env: t -> declaration list
65 val declarations_of_term: NotationPt.term -> declaration list
66 val combine: declaration list -> value list -> t  (** @raise Invalid_argument *)
67
68 (** {2 Environment lookup} *)
69
70 val lookup_value:   t -> string -> value  (** @raise Value_not_found *)
71
72 (** lookup_* functions below may raise Value_not_found and Type_mismatch *)
73
74 val lookup_term:    t -> string -> NotationPt.term
75 val lookup_string:  t -> string -> ident_or_var
76 val lookup_num:     t -> string -> string
77 val lookup_opt:     t -> string -> value option
78 val lookup_list:    t -> string -> value list
79
80 val remove_name:    t -> string -> t
81 val remove_names:   t -> string list -> t
82
83 (** {2 Bindings mangling} *)
84
85 val opt_binding_some: binding -> binding          (* v -> Some v *)
86 val opt_binding_none: binding -> binding          (* v -> None *)
87
88 val opt_binding_of_name:  declaration -> binding  (* None binding *)
89 val list_binding_of_name: declaration -> binding  (* [] binding *)
90
91 val opt_declaration:  declaration -> declaration  (* t -> OptType t *)
92 val list_declaration: declaration -> declaration  (* t -> ListType t *)
93
94 (** given a list of environments bindings a set of names n_1, ..., n_k, returns
95  * a single environment where n_i is bound to the list of values bound in the
96  * starting environments *)
97 val coalesce_env: declaration list -> t list -> t
98