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

#722 in Parser implementations

Download history 9270/week @ 2024-08-13 9191/week @ 2024-08-20 8860/week @ 2024-08-27 8253/week @ 2024-09-03 8375/week @ 2024-09-10 7027/week @ 2024-09-17 8928/week @ 2024-09-24 9358/week @ 2024-10-01 9110/week @ 2024-10-08 8869/week @ 2024-10-15 11318/week @ 2024-10-22 10218/week @ 2024-10-29 10295/week @ 2024-11-05 9982/week @ 2024-11-12 8697/week @ 2024-11-19 5841/week @ 2024-11-26

36,474 downloads per month
Used in 94 crates (2 directly)

MIT/Apache

48KB
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
~19K SLoC