assembler: clippy lints, better error formatting

Adds regex dependency and enhances error handling system

Introduces comprehensive error type hierarchy with specific variants for parser, symbol, codegen, threading, and IO errors to improve error reporting and debugging capabilities.

Adds regex crate for pattern matching in tokenizer implementation with pre-compiled patterns for labels, registers, immediates, directives, instructions, and symbols.

Enhances source info functionality with context printing and error underlining similar to compiler diagnostics.

Implements better error conversions and threading error handling for lock failures and panics.
This commit is contained in:
2025-06-25 16:50:17 +01:00
parent 4e5db58a84
commit fb84a6d3c3
12 changed files with 519 additions and 49 deletions
+10 -1
View File
@@ -1,10 +1,14 @@
//! This module contains anything within the first stage of assembly, i.e. the
//! tokenisation stage, or utility functions for reading input files.
use std::path::Path;
use std::{
io::{BufRead, Lines},
path::Path,
};
use crate::error::AssembleError;
pub mod lines;
pub mod source_info;
pub mod token;
pub mod token_info;
@@ -17,3 +21,8 @@ pub fn load_source_bytes<P: AsRef<Path>>(p: P) -> Result<Vec<u8>, AssembleError>
Ok(std::fs::read(path)?)
}
/// Get the lines from a [`BufReader`].
pub fn reader_lines<R: BufRead>(rdr: R) -> Lines<R> {
rdr.lines()
}