yamleam/parser

YAML parser — block-style only.

Consumes the List(Line) produced by the lexer and constructs a YamlNode tree. Recursive descent with indent-column tracking.

Three families of blocks:

The interesting case is - key: value opening an inline mapping inside a sequence item. The parser tracks the column where the mapping’s first key sits and treats subsequent lines at that column as continuations of the same mapping until indent drops or a dash reappears at the sequence’s indent level.

Anchors are threaded explicitly as a state parameter (Anchors) through every parser function. A fresh table is created at the start of each document and accumulated as &name declarations are encountered; alias lookups (*name) read from the table at the site of use. Nothing escapes the parser.

Values

pub fn parse(
  lines: List(token.Line),
) -> Result(node.YamlNode, error.YamlError)

Top-level entry: parse a list of lexer lines into a single YamlNode tree. If the source contains multiple documents (more than one non-empty segment separated by ---/...), returns a ParseError. Use parse_all if you need every document in a stream.

pub fn parse_all(
  lines: List(token.Line),
) -> Result(List(node.YamlNode), error.YamlError)

Parse all documents in a YAML stream, splitting on --- / ... markers. Returns one YamlNode per non-empty document. Empty documents (between consecutive markers) are skipped.

Search Document