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