peg 0.8.6

A simple Parsing Expression Grammar (PEG) parser generator.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use peg::parser;

parser! {
    grammar byteparser() for [u8] {
        pub rule commands() -> Vec<&'input[u8]> = command()*
        rule command() -> &'input [u8] = ">" val:$([b' ' ..= b'~']+) [0] { val }
    }
}

#[test]
fn main() {
    assert_eq!(
        byteparser::commands(b">asdf\0>xyz\0"),
        Ok(vec![&b"asdf"[..], &b"xyz"[..]])
    );
}