peg 0.8.5

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

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

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