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.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stages/semantic_tokens.rs b/src/stages/semantic_tokens.rs
index a873df0..7aa6093 100644
--- a/src/stages/semantic_tokens.rs
+++ b/src/stages/semantic_tokens.rs
@@ -6,12 +6,14 @@ pub enum SemanticToken {
BlockToken(BlockToken),
}
+#[derive(Clone)]
pub struct MacroDefinition {
pub name: Tracked<String>,
pub arguments: Vec<Tracked<ArgumentDefinition>>,
pub body: MacroDefinitionBody,
}
+#[derive(Clone)]
pub struct ArgumentDefinition {
pub name: String,
pub variant: ArgumentType,
@@ -34,6 +36,7 @@ impl std::fmt::Display for ArgumentType {
}
}
+#[derive(Clone)]
pub enum MacroDefinitionBody {
Integer(Tracked<IntegerToken>),
Block(Vec<Tracked<BlockToken>>),
@@ -41,21 +44,25 @@ pub enum MacroDefinitionBody {
Invocation(Tracked<Invocation>),
}
+#[derive(Clone)]
pub struct ConditionalBlock {
pub predicate: Tracked<IntegerToken>,
pub body: Tracked<BlockToken>,
}
+#[derive(Clone)]
pub enum IntegerToken {
IntegerLiteral(isize),
Expression(Expression),
Invocation(Invocation),
}
+#[derive(Clone)]
pub struct Expression {
pub tokens: Vec<Tracked<ExpressionToken>>,
}
+#[derive(Clone)]
pub enum ExpressionToken {
IntegerToken(Box<IntegerToken>),
ListToken(ListToken),
@@ -63,6 +70,7 @@ pub enum ExpressionToken {
Operator(Operator),
}
+#[derive(Clone)]
pub enum BlockToken {
LabelDefinition(String),
PinnedAddress(Tracked<IntegerToken>),
@@ -72,17 +80,20 @@ pub enum BlockToken {
Invocation(Invocation),
}
+#[derive(Clone)]
pub enum ListToken {
StringLiteral(StringLiteral),
ListLiteral(Vec<Tracked<IntegerToken>>),
Invocation(Invocation),
}
+#[derive(Clone)]
pub struct Invocation {
pub name: String,
pub arguments: Vec<Tracked<InvocationArgument>>,
}
+#[derive(Clone)]
pub enum InvocationArgument {
IntegerToken(IntegerToken),
BlockToken(BlockToken),
@@ -137,6 +148,7 @@ pub enum SemanticError {
InvalidArgumentDefinition,
InvalidInvocationArgument,
+ InvalidBlockInExpression,
GlobalLabelInMacroDefinition,
LocalLabelWithoutNamespace,
@@ -202,6 +214,8 @@ fn report_semantic_error(error: &Tracked<SemanticError>, source_code: &str) {
"Argument definition must take one of the following forms: name, {name}, \"name\", or [name]",
SemanticError::InvalidInvocationArgument =>
"This token cannot be used in an invocation argument",
+ SemanticError::InvalidBlockInExpression =>
+ "Expression cannot contain a block token",
SemanticError::GlobalLabelInMacroDefinition =>
&format!("Macro definition cannot contain a global label"),