From e4e71cda739c9af83302af85520518b838739f91 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 16 Jan 2025 23:13:44 +0100 Subject: Whitelist valid identifier characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of making up a list of characters that end an identifier, do the other way around since it's far less cumbersome and it prevents from silly bugs such as "var+1" being considered a single identifier. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib/xixanta/src/assembler.rs') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index e189b08..5e94070 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -2385,15 +2385,24 @@ mod tests { r#" Variable = 4 adc Variable + adc Variable + 1 + adc Variable+1 "#, ); - assert_eq!(res.len(), 1); + assert_eq!(res.len(), 3); + + assert_eq!(res[0].size, 2); + assert_eq!(res[0].bytes[0], 0x65); + assert_eq!(res[0].bytes[1], 0x04); - let instr = res.first().unwrap(); - assert_eq!(instr.size, 2); - assert_eq!(instr.bytes[0], 0x65); - assert_eq!(instr.bytes[1], 0x04); + assert_eq!(res[1].size, 2); + assert_eq!(res[1].bytes[0], 0x65); + assert_eq!(res[1].bytes[1], 0x05); + + assert_eq!(res[2].size, 2); + assert_eq!(res[2].bytes[0], 0x65); + assert_eq!(res[2].bytes[1], 0x05); } #[test] -- cgit v1.2.3