test case to debug : in predicates, only recurse on left child for the first step,
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 21 Nov 2008 07:36:20 +0000 (07:36 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 21 Nov 2008 07:36:20 +0000 (07:36 +0000)
not the right

git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/xpathcomp@4 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

main.ml
tests/test.xml
xPath.ml

diff --git a/main.ml b/main.ml
index c8ca27e..3c698cd 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -40,7 +40,7 @@ let main filename query output =
        Format.eprintf "\n%!";
 
        Printf.eprintf "TopDown (No BackTrack) : \n";
-       time (TopDown.run auto) v;
+       time (fun v -> ignore (TopDown.accept auto v)) v;
        P(Printf.eprintf "Max states in TopDownNOBT : %i\n%!" auto.max_states);
        begin
          match output with
index cfeb539..d83dfc0 100644 (file)
@@ -2,7 +2,9 @@
 <a id="3">
   <c/>
   <b>
+    <c/>
     <d/>
+    <c/>
   </b>
   <b/>
   <a/>
index 727c25e..661863d 100644 (file)
--- a/xPath.ml
+++ b/xPath.ml
@@ -211,11 +211,20 @@ module Functions = struct
 
   let rec eval_expr tree (e:expr) : value = match e with 
     | `Call (f,args) -> (List.assoc f globals) (List.map (eval_expr tree) args)
-    | `Auto(a) -> `NodeSet(ignore (Automaton.BottomUp.accept a tree);a.Automaton.result)
+    | `Auto(a) -> `NodeSet(ignore (Automaton.dump Format.err_formatter a;
+                                 Tree.Binary.print_xml_fast stderr tree;
+                                 Printf.eprintf "\n=======================\n%!";
+                                 Automaton.TopDown.run a tree);
+                         Printf.eprintf "Results : %i\n%!" 
+                           (Automaton.BST.cardinal a.Automaton.result);
+                         Automaton.BST.iter (fun t -> Tree.Binary.print_xml_fast stderr t;
+                                               Printf.eprintf "^^^^^^^^^^^^^^^^^^^^^^^^\n%!") 
+                         a.Automaton.result;
+                         a.Automaton.result)
     | #value as x  -> x
        
   let truth_value = 
-    function `NodeSet s -> Automaton.BST.is_empty s
+    function `NodeSet s -> not (Automaton.BST.is_empty s)
       |`Bool(b) -> b
       | _ -> failwith "truth_value"
     
@@ -321,6 +330,7 @@ module Compile = struct
              (* q' is not returned and thus not added to the set of final states.
                 It's ok since we should never be in a final state on a node
                 <@> *)
+
        | Attribute,ts -> let q'' = State.mk() in
            (mk_tag_t Left q (TagSet.Xml.attribute) q' ignore)::
              (mk_tag_t Left q' (ts) q'' ignore)::( q==> any @@ (ignore,q))::trs, q''::q'::final,initial
@@ -346,7 +356,8 @@ module Compile = struct
       | Expr e -> match compile_expr e with
          | `True -> `Label (TagSet.Xml.any)
          | `False -> `Label (TagSet.Xml.empty)
-         | e -> `Fun (fun t -> Functions.truth_value (Functions.eval_expr t e))
+         | e -> `Fun (fun t -> let r = Functions.truth_value (Functions.eval_expr t e) 
+                     in Printf.eprintf "Truth value is %b\n%!" r;r)
 
     in match pred_rec p with
        `Fun f -> mk_pred_trs f tkeep tchange