let last_child t n = tree_last_child t.doc n
-
external tree_next_sibling : tree -> [`Tree] Node.t -> [`Tree] Node.t = "caml_xml_tree_next_sibling" "noalloc"
let next_sibling t n = tree_next_sibling t.doc n
external tree_flush : tree -> Unix.file_descr -> unit = "caml_xml_tree_flush"
let flush t fd = tree_flush t.doc fd
-external text_prefix : tree -> string -> query_result = "caml_text_collection_prefix_bv"
-let text_prefix t s = text_prefix t.doc s
+external text_prefix : tree -> string -> bool -> query_result = "caml_text_collection_prefix_bv"
+let text_prefix t s b = text_prefix t.doc s b
-external text_suffix : tree -> string -> query_result = "caml_text_collection_suffix_bv"
-let text_suffix t s = text_suffix t.doc s
+external text_suffix : tree -> string -> bool -> query_result = "caml_text_collection_suffix_bv"
+let text_suffix t s b = text_suffix t.doc s b
-external text_equals : tree -> string -> query_result = "caml_text_collection_equals_bv"
-let text_equals t s = text_equals t.doc s
+external text_equals : tree -> string -> bool -> query_result = "caml_text_collection_equals_bv"
+let text_equals t s b = text_equals t.doc s b
-external text_contains : tree -> string -> query_result = "caml_text_collection_contains_bv"
-let text_contains t s = text_contains t.doc s
+external text_contains : tree -> string -> bool -> query_result = "caml_text_collection_contains_bv"
+let text_contains t s b = text_contains t.doc s b
module Predicate = Hcons.Make (
let _pred_cache = Hashtbl.create 17
;;
let mk_pred query s =
- let f = query_fun query in
+ let f = query_fun query in
let memo = ref (fun _ _ -> failwith "Undefined") in
memo := begin fun tree node ->
let results =
Not_found ->
time ~count:1 ~msg:(Printf.sprintf "Computing text query %s(%s)"
(string_of_query query) s)
- (f tree) s
+ (f tree) s true
in
let bv = results.bv in
memo := begin fun _ n ->
Predicate.make memo
-let full_text_prefix t s = (text_prefix t s).pos
+let full_text_prefix t s = (text_prefix t s true).pos
-let full_text_suffix t s = (text_suffix t s).pos
+let full_text_suffix t s = (text_suffix t s true).pos
-let full_text_equals t s = (text_equals t s).pos
+let full_text_equals t s = (text_equals t s true).pos
-let full_text_contains t s = (text_contains t s).pos
+let full_text_contains t s = (text_contains t s true).pos
let full_text_query q t s =
- let res = (query_fun q) t s in
+ let res = (query_fun q) t s true in
Hashtbl.replace _pred_cache (q,s) res;
res.pos