Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file parser_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146openCoremoduletypeS=sig(** A value of type ['a t] is a regex that parses ['a]s.
The matching is implemented using Re2.
UTF-8 is supported by Re2 but not by this module. This is because we want to use
[char] as a character type, but that's just wrong in a multibyte encoding. *)type'at[@@derivingsexp_of](** [case_sensitive] defaults to [true]. *)valcompile:?case_sensitive:bool->'at->(string->'aoption)Staged.tvalrun:?case_sensitive:bool->'at->string->'aoptionvalmatches:?case_sensitive:bool->'at->string->bool(** [to_regex_string] and [to_re2] both forget what a ['a t] knows
about turning the matching strings into ['a]s *)valto_regex_string:_t->stringvalto_re2:?case_sensitive:bool->_t->Regex.t(** The applicative interface provides sequencing, e.g. [both a b] is a regex that
parses an [a] followed by a [b] and returns both results in a pair. *)includeApplicative.Swithtype'at:='at(** [of_re2 r] forgets the options that [r] was compiled with, instead using
[`Encoding_latin1 true], [`Dot_nl true], and the case-sensitivity setting of the
overall pattern. You can still try and use '(?flags:re)' Re2 syntax to set options
for the scope of this regex.
The returned values are precisely the captures of the underlying regex, in order:
note that unlike (say) [Re2.Match.get_all], the whole match is *not* included (if
you want that, just use [capture]). Named captures are not accessible by name. *)valof_re2:Regex.t->stringoptionarrayt(** [ignore_m t] is a regex which matches the same strings that [t] matches, but doesn't
call functions on the captured submatches. Particularly, something like [ignore (map
(string "x") ~f:Int.of_string)] won't raise an exception, because the int conversion
is never attempted. *)valignore_m:_t->unitt(** [capture t] returns the string matched by [t] *)valcapture:unitt->stringt(** [and_capture t] returns the string matched by [t] in addition to whatever it was
already going to return. *)valand_capture:'at->('a*string)t(** Regex that matches nothing *)valfail:'atvalor_:'atlist->'at(** [greedy] defaults to true. If false, the regexp will prefer not matching. *)valoptional:?greedy:bool->'at->'aoptiont(** [repeat ~min ~max t] constructs the regex [t{min,max}]. [min] defaults to [0] and
[max] defaults to [None] (unbounded), so that just plain [repeat t] is equivalent
to [t*].
It would be better for [repeat] to be ['a t -> 'a list t], but the re2 library
doesn't give you access to repeated submatches like that. Hence, [repeat] ignores
all submatches of its argument and does not call any callbacks that may have been
attached to them, as if it had [ignore] called on its result. *)valrepeat:?greedy:bool->?min:int->?max:intoption->unitt->unitt(** [times r n] essentially constructs the regex [r{n}]. It is equivalent to
[repeat ~min:n ~max:(Some n) r].
Compare with, say, [all (List.init n ~f:(fun _ -> r))], which constructs the regex
rrr...r (with n copies of r) and has the type ['a t -> 'a list t]. *)valtimes:unitt->int->unittvalstring:string->unittvalany_string:stringt(** Matches empty string at the beginning of the text *)valstart_of_input:unitt(** Matches empty string at the end of the text *)valend_of_input:unittmoduleChar:sig(** [any], unlike "." by default, matches newline.
(However, note that [of_re2 (Re2.create_exn ".")] will match newline. See the
comment on [of_re2] for more information.)
*)valany:chart(** Duplicates in the lists given to [one_of] and [not_one_of] are ignored. *)valone_of:charlist->chartvalnot_one_of:charlist->chart(** The following 6 values match the Re2 character classes with the same name. *)(** A character matching [Char.is_uppercase] *)valupper:chart(** A character matching [Char.is_lowercase] *)vallower:chart(** A character matching [Char.is_alpha] *)valalpha:chart(** A character matching [Char.is_digit] *)valdigit:chart(** A character matching [Char.is_alphanum] *)valalnum:chart(** A character matching [Char.is_whitespace] *)valspace:chartendmoduleDecimal:sigvaldigit:intt(** optional sign symbol:
"+" or "" mean 1
"-" means -1
*)valsign:inttvalunsigned:inttvalint:inttendendmoduletypeParser=sigtype'atmoduleOpen_on_rhs_intf:sigmoduletypeS=Swithtype'at='atendincludeApplicative.Let_syntaxwithtype'at:='atwithmoduleOpen_on_rhs_intf:=Open_on_rhs_intfincludeOpen_on_rhs_intf.Swithtype'at:='atend