use thiserror::Error;
#[derive(Debug, Error, Clone)]
pub enum GrammarError {
#[error("grammar parse error at position {pos}: {msg}")]
ParseError {
pos: usize,
msg: String,
},
#[error("grammar reached a stuck state — no valid next tokens")]
Stuck,
#[error("unknown rule reference: '{rule}'")]
UnknownRule {
rule: String,
},
#[error(
"grammar recursion depth limit exceeded (possible infinite recursion in rule '{rule}')"
)]
RecursionLimit {
rule: String,
},
}
pub type GrammarResult<T> = Result<T, GrammarError>;