From 00fbfb4ac3db258d2cc544d0561d186276d6039b Mon Sep 17 00:00:00 2001 From: darcy Date: Wed, 4 Dec 2024 22:12:55 +1100 Subject: [PATCH] feat: use better error handling for `eval` --- src/parser.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 6e2645d..4f11c0f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -89,8 +89,7 @@ fn preprocess_simple(src: &'static str) -> Result> { let token = cur.advance_real()?; match token.kind { TokenKind::Dir(_) => { - // TODO(feat): Handle error - panic!("unexpected directive"); + return Err(error::parse_generic_unexpected(src, "instruction", token)); } TokenKind::Byte(_) => unreachable!("Found byte in stream"), @@ -236,8 +235,7 @@ impl AsmParser { pub fn parse_simple(&mut self) -> Result { let Some(tok) = self.toks.next() else { - // TODO(feat): Handle error - panic!("unexpected eof"); + return Err(error::parse_eof(self.src)); }; match tok.kind {