Skip to content

Distribute and run LLMs with a single file.

Add Lua syntax highlighting

Justine Tunney19e3de3e6aac
diff --git a/llamafile/BUILD.mk b/llamafile/BUILD.mk
index 00aa43bd..a41805e1 100644
--- a/llamafile/BUILD.mk
+++ b/llamafile/BUILD.mk
@@ -169,6 +169,7 @@ o/$(MODE)/llamafile/highlight_c_test: \
o/$(MODE)/llamafile/highlight_c_test.o \
o/$(MODE)/llamafile/highlight_c.o \
o/$(MODE)/llamafile/is_keyword_c.o \
+ o/$(MODE)/llamafile/is_keyword_c_type.o \
o/$(MODE)/llamafile/is_keyword_js.o \
o/$(MODE)/llamafile/highlight_python_test: \
diff --git a/llamafile/highlight.cpp b/llamafile/highlight.cpp
index 14dc65b3..86a560e8 100644
--- a/llamafile/highlight.cpp
+++ b/llamafile/highlight.cpp
@@ -21,9 +21,9 @@ Highlight *Highlight::create(const std::string_view &lang) {
if (lang == "markdown" || lang == "md") {
return new HighlightMarkdown;
} else if (lang == "c") {
- return new HighlightC(is_keyword_c);
+ return new HighlightC(is_keyword_c, is_keyword_c_type);
} else if (lang == "c++" || lang == "cxx" || lang == "cpp") {
- return new HighlightC(is_keyword_cxx);
+ return new HighlightC(is_keyword_cxx, is_keyword_c_type);
} else if (lang == "js" || lang == "javascript") {
return new HighlightC(is_keyword_js);
} else if (lang == "java") {
@@ -52,6 +52,8 @@ Highlight *Highlight::create(const std::string_view &lang) {
return new HighlightC(is_keyword_csharp);
} else if (lang == "kotlin") {
return new HighlightC(is_keyword_kotlin);
+ } else if (lang == "lua") {
+ return new HighlightLua;
} else {
return new HighlightPlain;
}
diff --git a/llamafile/highlight.h b/llamafile/highlight.h
index 24f00852..e0b6cda7 100644
--- a/llamafile/highlight.h
+++ b/llamafile/highlight.h
@@ -35,12 +35,14 @@
#define HI_PROPERTY "\033[36m" // cyan
#define HI_TAG "\033[33m" // yellow
#define HI_INCODE "\033[1;35m" // magenta
+#define HI_BUILTIN "\033[35m" // magenta
#define HI_ENTITY "\033[36m" // cyan
typedef const char *is_keyword_f(const char *, size_t);
extern "C" {
is_keyword_f is_keyword_c;
+is_keyword_f is_keyword_c_type;
is_keyword_f is_keyword_cxx;
is_keyword_f is_keyword_js;
is_keyword_f is_keyword_java;
@@ -57,6 +59,8 @@ is_keyword_f is_keyword_sql;
is_keyword_f is_keyword_php;
is_keyword_f is_keyword_csharp;
is_keyword_f is_keyword_kotlin;
+is_keyword_f is_keyword_lua;
+is_keyword_f is_keyword_lua_builtin;
}
class Highlight {
@@ -77,7 +81,7 @@ class HighlightPlain : public Highlight {
class HighlightC : public Highlight {
public:
- explicit HighlightC(is_keyword_f is_keyword = is_keyword_c, is_keyword_f is_type = nullptr);
+ HighlightC(is_keyword_f is_keyword = is_keyword_c, is_keyword_f is_type = nullptr);
~HighlightC() override;
void feed(std::string *result, std::string_view input) override;
void flush(std::string *result) override;
@@ -215,3 +219,17 @@ class HighlightPhp : public Highlight {
int t_ = 0;
std::string word_;
};
+
+class HighlightLua : public Highlight {
+ public:
+ HighlightLua();
+ ~HighlightLua() override;
+ void feed(std::string *result, std::string_view input) override;
+ void flush(std::string *result) override;
+
+ private:
+ int t_ = 0;
+ int level1_;
+ int level2_;
+ std::string word_;
+};
diff --git a/llamafile/highlight_lua.cpp b/llamafile/highlight_lua.cpp
new file mode 100644
index 00000000..7ba797e9
--- /dev/null
+++ b/llamafile/highlight_lua.cpp
@@ -0,0 +1,222 @@
+// -*- mode:c++;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-
+// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
+//
+// Copyright 2024 Mozilla Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "highlight.h"
+
+#include <ctype.h>
+
+#define NORMAL 0
+#define WORD 1
+#define QUOTE 2
+#define DQUOTE 3
+#define HYPHEN 4
+#define COMMENT 5
+#define TICK 6
+#define LSB 7
+#define LITERAL 8
+#define LITERAL_RSB 9
+#define BACKSLASH 64
+
+HighlightLua::HighlightLua() {
+}
+
+HighlightLua::~HighlightLua() {
+}
+
+void HighlightLua::feed(std::string *r, std::string_view input) {
+ int c;
+ for (size_t i = 0; i < input.size(); ++i) {
+ c = input[i] & 255;
+
+ if (t_ & BACKSLASH) {
+ t_ &= ~BACKSLASH;
+ *r += c;
+ continue;
+ } else if (c == '\\') {
+ *r += c;
+ t_ |= BACKSLASH;
+ continue;
+ }
+
+ switch (t_) {
+
+ Normal:
+ case NORMAL:
+ if (!isascii(c) || isalpha(c) || c == '_') {
+ t_ = WORD;
+ goto Word;
+ } else if (c == '-') {
+ t_ = HYPHEN;
+ } else if (c == '\'') {
+ t_ = QUOTE;
+ *r += HI_STRING;
+ *r += c;
+ } else if (c == '"') {
+ t_ = DQUOTE;
+ *r += HI_STRING;
+ *r += c;
+ } else if (c == '[') {
+ t_ = LSB;
+ level1_ = 0;
+ } else {
+ *r += c;
+ }
+ break;
+
+ Word:
+ case WORD:
+ if (!isascii(c) || isalpha(c) || isdigit(c) || c == '_') {
+ word_ += c;
+ } else {
+ if (is_keyword_lua(word_.data(), word_.size())) {
+ *r += HI_KEYWORD;
+ *r += word_;
+ *r += HI_RESET;
+ } else if (is_keyword_lua_builtin(word_.data(), word_.size())) {
+ *r += HI_BUILTIN;
+ *r += word_;
+ *r += HI_RESET;
+ } else {
+ *r += word_;
+ }
+ word_.clear();
+ t_ = NORMAL;
+ goto Normal;
+ }
+ break;
+
+ case HYPHEN:
+ if (c == '-') {
+ *r += HI_COMMENT;
+ *r += "--";
+ t_ = COMMENT;
+ } else {
+ *r += '/';
+ t_ = NORMAL;
+ goto Normal;
+ }
+ break;
+
+ case COMMENT:
+ if (c == '\n') {
+ *r += HI_RESET;
+ *r += c;
+ t_ = NORMAL;
+ } else {
+ *r += c;
+ }
+ break;
+
+ case QUOTE:
+ *r += c;
+ if (c == '\'') {
+ *r += HI_RESET;
+ t_ = NORMAL;
+ }
+ break;
+
+ case DQUOTE:
+ *r += c;
+ if (c == '"') {
+ *r += HI_RESET;
+ t_ = NORMAL;
+ }
+ break;
+
+ case LSB:
+ if (c == '=') {
+ ++level1_;
+ } else if (c == '[') {
+ *r += HI_STRING;
+ *r += '[';
+ for (int i = 0; i < level1_; ++i)
+ *r += '=';
+ *r += '[';
+ t_ = LITERAL;
+ } else {
+ *r += '[';
+ for (int i = 0; i < level1_; ++i)
+ *r += '=';
+ t_ = NORMAL;
+ goto Normal;
+ }
+ break;
+
+ case LITERAL:
+ *r += c;
+ if (c == ']') {
+ t_ = LITERAL_RSB;
+ level2_ = 0;
+ }
+ break;
+
+ case LITERAL_RSB:
+ *r += c;
+ if (c == '=') {
+ ++level2_;
+ } else if (c == ']') {
+ if (level2_ == level1_) {
+ *r += HI_RESET;
+ t_ = NORMAL;
+ } else {
+ level2_ = 0;
+ }
+ }
+ break;
+
+ default:
+ __builtin_unreachable();
+ }
+ }
+}
+
+void HighlightLua::flush(std::string *r) {
+ t_ &= ~BACKSLASH;
+ switch (t_) {
+ case WORD:
+ if (is_keyword_lua(word_.data(), word_.size())) {
+ *r += HI_KEYWORD;
+ *r += word_;
+ *r += HI_RESET;
+ } else if (is_keyword_lua_builtin(word_.data(), word_.size())) {
+ *r += HI_BUILTIN;
+ *r += word_;
+ *r += HI_RESET;
+ } else {
+ *r += word_;
+ }
+ word_.clear();
+ break;
+ case LSB:
+ *r += '[';
+ for (int i = 0; i < level1_; ++i)
+ *r += '=';
+ case HYPHEN:
+ *r += '-';
+ break;
+ case QUOTE:
+ case DQUOTE:
+ case COMMENT:
+ case LITERAL:
+ case LITERAL_RSB:
+ *r += HI_RESET;
+ break;
+ default:
+ break;
+ }
+ t_ = NORMAL;
+}
diff --git a/llamafile/is_keyword_c.c b/llamafile/is_keyword_c.c
index 97cd3c73..90de6d33 100644
--- a/llamafile/is_keyword_c.c
+++ b/llamafile/is_keyword_c.c
@@ -33,7 +33,7 @@
#include <string.h>
-#define TOTAL_KEYWORDS 104
+#define TOTAL_KEYWORDS 110
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 19
#define MIN_HASH_VALUE 10
@@ -56,11 +56,11 @@ hash (register const char *str, register size_t len)
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 0, 192, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
- 30, 192, 10, 192, 192, 192, 0, 192, 192, 192,
- 192, 192, 192, 192, 192, 70, 35, 70, 0, 192,
- 0, 60, 192, 0, 192, 192, 192, 192, 0, 192,
- 5, 192, 192, 5, 70, 192, 192, 192, 192, 192,
+ 192, 192, 192, 192, 192, 192, 192, 192, 20, 192,
+ 7, 192, 125, 192, 75, 192, 0, 192, 192, 192,
+ 192, 192, 192, 192, 192, 70, 35, 75, 0, 192,
+ 0, 70, 192, 0, 192, 192, 192, 192, 0, 192,
+ 5, 192, 192, 5, 22, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 5, 192, 60, 65, 70,
75, 0, 15, 85, 0, 25, 192, 15, 5, 55,
10, 60, 40, 192, 40, 35, 20, 40, 0, 10,
@@ -102,12 +102,14 @@ is_keyword_c (register const char *str, register size_t len)
"",
"#else",
"_Decimal128",
- "", "", "",
- "__volatile",
"", "",
+ "_Float128",
+ "__volatile",
+ "",
+ "_Decimal32",
"__volatile__ ",
"",
- "_Decimal64",
+ "_Float32",
"inline",
"__FUNCTION__",
"__extension__",
@@ -127,7 +129,7 @@ is_keyword_c (register const char *str, register size_t len)
"",
"__inline",
"__imag__ ",
- "_Decimal32",
+ "_Thread_local",
"switch",
"default",
"#include",
@@ -136,7 +138,7 @@ is_keyword_c (register const char *str, register size_t len)
"extern",
"",
"__typeof",
- "",
+ "__float80",
"union",
"sizeof",
"alignof",
@@ -172,7 +174,7 @@ is_keyword_c (register const char *str, register size_t len)
"short",
"struct",
"_BitInt",
- "_Thread_local",
+ "_Float16",
"__alignof",
"float",
"__complex__",
@@ -210,16 +212,21 @@ is_keyword_c (register const char *str, register size_t len)
"bool",
"", "", "",
"register",
- "", "",
+ "",
+ "_Decimal64",
"#embed",
"",
- "_Generic",
+ "_Float64",
"", "", "", "",
"for",
"goto",
"", "", "",
+ "_Generic",
+ "", "",
+ "__bf16",
+ "",
"_Complex",
- "", "", "", "", "", "", "",
+ "", "",
"static",
"", "",
"long",
diff --git a/llamafile/is_keyword_c.gperf b/llamafile/is_keyword_c.gperf
index 4df62c56..3f5c7f1a 100644
--- a/llamafile/is_keyword_c.gperf
+++ b/llamafile/is_keyword_c.gperf
@@ -29,6 +29,10 @@ _Complex
_Decimal128
_Decimal32
_Decimal64
+_Float128
+_Float16
+_Float32
+_Float64
_Generic
_Imaginary
_Noreturn
@@ -42,12 +46,14 @@ __asm
__asm__
__attribute
__attribute__
+__bf16
__builtin_offsetof
__builtin_va_arg
__complex
__complex__
__const
__extension__
+__float80
__func__
__imag
__imag__
diff --git a/llamafile/is_keyword_c_type.c b/llamafile/is_keyword_c_type.c
new file mode 100644
index 00000000..42e37d8f
--- /dev/null
+++ b/llamafile/is_keyword_c_type.c
@@ -0,0 +1,438 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf is_keyword_c_type.gperf */
+/* Computed positions: -k'1-2,4-6,8,10,12,17-18' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646. */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
+#endif
+
+#line 1 "is_keyword_c_type.gperf"
+
+#include <string.h>
+
+#define TOTAL_KEYWORDS 179
+#define MIN_WORD_LENGTH 3
+#define MAX_WORD_LENGTH 26
+#define MIN_HASH_VALUE 3
+#define MAX_HASH_VALUE 584
+/* maximum key range = 582, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+hash (register const char *str, register size_t len)
+{
+ static const unsigned short asso_values[] =
+ {
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 60,
+ 110, 45, 180, 585, 30, 585, 165, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 0, 0,
+ 0, 585, 585, 0, 585, 585, 585, 585, 5, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 0, 585, 0, 105, 10,
+ 110, 5, 75, 220, 120, 0, 585, 185, 30, 5,
+ 5, 80, 0, 5, 0, 65, 0, 35, 15, 160,
+ 220, 160, 170, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585, 585, 585, 585, 585,
+ 585, 585, 585, 585, 585, 585
+ };
+ register unsigned int hval = len;
+
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[17]];
+ /*FALLTHROUGH*/
+ case 17:
+ hval += asso_values[(unsigned char)str[16]];
+ /*FALLTHROUGH*/
+ case 16:
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ hval += asso_values[(unsigned char)str[11]];
+ /*FALLTHROUGH*/
+ case 11:
+ case 10:
+ hval += asso_values[(unsigned char)str[9]];
+ /*FALLTHROUGH*/
+ case 9:
+ case 8:
+ hval += asso_values[(unsigned char)str[7]];
+ /*FALLTHROUGH*/
+ case 7:
+ case 6:
+ hval += asso_values[(unsigned char)str[5]];
+ /*FALLTHROUGH*/
+ case 5:
+ hval += asso_values[(unsigned char)str[4]];
+ /*FALLTHROUGH*/
+ case 4:
+ hval += asso_values[(unsigned char)str[3]];
+ /*FALLTHROUGH*/
+ case 3:
+ case 2:
+ hval += asso_values[(unsigned char)str[1]];
+ /*FALLTHROUGH*/
+ case 1:
+ hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval;
+}
+
+const char *
+is_keyword_c_type (register const char *str, register size_t len)
+{
+ static const char * const wordlist[] =
+ {
+ "", "", "",
+ "DIR",
+ "FILE",
+ "pid_t",
+ "", "", "", "",
+ "ino_t",
+ "time_t",
+ "timer_t",
+ "intptr_t",
+ "pthread_t",
+ "mqd_t",
+ "intN_t",
+ "", "",
+ "pthread_attr_t",
+ "", "",
+ "pthread_barrier_t",
+ "pthread_key_t",
+ "cc_t",
+ "atomic_int",
+ "pthread_barrierattr_t",
+ "trace_attr_t",
+ "pthread_spinlock_t",
+ "pthread_once_t",
+ "atomic_intptr_t",
+ "atomic_ptrdiff_t",
+ "", "", "",
+ "mcontext_t",
+ "atomic_char",
+ "iconv_t",
+ "", "",
+ "uid_t",
+ "rlim_t",
+ "",
+ "rlimit_t",
+ "uintptr_t",
+ "", "", "", "",
+ "uintmax_t",
+ "t_scalar_t",
+ "trace_event_id_t",
+ "trace_event_set_t",
+ "", "", "", "", "", "", "",
+ "pthread_mutex_t",
+ "atomic_long",
+ "", "",
+ "pthread_mutexattr_t",
+ "ucontext_t",
+ "atomic_uint",
+ "", "", "", "",
+ "atomic_uintptr_t",
+ "", "", "",
+ "sem_t",
+ "size_t",
+ "",
+ "uint_least8_t",
+ "",
+ "register_t",
+ "",
+ "lldiv_t",
+ "", "",
+ "atomic_char32_t",
+ "t_uscalar_t",
+ "", "",
+ "cpu_set_t",
+ "",
+ "int_fast8_t",
+ "sig_atomic_t",
+ "",
+ "in_port_t",
+ "",
+ "mode_t",
+ "errno_t",
+ "atomic_ullong",
+ "",
+ "atomic_char16_t",
+ "fenv_t",
+ "int16_t",
+ "",
+ "fexcept_t",
+ "",
+ "atomic_uint_least64_t",
+ "",
+ "atomic_int_fast8_t",
+ "uint_least16_t",
+ "", "",
+ "float_t",
+ "",
+ "id_t",
+ "div_t",
+ "data_t",
+ "",
+ "msglen_t",
+ "mbstate_t",
+ "dev_t",
+ "atomic_uint_least32_t",
+ "int_fast16_t",
+ "",
+ "msgqnum_t",
+ "", "", "", "", "", "", "", "",
+ "uint16_t",
+ "",
+ "trace_id_t",
+ "atomic_uint_least16_t",
+ "", "",
+ "atomic_int_fast16_t",
+ "regmatch_t",
+ "", "",
+ "sigset_t",
+ "float64_t",
+ "",
+ "fpos_t",
+ "",
+ "int_least64_t",
+ "", "",
+ "nfds_t",
+ "",
+ "locale_t",
+ "siginfo_t",
+ "atomic_int_least16_t",
+ "", "",
+ "blkcnt_t",
+ "float32_t",
+ "off_t",
+ "ldiv_t",
+ "",
+ "int_least32_t",
+ "",
+ "atomic_uint_fast16_t",
+ "wint_t",
+ "int32_t",
+ "timed_mutex_t",
+ "", "", "",
+ "atomic_short",
+ "",
+ "float16_t",
+ "",
+ "int8_t",
+ "wchar_t",
+ "int_least16_t",
+ "", "", "",
+ "atomic_uchar",
+ "atomic_ushort",
+ "wctrans_t",
+ "",
+ "sa_family_t",
+ "speed_t",
+ "ushort_t",
+ "uint_least32_t",
+ "fsfilcnt_t",
+ "loff_t",
+ "",
+ "shmatt_t",
+ "ptrdiff_t",
+ "key_t",
+ "", "",
+ "uint32_t",
+ "", "",
+ "semaphore_t",
+ "int_fast32_t",
+ "", "", "", "",
+ "uint8_t",
+ "",
+ "pthread_cond_t",
+ "",
+ "atomic_bool",
+ "atomic_schar",
+ "pthread_condattr_t",
+ "uint128_t",
+ "", "", "",
+ "uint_fast64_t",
+ "atomic_int_fast32_t",
+ "atomic_int_least32_t",
+ "",
+ "int64_t",
+ "", "",
+ "gid_t",
+ "", "",
+ "char16_t",
+ "atomic_int_least8_t",
+ "atomic_uint_fast32_t",
+ "",
+ "nlink_t",
+ "uint_fast32_t",
+ "in_addr_t",
+ "",
+ "thrd_t",
+ "regex_t",
+ "intmax_t",
+ "atomic_uint_fast8_t",
+ "atomic_uint_least8_t",
+ "",
+ "clock_t",
+ "regoff_t",
+ "clockid_t",
+ "", "", "",
+ "uint_fast16_t",
+ "", "", "", "",
+ "uint64_t",
+ "", "", "", "",
+ "atomic_bool32",
+ "uint_least64_t",
+ "",
+ "pthread_rwlock_t",
+ "",
+ "atomic_size_t",
+ "",
+ "pthread_rwlockattr_t",
+ "max_align_t",
+ "stack_t",
+ "tcflag_t",
+ "",
+ "useconds_t",
+ "",
+ "int_fast64_t",
+ "", "",
+ "atomic_int_least64_t",
+ "", "",
+ "syscall_arg_t",
+ "", "", "",
+ "int_least8_t",
+ "idtype_t",
+ "",
+ "atomic_uint_fast64_t",
+ "", "", "",
+ "atomic_int_fast64_t",
+ "", "", "",
+ "char32_t",
+ "", "", "", "", "", "",
+ "bfloat16_t",
+ "", "", "", "", "", "", "", "",
+ "atomic_wchar_t",
+ "", "",
+ "ssize_t",
+ "ssizet_t",
+ "", "",
+ "suseconds_t",
+ "", "", "", "", "", "", "", "", "",
+ "", "",
+ "posix_trace_attr_t",
+ "", "", "", "",
+ "uint24_t",
+ "", "", "", "",
+ "double_t",
+ "",
+ "float128_t",
+ "", "",
+ "wctype_t",
+ "imaxdiv_t",
+ "", "", "",
+ "int128_t",
+ "", "", "",
+ "uint_fast8_t",
+ "", "", "", "",
+ "atomic_llong",
+ "", "", "",
+ "glob_t",
+ "atomic_ulong",
+ "",
+ "timed_thread_t",
+ "", "", "", "", "", "", "", "", "",
+ "socklen_t",
+ "fsblkcnt_t",
+ "bool32",
+ "", "",
+ "blksize_t",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "",
+ "posix_spawnattr_t",
+ "", "", "", "", "", "", "", "",
+ "posix_spawn_file_actions_t",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "",
+ "wordexp_t"
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register const char *s = wordlist[key];
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return s;
+ }
+ }
+ return 0;
+}
diff --git a/llamafile/is_keyword_c_type.gperf b/llamafile/is_keyword_c_type.gperf
new file mode 100644
index 00000000..3bb5f6f0
--- /dev/null
+++ b/llamafile/is_keyword_c_type.gperf
@@ -0,0 +1,187 @@
+%{
+#include <string.h>
+%}
+%compare-strncmp
+%language=ANSI-C
+%readonly-tables
+%define lookup-function-name is_keyword_c_type
+%%
+DIR
+FILE
+atomic_bool
+atomic_bool32
+atomic_char
+atomic_char16_t
+atomic_char32_t
+atomic_int
+atomic_int_fast16_t
+atomic_int_fast32_t
+atomic_int_fast64_t
+atomic_int_fast8_t
+atomic_int_least16_t
+atomic_int_least32_t
+atomic_int_least64_t
+atomic_int_least8_t
+atomic_intptr_t
+atomic_llong
+atomic_long
+atomic_ptrdiff_t
+atomic_schar
+atomic_short
+atomic_size_t
+atomic_uchar
+atomic_uint
+atomic_uint_fast16_t
+atomic_uint_fast32_t
+atomic_uint_fast64_t
+atomic_uint_fast8_t
+atomic_uint_least16_t
+atomic_uint_least32_t
+atomic_uint_least64_t
+atomic_uint_least8_t
+atomic_uintptr_t
+atomic_ullong
+atomic_ulong
+atomic_ushort
+atomic_wchar_t
+bfloat16_t
+blkcnt_t
+blksize_t
+bool32
+cc_t
+char16_t
+char32_t
+clock_t
+clockid_t
+cpu_set_t
+data_t
+dev_t
+div_t
+double_t
+errno_t
+fenv_t
+fexcept_t
+float128_t
+float16_t
+float32_t
+float64_t
+float_t
+fpos_t
+fsblkcnt_t
+fsfilcnt_t
+gid_t
+glob_t
+iconv_t
+id_t
+idtype_t
+imaxdiv_t
+in_addr_t
+in_port_t
+ino_t
+int128_t
+int16_t
+int32_t
+int64_t
+int8_t
+intN_t
+int_fast16_t
+int_fast32_t
+int_fast64_t
+int_fast8_t
+int_least16_t
+int_least32_t
+int_least64_t
+int_least8_t
+intmax_t
+intptr_t
+key_t
+ldiv_t
+lldiv_t
+locale_t
+loff_t
+max_align_t
+mbstate_t
+mcontext_t
+mode_t
+mqd_t
+msglen_t
+msgqnum_t
+nfds_t
+nlink_t
+off_t
+pid_t
+posix_spawn_file_actions_t
+posix_spawnattr_t
+posix_trace_attr_t
+pthread_attr_t
+pthread_barrier_t
+pthread_barrierattr_t
+pthread_cond_t
+pthread_condattr_t
+pthread_key_t
+pthread_mutex_t
+pthread_mutexattr_t
+pthread_once_t
+pthread_rwlock_t
+pthread_rwlockattr_t
+pthread_spinlock_t
+pthread_t
+ptrdiff_t
+regex_t
+register_t
+regmatch_t
+regoff_t
+rlim_t
+rlimit_t
+sa_family_t
+sem_t
+semaphore_t
+shmatt_t
+sig_atomic_t
+siginfo_t
+sigset_t
+size_t
+socklen_t
+speed_t
+ssize_t
+ssizet_t
+stack_t
+suseconds_t
+syscall_arg_t
+t_scalar_t
+t_uscalar_t
+tcflag_t
+thrd_t
+time_t
+timed_mutex_t
+timed_thread_t
+timer_t
+trace_attr_t
+trace_event_id_t
+trace_event_set_t
+trace_id_t
+ucontext_t
+uid_t
+uint128_t
+uint16_t
+uint24_t
+uint32_t
+uint64_t
+uint8_t
+uint_fast16_t
+uint_fast32_t
+uint_fast64_t
+uint_fast8_t
+uint_least16_t
+uint_least32_t
+uint_least64_t
+uint_least8_t
+uintmax_t
+uintptr_t
+useconds_t
+ushort_t
+wchar_t
+wctrans_t
+wctype_t
+wint_t
+wordexp_t
diff --git a/llamafile/is_keyword_cxx.c b/llamafile/is_keyword_cxx.c
index 506e1f52..1e2af3fc 100644
--- a/llamafile/is_keyword_cxx.c
+++ b/llamafile/is_keyword_cxx.c
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf llamafile/is_keyword_cxx.gperf */
+/* Command-line: gperf is_keyword_cxx.gperf */
/* Computed positions: -k'1,3,5,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -29,11 +29,11 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
#endif
-#line 1 "llamafile/is_keyword_cxx.gperf"
+#line 1 "is_keyword_cxx.gperf"
#include <string.h>
-#define TOTAL_KEYWORDS 142
+#define TOTAL_KEYWORDS 148
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 19
#define MIN_HASH_VALUE 3
@@ -56,8 +56,8 @@ hash (register const char *str, register size_t len)
362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
362, 362, 95, 362, 362, 15, 362, 362, 362, 362,
- 362, 362, 362, 362, 362, 362, 362, 362, 362, 70,
- 362, 40, 362, 362, 362, 362, 10, 362, 362, 362,
+ 362, 362, 362, 362, 362, 362, 362, 362, 5, 70,
+ 140, 125, 75, 362, 30, 362, 15, 362, 362, 362,
362, 362, 362, 362, 362, 362, 362, 362, 362, 15,
0, 362, 362, 362, 362, 362, 362, 362, 0, 362,
10, 362, 362, 362, 362, 362, 362, 362, 362, 362,
@@ -145,12 +145,12 @@ is_keyword_cxx (register const char *str, register size_t len)
"constinit",
"const_cast",
"__attribute",
- "char8_t",
+ "",
"__inline",
"consteval",
"",
"not_eq",
- "",
+ "char8_t",
"continue",
"",
"union",
@@ -162,7 +162,7 @@ is_keyword_cxx (register const char *str, register size_t len)
"extern",
"",
"#warning",
- "",
+ "_Float128",
"catch",
"reinterpret_cast",
"thread_local",
@@ -175,7 +175,7 @@ is_keyword_cxx (register const char *str, register size_t len)
"using",
"__imag",
"__const",
- "char32_t",
+ "_Float16",
"co_return",
"", "", "",
"__attribute__",
@@ -216,7 +216,7 @@ is_keyword_cxx (register const char *str, register size_t len)
"",
"double",
"default",
- "",
+ "_Float64",
"void",
"",
"friend",
@@ -244,11 +244,13 @@ is_keyword_cxx (register const char *str, register size_t len)
"switch",
"or",
"typename",
- "", "",
+ "__float80",
+ "",
"__complex__",
"private",
"__volatile__ ",
- "", "", "", "", "",
+ "", "", "", "",
+ "char32_t",
"namespace",
"",
"#embed",
@@ -267,7 +269,8 @@ is_keyword_cxx (register const char *str, register size_t len)
"__thread",
"", "",
"export",
- "", "",
+ "",
+ "_Float32",
"__real__ ",
"__signed__",
"", "",
@@ -315,11 +318,13 @@ is_keyword_cxx (register const char *str, register size_t len)
"bitand",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
+ "",
+ "__bf16",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "",
"protected",
"",
"public"
diff --git a/llamafile/is_keyword_cxx.gperf b/llamafile/is_keyword_cxx.gperf
index 6dbbe7f7..e58e23d2 100644
--- a/llamafile/is_keyword_cxx.gperf
+++ b/llamafile/is_keyword_cxx.gperf
@@ -20,6 +20,10 @@
"#line"
"#undef"
"#warning"
+_Float128
+_Float16
+_Float32
+_Float64
__FUNCTION__
__PRETTY_FUNCTION__
__alignof
@@ -28,12 +32,14 @@ __asm
__asm__
__attribute
__attribute__
+__bf16
__builtin_offsetof
__builtin_va_arg
__complex
__complex__
__const
__extension__
+__float80
__func__
__imag
__imag__
diff --git a/llamafile/is_keyword_lua.c b/llamafile/is_keyword_lua.c
new file mode 100644
index 00000000..8377b294
--- /dev/null
+++ b/llamafile/is_keyword_lua.c
@@ -0,0 +1,134 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf is_keyword_lua.gperf */
+/* Computed positions: -k'1,$' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646. */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
+#endif
+
+#line 1 "is_keyword_lua.gperf"
+
+#include <string.h>
+
+#define TOTAL_KEYWORDS 22
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 8
+#define MIN_HASH_VALUE 2
+#define MAX_HASH_VALUE 29
+/* maximum key range = 28, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+hash (register const char *str, register size_t len)
+{
+ static const unsigned char asso_values[] =
+ {
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 10, 10, 30,
+ 15, 5, 5, 15, 30, 0, 30, 10, 0, 30,
+ 0, 10, 30, 30, 0, 30, 15, 15, 30, 0,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30
+ };
+ return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
+}
+
+const char *
+is_keyword_lua (register const char *str, register size_t len)
+{
+ static const char * const wordlist[] =
+ {
+ "", "",
+ "in",
+ "nil",
+ "",
+ "local",
+ "return",
+ "if",
+ "for",
+ "",
+ "while",
+ "",
+ "or",
+ "function",
+ "else",
+ "false",
+ "elseif",
+ "",
+ "not",
+ "then",
+ "until",
+ "repeat",
+ "",
+ "end",
+ "true",
+ "break",
+ "",
+ "do",
+ "and",
+ "goto"
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register const char *s = wordlist[key];
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return s;
+ }
+ }
+ return 0;
+}
diff --git a/llamafile/is_keyword_lua.gperf b/llamafile/is_keyword_lua.gperf
new file mode 100644
index 00000000..00a18ed2
--- /dev/null
+++ b/llamafile/is_keyword_lua.gperf
@@ -0,0 +1,30 @@
+%{
+#include <string.h>
+%}
+%compare-strncmp
+%language=ANSI-C
+%readonly-tables
+%define lookup-function-name is_keyword_lua
+%%
+and
+break
+do
+else
+elseif
+end
+false
+for
+function
+goto
+if
+in
+local
+nil
+not
+or
+repeat
+return
+then
+true
+until
+while
diff --git a/llamafile/is_keyword_lua_builtin.c b/llamafile/is_keyword_lua_builtin.c
new file mode 100644
index 00000000..c294d32c
--- /dev/null
+++ b/llamafile/is_keyword_lua_builtin.c
@@ -0,0 +1,207 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf is_keyword_lua_builtin.gperf */
+/* Computed positions: -k'1,4-5' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646. */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
+#endif
+
+#line 1 "is_keyword_lua_builtin.gperf"
+
+#include <string.h>
+
+#define TOTAL_KEYWORDS 61
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 14
+#define MIN_HASH_VALUE 2
+#define MAX_HASH_VALUE 112
+/* maximum key range = 111, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+hash (register const char *str, register size_t len)
+{
+ static const unsigned char asso_values[] =
+ {
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 5, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 5, 0, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 5, 113, 25, 60, 30,
+ 5, 15, 5, 40, 55, 10, 113, 0, 20, 40,
+ 0, 0, 25, 5, 25, 45, 0, 25, 45, 50,
+ 11, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
+ 113, 113, 113, 113, 113, 113
+ };
+ register unsigned int hval = len;
+
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[4]];
+ /*FALLTHROUGH*/
+ case 4:
+ hval += asso_values[(unsigned char)str[3]];
+ /*FALLTHROUGH*/
+ case 3:
+ case 2:
+ case 1:
+ hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval;
+}
+
+const char *
+is_keyword_lua_builtin (register const char *str, register size_t len)
+{
+ static const char * const wordlist[] =
+ {
+ "", "",
+ "os",
+ "",
+ "next",
+ "", "",
+ "_G",
+ "",
+ "__lt",
+ "",
+ "__bnot",
+ "io",
+ "__concat",
+ "__eq",
+ "__mod",
+ "__mode",
+ "__index",
+ "_VERSION",
+ "type",
+ "__add",
+ "",
+ "__bxor",
+ "",
+ "__le",
+ "__len",
+ "__idiv",
+ "", "",
+ "load",
+ "print",
+ "",
+ "__close",
+ "tostring",
+ "utf8",
+ "__bor",
+ "__band",
+ "",
+ "loadfile",
+ "__gc",
+ "table",
+ "dofile",
+ "", "", "",
+ "error",
+ "", "", "", "",
+ "__unm",
+ "ipairs",
+ "",
+ "rawequal",
+ "warn",
+ "__mul",
+ "__call",
+ "package",
+ "", "",
+ "__pow",
+ "string",
+ "xpcall",
+ "",
+ "coroutine",
+ "__div",
+ "rawlen",
+ "require",
+ "", "",
+ "pcall",
+ "assert",
+ "",
+ "tonumber",
+ "",
+ "debug",
+ "__name",
+ "", "",
+ "collectgarbage",
+ "__newindex",
+ "", "", "", "",
+ "__shl",
+ "rawget",
+ "", "", "",
+ "__shr",
+ "rawset",
+ "", "", "",
+ "__sub",
+ "select",
+ "", "",
+ "math",
+ "pairs",
+ "", "", "", "", "", "",
+ "getmetatable",
+ "", "", "", "",
+ "setmetatable"
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register const char *s = wordlist[key];
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return s;
+ }
+ }
+ return 0;
+}
diff --git a/llamafile/is_keyword_lua_builtin.gperf b/llamafile/is_keyword_lua_builtin.gperf
new file mode 100644
index 00000000..a42f01a1
--- /dev/null
+++ b/llamafile/is_keyword_lua_builtin.gperf
@@ -0,0 +1,69 @@
+%{
+#include <string.h>
+%}
+%compare-strncmp
+%language=ANSI-C
+%readonly-tables
+%define lookup-function-name is_keyword_lua_builtin
+%%
+_G
+_VERSION
+__add
+__band
+__bnot
+__bor
+__bxor
+__call
+__close
+__concat
+__div
+__eq
+__gc
+__idiv
+__index
+__le
+__len
+__lt
+__mod
+__mode
+__mul
+__name
+__newindex
+__pow
+__shl
+__shr
+__sub
+__unm
+assert
+collectgarbage
+coroutine
+debug
+dofile
+error
+getmetatable
+io
+ipairs
+load
+loadfile
+math
+next
+os
+package
+pairs
+pcall
+print
+rawequal
+rawget
+rawlen
+rawset
+require
+select
+setmetatable
+string
+table
+tonumber
+tostring
+type
+utf8
+warn
+xpcall