boseiju/lexer/error.rs
1/// Errors that can be thrown by the lexer.
2#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3pub enum LexerError {
4 NoTokenMatch { start: usize, end: usize, tokens: String },
5}
6
7impl std::fmt::Display for LexerError {
8 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9 match self {
10 LexerError::NoTokenMatch {
11 start, tokens: message, ..
12 } => {
13 write!(f, "At character {start}, no tokens matched for: \"{message}\"")
14 }
15 }
16 }
17}
18
19impl std::error::Error for LexerError {}