]> matita.cs.unibo.it Git - helm.git/blobdiff - matitaB/matita/matitadaemon.ml
Matitaweb: added preliminary support for interactive disambiguation.
[helm.git] / matitaB / matita / matitadaemon.ml
index c92811c4e6ea53e2eaa75aac97e793f58c8b50c7..c2a586120227bd3fcbc11b2aa7103b039c8580f1 100644 (file)
@@ -362,8 +362,28 @@ let advance0 sid text =
       let marked = Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false 
       () (html_of_matita marked) in
       raise (Emphasized_error marked) 
+    | GrafiteDisambiguate.Ambiguous_input (loc,choices) -> 
+        let strchoices = 
+          String.concat "\n" (List.map
+            GrafiteAst.description_of_alias choices)
+        in
+        let x,y = HExtlib.loc_of_floc loc in
+        prerr_endline (Printf.sprintf
+          "@@@ Ambiguous input at (%d,%d). Possible choices:\n\n%s\n\n@@@ End."
+          x y strchoices);
+      let pre = Netconversion.ustring_sub `Enc_utf8  0 x text in
+      let err = Netconversion.ustring_sub `Enc_utf8  x (y-x) text in
+      let post = Netconversion.ustring_sub `Enc_utf8 y 
+         (Netconversion.ustring_length `Enc_utf8 text - y) text in
+      let title = "Disambiguation Error" in
+      (* let title = "" in *)
+      let marked = 
+       pre ^ "\005span class=\"error\" title=\"" ^ title ^ "\"\006" ^ err ^ "\005/span\006" ^ post in
+      let marked = Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false 
+      () (html_of_matita marked) in
+      raise (Emphasized_error marked) 
    (* | End_of_file -> ...          *)
-   in
+  in
   let stringbuf = Ulexing.from_utf8_string new_statements in
   let interpr = GrafiteDisambiguate.get_interpr st#disambiguate_db in
   let outstr = ref "" in