summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-03-23 11:37:29 +1300
committerBen Bridle <ben@derelict.engineering>2025-03-23 11:37:29 +1300
commit315d23bf2148e831b0c14a118841133aacc1fb96 (patch)
tree2f8a8cb7e5d9a5c55902b1731e1671a951421282
parentb2f78331d90196a0fd87fce4319c77f3248592a1 (diff)
downloadtorque-asm-315d23bf2148e831b0c14a118841133aacc1fb96.zip
Report token without prefix in invalid literal errors
Previously, the token quoted in the error message for an invalid literal error included the radix prefix. This is already visible in the highlighted source report, and implied by the named radix in the error message.
-rw-r--r--src/stages/syntactic.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/stages/syntactic.rs b/src/stages/syntactic.rs
index 3be8307..14f8815 100644
--- a/src/stages/syntactic.rs
+++ b/src/stages/syntactic.rs
@@ -169,14 +169,16 @@ fn parse_syntactic_from_tokeniser(mut t: Tokeniser) -> Result<Vec<Tracked<Syntac
c => {
let token = format!("{c}{}", t.eat_token());
if let Some(hex_string) = token.strip_prefix("0x") {
- match parse_integer_literal(hex_string, 16) {
+ let hex_string = hex_string.to_string();
+ match parse_integer_literal(&hex_string, 16) {
Ok(value) => SyntacticToken::IntegerLiteral(value),
- Err(_) => err!(SyntacticError::InvalidHexadecimalLiteral(token)),
+ Err(_) => err!(SyntacticError::InvalidHexadecimalLiteral(hex_string)),
}
} else if let Some(binary_string) = token.strip_prefix("0b") {
- match parse_integer_literal(binary_string, 2) {
+ let binary_string = binary_string.to_string();
+ match parse_integer_literal(&binary_string, 2) {
Ok(value) => SyntacticToken::IntegerLiteral(value),
- Err(_) => err!(SyntacticError::InvalidBinaryLiteral(token)),
+ Err(_) => err!(SyntacticError::InvalidBinaryLiteral(binary_string)),
}
} else {
match parse_integer_literal(&token, 10) {