4 releases (2 breaking)

0.3.0 May 28, 2022
0.2.1 Apr 25, 2020
0.2.0 Apr 21, 2020
0.1.0 Feb 15, 2020

#202 in Parser tooling

MIT license

32KB
635 lines

memoir

Memoir is a library of self-describing parser-combinators. Parsers are represented as reified objects that can print themselves as documentation. This keeps documentation for command-based languages always up to date with the grammar.

This library is used in rx's command interface.


lib.rs:

Memoir is a library of self-describing, reflective parser-combinators. Parsers are represented as reified objects that can print themselves as documentation.

For most purposes, memoir's prelude should be imported.

use memoir::*;

let parser =
    string("set").then(optional(symbol('!')))
    .then(whitespace())
    .then(either(string("on"), string("off")));

assert_eq!(parser.label, r#""set" ['!'] <whitespace> "on" | "off""#);
assert!(parser.parse("set on").is_ok());

No runtime deps