Expand description
A helper that will parse using the pest grammar
Examples found in repository?
src/lib.rs (line 62)
59 60 61 62 63 64 65 66 67 68 69 70 71
pub fn parse_and_optimize(
grammar: &str,
) -> Result<UsedBuiltinAndOptimized<'_>, Vec<Error<parser::Rule>>> {
let pairs = match parser::parse(parser::Rule::grammar_rules, grammar) {
Ok(pairs) => Ok(pairs),
Err(error) => Err(vec![error]),
}?;
let defaults = validator::validate_pairs(pairs.clone())?;
let ast = parser::consume_rules(pairs)?;
Ok((defaults, optimizer::optimize(ast)))
}