X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fsolve.ml;h=4ab11479c7765fb02ad6673dd644810ef8abaccc;hb=5e7268fb95cdc7e56fe24f324a710550ade3d851;hp=c94967db1449fc60d51772fb9d23d1d97e20755e;hpb=5cfe8f8725b83eadae6923a10929b5db9204049c;p=tatoo.git diff --git a/src/solve.ml b/src/solve.ml index c94967d..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,13 +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" - -let build_asta query = - let asta = Compil.trans query in - asta + else failwith "Use ./test xml_file -f XPath_queries_file" let compute_run doc query = let run = Run.compute doc query in @@ -52,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) @@ -65,13 +61,18 @@ let () = let rec solve_queries = function | [] -> () | query :: tl -> - let asta = build_asta query in + 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;