KmolYuan / yaml-peg-rs

A YAML 1.2 parser using a greedy parsing algorithm with PEG atoms. Support anchors, directives, positions, tags, serde, and no-std.
https://crates.io/crates/yaml-peg
MIT License
16 stars 4 forks source link
parser rust yaml

yaml-peg

dependency status documentation

A YAML 1.2 parser using a greedy parsing algorithm with PEG atoms. Support anchors, directives, positions, tags, serde, and no-std.

Inspired from yaml-rust and serde-yaml.

This parser is not ensure about YAML spec but almost functions are well-implemented. The buffer reader has also not yet been implemented, but the chunks can be read by the sub-parsers.

The anchors can be visited by the loader after parsing.

use yaml_peg::{parse, node};

let doc = "
---
name: Bob
married: true
age: 46
";
let root = parse(doc).unwrap();
assert_eq!(root, vec![node!({
    "name" => "Bob",
    "married" => true,
    "age" => 46,
})]);

See the API doc for more information.

Features