Module Biocaml_transform.Line_oriented (.ml)

module Line_oriented: sig .. end
A buffering parsing_buffer for line-oriented formats.

type parsing_buffer 
val parsing_buffer : ?filename:string -> unit -> parsing_buffer
Create a "parser"; the optional filename is used only to create error locations.
val feed_line : parsing_buffer -> string -> unit
Feed the parser with a line.
val feed_string : parsing_buffer -> string -> unit
Feed the parser with an arbitrary string buffer.
val queued_lines : parsing_buffer -> int
Get the number of lines ready-to-use in the buffer/queue.
val is_empty : parsing_buffer -> bool
Tell if the parser's buffers are empty or not. For instance, when there is no more content to feed and next_line returns None, is_empty p = true means that the content did not end with a complete line.
val next_line : parsing_buffer -> string option
Get the next line.
exception No_next_line
The exception thrown by next_line_exn.
val next_line_exn : parsing_buffer -> string
Get the next line, but throw No_next_line if there is no line to return.
val current_position : parsing_buffer -> Biocaml_pos.t
Get the current position in the stream.
val contents : parsing_buffer -> string list * string option
Return any remaining lines and the unfinished string, without removing them from the buffer.
val empty : parsing_buffer -> unit
Empty the buffer. Subsequent call to contents will return ([], None).
val make : ?name:string ->
?filename:string ->
next:(parsing_buffer ->
[ `not_ready | `output of ('b, 'errnext) Core.Result.t ]) ->
on_error:([ `incomplete_input of Biocaml_pos.t * string list * string option
| `next of 'errnext ] -> 'err) ->
unit -> (string, ('b, 'err) Core.Result.t) Biocaml_transform.t
Build a stoppable line-oriented parsing_buffer.
val make_merge_error : ?name:string ->
?filename:string ->
next:(parsing_buffer ->
[ `not_ready
| `output of
[> `incomplete_input of
Biocaml_pos.t * string list * string option ]
as 'b)
Core.Result.t ]) ->
unit -> (string, ('a, 'b) Core.Result.t) Biocaml_transform.t
Do like make but merge `incomplete_input _ with the errors of ~next (which must be polymorphic variants).
val lines : unit -> (string, string) Biocaml_transform.t
Return a transform that converts a stream of arbitrary strings to a stream of lines. If the input terminates without a newline, the trailing string is still considered a line.