package earley

  1. Overview
  2. Docs

A small module for efficient regular expressions.

type regexp =
  1. | Chr of char
  2. | Set of Charset.t
  3. | Seq of regexp list
  4. | Alt of regexp list
  5. | Opt of regexp
  6. | Str of regexp
  7. | Pls of regexp
  8. | Sav of regexp * string ref

Type of a regular expression.

exception Regexp_error of Input.buffer * int

Exception that is raised when a regexp cannot be read.

val print_regexp : out_channel -> regexp -> unit
val accept_empty : regexp -> bool
val accepted_first_chars : regexp -> Charset.t
val regexp_from_string : string -> regexp * string ref array
val read_regexp : regexp -> Input.buffer -> int -> Input.buffer * int

read_regexp re buf pos attempts to parse using the buffer buf at position pos using the regular expression re. The return value is a triple of the parsed string, the buffer after parsing and the position after parsing. The exception Regexp_error(err_buf, err_pos is raised in case of failure at the given position.

OCaml

Innovation. Community. Security.