use lalrpop_util::ErrorRecovery; use crate::bnf::{Syntax, Rule, Expression, List, Term}; grammar<'env>(errors: &'env mut Vec, &'static str>>); extern { type Location = usize; type Error = &'static str; } pub Syntax: Syntax = { => Syntax::from_rule(<>), => Syntax::from_rule(head).with_more(tail), }; Rule: Rule = { ";"* "<" ">" "::=" ";" => Rule::new(lhs, rhs), }; Expression: Expression = { => Expression::from_list(<>), "|" => Expression::from_list(head).with_more(tail), }; List: List = { => List::from_term(<>), => List::from_term(head).with_more(tail), }; Term: Term = { => Term::new_literal(<>).unwrap(), "<" ">" => Term::new_rule_name(<>), }; Literal: String = r#""([^\\"]|\\")+""# => <>.to_owned(); RuleName: String = r#"[A-Za-z][A-Za-z0-9-]*"# => <>.to_owned();