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

#321 in Parser tooling

Download history 1/week @ 2024-10-28 5/week @ 2024-11-04 14/week @ 2024-11-18 20/week @ 2024-12-09 7/week @ 2024-12-30 1/week @ 2025-01-06

57 downloads per month

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