X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=matitaB%2Fmatita%2Fmatitadaemon.ml;h=a53d24f676ae3c3ec9a86e8182700e1a4aa9942c;hb=80e732607c2b96569ed7826bb2372bc8ace885db;hp=c92811c4e6ea53e2eaa75aac97e793f58c8b50c7;hpb=a7b54fb6f31e5ac626853890686ee54033dc7b24;p=helm.git diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index c92811c4e..a53d24f67 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -2,6 +2,7 @@ open Printf;; open Http_types;; exception Emphasized_error of string +exception Ambiguous of string module Stack = Continuationals.Stack @@ -362,8 +363,57 @@ 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) + | NTacStatus.Error (s,None) as e -> + prerr_endline + ("NTacStatus.Error " ^ (Lazy.force s)); + raise e + | NTacStatus.Error (s,Some exc) as e -> + prerr_endline + ("NTacStatus.Error " ^ Lazy.force s ^ " -- " ^ (Printexc.to_string exc)); + raise e + | GrafiteDisambiguate.Ambiguous_input (loc,choices) -> + let x,y = HExtlib.loc_of_floc loc in + let choice_of_alias = function + | GrafiteAst.Ident_alias (_,uri) -> uri, None, uri + | GrafiteAst.Number_alias (None,desc) + | GrafiteAst.Symbol_alias (_,None,desc) -> "cic:/fakeuri.def(1)", Some desc, desc + | GrafiteAst.Number_alias (Some uri,desc) + | GrafiteAst.Symbol_alias (_,Some uri,desc) -> uri, Some desc, desc + in + let tag_of_choice (uri,title,desc) = + match title with + | None -> Printf.sprintf "%s" + uri + (Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false () desc) + | Some t -> Printf.sprintf "%s" + uri + (Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false () t) + (Netencoding.Html.encode ~in_enc:`Enc_utf8 ~prefer_name:false () desc) + in + let strchoices = + String.concat "\n" + (List.map (fun x -> tag_of_choice (choice_of_alias x)) choices) + 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 + *) + let strchoices = Printf.sprintf + "%s" x y strchoices + in raise (Ambiguous strchoices) (* | 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 @@ -635,7 +685,14 @@ let advance (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = with | Emphasized_error text -> (* | MultiPassDisambiguator.DisambiguationError (offset,errorll) -> *) - let body = "" ^ text ^ " " in + let body = "" ^ text ^ "" in + cgi # set_header + ~cache:`No_cache + ~content_type:"text/xml; charset=\"utf-8\"" + (); + cgi#out_channel#output_string body + | Ambiguous text -> + let body = "" ^ text ^ "" in cgi # set_header ~cache:`No_cache ~content_type:"text/xml; charset=\"utf-8\""