From 587dd5bb80364688419bb43aba4afc044ac0ef48 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 17 May 2024 07:39:05 +0200 Subject: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A lot is missing and there is a long road ahead to make the assembler even work. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/errors.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/xixanta/src/errors.rs (limited to 'lib/xixanta/src/errors.rs') diff --git a/lib/xixanta/src/errors.rs b/lib/xixanta/src/errors.rs new file mode 100644 index 0000000..48f7286 --- /dev/null +++ b/lib/xixanta/src/errors.rs @@ -0,0 +1,25 @@ +use std::fmt; + +#[derive(Debug, Clone, PartialEq)] +pub struct ParseError { + pub line: usize, + pub message: String, +} + +impl std::error::Error for ParseError {} + +impl From for ParseError { + fn from(err: std::io::Error) -> Self { + // TODO + ParseError { + line: 0, + message: err.to_string(), + } + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "parser (line {}): {}.", self.line + 1, self.message) + } +} -- cgit v1.2.3