let build_tree annot_string =
let locs = cut_by_locations annot_string in
let rec iter trees = function
[] -> trees
| [(_,stop,left,right)] ->
get_annots annot_string trees ~left ~right stop None
| (_,pos_start,left,right)::(((pos_end,_,_,_) :: _) as q) ->
let t = get_annots annot_string
trees ~left ~right pos_start (Some pos_end)
in
iter t q
in
match iter [] locs with
[t] -> Some t
| [] -> None
| l ->
let t = {
t_pos_left = (List.hd l).t_pos_left ;
t_pos_right = (List.hd (List.rev l)).t_pos_right ;
t_kind = None ;
t_children = l;
}
in
Some t