3 releases

new 0.1.3 Apr 16, 2019
0.1.2 Apr 15, 2019
0.1.1 Apr 15, 2019

#25 in #nom

9 downloads per month
Used in 1 crate

AGPL-3.0

24KB
815 lines

ABNF

A nom-based ABNF parser.

Status

Not thoroughly tested, but works with arguably complex ABNFs.

Branches

There are some experimental branches. The with_generic_node branch uses an enum...

enum Node {
    Alternation(Vec<Node>>),
    Concatenation(Vec<Node>>),
    ...
}

...which may be more suitable when implementing transformations.

The master branch is a direct transformation of RFC 5234 to code.


lib.rs:

use abnf::abnf::rulelist_comp;

// Nom is a streaming parser. Thus, when handling finite input,
// use functions with _comp suffix to avoid `Err::Incomplete`.
let res = rulelist_comp(b"rule = A / B\n\n").unwrap().1;

for rule in &res {
    println!("{}\n", rule);
}

Dependencies

~581KB
~14K SLoC