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:
+10
-1
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user