diff options
Diffstat (limited to 'src/semantic_token.rs')
-rw-r--r-- | src/semantic_token.rs | 11 |
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 } } |