projects
/
SXSI
/
xpathcomp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Eta expand (land) and (lor) to fun a b -> a land b
[SXSI/xpathcomp.git]
/
tree.ml
diff --git
a/tree.ml
b/tree.ml
index
0c1f10b
..
8ebcdcc
100644
(file)
--- a/
tree.ml
+++ b/
tree.ml
@@
-52,7
+52,7
@@
struct
module Text =
struct
module Text =
struct
- type t (* pointer to the text collection *)
+
(* Todo *)
external nullt : unit -> [`Text ] node = "caml_xml_tree_nullt"
let nil = nullt ()
(* Todo *)
external nullt : unit -> [`Text ] node = "caml_xml_tree_nullt"
let nil = nullt ()
@@
-98,8
+98,6
@@
struct
external tag : t -> [`Tree ] node -> Tag.t = "caml_xml_tree_tag"
external tag_id : t -> [`Tree ] node -> unit = "caml_xml_tree_tag_id"
external tag : t -> [`Tree ] node -> Tag.t = "caml_xml_tree_tag"
external tag_id : t -> [`Tree ] node -> unit = "caml_xml_tree_tag_id"
- external text_collection : t -> Text.t = "caml_xml_tree_text_collection"
-
let is_last t n = equal nil (next_sibling t n)
external prev_text : t -> [`Tree] node -> [`Text ] node = "caml_xml_tree_prev_text"
let is_last t n = equal nil (next_sibling t n)
external prev_text : t -> [`Tree] node -> [`Text ] node = "caml_xml_tree_prev_text"
@@
-113,7
+111,6
@@
struct
external is_ancestor : t -> [`Tree ] node -> [`Tree ] node -> bool = "caml_xml_tree_is_ancestor"
let print_skel t =
external is_ancestor : t -> [`Tree ] node -> [`Tree ] node -> bool = "caml_xml_tree_is_ancestor"
let print_skel t =
- let textcol = text_collection t in
let rec aux id =
if (is_nil id)
then Printf.eprintf "#\n"
let rec aux id =
if (is_nil id)
then Printf.eprintf "#\n"
@@
-124,11
+121,11
@@
struct
(Tag.to_string (tag t id))
(node_xml_id t id)
(int_of_node (prev_text t id))
(Tag.to_string (tag t id))
(node_xml_id t id)
(int_of_node (prev_text t id))
- (Text.get_text t
extcol
(prev_text t id))
+ (Text.get_text t (prev_text t id))
(int_of_node (my_text t id))
(int_of_node (my_text t id))
- (Text.get_text t
extcol
(my_text t id))
+ (Text.get_text t (my_text t id))
(int_of_node (next_text t id))
(int_of_node (next_text t id))
- (Text.get_text t
extcol
(next_text t id));
+ (Text.get_text t (next_text t id));
aux(first_child t id);
aux(next_sibling t id);
end
aux(first_child t id);
aux(next_sibling t id);
end
@@
-136,17
+133,16
@@
struct
aux (root t)
let traversal t =
aux (root t)
let traversal t =
- let textcol = text_collection t in
let rec aux id =
if not (is_nil id)
then
begin
(* ignore (tag t id);
let rec aux id =
if not (is_nil id)
then
begin
(* ignore (tag t id);
- ignore (Text.get_text t
extcol
(prev_text t id));
+ ignore (Text.get_text t (prev_text t id));
if (is_leaf t id)
if (is_leaf t id)
- then ignore (Text.get_text t
extcol
(my_text t id));
+ then ignore (Text.get_text t (my_text t id));
if (is_last t id)
if (is_last t id)
- then ignore (Text.get_text t
extcol
(next_text t id)); *)
+ then ignore (Text.get_text t (next_text t id)); *)
aux (first_child t id);
aux (next_sibling t id);
end
aux (first_child t id);
aux (next_sibling t id);
end
@@
-168,8
+164,7
@@
struct
type doc = t
type doc = t
- type t = { doc : doc;
- text : Text.t;
+ type t = { doc : doc;
node : descr }
let dump { doc=t } = Tree.print_skel t
node : descr }
let dump { doc=t } = Tree.print_skel t
@@
-179,7
+174,6
@@
struct
open Tree
let node_of_t t = { doc= t;
open Tree
let node_of_t t = { doc= t;
- text = text_collection t;
node = Node(NC (root t)) }
node = Node(NC (root t)) }
@@
-201,7
+195,7
@@
struct
let equal a b = (compare a b) == 0
let string t = match t.node with
let equal a b = (compare a b) == 0
let string t = match t.node with
- | String i -> Text.get_text t.
text
i
+ | String i -> Text.get_text t.
doc
i
| _ -> assert false
let norm (n : [`Tree ] node ) = if is_nil n then Nil else Node (NC n)
| _ -> assert false
let norm (n : [`Tree ] node ) = if is_nil n then Nil else Node (NC n)
@@
-231,13
+225,13
@@
struct
match n.node with
| Node (NC t) when is_leaf n.doc t ->
let txt = my_text n.doc t in
match n.node with
| Node (NC t) when is_leaf n.doc t ->
let txt = my_text n.doc t in
- if Text.is_empty n.
text
txt
+ if Text.is_empty n.
doc
txt
then Nil
else Node(SC (txt,Tree.nil))
| Node (NC t) ->
let fs = first_child n.doc t in
let txt = prev_text n.doc fs in
then Nil
else Node(SC (txt,Tree.nil))
| Node (NC t) ->
let fs = first_child n.doc t in
let txt = prev_text n.doc fs in
- if Text.is_empty n.
text
txt
+ if Text.is_empty n.
doc
txt
then norm fs
else Node (SC (txt, fs))
| Node(SC (i,_)) -> String i
then norm fs
else Node (SC (txt, fs))
| Node(SC (i,_)) -> String i
@@
-253,7
+247,7
@@
struct
| Node(NC t) ->
let ns = next_sibling n.doc t in
let txt = next_text n.doc t in
| Node(NC t) ->
let ns = next_sibling n.doc t in
let txt = next_text n.doc t in
- if Text.is_empty n.
text
txt
+ if Text.is_empty n.
doc
txt
then norm ns
else Node (SC (txt, ns))
| Nil | String _ -> failwith "next_sibling"
then norm ns
else Node (SC (txt, ns))
| Nil | String _ -> failwith "next_sibling"
@@
-287,7
+281,7
@@
struct
| _ -> false
let contains t s =
| _ -> false
let contains t s =
- Array.fold_left (fun a i -> DocIdSet.add i a) DocIdSet.empty (Text.contains t.
text
s)
+ Array.fold_left (fun a i -> DocIdSet.add i a) DocIdSet.empty (Text.contains t.
doc
s)
let contains_old t s =
let regexp = Str.regexp_string s in
let contains_old t s =
let regexp = Str.regexp_string s in
@@
-367,7
+361,7
@@
struct
let rec aux n =
match n.node with
| Nil -> ()
let rec aux n =
match n.node with
| Nil -> ()
- | String i -> () (*ignore(Text.get_text t.
text
i) *)
+ | String i -> () (*ignore(Text.get_text t.
doc
i) *)
| Node(_) ->
(* tag_id n; *)
aux (first_child n);
| Node(_) ->
(* tag_id n; *)
aux (first_child n);
@@
-438,13
+432,13
@@
module DEBUGTREE
match n.node with
| Node (NC t) when is_leaf_ n.doc t ->
let txt = my_text_ n.doc t in
match n.node with
| Node (NC t) when is_leaf_ n.doc t ->
let txt = my_text_ n.doc t in
- if is_empty_ n.
text
txt
+ if is_empty_ n.
doc
txt
then Nil
else Node(SC (txt,XML.Tree.nil))
| Node (NC t) ->
let fs = first_child_ n.doc t in
let txt = prev_text_ n.doc fs in
then Nil
else Node(SC (txt,XML.Tree.nil))
| Node (NC t) ->
let fs = first_child_ n.doc t in
let txt = prev_text_ n.doc fs in
- if is_empty_ n.
text
txt
+ if is_empty_ n.
doc
txt
then norm fs
else Node (SC (txt, fs))
| Node(SC (i,_)) -> String i
then norm fs
else Node (SC (txt, fs))
| Node(SC (i,_)) -> String i
@@
-459,8
+453,12
@@
module DEBUGTREE
| Node (SC (_,ns)) -> norm ns
| Node(NC t) ->
let ns = next_sibling_ n.doc t in
| Node (SC (_,ns)) -> norm ns
| Node(NC t) ->
let ns = next_sibling_ n.doc t in
- let txt = next_text_ n.doc t in
- if is_empty_ n.text txt
+ let txt =
+ if XML.Tree.is_nil ns then
+ next_text_ n.doc t
+ else prev_text_ n.doc ns
+ in
+ if is_empty_ n.doc txt
then norm ns
else Node (SC (txt, ns))
| Nil | String _ -> failwith "next_sibling"
then norm ns
else Node (SC (txt, ns))
| Nil | String _ -> failwith "next_sibling"
@@
-472,7
+470,6
@@
module DEBUGTREE
| { doc=d; node=Node(SC (i,_) )} -> text_xml_id_ d i
| _ -> failwith "id"
| { doc=d; node=Node(SC (i,_) )} -> text_xml_id_ d i
| _ -> failwith "id"
-
(* Wrapper around critical function *)
let string t = time ("TextCollection.GetText()") (string) t
let left = first_child
(* Wrapper around critical function *)
let string t = time ("TextCollection.GetText()") (string) t
let left = first_child
@@
-564,4
+561,3
@@
module DEBUGTREE
end
module Binary = DEBUGTREE
end
module Binary = DEBUGTREE
-