]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaDisambiguator.ml
checked in new version of matita from svn
[helm.git] / helm / matita / matitaDisambiguator.ml
diff --git a/helm/matita/matitaDisambiguator.ml b/helm/matita/matitaDisambiguator.ml
new file mode 100644 (file)
index 0000000..fcbcdea
--- /dev/null
@@ -0,0 +1,65 @@
+(* Copyright (C) 2004-2005, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+open Printf
+
+open MatitaTypes
+
+exception Ambiguous_input
+
+type choose_uris_callback = id:string -> string list -> string list
+type choose_interp_callback = (string * string) list list -> int list
+
+let mono_uris_callback ~id = raise Ambiguous_input
+let mono_interp_callback _ = raise Ambiguous_input
+
+let _choose_uris_callback = ref mono_uris_callback
+let _choose_interp_callback = ref mono_interp_callback
+let set_choose_uris_callback f = _choose_uris_callback := f
+let set_choose_interp_callback f = _choose_interp_callback := f
+
+module Callbacks =
+  struct
+    let interactive_user_uri_choice ~selection_mode ?ok
+          ?(enable_button_for_non_vars = true) ~title ~msg ~id uris =
+              !_choose_uris_callback ~id uris
+
+    let interactive_interpretation_choice interp =
+      !_choose_interp_callback interp
+
+    let input_or_locate_uri ~(title:string) ?id =
+      (* Zack: I try to avoid using this callback. I therefore assume that
+      * the presence of an identifier that can't be resolved via "locate"
+      * query is a syntax error *)
+      let msg = match id with Some id -> id | _ -> "_" in
+      raise (Unbound_identifier msg)
+  end
+  
+module Disambiguator = Disambiguate.Make (Callbacks)
+
+(* implement module's API *)
+
+let disambiguate_term = Disambiguator.disambiguate_term
+