17 releases (10 breaking)

0.11.3 Apr 14, 2021
0.10.0 Feb 22, 2021
0.9.0 Mar 21, 2020
0.6.1 Dec 31, 2019
0.2.0 Jul 1, 2019

#66 in Parser implementations

Download history 339/week @ 2021-02-21 239/week @ 2021-02-28 262/week @ 2021-03-07 167/week @ 2021-03-14 456/week @ 2021-03-21 755/week @ 2021-03-28 1063/week @ 2021-04-04 880/week @ 2021-04-11 723/week @ 2021-04-18 648/week @ 2021-04-25 556/week @ 2021-05-02 454/week @ 2021-05-09 589/week @ 2021-05-16 371/week @ 2021-05-23 446/week @ 2021-05-30 529/week @ 2021-06-06

2,261 downloads per month
Used in 6 crates (via abnf_to_pest)

MIT/Apache

42KB
832 lines

ABNF

A parser for ABNF based on nom 6.

Example

The following code

use abnf::rulelist;

// Note: mind the trailing newline!
match rulelist("a = b / c\nc = *(d e)\n") {
    Ok(rules) => println!("{:#?}", rules),
    Err(error) => eprintln!("{}", error),
}

outputs

[
    Rule {
        name: "a",
        node: Alternatives(
            [
                Rulename(
                    "b",
                ),
                Rulename(
                    "c",
                ),
            ],
        ),
        kind: Basic,
    },
    Rule {
        name: "c",
        node: Repetition {
            repeat: Variable {
                min: None,
                max: None,
            },
            node: Group(
                Concatenation(
                    [
                        Rulename(
                            "d",
                        ),
                        Rulename(
                            "e",
                        ),
                    ],
                ),
            ),
        },
        kind: Basic,
    },
]

You can also use the provided example to parse and Debug-print any ABNF file.

cargo run --example=example examples/assets/abnf.abnf

License

This crate is dual-licensed under Apache 2.0 and MIT terms.

Dependencies

~2MB
~36K SLoC