X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=daemons%2Fwhelp%2FsearchEngine.ml;h=dd3c8f2c42ba3b4db31bd176c1c373af6c88544e;hb=190662b877ba89ccb152f0bf5c67df62be737335;hp=26c1def3e60c6c7cbb4cd405829136993420f7b4;hpb=28eef5b98d64d50e0c593a538f5eacb6279d395b;p=helm.git diff --git a/daemons/whelp/searchEngine.ml b/daemons/whelp/searchEngine.ml index 26c1def3e..dd3c8f2c4 100644 --- a/daemons/whelp/searchEngine.ml +++ b/daemons/whelp/searchEngine.ml @@ -37,7 +37,7 @@ exception Invalid_action of string (* invalid action for "/search" method *) exception Not_a_MutInd let daemon_name = "Whelp" -let configuration_file = "/projects/helm/etc/whelp.conf.xml" +let configuration_file = "searchEngine.conf.xml" let placeholders = [ "ACTION"; "ADVANCED"; "ADVANCED_CHECKED"; "CHOICES"; "CURRENT_CHOICES"; @@ -260,6 +260,7 @@ let send_results results moogle_TPL let exec_action dbd (req: Http_types.request) outchan = + let dbd = dbd () in let term_str = req#param "expression" in try if req#path = "/elim" && @@ -357,7 +358,8 @@ let exec_action dbd (req: Http_types.request) outchan = end in let module Disambiguate' = Disambiguate.Make(Chat) in - let ast = Grammar.Entry.parse CicNotationParser.term (Stream.of_string term_str) in + let ast = + CicNotationParser.parse_term (Ulexing.from_utf8_string term_str) in let (id_to_uris, metasenv, term) = match Disambiguate'.disambiguate_term ~dbd ~context ~metasenv @@ -371,7 +373,7 @@ let exec_action dbd (req: Http_types.request) outchan = | "/match" -> Whelp.match_term ~dbd term | "/instance" -> Whelp.instance ~dbd term | "/hint" -> - let status = ProofEngineTypes.initial_status term metasenv in + let status = ProofEngineTypes.initial_status term metasenv [] in let intros = PrimitiveTactics.intros_tac () in let subgoals = ProofEngineTypes.apply_tactic intros status in (match subgoals with @@ -448,7 +450,7 @@ let callback dbd (req: Http_types.request) outchan = if expression = "" then send_results (`Results []) req outchan else begin - let results = Whelp.locate ~dbd expression in + let results = Whelp.locate ~dbd:(dbd ()) expression in let results = List.map UriManager.string_of_uri results in send_results (`Results results) req outchan end @@ -466,6 +468,11 @@ let callback dbd (req: Http_types.request) outchan = bad_request (sprintf "Parameter '%s' is missing" attr_name) outchan | CicNotationParser.Parse_error msg -> send_results (`Error (MooglePp.pp_error "Parse error" msg)) req outchan + | Stdpp.Exc_located (floc, Stream.Error msg) -> + send_results (`Error (MooglePp.pp_error "Parse error" msg)) req outchan + | Stdpp.Exc_located (floc, exn) -> + let msg = Printexc.to_string exn in + send_results (`Error (MooglePp.pp_error "Unknown error" msg)) req outchan | Unbound_identifier id -> send_results (`Error (MooglePp.pp_error "Unbound identifier" id)) req outchan @@ -488,11 +495,10 @@ let restore_environment () = printf "done!\n"; flush stdout let read_notation () = - let _ = assert false in () - (* - CicNotation.load_notation (Helm_registry.get "search_engine.notations"); - CicNotation.load_notation (Helm_registry.get "search_engine.interpretations") - *) + ignore (CicNotation2.load_notation ~include_paths:[] + (Helm_registry.get "search_engine.notations")); + ignore (CicNotation2.load_notation ~include_paths:[] + (Helm_registry.get "search_engine.interpretations")) let _ = printf "%s started and listening on port %d\n" daemon_name port; @@ -500,7 +506,7 @@ let _ = printf "HTML directory is %s\n" pages_dir; flush stdout; Unix.putenv "http_proxy" ""; - let dbd = + let dbd () = HMysql.quick_connect ~host:(Helm_registry.get "db.host") ~database:(Helm_registry.get "db.database") @@ -509,6 +515,7 @@ let _ = in restore_environment (); read_notation (); - Http_daemon.start' ~port (callback dbd); + let d_spec = Http_daemon.daemon_spec ~port ~callback:(callback dbd) ~auto_close:true () in + Http_daemon.main d_spec; printf "%s is terminating, bye!\n" daemon_name