]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gTopLevel/termEditor.ml
- Added DisambiguatingParser (that abstracts both the parser and the
[helm.git] / helm / gTopLevel / termEditor.ml
index f034c45b15b9bc9b48ed23176a6cda65a9e18375..ca5cca601e615c6daf96b5bdcaff3f525852e1d3 100644 (file)
@@ -35,8 +35,6 @@
 
 open Printf
 
-open Disambiguate_types
-
 (* A WIDGET TO ENTER CIC TERMS *)
 
 class type term_editor =
@@ -50,23 +48,21 @@ class type term_editor =
    method reset : unit
    (* The input of set_term is unquoted *)
    method set_term : string -> unit
-   method id_to_uris : environment ref
+   method environment : DisambiguatingParser.Environment.t ref
  end
 
-let empty_id_to_uris = Environment.empty
-
-module Make(C: Callbacks) =
+module Make(C:Disambiguate_types.Callbacks) =
   struct
 
-   module Disambiguate' = Disambiguate.Make(C);;
+   module Disambiguate' = DisambiguatingParser.Make(C);;
 
    class term_editor_impl mqi_handle ?packing ?width ?height
-    ?isnotempty_callback ?share_id_to_uris_with () : term_editor
+    ?isnotempty_callback ?share_environment_with () : term_editor
    =
-    let id_to_uris =
-     match share_id_to_uris_with with
-        None -> ref empty_id_to_uris
-      | Some obj -> obj#id_to_uris
+    let environment =
+     match share_environment_with with
+        None -> ref DisambiguatingParser.Environment.empty
+      | Some obj -> obj#environment
     in
     let input = GText.view ~editable:true ?width ?height ?packing () in
     let _ =
@@ -100,17 +96,14 @@ module Make(C: Callbacks) =
            | None -> None
          ) context
        in
-        let term =
-          Parser.parse_term (Stream.of_string (input#buffer#get_text ()))
-        in
-        let id_to_uris',metasenv,expr =
-          Disambiguate'.disambiguate_term mqi_handle context metasenv term
-            ~aliases:!id_to_uris
+        let environment',metasenv,expr =
+          Disambiguate'.disambiguate_term mqi_handle context metasenv
+           (input#buffer#get_text ()) !environment
         in
-        id_to_uris := id_to_uris';
+        environment := environment';
         (metasenv, expr)
 
-      method id_to_uris = id_to_uris
+      method environment = environment
    end
 
    let term_editor = new term_editor_impl