use crate::lexer::spanned_token::Span;
#[derive(Debug, Clone, PartialEq)]
pub struct ParserError {
pub message: String,
pub span: Span,
}
impl ParserError {
pub fn new(message: impl Into<String>, span: Span) -> Self {
Self {
message: message.into(),
span,
}
}
}
impl std::fmt::Display for ParserError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Parse error: {} at line {}, col {}",
self.message, self.span.line, self.span.column
)
}
}
impl std::error::Error for ParserError {}