summaryrefslogtreecommitdiff
path: root/src/semantic_token.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/semantic_token.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/semantic_token.rs')
-rw-r--r--src/semantic_token.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/semantic_token.rs b/src/semantic_token.rs
index 3d08b25..77ba892 100644
--- a/src/semantic_token.rs
+++ b/src/semantic_token.rs
@@ -24,11 +24,15 @@ pub struct SemanticToken {
}
impl SemanticToken {
- pub fn print_error(&self, source_code: &str) {
+ /// Returns true if an error was printed.
+ pub fn print_error(&self, source_code: &str) -> bool {
+ let mut is_error = false;
macro_rules! red {()=>{eprint!("\x1b[31m")};}
macro_rules! normal {()=>{eprint!("\x1b[0m")};}
if let SemanticTokenType::Error(token, error) = &self.r#type {
+ is_error = true;
+
red!(); eprint!("[ERROR] "); normal!();
let source = &self.source_location.source;
match error {
@@ -70,11 +74,12 @@ impl SemanticToken {
}
normal!(); eprintln!();
}
- if let SemanticTokenType::MacroDefinition(definition) = &self.r#type {
+ else if let SemanticTokenType::MacroDefinition(definition) = &self.r#type {
for token in &definition.body_tokens {
- token.print_error(source_code);
+ if token.print_error(source_code) { is_error = true }
}
}
+ is_error
}
}