Bcfg_streamFully streaming, SAX-like API for bcfg.
This module lets one process a configuration as a flat sequence of lexemes, both for decoding (reading) and encoding (writing), without ever materialising the whole Bcfg_type.t tree. The memory footprint is bounded by the nesting depth of the configuration, not by the size of the input.
type lexeme = Bcfg_type.Stream.lexeme = val pp_lexeme : Format.formatter -> lexeme -> unittype error = [ | `Lexer_error of
Bcfg_txtloc.t * [ `Invalid_character of char | `Message of string ]| `Parser_error of Bcfg_txtloc.t * string ]val pp_error : Format.formatter -> error -> unitPretty-printer for error values.
val decoder : Lexing.lexbuf -> decoderdecoder lexbuf creates a streaming decoder pulling tokens from lexbuf. Using Lexing.from_channel keeps the input bounded.
decode d returns the next lexeme. Ok None signals the end of the configuration; Error _ a lexing or structural error, after which the decoder must not be used anymore.
val to_seq : Lexing.lexbuf -> (lexeme, error) result Seq.tto_seq lexbuf is the lazy sequence of all lexemes (or the first error) pulled from lexbuf.
val encode :
?cfg:Bcfg_out.cfg ->
(unit -> lexeme option) ->
(string -> unit) ->
unitencode ?cfg next sink pulls lexemes from next and pushes the rendered chunks to sink, producing the same output as Bcfg.emitter would on the equivalent tree.
val to_string : ?cfg:Bcfg_out.cfg -> lexeme Seq.t -> string Seq.tto_string ?cfg seq is the lazy sequence of rendered chunks for seq.
val of_t : Bcfg_type.t -> lexeme Seq.tof_t t is the lexeme sequence equivalent to the tree t.
val to_t : lexeme Seq.t -> (Bcfg_type.t, error) resultto_t seq rebuilds the tree from a lexeme sequence.
val to_directives : Lexing.lexbuf -> (Bcfg_type.directive, error) result Seq.tto_directives lexbuf yields the top-level directives one at a time, rebuilt from the lexeme stream. Only a single top-level subtree is held in memory at a time, so a whole (large) document is never materialised.