- fixed some clippy lints
- updated comments in compiler codegen - deleted old dsa compiler outputs - settings for zed
This commit is contained in:
@@ -184,11 +184,11 @@ pub enum Token {
|
||||
impl fmt::Display for Token {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Symbol(symbol) => write!(f, "{}", symbol),
|
||||
Self::Register(register) => write!(f, "{}", register),
|
||||
Self::Immediate(immediate) => write!(f, "{}", immediate),
|
||||
Self::StringLit(string_lit) => write!(f, "{}", string_lit),
|
||||
Self::Opcode(opcode) => write!(f, "{}", opcode),
|
||||
Self::Symbol(symbol) => write!(f, "{symbol}"),
|
||||
Self::Register(register) => write!(f, "{register}",),
|
||||
Self::Immediate(immediate) => write!(f, "{immediate}",),
|
||||
Self::StringLit(string_lit) => write!(f, "{string_lit}",),
|
||||
Self::Opcode(opcode) => write!(f, "{opcode}",),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ impl Parser {
|
||||
let opcode = expect_token!(self.next()?, Opcode)?;
|
||||
let args: Vec<Token>;
|
||||
|
||||
#[allow(clippy::match_same_arms)]
|
||||
match opcode {
|
||||
// R-type instructions
|
||||
Opcode::Mov | Opcode::Movs => {
|
||||
@@ -113,24 +114,25 @@ impl Parser {
|
||||
let base = expect_type!(self.next()?, Register, Symbol)?;
|
||||
let dest = expect_type!(self.next()?, Register)?;
|
||||
|
||||
let mut offset = Token::Immediate(0);
|
||||
if let Ok(next) = self.peek_next()
|
||||
&& expect_type!(next, Immediate).is_ok()
|
||||
{
|
||||
offset = self.next()?;
|
||||
}
|
||||
let offset = match self.peek_next() {
|
||||
Ok(next) if expect_type!(next.clone(), Immediate).is_ok() => {
|
||||
self.next()?
|
||||
}
|
||||
_ => Token::Immediate(0),
|
||||
};
|
||||
|
||||
args = vec![base, dest, offset];
|
||||
}
|
||||
Opcode::Stb | Opcode::Sth | Opcode::Stw => {
|
||||
let base = expect_type!(self.next()?, Register)?;
|
||||
let dest = expect_type!(self.next()?, Register, Symbol)?;
|
||||
let mut offset = Token::Immediate(0);
|
||||
if let Ok(next) = self.peek_next()
|
||||
&& expect_type!(next, Immediate).is_ok()
|
||||
{
|
||||
offset = self.next()?;
|
||||
}
|
||||
|
||||
let offset = match self.peek_next() {
|
||||
Ok(next) if expect_type!(next.clone(), Immediate).is_ok() => {
|
||||
self.next()?
|
||||
}
|
||||
_ => Token::Immediate(0),
|
||||
};
|
||||
args = vec![base, dest, offset];
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ use crate::prelude::CompilerEngine;
|
||||
pub fn assemble_file(input: &str, output: &str) -> Result<(), std::io::Error> {
|
||||
let mut engine = CompilerEngine::new();
|
||||
engine.start_compilation(Path::new(input));
|
||||
let result = engine.wait_for_result().unwrap();
|
||||
let result = engine.wait_for_result().expect("assembler failed.");
|
||||
|
||||
let buffer: Vec<u8> = result
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user