6 releases
Uses new Rust 2024
| 0.3.0 | Jan 9, 2026 |
|---|---|
| 0.2.3 | May 8, 2025 |
| 0.2.2 | Aug 25, 2024 |
| 0.2.1 | Jul 20, 2024 |
| 0.1.0 | Jul 4, 2024 |
#2557 in Parser implementations
23,325 downloads per month
Used in 5 crates
(via pretty_yaml)
83KB
2.5K
SLoC
Semi-tolerant YAML concrete syntax tree parser.
Usage
let code = "";
match yaml_parser::parse(code) {
Ok(tree) => println!("{tree:#?}"),
Err(err) => eprintln!("{err}"),
};
It produces rowan tree if succeeded. For consuming the tree, see rowan's docs.
To build AST from CST:
use rowan::ast::AstNode;
use yaml_parser::{ast::Root, parse};
let code = "";
let tree = parse(code).unwrap();
let ast = Root::cast(tree);
assert!(matches!(ast, Some(Root { .. })));
yaml_parser
Semi-tolerant YAML concrete syntax tree parser.
Usage
match yaml_parser::parse(&code) {
Ok(tree) => println!("{tree:#?}"),
Err(err) => eprintln!("{err}"),
};
It produces rowan tree if succeeded. For consuming the tree, see rowan's docs.
If you need to build AST from CST, use ast module:
use rowan::ast::AstNode;
let root = yaml_parser::ast::Root::cast(tree).unwrap();
dbg!(root);
Tests
Tests come from official test suite.
License
MIT License
Copyright (c) 2024-present Pig Fang
Dependencies
~2MB
~40K SLoC