From 343b2a41a36286a5f950116c183cd2ae54aad1bd Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 10 Jan 2025 12:50:10 +0100 Subject: Improve the message on bad file includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also remove some pending TODOs. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 5 ++--- lib/xixanta/src/parser.rs | 20 ++++++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) (limited to 'lib/xixanta') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 06f0b24..7f46384 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -78,7 +78,8 @@ pub struct Assembler<'a> { // Warnings that have accumulated over the run. warnings: Vec, - // TODO + // Sources that have been evaluated for the current session. This is + // directly tied to `Parser::sources`. sources: Vec, } @@ -3802,6 +3803,4 @@ lda #Variable ".segment must be on the global scope", ); } - - // TODO: jmp/beq outside of allocated PRG ROM } diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs index 2e938d3..eb06040 100644 --- a/lib/xixanta/src/parser.rs +++ b/lib/xixanta/src/parser.rs @@ -632,22 +632,11 @@ impl Parser { }; let abs_file = current_source.directory.join(file_path); - // Validate that this is really a path that points to a file. - let path = std::path::Path::new(&abs_file); - if !path.is_file() { - return Err(Error { - line: node.value.line, - global: false, - source: current_source.clone(), - message: "expecting a file ({})".to_string(), - } - .into()); - } - // And open the file. This is the object to be passed as a reader for // the recursive `parse` call, but it also allows us to construct the // SourceInfo for the next session because we need to point to its // parent in the file system. + let path = std::path::Path::new(&abs_file); let file = match std::fs::File::open(path) { Ok(f) => f, Err(e) => { @@ -655,7 +644,7 @@ impl Parser { line: node.value.line, global: false, source: current_source.clone(), - message: format!("could not open source file: {}", e), + message: format!("could not open source file '{}': {}", file_path, e), } .into()) } @@ -665,7 +654,10 @@ impl Parser { line: node.value.line, global: false, source: current_source.clone(), - message: "could not find out the parent directory for file".to_string(), + message: format!( + "could not find out the parent directory for file '{}'", + file_path + ), } .into()); }; -- cgit v1.2.3