Skip to main content

Crate oxc_yaml_parser

Crate oxc_yaml_parser 

Source
Expand description

oxc-yaml-parser is a YAML 1.2 parser that produces a comment-preserving, span-faithful typed AST, designed for building formatters.

§Basic Usage

use oxc_yaml_parser::{Allocator, Parser};

let allocator = Allocator::default();
let parser = Parser::new(&allocator, "key: value # comment");
match parser.parse() {
    Ok(root) => {
        assert_eq!(root.children.len(), 1);
        assert_eq!(root.comments.len(), 1);
    }
    Err(error) => {
        // Syntax error with span; no partial AST is produced.
        println!("{error}");
    }
}

Modules§

ast
AST node definitions.

Structs§

Allocator
A bump-allocated memory arena.
Error
Parser
Span
Span represents a range of a piece of source code. It counts by byte offset, so it’s 0-based.

Enums§

ErrorKind