12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152(*
* zed_re.ml
* ---------
* Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
* Licence : BSD3
*
* This file is a part of Zed, an editor engine.
*)openCamomileLibraryDyn.CamomilemoduleRe=URe.Make(Zed_rope.Text)typet=Re.compiled_regexptypematch_result=(Zed_rope.Zip.t*Zed_rope.Zip.t)optionarrayoptionletcompile=Re.compileletconvert_successarr=Array.map(function|Somesub->let_rope,zip1,zip2=Re.SubText.contextsubinSome(zip1,zip2)|None->None)arrletconvert=function|Somearr->Some(convert_successarr)|None->Noneletregexp_match?semregexpropeidx=convert(Re.regexp_match?semregexprope(Zed_rope.Zip.make_fropeidx))letsearch_forward?semregexpropeidx=convert(tryRe.search_forward?semregexprope(Zed_rope.Zip.make_fropeidx)withNot_found->None)letsearch_backward?semregexpropeidx=letrecloopzip=matchRe.regexp_match?semregexpropezipwith|Somearr->Some(convert_successarr)|None->ifZed_rope.Zip.at_boszipthenNoneelseloop(Zed_rope.Zip.move(-1)zip)inloop(Zed_rope.Zip.make_fropeidx)