assembler: start refactoring/rewriting tokeniser

This commit is contained in:
2025-06-25 14:48:45 +01:00
parent 11a57eab51
commit 4e5db58a84
5 changed files with 74 additions and 30 deletions
+8 -28
View File
@@ -2,7 +2,12 @@
//! easier to build from scratch and edit his code than it would be to try and wrangle it
//! into shape.
use crate::source::source_info::SourceInfo;
use crate::source::{
source_info::SourceInfo,
token_info::{
DirectiveToken, InstructionToken, LabelToken, RegisterToken, SymbolToken,
},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TokenType {
@@ -29,34 +34,9 @@ pub enum TokenType {
#[derive(Debug)]
pub struct Token {
/// The type of the token.
token_type: TokenType,
pub token_type: TokenType,
/// Where in the source code is this [`Token`]?
source_info: SourceInfo,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SymbolToken {
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LabelToken {
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DirectiveToken {
pub directive: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RegisterToken {
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct InstructionToken {
pub mnemonic: String,
pub source_info: SourceInfo,
}
impl Token {