X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=xPath.ml;fp=xPath.ml;h=661863d677524d227f5c65dc8ea58feb8b1ee879;hb=280fbebb046069cea454507fa7933b4330bff1eb;hp=727c25e425c1853be28c1dc19de1a0a4363a8117;hpb=3623eefccfb5fc69e19ad975a3669f51a2a8b276;p=SXSI%2Fxpathcomp.git diff --git a/xPath.ml b/xPath.ml index 727c25e..661863d 100644 --- 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