projects
/
tatoo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change command line options:
[tatoo.git]
/
src
/
tatoo.ml
diff --git
a/src/tatoo.ml
b/src/tatoo.ml
index
2c32062
..
4d7e693
100644
(file)
--- a/
src/tatoo.ml
+++ b/
src/tatoo.ml
@@
-13,10
+13,6
@@
(* *)
(***********************************************************************)
(* *)
(***********************************************************************)
-(*
- Time-stamp: <Last modified on 2013-04-22 18:48:48 CEST by Kim Nguyen>
-*)
-
open Format
let time f arg msg =
open Format
let time f arg msg =
@@
-24,16
+20,20
@@
let time f arg msg =
let r = f arg in
let t2 = Unix.gettimeofday () in
let time = (t2 -. t1) *. 1000. in
let r = f arg in
let t2 = Unix.gettimeofday () in
let time = (t2 -. t1) *. 1000. in
-
if !Options.stats then fprintf err_formatter "@[STATS: %s: %fms@]@.
" msg time;
+
Logger.msg `STATS "%s: %fms
" msg time;
r
let main () =
let () = Options.parse () in
let doc =
r
let main () =
let () = Options.parse () in
let doc =
- let fd = open_in !Options.input_file in
+ let fd, close_fd = match !Options.input_file with
+ None -> stdin, ignore
+ | Some input ->
+ let fd = open_in input in fd, fun () -> close_in fd
+ in
let d = time Naive_tree.load_xml_file fd "parsing xml document" in
let d = time Naive_tree.load_xml_file fd "parsing xml document" in
- close_
in fd
; d
+ close_
fd ()
; d
in
let query =
time
in
let query =
time
@@
-44,21
+44,20
@@
let main () =
let auto =
time Xpath.Compile.path query "compiling XPath query"
in
let auto =
time Xpath.Compile.path query "compiling XPath query"
in
+ let auto = time Ata.copy auto "copying Automaton" in
let output =
match !Options.output_file with
| None | Some "-" | Some "/dev/stdout" -> stdout
| Some f -> open_out f
in
if !Options.stats then begin
let output =
match !Options.output_file with
| None | Some "-" | Some "/dev/stdout" -> stdout
| Some f -> open_out f
in
if !Options.stats then begin
- fprintf err_formatter "@[STATS: Query: %a @]@." Xpath.Ast.print_path query;
- fprintf err_formatter "@[STATS: @[Automaton: @\n";
- Ata.print err_formatter auto;
- fprintf err_formatter "@]@]@.";
+ Logger.msg `STATS "Query: %a " Xpath.Ast.print_path query;
+ Logger.msg `STATS "@[Automaton: @\n%a@]" Ata.print auto;
end;
end;
- let module Naive =
Eval
.Make(Naive_tree) in
+ let module Naive =
Run
.Make(Naive_tree) in
let results =
let results =
- time (Naive.eval auto doc) (
Naive_tree.root doc
) "evaluating query"
+ time (Naive.eval auto doc) (
[Naive_tree.root doc]
) "evaluating query"
in
time (fun () ->
output_string output "<xml_result>\n";
in
time (fun () ->
output_string output "<xml_result>\n";
@@
-73,7
+72,7
@@
let main () =
output_string output "</xml_result>\n";
flush output;
if output != stdout then close_out output
output_string output "</xml_result>\n";
flush output;
if output != stdout then close_out output
-
+
) () "serializing results"
) () "serializing results"
@@
-83,6
+82,10
@@
let () =
with
Arg.Bad msg -> eprintf "Error: %s\n%!" msg; Options.usage (); exit 1
| Sys_error msg -> eprintf "Error: %s\n%!" msg; exit 2
with
Arg.Bad msg -> eprintf "Error: %s\n%!" msg; Options.usage (); exit 1
| Sys_error msg -> eprintf "Error: %s\n%!" msg; exit 2
- | Tree.Parse_error msg -> eprintf "Error: file %s, %s\n%!" !Options.input_file msg; exit 3
+ | Tree.Parse_error msg ->
+ eprintf "Error: %s, %s\n%!"
+ (match !Options.input_file with
+ Some s -> ("file " ^ s)
+ | None -> "[stdin]") msg; exit 3
| Xpath.Ulexer.Error (s, e, msg) -> eprintf "Error: character %i-%i: %s\n%!" s e msg; exit 4
| e -> eprintf "FATAL ERROR: %s\n%!" (Printexc.to_string e); exit 128
| Xpath.Ulexer.Error (s, e, msg) -> eprintf "Error: character %i-%i: %s\n%!" s e msg; exit 4
| e -> eprintf "FATAL ERROR: %s\n%!" (Printexc.to_string e); exit 128