package comby-kernel
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
md5=ee6556d8bd9b25ed0445ebe23862e48a
    
    
  sha512=e6386c8ce5ef14bbcab2b0ead5b1edc39375438f56330d5f02e81e467afe6623a7e299f97f26008d77bbc62850c6dc63a7cbe5b81671b5183ff3adeee5946bb3
    
    
  doc/comby-kernel.vangstrom/Vangstrom/Buffered/index.html
Module Vangstrom.BufferedSource
Buffered parsing interface.
Parsers run through this module perform internal buffering of input. The parser state will keep track of unconsumed input and attempt to minimize memory allocation and copying. The Buffered.state.Partial parser state will accept newly-read, incremental input and copy it into the internal buffer. Users can feed parser states using the feed function. As a result, the interface is much easier to use than the one exposed by the Unbuffered module.
On success or failure, any unconsumed input will be returned to the user for additional processing. The buffer that the unconsumed input is returned in can also be reused.
type 'a state = | Partial of [ input | `Eof ] -> 'a state(*The parser requires more input.
*)| Done of unconsumed * 'a(*The parser succeeded.
*)| Fail of unconsumed * string list * string(*The parser failed.
*)
parse ?initial_buffer_size t runs t and awaits input if needed. parse will allocate a buffer of size initial_buffer_size (defaulting to 4k bytes) to do input buffering and automatically grows the buffer as needed.
feed state input supplies the parser state with more input. If state is Partial, then parsing will continue where it left off. Otherwise, the parser is in a Fail or Done state, in which case the input will be copied into the state's buffer for later use by the caller.
state_to_option state returns Some v if the parser is in the Done (bs, v) state and None otherwise. This function has no effect on the current state of the parser.
state_to_result state returns Ok v if the parser is in the Done (bs, v) state and Error msg if it is in the Fail or Partial state.
This function has no effect on the current state of the parser.
state_to_unconsumed state returns Some bs if state = Done(bs, _) or state = Fail(bs, _, _) and None otherwise.