let get_annots annot_string trees ~left ~right pos_start pos_end =
let rec iter trees pos =
match
try Some (Str.search_forward annot_re annot_string pos)
with Not_found -> None
with
None -> List.rev trees
| Some pos ->
match pos_end with
Some p when p < pos -> trees
| _ ->
let start = Str.group_beginning 2 in
let stop = Str.group_end 2 in
let newp = Str.match_end () in
let kind = annot_kind_of_string
~start ~stop annot_string
(Str.matched_group 1 annot_string)
in
let new_trees = add_node trees ~left ~right ~kind in
iter new_trees newp
in
iter trees pos_start