diff --git a/parser/src/scanner.rs b/parser/src/scanner.rs index 470a25d..f78ae89 100644 --- a/parser/src/scanner.rs +++ b/parser/src/scanner.rs @@ -1,5 +1,6 @@ use std::collections::VecDeque; -use std::char; +use std::{char, fmt}; +use std::error::Error; #[derive(Clone, Copy, PartialEq, Debug, Eq)] pub enum TEncoding { @@ -49,6 +50,22 @@ impl ScanError { } } +impl Error for ScanError { + fn description(&self) -> &str { + self.info.as_ref() + } + + fn cause(&self) -> Option<&Error> { + None + } +} + +impl fmt::Display for ScanError { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + self.info.fmt(formatter) + } +} + #[derive(Clone, PartialEq, Debug, Eq)] pub enum TokenType { NoToken,