package reparse

  1. Overview
  2. Docs

Overview

Parser provides functions and types to construct robust, performant and reusable parsers. At the core is a type Reparse.PARSER.t which represents a constructed parser definition. A parser Reparse.PARSER.t is defined by composing together one or more parsers or Reparse.ts via usage of parser operators.

An instance of Reparse.PARSER.t represents an un-evaluated parser. Use Reparse.PARSER.parse function to evaluate it.

Reparse.INPUT represents a generalization of data input to Reparse.parse. Implement the interface to create new input types.

Parser functions are broadly organized into following categories:

  • Monadic parsers
  • Char/String parsers
  • Alternate parsers
  • Boolean parsers
  • Repetition parsers
  • RFC 5234 parsers
  • Others
module type PARSER = sig ... end
module type PROMISE = sig ... end
module type INPUT = sig ... end

Buffered Input

module type BUFFERED_INPUT = sig ... end
module Make_buffered_input (Promise : PROMISE) (Input : BUFFERED_INPUT with type 'a promise = 'a Promise.t) : INPUT with type 'a promise = 'a Promise.t with type input = Input.t

Makes a buffered INPUT module. Buffered input provide backtracking functionality in Reparse for those input that doesn't support random seeking, for eg. Unix socket descriptors, Lwt input channels, Lwt streams, etc.

Unbuffered Input

module type UNBUFFERED_INPUT = sig ... end
module Make_unbuffered_input (Promise : PROMISE) (Input : UNBUFFERED_INPUT with type 'a promise = 'a Promise.t) : INPUT with type 'a promise = 'a Promise.t with type input = Input.t

Makes a unbuffered INPUT module. Unbuffered input doesn't buffer any input since it natively supports random access and thus backtracking functionality is in-built to the input itself.

Make a parser

module Make (Promise : PROMISE) (Input : INPUT with type 'a promise = 'a Promise.t) : PARSER with type 'a promise = 'a Input.promise with type input = Input.t

A functor to create parsers based on the given Promise and Input module.

String Parser

module String : sig ... end