[][src]Crate abnf_to_pest

A tiny crate that helps convert ABNF grammars to pest.

Example usage:

let abnf_path = "src/grammar.abnf";
let pest_path = "src/grammar.pest";

let mut file = File::open(abnf_path)?;
let mut data = Vec::new();
file.read_to_end(&mut data)?;
data.push('\n' as u8);

let mut rules = abnf_to_pest::parse_abnf(&data)?;
rules.remove("some_inconvenient_rule");

let mut file = File::create(pest_path)?;
writeln!(&mut file, "{}", render_rules_to_pest(rules).pretty(80))?;

Structs

Alternation
Concatenation
PestyRule

Allow control over some of the pest properties of the outputted rule

Repeat
Repetition

Enums

Element
Range

Functions

escape_rulename

Escape the rule name to be a valid Rust identifier.

parse_abnf

Parse an abnf file. Returns a map of rules.

render_rules_to_pest