1use std::fmt::{ Display, Formatter };
2
3#[derive(Debug, Clone, PartialEq)]
4pub enum LexError {
5 Unrecognized {
6 token: String,
7 line: usize,
8 column: usize,
9 },
10 Eof,
11}
12
13impl Display for LexError {
14 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15 match self {
16 LexError::Unrecognized { token, line, column } =>
17 write!(f, "Unrecognized character '{}' at line {}, column {}", token, line, column),
18 LexError::Eof => write!(f, "End of file"),
19 }
20 }
21}
22
23pub type LexResult = Result<(), LexError>;