From 16114b2ca358dbbef09cb5a8d3a843a0e11a3b88 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 9 Oct 2024 15:41:30 +0200 Subject: Adapt the assembler to the changes on the parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of 184c39579227 ("Re-work the parser from scratch") the parser has a proper AST, and the assembler has to traverse it accordingly. Moreover, the assembler has been stripped from a lot of unneeded memory allocations and it's overall more keen on using mere references when possible. Signed-off-by: Miquel Sabaté Solà --- crates/nasm/src/main.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'crates/nasm') diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs index 52de035..fbe2bef 100644 --- a/crates/nasm/src/main.rs +++ b/crates/nasm/src/main.rs @@ -62,10 +62,19 @@ fn main() -> Result<()> { // output.write_all("\n".as_bytes())?; // } } else { - let bundles = assembler.assemble(input)?; - for b in bundles { - for i in 0..b.size { - output.write_all(&[b.bytes[i as usize]])?; + match assembler.assemble(input) { + Ok(bundles) => { + for b in bundles { + for i in 0..b.size { + output.write_all(&[b.bytes[i as usize]])?; + } + } + } + Err(errors) => { + for err in errors { + println!("{}", err); + } + std::process::exit(1); } } } -- cgit v1.2.3