assembler shenanigans. shiny ahh code.
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
use core::fmt;
|
||||
|
||||
use common::prelude::Instruction;
|
||||
|
||||
use crate::{lexer::Token, parser::TokenType};
|
||||
|
||||
pub mod lexer;
|
||||
pub mod parser;
|
||||
|
||||
pub fn assemble(src: &str) -> Vec<Instruction> {
|
||||
todo!()
|
||||
}
|
||||
@@ -12,3 +19,20 @@ pub fn disassemble(binary: Vec<Instruction>) -> String {
|
||||
// sequences that are expansions of pseduo-instructions and reversing this to produce near enough the original source code.
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AssembleError {
|
||||
Generic,
|
||||
UnexpectedToken(Token, TokenType),
|
||||
}
|
||||
|
||||
impl fmt::Display for AssembleError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AssembleError::Generic => write!(f, "Generic error"),
|
||||
AssembleError::UnexpectedToken(tok, expected) => {
|
||||
write!(f, "Unexpected token {:?}, expected {:?}", tok, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user