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.
val state_to_option : 'a state -> 'a optionstate_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.
val state_to_result : 'a state -> ('a, string) Stdlib.resultstate_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.
val state_to_unconsumed : _ state -> unconsumed optionstate_to_unconsumed state returns Some bs if state = Done(bs, _) or state = Fail(bs, _, _) and None otherwise.