aboutsummaryrefslogtreecommitdiff
path: root/src/keywords.gperf
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-07-09 23:04:47 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-07-09 23:04:54 +0200
commit2b0228cec24e49369634cb8239a1939f0fad7e2e (patch)
tree18d6f926ae47da1485e651896bfc0a3c06d7a4c0 /src/keywords.gperf
parent2b06086473b466fe989ce8629f941b9539ba1095 (diff)
Disallow keywords as identifier names
Diffstat (limited to 'src/keywords.gperf')
-rw-r--r--src/keywords.gperf40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/keywords.gperf b/src/keywords.gperf
new file mode 100644
index 0000000..7d81705
--- /dev/null
+++ b/src/keywords.gperf
@@ -0,0 +1,40 @@
+%compare-lengths
+%compare-strncmp
+%includes
+%readonly-tables
+
+%{
+#include <stdbool.h>
+
+#include "strview.h"
+
+static const char *in_word_set(const char *, size_t);
+%}
+
+%%
+pub
+static
+bool
+i8
+i16
+i32
+i64
+i128
+int
+u8
+u16
+u32
+u64
+u128
+uint
+f16
+f32
+f64
+f128
+rune
+%%
+bool
+iskeyword(strview_t sv)
+{
+ return in_word_set(sv.p, sv.len) != NULL;
+}