From e38f108921c61e1e66d65a368f2a67a763d61e69 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 6 May 2023 16:19:15 +1200 Subject: About to refactor parser to be a struct with a method for each stage --- src/semantic_token.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/semantic_token.rs (limited to 'src/semantic_token.rs') diff --git a/src/semantic_token.rs b/src/semantic_token.rs new file mode 100644 index 0000000..cac82a9 --- /dev/null +++ b/src/semantic_token.rs @@ -0,0 +1,38 @@ +use crate::*; + +pub enum SemanticTokenType { + LabelReference(usize), + MacroReference(usize), + + LabelDefinition(LabelDefinition), + MacroDefinition(MacroDefinition), + + Pad(u16), + Byte(u8), + Short(u16), + Instruction(u8), + + MacroTerminator, + Comment, + Error(SyntacticTokenType, Error), +} + +pub struct SemanticToken { + pub r#type: SemanticTokenType, + pub source_location: SourceLocation, + pub bytecode_location: BytecodeLocation, +} + +pub struct LabelDefinition { + pub name: String, + pub address: u16, + /// A list of pointers to label reference tokens + pub references: Vec, +} +pub struct MacroDefinition { + pub name: String, + pub body_tokens: Vec, + /// A list of pointers to macro reference tokens + pub references: Vec, +} + -- cgit v1.2.3-70-g09d2