abnf

Crates.ioabnf
lib.rsabnf
version0.13.0
sourcesrc
created_at2019-04-15 10:32:45.127549
updated_at2022-10-21 14:57:05.873546
descriptionA nom-based parser for ABNF.
homepage
repositoryhttps://github.com/duesee/abnf
max_upload_size
id128084
size93,889
Damian Poddebniak (duesee)

documentation

README

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.

Commit count: 135

cargo fmt