12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273(* Result of a successful match. *)typet={s:string;marks:Automata.mark_infos;pmarks:Pmark.Set.t;gpos:intarray;gcount:int}letoffsetti=if2*i+1>=Array.lengtht.marksthenraiseNot_found;letm1=t.marks.(2*i)inifm1=-1thenraiseNot_found;letp1=t.gpos.(m1)-1inletp2=t.gpos.(t.marks.(2*i+1))-1in(p1,p2)letgetti=let(p1,p2)=offsettiinString.subt.sp1(p2-p1)letstartsubsi=fst(offsetsubsi)letstopsubsi=snd(offsetsubsi)lettestti=if2*i>=Array.lengtht.marksthenfalseelseletidx=t.marks.(2*i)inidx<>-1letdummy_offset=(-1,-1)letall_offsett=letres=Array.maket.gcountdummy_offsetinfori=0toArray.lengtht.marks/2-1doletm1=t.marks.(2*i)inifm1<>-1thenbeginletp1=t.gpos.(m1)inletp2=t.gpos.(t.marks.(2*i+1))inres.(i)<-(p1-1,p2-1)enddone;resletdummy_string=""letallt=letres=Array.maket.gcountdummy_stringinfori=0toArray.lengtht.marks/2-1doletm1=t.marks.(2*i)inifm1<>-1thenbeginletp1=t.gpos.(m1)inletp2=t.gpos.(t.marks.(2*i+1))inres.(i)<-String.subt.s(p1-1)(p2-p1)enddone;resletppfmtt=letmatches=letoffsets=all_offsettinletstrs=alltinArray.to_list(Array.init(Array.lengthstrs)(funi->strs.(i),offsets.(i)))inletopenFmtinletpp_matchfmt(str,(start,stop))=fprintffmt"@[(%s (%d %d))@]"strstartstopinsexpfmt"Group"(listpp_match)matchesletnb_groupst=t.gcount