From 48457c0a99124a16ab29d7b84bcca85e0f3185a4 Mon Sep 17 00:00:00 2001 From: Lucca Hirschi Date: Fri, 13 Jul 2012 13:43:26 +0200 Subject: [PATCH] minor in run + fix infinite loop, must think about an algo here + fix print of solve --- src/run.ml | 25 ++++++++++++------------- src/solve.ml | 5 +++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/run.ml b/src/run.ml index af23b8c..fed18f0 100644 --- a/src/run.ml +++ b/src/run.ml @@ -141,19 +141,18 @@ let rec tp_max asta run tree tnode = with Not_found -> raise Max_fail in (* We must compute again accepting states from self transitions since previous calls of tp_max may remove them *) - let rec comp_acc_self set flag = function - | [] -> set,flag - | (q,form) :: tl -> - if Formula.infer_form set qf qn form - then if StateSet.mem q set - then comp_acc_self set 0 tl - else comp_acc_self (StateSet.add q set) 1 tl - else comp_acc_self set 0 tl - and rec fix_point selfq_i = - let setq,flag = comp_acc_self selfq_i 0 list_tr in - if flag = 1 then set - else fix_point setq qf qn 0 in - NodeHash.replace run node (fix_point set_node, set_nr); + let rec comp_acc_self set flag = + () (* given a current set of states we add + states from self transitions which satisfy the two conditions *) + (* With result (below) we have all valid transitions at step 0 + we compute the self states which occur in it and which are not in cthe current state. + For each of these states we compute the transitions with the correct label and state + we infer each of these transitions: true -> add self states occuring in it + to the acc and to the current set + add left and right states as result do *) + (* ----> With a FIFO *) + and fix_point selfq_i = + () in + NodeHash.replace run node (set_node, set_nr); let rec result = function | [] -> [] diff --git a/src/solve.ml b/src/solve.ml index d898bab..b6dee3b 100644 --- a/src/solve.ml +++ b/src/solve.ml @@ -59,19 +59,20 @@ let () = 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 solve_queries = function | [] -> () | query :: tl -> let asta = build_asta query in let selected_nodes = Run.selected_nodes doc asta in - fprintf err_formatter "Query: %a\n" + fprintf err_formatter "\n ### Query: %a\n" XPath.Ast.print query; let rec print_selec fmt l = match l with | [x] -> fprintf fmt "%s" (string_of_int x) | x :: tl -> fprintf fmt "%s" ((string_of_int x)^"; ");print_selec fmt tl | [] -> fprintf fmt "%s" "ø" in - fprintf err_formatter "@.@. # Selected nodes: {%a}@." + fprintf err_formatter "@. ### Selected nodes: {%a}@." print_selec selected_nodes in solve_queries queries; exit 0 -- 2.17.1