aboutsummaryrefslogtreecommitdiff
path: root/src/unicode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unicode.cpp')
-rw-r--r--src/unicode.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/unicode.cpp b/src/unicode.cpp
index cf415d86b..d8a26924c 100644
--- a/src/unicode.cpp
+++ b/src/unicode.cpp
@@ -39,3 +39,28 @@ b32 rune_is_whitespace(Rune r) {
}
return false;
}
+
+
+b32 is_string_an_identifier(String s) {
+ if (s.len < 1) {
+ return false;
+ }
+ isize offset = 0;
+ while (offset < s.len) {
+ b32 ok = false;
+ Rune r = -1;
+ isize size = gb_utf8_decode(s.text+offset, s.len-offset, &r);
+ if (offset == 0) {
+ ok = rune_is_letter(r);
+ } else {
+ ok = rune_is_letter(r) || rune_is_digit(r);
+ }
+
+ if (!ok) {
+ return false;
+ }
+ offset += size;
+ }
+
+ return offset == s.len;
+}