aboutsummaryrefslogtreecommitdiff
path: root/crates/nasm/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-10-09 15:41:30 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:46:17 +0100
commit16114b2ca358dbbef09cb5a8d3a843a0e11a3b88 (patch)
tree49103ed4c0e906128df23c20656d88e4c4d1645e /crates/nasm/src
parentabd9a7679e5da78a51ed5eb488ae081a2bcb2b6c (diff)
downloadtools.nes-16114b2ca358dbbef09cb5a8d3a843a0e11a3b88.tar.gz
tools.nes-16114b2ca358dbbef09cb5a8d3a843a0e11a3b88.zip
Adapt the assembler to the changes on the parser
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à <mikisabate@gmail.com>
Diffstat (limited to 'crates/nasm/src')
-rw-r--r--crates/nasm/src/main.rs17
1 files changed, 13 insertions, 4 deletions
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);
}
}
}