package angstrom-lwt-unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val parse : ?pushback:(unit -> unit Lwt.t) -> 'a Angstrom.t -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * ('a, string) result) Lwt.t
val parse_many : 'a Angstrom.t -> ('a -> unit Lwt.t) -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * (unit, string) result) Lwt.t
val with_buffered_parse_state : ?pushback:(unit -> unit Lwt.t) -> 'a Angstrom.Buffered.state -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * ('a, string) result) Lwt.t

Useful for resuming a parse that returns unconsumed data. Construct a Buffered.state by using Buffered.parse and provide it into this function. This is essentially what parse_many does, so consider using that if you don't require fine-grained control over how many times you want the parser to succeed.

Usage example:

parse parser in_channel >>= fun (unconsumed, result) ->
match result with
| Ok a ->
  let { buf; off; len } = unconsumed in
  let state = Buffered.parse parser in
  let state = Buffered.feed state (`Bigstring (Bigstringaf.sub ~off ~len buf)) in
  with_buffered_parse_state state in_channel
| Error err -> failwith err
OCaml

Innovation. Community. Security.