X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fmain.ml;h=2534d01e9a897f9d06bd6d25749a6c1510c9d42e;hb=d31315cfd8d95205dc0debf430bfa7ce762d9974;hp=48f2e468e8223f1b113eb8b5c776e24e1ee9df55;hpb=fcdb6b70f80c4777e319917e9318fc8d54e3a28f;p=SXSI%2Fxpathcomp.git diff --git a/src/main.ml b/src/main.ml index 48f2e46..2534d01 100644 --- a/src/main.ml +++ b/src/main.ml @@ -33,6 +33,7 @@ let mk_runtime run auto doc arg count print outfile = let main v query_string output = Tag.init (Tree.tag_operations v); + if !Options.docstats then Tree.stats v; let query = time ~msg:"Parsing query" XPath.parse query_string in @@ -54,7 +55,7 @@ let main v query_string output = if !Options.count_only then let module R = ResJIT.Count in let module M = Runtime.Make(R) in - mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize None + mk_runtime M.bottom_up_run auto v (query, pattern) R.NS.length R.NS.serialize !Options.output_file else let module R = ResJIT.Mat in let module M = Runtime.Make(R) in @@ -71,7 +72,7 @@ let main v query_string output = if !Options.twopass then mk_runtime M.twopass_top_down_run auto v Tree.root R.NS.length R.NS.serialize None else - mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize None + mk_runtime M.top_down_run auto v Tree.root R.NS.length R.NS.serialize !Options.output_file else let module R = ResJIT.Mat in let module M = Runtime.Make(R) in @@ -85,55 +86,8 @@ let () = Options.parse_cmdline() let _ = try Printexc.record_backtrace true; - let document = - if Filename.check_suffix !Options.input_file ".g.bin" || - Filename.check_suffix !Options.input_file ".g" - then - let is_index = Filename.check_suffix !Options.input_file ".g.bin" in - let g = - if is_index then - time ~msg:"Loading grammar" (Grammar2.load) !Options.input_file - else - let g = time ~msg:"Parsing grammar file" Grammar2.parse !Options.input_file in - if !Options.save_file <> "" then - time ~msg:"Saving index" (Grammar2.save g) !Options.save_file; - g - in - begin - (* TODO Factorise with main *) - Tag.init (Grammar2.tag_operations g); - let query = - time ~msg:"Parsing query" XPath.parse !Options.query - in - if !Options.verbose then begin - Printf.eprintf "Parsed query:\n%!"; - XPath.Ast.print Format.err_formatter query; - Format.fprintf Format.err_formatter "\n%!" - end; - let auto, bu_info = - time ~msg:"Compiling query" (Compile.compile) query - in - if !Options.verbose then Ata.print Format.err_formatter auto; - Gc.full_major(); - Gc.compact(); - Gc.set (tuned_gc); - let runtime = - if !Options.count_only then - let module R = ResJIT.Make(NodeSet.Partial(NodeSet.Count)) in - let module M = Runtime.Make(R) in - (* mk_runtime run auto doc arg count print outfile *) - mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None - else - let module R = ResJIT.Mat in - let module M = Runtime.Make(R) in - (* mk_runtime run auto doc arg count print outfile *) - mk_runtime M.grammar_run auto (Obj.magic g) () R.NS.length (Obj.magic R.NS.serialize) None - in - runtime (); - exit 0 - end - else if Filename.check_suffix !Options.input_file ".srx" + if Filename.check_suffix !Options.input_file ".srx" then time ~msg:"Loading file" @@ -172,5 +126,3 @@ let _ = Logger.print Format.err_formatter "BACKTRACE: %s@\n@?" (Printexc.get_backtrace()); Logger.print Format.err_formatter "FATAL ERROR: %s@\n@?" (Printexc.to_string e); exit 2 - -