package reparse

  1. Overview
  2. Docs

Module Reparse.Make_unbuffered_inputSource

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.

Parameters

module Promise : PROMISE
module Input : UNBUFFERED_INPUT with type 'a promise = 'a Promise.t

Signature

Sourcetype t

Represents the input.

Sourcetype 'a promise = 'a Promise.t

Represents an input promise.

Sourcetype input = Input.t
Sourceval create : input -> t
Sourceval trim_buffer : t -> pos:int -> unit promise

trim_buffer t ~pos removes data from the input buffer up till pos.

Note After the input buffer is trimmed the parser is unable to backtrack to pos less than pos.

Sourceval get_char : t -> pos:int -> [ `Char of char | `Eof ] promise
Sourceval get_char_unbuffered : t -> pos:int -> [ `Char of char | `Eof ] promise
Sourceval get_cstruct : t -> pos:int -> len:int -> [ `Cstruct of Cstruct.t | `Eof ] promise

get t ~pos ~len returns `String s where String.length s <= len or `Eof if EOI is reached.

Sourceval get_cstruct_unbuffered : t -> pos:int -> len:int -> [ `Cstruct of Cstruct.t | `Eof ] promise
Sourceval last_trimmed_pos : t -> int promise
Sourceval buffer_size : t -> int option promise