summaryrefslogtreecommitdiff
path: root/src/syntactic_token.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-10-28 19:52:29 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-10-28 19:52:47 +1300
commitf4027cae775e3c9c237675f9df35a744d54f3f2e (patch)
tree733fa3af9e1bd44d61dd83983a2da86cb75c53e9 /src/syntactic_token.rs
parent16ee0e9e8dce2c88acc88ba5ffd97e013624fa5e (diff)
downloadbedrock-asm-f4027cae775e3c9c237675f9df35a744d54f3f2e.zip
Rewrite assembler
This is an almost complete rewrite of the entire assembler from the ground up, with a different parsing strategy and a whole new symbol resolution mechanism for automatically including library files. The assembly syntax has also been slightly modified, with padding tokens now being prefixed with '#' instead of '$', and a block-style anonymous-label syntax which uses the '{' and '}' characters.
Diffstat (limited to 'src/syntactic_token.rs')
-rw-r--r--src/syntactic_token.rs43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/syntactic_token.rs b/src/syntactic_token.rs
deleted file mode 100644
index 4a50e8a..0000000
--- a/src/syntactic_token.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-use crate::*;
-
-pub enum SyntacticTokenType {
- Reference(String),
-
- LabelDefinition(String),
- MacroDefinition(String),
- MacroDefinitionTerminator,
-
- Padding(u16),
- ByteLiteral(u8),
- ShortLiteral(u16),
- Instruction(u8),
-
- Comment,
-}
-
-
-
-pub struct SyntacticToken {
- pub r#type: SyntacticTokenType,
- pub source_location: SourceLocation,
- pub error: Option<Error>,
-}
-
-impl SyntacticToken {
- // Call when this token is found inside a macro definition.
- pub fn use_in_macro_body(&mut self) {
- match self.r#type {
- SyntacticTokenType::LabelDefinition(..) |
- SyntacticTokenType::MacroDefinition(..) => {
- self.set_error(Error::InvalidTypeInMacroDefinition)
- }
- _ => (),
- };
- }
- pub fn set_error(&mut self, error: Error) {
- self.error = Some(error);
- }
- pub fn is_macro_terminator(&self) -> bool {
- if let SyntacticTokenType::MacroDefinitionTerminator = self.r#type {true} else {false}
- }
-}