let make ?name ?filename ~next ~on_error () =
let lo_parser = Buffer.make ?filename () in
Biocaml_transform.make ?name ()
~feed:(Buffer.feed_string lo_parser)
~next:(fun stopped ->
match next lo_parser with
| `output (Ok r) -> `output (Ok r)
| `output (Error r) -> `output (Error (on_error (`next r)))
| `not_ready ->
if stopped then (
if Buffer.is_empty lo_parser then
`end_of_stream
else
let l,o = Buffer.contents lo_parser in
`output
(Error (on_error
(`incomplete_input
(Buffer.current_position lo_parser,
(l :> string list), o))))
) else
`not_ready)