summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2023-11-26 10:29:55 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2023-11-26 10:33:01 +1300
commit8dfdd603b022ab9775cda08b9c2350d43667ff0f (patch)
tree016f51ecb50af368b37c4eac3c594d1375b7c8c2 /src/main.rs
parentd40c1f01ab3d30ee58ce56a907569c18f5441b17 (diff)
downloadbedrock-asm-8dfdd603b022ab9775cda08b9c2350d43667ff0f.zip
Exit with status 1 on assembly error
This will break unix pipelines in order to prevent any emulator down the pipeline from attempting to run a malassembled program.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index c7d3590..8d6e186 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,11 +12,17 @@ fn main() {
};
let (bytecode, tokens) = assemble(&source_code);
+ let mut is_error = false;
for token in &tokens {
- token.print_error(&source_code); }
+ if token.print_error(&source_code) { is_error = true };
+ }
eprintln!("Assembled program in {} bytes.", bytecode.len());
let bytecode_len = bytecode.len();
+ if is_error {
+ std::process::exit(1)
+ }
+
// Write bytecode to standard output
let mut stdout = std::io::stdout().lock();
match stdout.write(&bytecode) {