From 36f4d31fb204386db280ebc2544f5b4db6926706 Mon Sep 17 00:00:00 2001 From: Erin Date: Fri, 9 Jun 2023 18:35:34 +0200 Subject: [PATCH] sus --- hbasm/src/lib.rs | 4 ++-- hbasm/src/main.rs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hbasm/src/lib.rs b/hbasm/src/lib.rs index 0cb18d86..81eddc85 100644 --- a/hbasm/src/lib.rs +++ b/hbasm/src/lib.rs @@ -69,8 +69,8 @@ pub enum ErrorKind { #[derive(Clone, Debug, PartialEq, Eq)] pub struct Error { - kind: ErrorKind, - span: Span, + pub kind: ErrorKind, + pub span: Span, } impl Display for Error { diff --git a/hbasm/src/main.rs b/hbasm/src/main.rs index bdb6a7a7..6eae52fd 100644 --- a/hbasm/src/main.rs +++ b/hbasm/src/main.rs @@ -8,7 +8,14 @@ fn main() -> Result<(), Box> { stdin().read_to_string(&mut code)?; let mut buf = vec![]; - hbasm::assembly(&code, &mut buf)?; + if let Err(e) = hbasm::assembly(&code, &mut buf) { + eprintln!( + "Error {:?} at {:?} (`{}`)", + e.kind, + e.span.clone(), + &code[e.span], + ); + } stdout().write_all(&buf)?; Ok(()) }