1 (* Copyright (C) 2004-2005, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
33 | TermValue of NotationPt.term
34 | StringValue of ident_or_var
36 | OptValue of value option
37 | ListValue of value list
38 | DisambiguationValue of (string option * Stdpp.location * string option * string option)
41 | TermType of int (* the level of the expected term *)
44 | OptType of value_type
45 | ListType of value_type
48 (** looked up value not found in environment *)
49 exception Value_not_found of string
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
55 type declaration = string * value_type
56 type binding = string * (value_type * value)
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
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 *)
68 (** {2 Environment lookup} *)
70 val lookup_value: t -> string -> value (** @raise Value_not_found *)
72 (** lookup_* functions below may raise Value_not_found and Type_mismatch *)
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
80 val remove_name: t -> string -> t
81 val remove_names: t -> string list -> t
83 (** {2 Bindings mangling} *)
85 val opt_binding_some: binding -> binding (* v -> Some v *)
86 val opt_binding_none: binding -> binding (* v -> None *)
88 val opt_binding_of_name: declaration -> binding (* None binding *)
89 val list_binding_of_name: declaration -> binding (* [] binding *)
91 val opt_declaration: declaration -> declaration (* t -> OptType t *)
92 val list_declaration: declaration -> declaration (* t -> ListType t *)
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