zen_expression/lexer/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use thiserror::Error;

#[derive(Debug, PartialEq, Eq, Clone, Error)]
pub enum LexerError {
    #[error("Unexpected symbol: {symbol} at ({}, {})", span.0, span.1)]
    UnexpectedSymbol { symbol: String, span: (u32, u32) },

    #[error("Unmatched symbol: {symbol} at {position}")]
    UnmatchedSymbol { symbol: char, position: u32 },

    #[error("Unexpected EOF: {symbol} at {position}")]
    UnexpectedEof { symbol: char, position: u32 },
}

pub(crate) type LexerResult<T> = Result<T, LexerError>;