package yaml

  1. Overview
  2. Docs

Module Yaml.StreamSource

Low-level event streaming interface for parsing and emitting YAML files.

This module has a:

  • Stream.parser, which takes an input stream of bytes and produces a sequence of parsing events.
  • Stream.emitter, which takes a sequence of events and produces a stream of bytes.

The processes of parsing and presenting are inverse to each other. Any sequence of events produced by parsing a well-formed YAML document should be acceptable by the Emitter, which should produce an equivalent document. Similarly, any document produced by emitting a sequence of events should be acceptable for the Parser, which should produce an equivalent sequence of events.

Sourcemodule Mark : sig ... end

Position information for an event

Sourcemodule Event : sig ... end

Definition of an individual event during a processing stream

Parsing functions

Sourcetype parser

parser tracks the state of generating Event.t values.

Sourceval parser : string -> (parser, [> Rresult.R.msg ]) Result.result

parser () will allocate a fresh parser state.

Sourceval do_parse : parser -> (Event.t * Event.pos) res

do_parse parser will generate the next parsing event from an initialised parser.

Serialisation functions

Sourcetype emitter

emitter tracks the state of generating Event.t values for YAML output.

Sourceval emitter : ?len:int -> unit -> emitter res

emitter ?len () will allocate a new emitter state. Due to a temporary limitation in the implementation, len decides how large the fixed size buffer that the output is written into is. In the future, len will be redundant as the buffer will be dynamically allocated.

Sourceval emitter_buf : emitter -> Bytes.t
Sourceval emit : emitter -> Event.t -> unit res
Sourceval document_start : ?implicit:bool -> emitter -> unit res
Sourceval document_end : ?implicit:bool -> emitter -> unit res
Sourceval scalar : scalar -> emitter -> unit res
Sourceval alias : emitter -> string -> unit res
Sourceval stream_start : emitter -> encoding -> unit res
Sourceval stream_end : emitter -> unit res
Sourceval sequence_start : ?anchor:string -> ?tag:string -> ?implicit:bool -> ?style:layout_style -> emitter -> unit res
Sourceval sequence_end : emitter -> unit res
Sourceval mapping_start : ?anchor:string -> ?tag:string -> ?implicit:bool -> ?style:layout_style -> emitter -> unit res
Sourceval mapping_end : emitter -> unit res
Sourceval emitter_written : emitter -> int
Sourceval get_version : unit -> int * int * int

library_version () returns the major, minor and patch version of the underlying libYAML implementation.

OCaml

Innovation. Community. Security.