aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-21 23:13:00 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-21 23:13:00 +0100
commit98a084530dd9525db290f8ac63ad904ef2a3611b (patch)
tree5261f1d0f2f52594677149f6f4c890042d6cf95f /lib
parent183ad31518b3162eee01b1573947762461d723d3 (diff)
downloadtools.nes-98a084530dd9525db290f8ac63ad904ef2a3611b.tar.gz
tools.nes-98a084530dd9525db290f8ac63ad904ef2a3611b.zip
Be more explicit on empty identifiers
If the programmer only wrote a single special character for an identifier, then we will consider it empty to avoid shenanigans. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/xixanta/src/parser.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index d88a8a2..0a4d2b8 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -334,10 +334,7 @@ impl Parser {
line: self.line,
global: false,
source: self.sources[self.current_source].clone(),
- message: format!(
- "{} relative label can only have '{}' characters",
- msg, next
- ),
+ message: format!("{} relative label can only have '{}' characters", msg, next),
});
}
self.next();
@@ -359,7 +356,7 @@ impl Parser {
// The value of the identifier is whatever we have picked up
// along the parsing.
let value = String::from(line.get(base_offset..self.offset).unwrap_or("").trim());
- if value == "." {
+ if value == "." || value == "@" || value == "_" {
return Err(self.parser_error("empty identifier"));
}
@@ -392,7 +389,7 @@ impl Parser {
// The line is merely the identifier (e.g. instruction with implied
// addressing).
let id = String::from(line.get(base_offset..).unwrap_or_default().trim());
- if id == "." {
+ if id == "." || id == "@" || id == "_" {
return Err(self.parser_error("empty identifier"));
}
Ok((