1 (* Copyright (C) 2004, 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/
29 | Id of (string * string option) (* literal, opt. uri *)
30 | Symbol of string * (string option * string) option (* literal, opt. (uri,interp.) *)
31 | Num of (string option * string) option (* opt. uri, interpretation *)
35 | Id of string (* literal *)
36 | Symbol of string (* literal *)
40 exception Invalid_choice of (Stdpp.location * string) Lazy.t
42 module OrderedDomain =
45 let compare = Pervasives.compare
48 (* module Domain = Set.Make (OrderedDomain) *)
51 module Environment' = Map.Make (OrderedDomain)
59 | Symbol (sym,_) -> find (Symbol (sym,None)) env
60 | Num _ -> find (Num None) env
61 | Id (id,_) -> find (Id (id,None)) env
63 let cons desc_of_alias k v env =
64 let default_dom_item = function
65 | Id (s,_) -> Id (s,None)
66 | Symbol (s,_) -> Symbol (s,None)
71 let current = find k env in
72 let dsc = desc_of_alias v in
73 let entry = v::(List.filter (fun x -> desc_of_alias x <> dsc) current) in
76 | Symbol (sym,_) -> "SYMBOL:"^sym
79 prerr_endline (Printf.sprintf "updated alias for %s with entry of length %d (was: %d)" id (List.length entry) (List.length current));
80 let res = add k entry env
82 let test = find k res in
83 prerr_endline (Printf.sprintf "so the current length of the entry is %d."
86 with Not_found -> add k [v] env
90 let current = find k env in
91 let dsc = desc_of_alias v in
92 add k (v :: (List.filter (fun x -> desc_of_alias x <> dsc) current)) env
96 (* we also add default aliases *)
97 let k' = default_dom_item k in
99 let current = find k' env' in
100 let dsc = desc_of_alias v in
101 add k' (v :: (List.filter (fun x -> desc_of_alias x <> dsc) current)) env'
107 type 'term codomain_item =
108 string * (* description *)
109 [`Num_interp of string -> 'term
110 |`Sym_interp of 'term list -> 'term]
112 type interactive_user_uri_choice_type =
113 selection_mode:[`SINGLE | `MULTIPLE] ->
115 ?enable_button_for_non_vars:bool ->
116 title:string -> msg:string -> id:string -> NReference.reference list ->
117 NReference.reference list
119 type interactive_interpretation_choice_type = string -> int ->
120 (Stdpp.location list * string * string) list list -> int list
122 type input_or_locate_uri_type =
123 title:string -> ?id:string -> unit -> NReference.reference option
125 let string_of_domain_item item =
126 let f_opt f x default =
133 Printf.sprintf "ID(%s,%s)" s (f_opt (fun x -> x) huri "_")
134 | Symbol (s,_) -> Printf.sprintf "SYMBOL(%s)" s