diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-10 12:50:10 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-10 13:00:38 +0100 |
| commit | 343b2a41a36286a5f950116c183cd2ae54aad1bd (patch) | |
| tree | b69120f619c66ba1fe64ce02586e8a84b24b3731 /lib/xixanta | |
| parent | 7882e4474b77dfe4036f170cfce0e40b4f10ae93 (diff) | |
| download | tools.nes-343b2a41a36286a5f950116c183cd2ae54aad1bd.tar.gz tools.nes-343b2a41a36286a5f950116c183cd2ae54aad1bd.zip | |
Improve the message on bad file includes
Also remove some pending TODOs.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta')
| -rw-r--r-- | lib/xixanta/src/assembler.rs | 5 | ||||
| -rw-r--r-- | lib/xixanta/src/parser.rs | 20 |
2 files changed, 8 insertions, 17 deletions
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<Error>, - // TODO + // Sources that have been evaluated for the current session. This is + // directly tied to `Parser::sources`. sources: Vec<SourceInfo>, } @@ -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()); }; |
