[][src]Crate abnf

A crate for parsing ABNF definitions (RFC5234)

Two functions are exposed for now, rulelist and rule. They cover the use case, where the complete ABNF definition is provided as a string.

On success, both functions return Ok(...) with the parsed object. If the ABNF definition contains a syntax error, both functions return Err(ParsingError). ParsingError is intended to be Displayed to a user and should help correcting mistakes in the provided ABNF definition.

It is also possible to create rules manually as showed in the example in the types module.

Example

use abnf::rulelist;

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

Modules

error

This module contains error related structs.

types

This module contains a collection of all types in the ABNF crate. The types can also be used to manually construct new rules.

Functions

rule

Parses a single ABNF rule. Returns Ok(Rule) when everything went well and Err(ParsingError) in case of syntax errors.

rulelist

Parses a list of multiple ABNF rules. Returns Ok(Vec<Rule>) when everything went well and Err(ParsingError) in case of syntax errors.