Module Pacomb.RegexpSource

A small module for efficient regular expressions.

Sourcetype regexp =
  1. | Chr of char
    (*

    Single character.

    *)
  2. | Set of Charset.t
    (*

    Any character in a charset.

    *)
  3. | Not of Charset.t
    (*

    fail if character is in charset

    *)
  4. | Seq of regexp list
    (*

    Sequence of regular expressions.

    *)
  5. | Alt of regexp list
    (*

    Alternative between regexps.

    *)
  6. | Opt of regexp
    (*

    Optional regexp.

    *)
  7. | Str of regexp
    (*

    Zero or more times the regexp.

    *)
  8. | Pls of regexp
    (*

    One or more times the regexp.

    *)
  9. | Sav of regexp
    (*

    Save the matching string.

    *)

Type of a regular expression.

Sourcetype t = regexp

Short synonym of regexp.

Sourceval pp : Format.formatter -> regexp -> unit

pp ff re outputs the regexp re to the formatter ff.

Sourceval accepts_empty : regexp -> bool

accepts_empty re tells whether the empty input is valid for re.

Sourceval accepted_first_chars : regexp -> Charset.t

accepted_first_chars re returns the set of characters that are possible, valid first characters for matching re.

Sourceexception Regexp_error of Input.buffer * Input.idx

Exception raised when a regexp does not match. Note that the given buffer and position correspond to the first character that cannot be matched.

Sourceval from_string : string -> regexp

from_string s convert a string into a regexp following Str syntax.

Sourceval regexp : ?name:string -> regexp -> string Lex.t

create a terminal from a regexp. Returns the whole matched string

Sourceval regexp_grps : ?name:string -> ?grps:int list -> regexp -> string list Lex.t

create a terminal from a regexp. Returns the groups list, last to finish to be parsed is first in the result. The optional argument grps allows selection of the produced groups. As usual, 0 means the whole regexp and n > 0 the sub string corresponding to the nth opening parenthesis.

Sourceval blank_regexp : string -> Blank.t

create a blank function from a string representing a regexp