Legend:
Library
Module
Module type
Parameter
Class
Class type
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.
val parse : ?initial_buffer_size:int ->?input:input->'at->'astate
parse ?initial_buffer_size ?input t runs t on input, if present, 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. If input is a bigstring, its contents will be copied into the parser's internal buffer, leaving ownership with the caller.
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 (bs, 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.