Skip to main content

Module yaml

Module yaml 

Source
Expand description

In-tree YAML parser. Produces a lossless, Panache-compatible CST that the host parser embeds directly into the document tree (frontmatter and hashpipe option bodies) and that the in-tree YAML formatter consumes.

  • supports plain YAML and hashpipe-prefixed YAML from shared parsing primitives (see parse_stream / parse_stream_with_prefix),
  • preserves lossless syntax/trivia needed for exact host document ranges,
  • backs first-class YAML formatting via crate::syntax::yaml_ast.

Modules§

diagnostic_codes

Structs§

YamlDiagnostic
YamlParseReport

Functions§

locate_yaml_diagnostic
Locate a structural YAML diagnostic in input (raw, possibly prefix-marked), returning the diagnostic plus the byte range within input it covers (start, end). An empty prefix is plain YAML with identity offsets. Returns None when input is valid — the verdict matches validate_yaml_with_prefix. The host parser adds the region’s document start to emit a host-ranged SyntaxError for malformed embedded YAML.
parse_stream
Drive the scanner over input and build a CST. Always returns a SyntaxNode — the scanner is permissive and the builder preserves bytes regardless of well-formedness.
parse_stream_with_prefix
Like parse_stream, but treats prefix (e.g. hashpipe "#|") as an embedded-YAML per-line marker: the scanner excludes it from column/indent accounting and the builder peels it into YAML_LINE_PREFIX leaves, so the resulting CST’s token ranges are host ranges directly (prefix bytes included as trivia, no offset remapping). An empty prefix behaves like parse_stream.
parse_yaml_report
Parse YAML tree structure and include diagnostics on failure.
parse_yaml_tree
Parse YAML tree structure from input, or None if it fails to parse.
project_events
Walk the YAML CST for input and return the projected yaml-test-suite event stream. Returns an empty vector if the input fails to parse.
project_events_from_tree
Walk a YAML parser CST and return the projected yaml-test-suite event stream. Decoupled from parse_yaml_tree so callers that already hold a tree (e.g. yaml-test-suite parity checks) can reuse the same projection.
validate_yaml_with_prefix
Structural validation for embedded (prefixed) YAML. Strips the per-line prefix to the plain-YAML baseline and runs the standard [super::validator::validate_yaml] pass. The verdict matches the stripped baseline; diagnostic offsets refer to the stripped text (host-offset remapping is a later concern). An empty prefix is plain validation.