Expand description
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 Display
ed 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
This module contains error related structs.
This module contains a collection of all types in the ABNF crate.
The types can also be used to manually construct new rules.