Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file selector.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194moduleStable=structopenCore_kernel.Core_kernel_stableopenSexplib.TypemoduleDate_selector=structmoduleV1=structtypet=|GTofDate.V1.t|LTofDate.V1.t|BetweenofDate.V1.t*Date.V1.t|OnofDate.V1.t[@@derivingbin_io,compare,sexp]lett_of_sexpsexp=letmoduleDate=Core_kernel.Dateinmatchsexpwith|Atom_asd->On(Date.t_of_sexpd)|List[Atom">";Atom_asd]->GT(Date.t_of_sexpd)|List[Atom">=";Atom_asd]->GT(Date.add_days(Date.t_of_sexpd)(-1))|List[Atom"<";Atom_asd]->LT(Date.t_of_sexpd)|List[Atom"<=";Atom_asd]->LT(Date.add_days(Date.t_of_sexpd)(1))|List[Atom_asd1;Atom"><";Atom_asd2]|List[Atom"><";Atom_asd1;Atom_asd2]|List[Atom_asd1;Atom_asd2]->(* The basic cases (GT, LT etc.) are being matched here, since
they are lists of two atoms. Here the check whether the first
atom is a date is done with try-with. *)begintryBetween((Date.t_of_sexpd1),(Date.t_of_sexpd2))with_->t_of_sexpsexpend|_->t_of_sexpsexpendmoduleCurrent=V1endmoduleString_selector=structmoduleRegexp=structmoduleV1=structmoduleT=struct(* This type is stable in spite of using the Re2's non-stable type because
bin_io and sexp conversion functions are explicitly defined below. *)typet=string*Re.reletto_string(s,_)=sletof_regexps=s,Re.Perl.compile_patsletof_strings=of_regexpsletcomparet1t2=String.V1.compare(to_stringt1)(to_stringt2)endincludeTincludeBinable.Of_stringable.V1(T)lett_of_sexpsexp=letopenCore_kernelinletopenPolyinletfail()=of_sexp_error"expected string bounded with / on both sides"sexpinmatchsexpwith|List_->of_sexp_error"expected Atom"sexp|Atoms->ifString.lengths<2thenfail()elseifs.[0]='/'&&s.[String.lengths-1]='/'thenlets=String.subs~pos:1~len:(String.lengths-2)inof_regexpselsefail()letsexp_of_t(s,_)=Sexp.V1.Atom("/"^s^"/")endmoduleCurrent=V1endmoduleV1=structtypet=|Equalofstringlist|MatchesofRegexp.V1.tlist|Mixedof[`RegexpofRegexp.V1.t|`Literalofstring]list[@@derivingbin_io,compare,sexp]lett_of_sexpsexp=letparse_atoma=matchawith|List_->assertfalse|Atoms->ifCore_kernel.(letopenPolyinString.lengths>=1&&s.[0]='/')then`Regexp(Regexp.V1.t_of_sexpa)else`Literalsintrymatchsexpwith|Atom_asa->beginmatchparse_atomawith|`Regexpr->Matches[r]|`Literals->Equal[s]end|Listl->Mixed(Core_kernel.List.mapl~f:(funsexp->matchsexpwith|List_->Core_kernel.of_sexp_error"expected Atom"sexp|Atom_asa->parse_atoma))with|e->tryt_of_sexpsexpwith_->raiseeendmoduleCurrent=V1endmoduleString_list_selector=structmoduleV1=structtypet=stringlist[@@derivingbin_io,sexp]lett_of_sexpsexp=matchsexpwith|Sexp.V1.Atoms->[s]|_->t_of_sexpsexpendmoduleCurrent=V1endendopenCore_kernelopenPolymoduletypeSelector=sigtypeselectortypevaluevaleval:selector->value->boolendmoduleDate_selector=structincludeStable.Date_selector.Currenttypeselector=ttypevalue=Date.tletevaltd=matchtwith|GTgtd->Date.(>)dgtd|LTltd->Date.(<)dltd|Between(d1,d2)->Date.(>=)dd1&&Date.(<=)dd2|Onond->Date.(=)dondendmoduleString_selector=structmoduleRegexp:sigtypet=Stable.String_selector.Regexp.Current.t[@@derivingbin_io,sexp]valof_regexp:string->tvalto_string:t->stringvalmatches:t->string->boolvalto_regexp:t->Re.reend=structincludeStable.String_selector.Regexp.Currentletto_regexp(_,p)=pletmatches(_,rex)s=Re.execprexsendincludeStable.String_selector.Currenttypeselector=ttypevalue=String.tletevalts=matchtwith|Equalel->Option.is_some(List.findel~f:(fune->e=s))|Matchesml->Option.is_some(List.findml~f:(funrex->Regexp.matchesrexs))|Mixedml->Option.is_some(List.findml~f:(function|`Regexprex->Regexp.matchesrexs|`Literall->l=s))endmoduleString_list_selector=structincludeStable.String_list_selector.Currenttypeselector=ttypevalue=stringletevalts=matchList.findt~f:(funm->m=s)with|None->false|Some_->trueend