From 2b4e522b12a7eb87e91cd1cdc56064ee429a5212 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 11 Feb 2025 14:00:20 +1300 Subject: Initial commit --- src/tokens/semantic.rs | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/tokens/semantic.rs (limited to 'src/tokens/semantic.rs') diff --git a/src/tokens/semantic.rs b/src/tokens/semantic.rs new file mode 100644 index 0000000..ed53685 --- /dev/null +++ b/src/tokens/semantic.rs @@ -0,0 +1,71 @@ +use crate::*; + + +pub enum SemanticToken { + MacroDefinition, + Invocation, +} + +pub struct Invocation { + pub name: String, + pub bytecode: BytecodeSpan, + pub arguments: Vec, +} + +pub struct BlockLiteral { + pub tokens: Vec, +} + +pub struct BlockToken { + pub source: SourceSpan, + pub bytecode: BytecodeSpan, + pub variant: BlockTokenVariant, +} + +pub enum BlockTokenVariant { + Invocation(Invocation), + Word(PackedBinaryLiteral), +} + +pub struct MacroDefinition { + pub name: String, + pub arguments: Vec, + pub body: BlockLiteral, +} + +// -------------------------------------------------------------------------- // + +pub struct SemanticParseError { + pub source: SourceSpan, + pub variant: SemanticParseErrorVariant, +} + +pub enum SemanticParseErrorVariant { + +} + +// -------------------------------------------------------------------------- // + +pub struct DefinitionArgument { + pub name: String, + pub source: SourceSpan, + pub variant: DefinitionArgumentVariant, +} + +pub enum DefinitionArgumentVariant { + Integer, + Block, +} + +pub struct InvocationArgument { + pub source: SourceSpan, + pub variant: InvocationArgumentVariant, +} + +pub enum InvocationArgumentVariant { + BlockLiteral(BlockLiteral), + IntegerLiteral(usize), + ConstantExpression(ConstantExpression), + Invocation(Invocation), +} + -- cgit v1.2.3-70-g09d2