tokeniser: add some actual tokeniser errors
TODO: Return these lol
This commit is contained in:
@@ -1,12 +1,33 @@
|
||||
//! This module contains the error types for the tokeniser.
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum TokeniserError {}
|
||||
/// Types of errors that may be returned during tokenisation.
|
||||
pub enum TokeniserError {
|
||||
/// An unexpected character was found in the source code.
|
||||
UnexpectedChar(char),
|
||||
/// An unterminated string literal was found. [`SourceInfo`] will be attached if this
|
||||
/// was returned.
|
||||
UnterminatedString,
|
||||
/// An invalid number format was encountered when parsing a literal value
|
||||
/// ([`TokenType::Immediate`]).
|
||||
InvalidNumber(&'static str),
|
||||
/// An unrecognized token was encountered.
|
||||
UnrecognisedToken,
|
||||
}
|
||||
|
||||
impl TokeniserError {}
|
||||
|
||||
impl std::fmt::Display for TokeniserError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "TODO!!!!!!")
|
||||
match self {
|
||||
Self::UnexpectedChar(c) => write!(f, "unexpected char '{c}' found in input")?,
|
||||
Self::InvalidNumber(lit) => {
|
||||
write!(f, "invalid integer literal \"{lit}\" found in input")?;
|
||||
}
|
||||
&Self::UnrecognisedToken => write!(f, "unrecognised token found in input")?,
|
||||
&Self::UnterminatedString => write!(f, "unterminated string literal")?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user