Expand description
Typed AST wrappers over the in-tree YAML CST.
These wrappers give value-extraction consumers (metadata, bibliography,
includes, hashpipe) a typed traversal API over the rowan CST produced by
crate::parser::yaml::parse_yaml_tree, replacing the external
yaml_parser crate’s ast module. They follow the house pattern
(super::headings, super::references): newtype wrappers with
hand-written AstNode impls and rowan::ast::support-based accessors.
Two CST facts shape the API:
- YAML parses produce one or more
YAML_DOCUMENTchildren under a stream-equivalent container. Standalone parses (crate::parser::yaml::parse_yaml_tree) root the tree atYAML_STREAM; embedded parses nest the documents directly under the host wrapper (YAML_METADATA_CONTENTfor frontmatter,HASHPIPE_YAML_CONTENTfor hashpipe), which plays the stream role for its singleton-stream embedding.parse_yaml_documentcentralizes the descent so no consumer re-implements it. YAML_BLOCK_MAP_KEYincludes the trailing:(YAML_COLON) token, soYamlBlockMapKey::scalarreads theYAML_SCALARnode child rather than the whole-key text.
Scalar style is not a CST kind — every style is a YAML_SCALAR node
(wrapping YAML_SCALAR_TEXT content) — so YamlScalar detects the
style from the leading byte and cooks via the shared
[crate::parser::yaml::cook] primitives.
Structs§
- Yaml
Block Map - A block mapping (
key: valueentries). - Yaml
Block MapEntry - One
key: valuepair in a block mapping. - Yaml
Block MapKey - The key side of a block-map entry. Holds the
YAML_SCALARnode AND the trailingYAML_COLONtoken. - Yaml
Block MapValue - The value side of a block-map entry: a scalar, a nested container, or empty.
- Yaml
Block Sequence - A block sequence (
- itementries). - Yaml
Block Sequence Item - One
- itemin a block sequence. The leading-is aYAML_BLOCK_SEQ_ENTRYtoken, skipped by the content projections. - Yaml
Document - A single YAML document inside the stream.
- Yaml
Flow Map - A flow mapping (
{k: v, ...}). - Yaml
Flow MapEntry - One
k: vpair in a flow mapping. - Yaml
Flow MapKey - The key side of a flow-map entry.
- Yaml
Flow MapValue - The value side of a flow-map entry.
- Yaml
Flow Sequence - A flow sequence (
[a, b, c]). - Yaml
Flow Sequence Item - One item in a flow sequence.
- Yaml
Scalar - A scalar value node. Its leaves are the per-physical-line content fragments
(
YAML_SCALAR_TEXT) interleaved withNEWLINE(and, for embedded hashpipe, line-prefix) tokens;rawreassembles them.
Enums§
- Yaml
Node - The five concrete node shapes a value, sequence item, or document body can
take.
None(i.e. an absentYamlNode) models an empty YAML value. - Yaml
Scalar Style - The lexical style of a scalar, detected from its raw source. (The CST does
not record style as a distinct kind — every style is a
YAML_SCALARnode.)
Functions§
- parse_
yaml_ document - Parse
inputand return the first YAML document. Descends through any stream-equivalent container ([is_stream_equivalent]) so it works against standalone parses (rooted atYAML_STREAM) and host embeddings alike. ReturnsNonewhen the input fails the structural validator (no tree) or has no document. - parse_
yaml_ documents - Parse
inputand return every YAML document in the stream. Most consumers only need the first (parse_yaml_document); this exists for multi-document completeness (a: 1\n---\nb: 2).