4 releases

0.2.2 Aug 25, 2024
0.2.1 Jul 20, 2024
0.2.0 Jul 6, 2024
0.1.0 Jul 4, 2024

#1386 in Parser implementations

Download history 1067/week @ 2024-09-27 1874/week @ 2024-10-04 1616/week @ 2024-10-11 1537/week @ 2024-10-18 2117/week @ 2024-10-25 1372/week @ 2024-11-01 1281/week @ 2024-11-08 1249/week @ 2024-11-15 1462/week @ 2024-11-22 5492/week @ 2024-11-29 4944/week @ 2024-12-06 4714/week @ 2024-12-13 2259/week @ 2024-12-20 2011/week @ 2024-12-27 4178/week @ 2025-01-03 3484/week @ 2025-01-10

12,682 downloads per month
Used in 5 crates (via pretty_yaml)

MIT license

84KB
2.5K SLoC

yaml_parser

Crates.io docs.rs

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:

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


lib.rs:

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 yaml_parser::{ast::{AstNode, Root}, parse};

let code = "";
let tree = parse(code).unwrap();
let ast = Root::cast(tree);
assert!(matches!(ast, Some(Root { .. })));

Dependencies

~1.5MB
~30K SLoC