diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-21 23:13:00 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-21 23:13:00 +0100 |
| commit | 98a084530dd9525db290f8ac63ad904ef2a3611b (patch) | |
| tree | 5261f1d0f2f52594677149f6f4c890042d6cf95f /lib/xixanta/src | |
| parent | 183ad31518b3162eee01b1573947762461d723d3 (diff) | |
| download | tools.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/xixanta/src')
| -rw-r--r-- | lib/xixanta/src/parser.rs | 9 |
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(( |
