Crate abnf_to_pest
source · [−]Expand description
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
Allow control over some of the pest properties of the outputted rule
Functions
Escape the rule name to be a valid Rust identifier.
Parse an abnf file. Returns a map of rules.