- match ctx.stack with
- [ root ] ->
- root.next_sibling <- nil;
- { root = root;
- size = ctx.current_preorder
- }
- | _ -> raise (Expat.Expat_error Expat.UNCLOSED_TOKEN)
+ Expat.final psr;
+ let root = List.hd ctx.stack in
+ root.next_sibling <- nil;
+ let a = Array.make ctx.current_preorder nil in
+ let rec loop n =
+ if n != nil then
+ begin
+ n.summary <-
+ Tree.NodeSummary.make
+ (n == n.parent.first_child)
+ (n == n.parent.next_sibling)
+ (n.first_child != nil)
+ (n.next_sibling != nil)
+ (Tree.NodeSummary.kind n.summary);
+ a.(n.preorder) <- n;
+ loop n.first_child;
+ loop n.next_sibling;
+ end
+ in
+ loop root;
+ { root = root;
+ size = ctx.current_preorder;
+ by_preorder = a
+ }