Skip to content

Package io.github.qishr.cascara.lang.yaml.processor

Class YamlParser

java.lang.Object
        io.github.qishr.cascara.lang.yaml.processor.AbstractYamlProcessor<io.github.qishr.cascara.lang.yaml.processor.YamlParser>
                io.github.qishr.cascara.lang.yaml.processor.YamlParser

All Implemented Interfaces:
    Parser<YamlNode, YamlToken>


public class YamlParser
extends AbstractYamlProcessor<YamlParser>

A recursive descent parser that transforms a stream of YamlTokens into a YamlNode AST.This parser is designed for high-fidelity AST construction, meaning it preserves comments, indentation styles, and quote styles for round-tripping.

Core Responsibilities

  • Structural Validation: Enforces strict column alignment for map keys and sequence items.
  • Trivia Management: Buffers comments using pendingComments and attaches them to the next appropriate data node (Scalar, Map, or Sequence).
  • Indentation Lifecycle: Manages block boundaries by consuming INDENT and DEDENT tokens through the parseValue dispatcher.

Constructor Summary

Constructor Description
YamlParser() Default constructor for SPI

Method Summary

Modifier and Type Method Description
protected YamlParser self()
public YamlNode parse(String text) Entry point for parsing a full YAML source string.
public YamlNode parse(List<YamlToken> tokens)

Methods inherited from AbstractYamlProcessor

setReporter, getContentType, setOptions, getServiceProperties

Method Details

self

protected YamlParser self()


parse

public YamlNode parse(String text)

Entry point for parsing a full YAML source string.

Parameters:

text - The raw YAML source.

Returns:

A YamlNode representing the root of the AST.

Specified By:

Parser


parse

public YamlNode parse(List<YamlToken> tokens)

Specified By:

Parser