X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fsolve.ml;h=4ab11479c7765fb02ad6673dd644810ef8abaccc;hb=5e7268fb95cdc7e56fe24f324a710550ade3d851;hp=5074ae068ec2e20b09e73c1566cf2e3556c59fd4;hpb=a43a51c51314468a47a36904c2b904f5a9a14bca;p=tatoo.git diff --git a/src/solve.ml b/src/solve.ml index 5074ae0..4ab1147 100644 --- a/src/solve.ml +++ b/src/solve.ml @@ -15,7 +15,8 @@ (** use: [./test xml_file -f XPath_queries_file] - one query per line [XPath_querie_file] + one query per line [XPath_querie_file], output + a solution per line. *) open Format @@ -24,7 +25,6 @@ let doc () = let fd = open_in Sys.argv.(1) in let d = Tree.load_xml_file fd in close_in fd; - fprintf err_formatter "Parse Tree OK ! "; d @@ -38,9 +38,8 @@ let query () = with _ -> list in let list = list_qu fq [] in close_in fq; - fprintf err_formatter "Parse query OK !\n %!"; list - else failwith "Use -f" + else failwith "Use ./test xml_file -f XPath_queries_file" let compute_run doc query = let run = Run.compute doc query in @@ -48,11 +47,12 @@ let compute_run doc query = let () = let flag = Array.length Sys.argv = 5 in + let flag2 = + if flag + then int_of_string Sys.argv.(4) = 1 + else false in Format.pp_set_margin err_formatter 80; let doc = doc () in - output_string stderr "##### Doc with positions #####\n"; - Tree.print_xml_preorder stderr doc (Tree.root doc); - output_string stderr "\n"; let queries = query () in let rec print_selec fmt l = match l with | [x] -> fprintf fmt "%s" (string_of_int x) @@ -64,17 +64,21 @@ let () = let asta = Compil.trans query in let selected_nodes = Run.selected_nodes doc asta in let run = compute_run doc asta in - fprintf err_formatter "\n ### Query: %a" - XPath.Ast.print query; - fprintf err_formatter "@. ### Selected nodes: {%a}@." - print_selec selected_nodes; + if flag + then + fprintf err_formatter " ### Query: %a" + XPath.Ast.print query + else (); + if flag2 then + fprintf err_formatter "@. ### Selected nodes: {%a}@." + print_selec selected_nodes + else (); if flag then begin Asta.print err_formatter asta; Run.print err_formatter run; end else (); - let asta = Asta.empty in solve_queries tl in solve_queries queries; exit 0