A YAML 1.2 parser using greedy parsing algorithm with PEG atoms. Support anchor visitor 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 sub-parsers.
```rust use yaml_peg::{parse, node};
name: Bob married: true age: 46 "; let (n, anchors) = parse(doc).unwrap(); asserteq!(anchors.len(), 0); asserteq!(n, vec![node!({ "name" => "Bob", "married" => true, "age" => 46, })]); ```
See the API doc for more information.
#![no_std]
.Rc
/ Arc
provides parallel visiting and less copy cost.YAML
and TAG
are allowed.
```yaml
% YAML 1.2
% TAG !x! tag:my.prefix:
+ Support [`serde`](https://github.com/serde-rs/serde) to help you serialize and deserialize a specific type.
rust
use serde::Deserialize;
use yamlpeg::serialize::fromstr;
#[derive(Deserialize)] struct Member { name: String, married: bool, age: u8, }
let doc = "
name: Bob
married: true
age: 46
";
// Return Vec.remove(0)
to get the first one
let officer = fromstr::