summaryrefslogtreecommitdiff
path: root/src/stages/semantic_tokens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/stages/semantic_tokens.rs')
-rw-r--r--src/stages/semantic_tokens.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/stages/semantic_tokens.rs b/src/stages/semantic_tokens.rs
index fe49c26..c735828 100644
--- a/src/stages/semantic_tokens.rs
+++ b/src/stages/semantic_tokens.rs
@@ -1,10 +1,10 @@
use crate::*;
-use std::collections::HashMap;
+use indexmap::IndexMap;
pub struct Program {
- pub definitions: HashMap<String, Tracked<Definition>>,
+ pub definitions: IndexMap<String, Tracked<Definition>>,
pub tokens: Vec<Tracked<SemanticToken>>,
}
@@ -49,6 +49,7 @@ pub enum SemanticToken {
pub enum SemanticError {
InvocationBeforeDefinition,
+ ReservedIdentifier(String),
}
@@ -64,12 +65,14 @@ fn report_semantic_error(error: &Tracked<SemanticError>, source_code: &str) {
let message = match &error.value {
SemanticError::InvocationBeforeDefinition =>
"Macro cannot be invoked before it has been defined",
+ SemanticError::ReservedIdentifier(name) =>
+ &format!("Identifier '{name}' is reserved for a built-in instruction"),
};
report_source_issue(LogLevel::Error, &context, message);
}
-pub fn print_semantic_token(i: usize, token: &SemanticToken, definitions: &HashMap<String, Tracked<Definition>>) {
+pub fn print_semantic_token(i: usize, token: &SemanticToken, definitions: &IndexMap<String, Tracked<Definition>>) {
match token {
SemanticToken::Literal(value) => indent!(i, "Literal({value})"),
SemanticToken::Pad(value) => indent!(i, "Pad({value})"),