26 lines
665 B
Rust
26 lines
665 B
Rust
use core::fmt;
|
|
use std::error::Error;
|
|
|
|
pub type LexingError = crate::error::ErrorLocationWrapper<LexingErrorKind>;
|
|
|
|
#[derive(Debug)]
|
|
pub enum LexingErrorKind {
|
|
UnmatchedQuote,
|
|
IntPrimitiveTooBig,
|
|
UnexpectedCharacter(char),
|
|
}
|
|
|
|
impl fmt::Display for LexingErrorKind {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match *self {
|
|
LexingErrorKind::UnmatchedQuote => write!(f, "Unmatched \" character"),
|
|
LexingErrorKind::UnexpectedCharacter(c) => write!(f, "Unexpected character {c}"),
|
|
LexingErrorKind::IntPrimitiveTooBig => {
|
|
write!(f, "Integer too large. Max value is i32_max({})", i32::MAX)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for LexingErrorKind {}
|