From ba5f7c4e2af5c82c220b7e1796fde2f026ce4208 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 1 Jun 2022 11:08:19 +0100 Subject: [PATCH] Deprecate `a..b` based ranges in favour of `..=` --- core/encoding/entity/entity.odin | 6 +++--- core/encoding/xml/tokenizer.odin | 2 +- src/parser.cpp | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/encoding/entity/entity.odin b/core/encoding/entity/entity.odin index db1a5ad0b..e5831a75f 100644 --- a/core/encoding/entity/entity.odin +++ b/core/encoding/entity/entity.odin @@ -231,16 +231,16 @@ xml_decode_entity :: proc(entity: string) -> (decoded: rune, ok: bool) { for len(entity) > 0 { r := entity[0] switch r { - case '0'..'9': + case '0'..='9': val *= base val += int(r - '0') - case 'a'..'f': + case 'a'..='f': if base == 10 { return -1, false } val *= base val += int(r - 'a' + 10) - case 'A'..'F': + case 'A'..='F': if base == 10 { return -1, false } val *= base val += int(r - 'A' + 10) diff --git a/core/encoding/xml/tokenizer.odin b/core/encoding/xml/tokenizer.odin index c3fece76e..d225c5d90 100644 --- a/core/encoding/xml/tokenizer.odin +++ b/core/encoding/xml/tokenizer.odin @@ -198,7 +198,7 @@ is_valid_identifier_rune :: proc(r: rune) -> bool { switch r { case '_', '-', ':': return true case 'A'..='Z', 'a'..='z': return true - case '0'..'9': return true + case '0'..='9': return true case -1: return false } } diff --git a/src/parser.cpp b/src/parser.cpp index 5280fd4b0..b58e3c320 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1428,6 +1428,7 @@ Token expect_operator(AstFile *f) { LIT(p)); } if (f->curr_token.kind == Token_Ellipsis) { + syntax_warning(f->curr_token, "'..' for ranges has now be deprecated, prefer '..='"); f->tokens[f->curr_token_index].flags |= TokenFlag_Replace; }