diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2024-10-28 19:52:29 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2024-10-28 19:52:47 +1300 |
commit | f4027cae775e3c9c237675f9df35a744d54f3f2e (patch) | |
tree | 733fa3af9e1bd44d61dd83983a2da86cb75c53e9 /src/tokens/syntactic.rs | |
parent | 16ee0e9e8dce2c88acc88ba5ffd97e013624fa5e (diff) | |
download | bedrock-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/tokens/syntactic.rs')
-rw-r--r-- | src/tokens/syntactic.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tokens/syntactic.rs b/src/tokens/syntactic.rs new file mode 100644 index 0000000..8684ed9 --- /dev/null +++ b/src/tokens/syntactic.rs @@ -0,0 +1,39 @@ +use crate::*; + + +pub struct SyntacticToken { + /// Location of token in source files. + pub source: SourceSpan, + pub variant: SyntacticTokenVariant, +} + + +pub enum SyntacticTokenVariant { + LabelDefinition(String), + MacroDefinition(String), + MacroDefinitionTerminator, + + Literal(Value), + Padding(Value), + Instruction(Instruction), + + Comment(String), + String(Vec<u8>), + + BlockOpen, + BlockClose, + MarkOpen, + MarkClose, + + Symbol(String), + + Error(SyntacticParseError), +} + + +pub enum SyntacticParseError { + UnterminatedComment, + UnterminatedRawString, + UnterminatedNullString, + InvalidPaddingValue(String), +} |