19 releases (12 breaking)

0.13.0 Oct 21, 2022
0.12.0 Jul 16, 2021
0.11.3 Apr 14, 2021
0.10.0 Feb 22, 2021
0.2.0 Jul 1, 2019

#207 in Parser implementations

Download history 4358/week @ 2022-08-03 3188/week @ 2022-08-10 3056/week @ 2022-08-17 3567/week @ 2022-08-24 2585/week @ 2022-08-31 2476/week @ 2022-09-07 3271/week @ 2022-09-14 4212/week @ 2022-09-21 2921/week @ 2022-09-28 3061/week @ 2022-10-05 3277/week @ 2022-10-12 3514/week @ 2022-10-19 3266/week @ 2022-10-26 3037/week @ 2022-11-02 3196/week @ 2022-11-09 2642/week @ 2022-11-16

13,028 downloads per month
Used in 12 crates (via abnf_to_pest)

MIT/Apache

47KB
946 lines

CI Scheduled docs

ABNF

A parser for ABNF based on nom 7.

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

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1MB
~17K SLoC