wiki:LibYAML

Version 1 (modified by xi, 8 years ago) (diff)

--

LibYAML

LibYAML is a YAML 1.1 parser and emitter written in C. It's in an early stage of development.

Scope

LibYAML covers presenting and parsing processes (see  http://yaml.org/spec/cvs/current.html#id859458). Thus LibYAML defines the following two processors:

  • Parser, which takes an input stream of bytes and produces a sequence of parsing events.
  • 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.

The job of resolving implicit tags, composing and serializing representation trees, as well as constructing and representing native objects is left to applications and bindings. Although some of these processes may be covered in the latter releases, they are not in the scope of the initial release of LibYAML.

Events

The Parser produces while the Emitter accepts the following types of events:

  • STREAM-START
  • STREAM-END
  • DOCUMENT-START
  • DOCUMENT-END
  • ALIAS
  • SCALAR
  • SEQUENCE-START
  • SEQUENCE-END
  • MAPPING-START
  • MAPPING-END

A valid sequence of events should obey the grammar:

stream ::= STREAM-START document* STREAM-END
document ::= DOCUMENT-START node DOCUMENT-END
node ::= ALIAS | SCALAR | sequence | mapping
sequence ::= SEQUENCE-START node* SEQUENCE-END
mapping ::= MAPPING-START (node node)* MAPPING-END