diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2023-05-06 16:19:15 +1200 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2023-05-06 16:19:15 +1200 |
commit | e38f108921c61e1e66d65a368f2a67a763d61e69 (patch) | |
tree | 2718330c1e9963a21bc08db3ddc18574b078d004 /src/semantic_token.rs | |
download | bedrock-asm-e38f108921c61e1e66d65a368f2a67a763d61e69.zip |
About to refactor parser to be a struct with a method for each stage
Diffstat (limited to 'src/semantic_token.rs')
-rw-r--r-- | src/semantic_token.rs | 38 |
1 files changed, 38 insertions, 0 deletions
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<usize>, +} +pub struct MacroDefinition { + pub name: String, + pub body_tokens: Vec<SemanticToken>, + /// A list of pointers to macro reference tokens + pub references: Vec<usize>, +} + |