refactor(CommandParseError): remove the display implementation
we want to be able to give additional arguments to the display function later, so this is needed
This commit is contained in:
parent
b8ed0868cb
commit
55b4779964
4 changed files with 33 additions and 11 deletions
|
|
@ -67,12 +67,30 @@ pub enum ScanErrorKind {
|
|||
UnknownMetaCommand(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ScanErrorKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
ScanErrorKind::UnexpectedChar(c) => write!(f, "unexpected char: {c:?}"),
|
||||
ScanErrorKind::UnexpectedEndOfInput => write!(f, "unexpected end of input"),
|
||||
ScanErrorKind::UnknownKeyword(x) => write!(f, "unknown keyword: {x:?}"),
|
||||
ScanErrorKind::UnknownMetaCommand(x) => write!(f, "unknown meta-command: {x:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct ScanError {
|
||||
pub location: Location,
|
||||
pub kind: ScanErrorKind,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ScanError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let kind = &self.kind;
|
||||
write!(f, "{kind}")
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizer {
|
||||
fn new(input: String, file: String) -> Self {
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue