Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Add assembly syntax highlighting
Justine Tunneyd4eac09722c5
diff --git a/llamafile/highlight.cpp b/llamafile/highlight.cppindex cda98467..11fe2934 100644--- a/llamafile/highlight.cpp+++ b/llamafile/highlight.cpp@@ -45,6 +45,15 @@ Highlight *Highlight::create(const std::string_view &lang) {is_keyword_c_builtin, //is_keyword_c_constant);+ if (lang == "s" || //+ lang == "asm" || //+ lang == "nasm" || //+ lang == "yasm" || //+ lang == "fasm" || //+ lang == "assembly" || //+ lang == "assembler")+ return new HighlightAsm;+if (lang == "js" || //lang == "json" || //lang == "javascript")diff --git a/llamafile/highlight.h b/llamafile/highlight.hindex 6df55998..66c9556f 100644--- a/llamafile/highlight.h+++ b/llamafile/highlight.h@@ -45,6 +45,9 @@#define HI_ENTITY "\033[36m" // cyan#define HI_OPERATOR "\033[36m" // cyan#define HI_ESCAPE "\033[33m" // yellow+#define HI_QUALIFIER "\033[35m" // magenta+#define HI_IMMEDIATE "\033[36m" // cyan+#define HI_REGISTER "\033[1;35m" // bold magentatypedef const char *is_keyword_f(const char *, size_t);@@ -109,6 +112,8 @@ is_keyword_f is_keyword_forth_def;is_keyword_f is_keyword_m4;is_keyword_f is_keyword_make;is_keyword_f is_keyword_make_builtin;+is_keyword_f is_keyword_asm_prefix;+is_keyword_f is_keyword_asm_qualifier;}class Highlight {@@ -227,6 +232,8 @@ class HighlightMarkdown : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;bool bol_ = true;bool tail_ = false;@@ -396,9 +403,10 @@ class HighlightPerl : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;int i_ = 0;- int c_ = 0;int last_ = 0;int expect_ = 0;unsigned char opener_ = 0;@@ -417,6 +425,8 @@ class HighlightShell : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;int i_ = 0;bool pending_heredoc_ = false;@@ -433,6 +443,8 @@ class HighlightZig : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;std::string word_;};@@ -445,6 +457,8 @@ class HighlightTcl : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;std::string word_;};@@ -518,6 +532,26 @@ class HighlightMake : public Highlight {void flush(std::string *result) override;private:+ int c_ = 0;+ int u_ = 0;+ int t_ = 0;+ std::string word_;+};++class HighlightAsm : public Highlight {+ public:+ HighlightAsm();+ ~HighlightAsm() override;+ void feed(std::string *result, std::string_view input) override;+ void flush(std::string *result) override;++ private:+ int c_ = 0;+ int u_ = 0;int t_ = 0;+ int col_ = 0;+ int last_ = 0;+ bool is_preprocessor_ = false;+ bool is_first_thing_on_line_ = true;std::string word_;};diff --git a/llamafile/highlight_asm.cpp b/llamafile/highlight_asm.cppnew file mode 100644index 00000000..8a3f07ab--- /dev/null+++ b/llamafile/highlight_asm.cpp@@ -0,0 +1,451 @@+// -*- 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 "string.h"+#include <cosmo.h>+#include <ctype.h>++// syntax highlighting for assembly code+//+// this syntax highlighter aims to support a blended dialect of+//+// - at&t style assembly (e.g. gnu as)+// - intel style assembly (e.g. nasm)+// - arm style assembly+// - c preprocessor+// - m4+//+// doing that requires special care++enum {+ NORMAL,+ WORD,+ COMMENT,+ BACKSLASH,+ SLASH0,+ SLASH,+ REG0,+ REG,+ SLASH_SLASH,+ SLASH_STAR,+ SLASH_STAR_STAR,+ QUOTE,+ QUOTE_BACKSLASH,+ QUOTE_FINISH,+ DQUOTE,+ DQUOTE_BACKSLASH,+ DOLLAR,+ IMMEDIATE,+ IMMEDIATE_QUOTE,+ IMMEDIATE_QUOTE_BACKSLASH,+ IMMEDIATE_QUOTE_FINISH,+ HASH,+};++static bool is_immediate(int c) {+ switch (c) {+ case '&':+ case '*':+ case '+':+ case '-':+ case '/':+ case '0' ... '9':+ case '<':+ case '>':+ case 'A' ... 'Z':+ case '^':+ case '_':+ case 'a' ... 'z':+ case '|':+ return true;+ default:+ return false;+ }+}++HighlightAsm::HighlightAsm() {+}++HighlightAsm::~HighlightAsm() {+}++void HighlightAsm::feed(std::string *r, std::string_view input) {+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ last_ = c_;+ if (!u_) {+ if (b < 0300) {+ c_ = c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }+ switch (t_) {++ Normal:+ case NORMAL:+ if (!isascii(c) || //+ isalnum(c) || //+ c == '-' || //+ c == '.' || //+ c == '@' || //+ c == '_' || //+ (c == '#' && col_ == 0)) {+ t_ = WORD;+ append_wchar(&word_, c);+ break;+ } else if (c == '#' && col_ && isspace(last_)) {+ t_ = HASH;+ } else if ((c == ';' || c == '!') && (!col_ || isspace(last_))) {+ t_ = COMMENT;+ *r += HI_COMMENT;+ append_wchar(r, c);+ } else if (c == '/' && col_ == 0) {+ // bell system five allowed single slash comments+ // anywhere on the line, but we limit that a bit.+ t_ = SLASH0;+ *r += HI_COMMENT;+ *r += '/';+ } else if (c == '/') {+ t_ = SLASH;+ is_first_thing_on_line_ = false;+ } else if (c == '$') {+ *r += '$';+ t_ = DOLLAR;+ is_first_thing_on_line_ = false;+ } else if (c == '%') {+ t_ = REG0;+ is_first_thing_on_line_ = false;+ } else if (c == '\\') {+ t_ = BACKSLASH;+ *r += HI_ESCAPE;+ *r += '\\';+ is_first_thing_on_line_ = false;+ } else if (c == '\'') {+ t_ = QUOTE;+ *r += HI_STRING;+ *r += c;+ } else if (c == '"') {+ t_ = DQUOTE;+ *r += HI_STRING;+ *r += c;+ } else {+ if (c == '\n')+ is_preprocessor_ = false;+ if (!isspace(c))+ is_first_thing_on_line_ = false;+ if (c == ':')+ is_first_thing_on_line_ = true;+ append_wchar(r, c);+ }+ break;++ case DOLLAR:+ if (is_immediate(c) || c == '\'') {+ *r += HI_IMMEDIATE;+ t_ = IMMEDIATE;+ } else {+ t_ = NORMAL;+ goto Normal;+ }+ // fallthrough++ Immediate:+ case IMMEDIATE:+ if (is_immediate(c)) {+ append_wchar(r, c);+ } else if (c == '\'') {+ append_wchar(r, c);+ t_ = IMMEDIATE_QUOTE;+ } else {+ *r += HI_RESET;+ t_ = NORMAL;+ goto Normal;+ }+ break;++ case IMMEDIATE_QUOTE:+ if (c == '\\') {+ append_wchar(r, c);+ t_ = IMMEDIATE_QUOTE_BACKSLASH;+ } else if (c == '\n') {+ *r += HI_RESET;+ t_ = NORMAL;+ goto Normal;+ } else {+ append_wchar(r, c);+ t_ = IMMEDIATE_QUOTE_FINISH;+ }+ break;++ case IMMEDIATE_QUOTE_BACKSLASH:+ append_wchar(r, c);+ t_ = IMMEDIATE_QUOTE_FINISH;+ break;++ case IMMEDIATE_QUOTE_FINISH:+ if (c == '\'') {+ append_wchar(r, c);+ t_ = IMMEDIATE;+ } else {+ // yes '" means '"' in bell system five+ t_ = IMMEDIATE;+ goto Immediate;+ }+ break;++ case BACKSLASH:+ append_wchar(r, c);+ *r += HI_RESET;+ t_ = NORMAL;+ break;++ case HASH:+ if (isspace(c)) {+ *r += HI_COMMENT;+ *r += '#';+ t_ = COMMENT;+ goto Comment;+ } else {+ word_ += '#';+ t_ = WORD;+ }+ // fallthrough++ case WORD:+ if (!isascii(c) || isalnum(c) || c == '$' || c == '_' || c == '-' || c == '.') {+ append_wchar(&word_, c);+ } else {+ if (is_first_thing_on_line_) {+ if (word_.size() > 1 && word_[0] == '#' &&+ is_keyword_c_builtin(word_.data(), word_.size())) {+ *r += HI_BUILTIN;+ *r += word_;+ *r += HI_RESET;+ is_first_thing_on_line_ = false;+ is_preprocessor_ = true;+ } else if (c == ':') {+ *r += HI_LABEL;+ *r += word_;+ *r += HI_RESET;+ } else if (word_ == "C" || word_ == "dnl" || word_ == "m4_dnl") {+ *r += HI_COMMENT;+ *r += word_;+ word_.clear();+ t_ = COMMENT;+ goto Comment;+ } else {+ *r += HI_KEYWORD;+ *r += word_;+ *r += HI_RESET;+ if (!is_keyword_asm_prefix(word_.data(), word_.size()))+ is_first_thing_on_line_ = false;+ }+ } else if (is_preprocessor_ && is_keyword_c_builtin(word_.data(), word_.size())) {+ *r += HI_BUILTIN;+ *r += word_;+ *r += HI_RESET;+ } else if (is_keyword_asm_qualifier(word_.data(), word_.size())) {+ *r += HI_QUALIFIER;+ *r += word_;+ *r += HI_RESET;+ } else if (is_keyword_c_constant(word_.data(), word_.size())) {+ *r += HI_CONSTANT;+ *r += word_;+ *r += HI_RESET;+ } else {+ *r += word_;+ }+ word_.clear();+ t_ = NORMAL;+ goto Normal;+ }+ break;++ case REG0:+ if (isalpha(c) || c == '(' || c == ')') {+ t_ = REG;+ *r += HI_REGISTER;+ *r += '%';+ } else {+ *r += '%';+ t_ = NORMAL;+ goto Normal;+ }+ // fallthrough++ case REG:+ if (isalnum(c)) {+ append_wchar(r, c);+ } else {+ *r += HI_RESET;+ t_ = NORMAL;+ goto Normal;+ }+ break;++ case QUOTE:+ *r += c;+ if (c == '\'' || c == '\n') {+ *r += HI_RESET;+ t_ = NORMAL;+ } else if (c == '\\') {+ t_ = QUOTE_BACKSLASH;+ }+ break;++ case QUOTE_BACKSLASH:+ *r += c;+ t_ = QUOTE;+ break;++ case DQUOTE:+ *r += c;+ if (c == '"') {+ *r += HI_RESET;+ t_ = NORMAL;+ } else if (c == '\\') {+ t_ = DQUOTE_BACKSLASH;+ }+ break;++ case DQUOTE_BACKSLASH:+ *r += c;+ t_ = DQUOTE;+ break;++ case SLASH0:+ if (c == '*') {+ *r += '*';+ t_ = SLASH_STAR;+ } else {+ t_ = COMMENT;+ goto Comment;+ }+ break;++ case SLASH:+ if (c == '/') {+ *r += HI_COMMENT;+ *r += "//";+ t_ = SLASH_SLASH;+ } else if (c == '*') {+ *r += HI_COMMENT;+ *r += "/*";+ t_ = SLASH_STAR;+ } else {+ *r += '/';+ t_ = NORMAL;+ goto Normal;+ }+ break;++ case SLASH_SLASH:+ if (c == '\n') {+ *r += HI_RESET;+ append_wchar(r, c);+ t_ = NORMAL;+ } else {+ append_wchar(r, c);+ }+ break;++ case SLASH_STAR:+ append_wchar(r, c);+ if (c == '*')+ t_ = SLASH_STAR_STAR;+ break;++ case SLASH_STAR_STAR:+ append_wchar(r, c);+ if (c == '/') {+ *r += HI_RESET;+ t_ = NORMAL;+ } else if (c != '*') {+ t_ = SLASH_STAR;+ }+ break;++ Comment:+ case COMMENT:+ if (c == '\n') {+ *r += HI_RESET;+ *r += '\n';+ t_ = NORMAL;+ } else {+ append_wchar(r, c);+ }+ break;++ default:+ __builtin_unreachable();+ }++ if (c != '\n') {+ col_ += 1;+ } else {+ col_ = 0;+ is_first_thing_on_line_ = true;+ }+ }+}++void HighlightAsm::flush(std::string *r) {+ switch (t_) {+ case WORD:+ *r += word_;+ word_.clear();+ break;+ case HASH:+ *r += '#';+ break;+ case REG0:+ *r += '%';+ break;+ case SLASH:+ *r += '/';+ break;+ case REG:+ case SLASH0:+ case COMMENT:+ case BACKSLASH:+ case SLASH_SLASH:+ case SLASH_STAR:+ case SLASH_STAR_STAR:+ case QUOTE:+ case QUOTE_BACKSLASH:+ case DQUOTE:+ case DQUOTE_BACKSLASH:+ case IMMEDIATE:+ case IMMEDIATE_QUOTE:+ case IMMEDIATE_QUOTE_BACKSLASH:+ case IMMEDIATE_QUOTE_FINISH:+ *r += HI_RESET;+ break;+ default:+ break;+ }+ t_ = NORMAL;+}diff --git a/llamafile/highlight_make.cpp b/llamafile/highlight_make.cppindex 97eb5e8a..702f8e2c 100644--- a/llamafile/highlight_make.cpp+++ b/llamafile/highlight_make.cpp@@ -17,6 +17,7 @@#include "highlight.h"#include "string.h"+#include <cosmo.h>#include <ctype.h>enum {@@ -52,8 +53,22 @@ HighlightMake::~HighlightMake() {}void HighlightMake::feed(std::string *r, std::string_view input) {- for (size_t i = 0; i < input.size();) {- wchar_t c = read_wchar(input, &i);+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ if (!u_) {+ if (b < 0300) {+ c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/highlight_markdown.cpp b/llamafile/highlight_markdown.cppindex d432986f..797de276 100644--- a/llamafile/highlight_markdown.cpp+++ b/llamafile/highlight_markdown.cpp@@ -46,8 +46,22 @@ HighlightMarkdown::~HighlightMarkdown() {}void HighlightMarkdown::feed(std::string *r, std::string_view input) {- for (size_t i = 0; i < input.size();) {- wchar_t c = read_wchar(input, &i);+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ if (!u_) {+ if (b < 0300) {+ c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/highlight_perl.cpp b/llamafile/highlight_perl.cppindex 7fd6e726..9c3f4c1a 100644--- a/llamafile/highlight_perl.cpp+++ b/llamafile/highlight_perl.cpp@@ -17,6 +17,7 @@#include "highlight.h"#include "string.h"+#include <cosmo.h>#include <ctype.h>enum {@@ -147,10 +148,23 @@ HighlightPerl::~HighlightPerl() {}void HighlightPerl::feed(std::string *r, std::string_view input) {- int c = 0;- for (size_t i = 0; i < input.size();) {+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;last_ = c_;- c_ = c = read_wchar(input, &i);+ if (!u_) {+ if (b < 0300) {+ c_ = c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c_ = c = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/highlight_shell.cpp b/llamafile/highlight_shell.cppindex e9f9191c..303291c8 100644--- a/llamafile/highlight_shell.cpp+++ b/llamafile/highlight_shell.cpp@@ -17,6 +17,7 @@#include "highlight.h"#include "string.h"+#include <cosmo.h>#include <ctype.h>enum {@@ -46,8 +47,22 @@ HighlightShell::~HighlightShell() {}void HighlightShell::feed(std::string *r, std::string_view input) {- for (size_t i = 0; i < input.size();) {- wchar_t c = read_wchar(input, &i);+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ if (!u_) {+ if (b < 0300) {+ c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/highlight_tcl.cpp b/llamafile/highlight_tcl.cppindex 495eb256..ccaa0788 100644--- a/llamafile/highlight_tcl.cpp+++ b/llamafile/highlight_tcl.cpp@@ -17,6 +17,7 @@#include "highlight.h"#include "string.h"+#include <cosmo.h>#include <ctype.h>enum {@@ -38,8 +39,22 @@ HighlightTcl::~HighlightTcl() {}void HighlightTcl::feed(std::string *r, std::string_view input) {- for (size_t i = 0; i < input.size();) {- wchar_t c = read_wchar(input, &i);+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ if (!u_) {+ if (b < 0300) {+ c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/highlight_test.cpp b/llamafile/highlight_test.cppindex ae1478ac..f4229900 100644--- a/llamafile/highlight_test.cpp+++ b/llamafile/highlight_test.cpp@@ -29,6 +29,7 @@const char *const kLanguages[] = {"ada", //+ "asm", //"c", //"c#", //"c++", //diff --git a/llamafile/highlight_zig.cpp b/llamafile/highlight_zig.cppindex fed96513..1f21d378 100644--- a/llamafile/highlight_zig.cpp+++ b/llamafile/highlight_zig.cpp@@ -17,6 +17,7 @@#include "highlight.h"#include "string.h"+#include <cosmo.h>#include <ctype.h>enum {@@ -39,8 +40,22 @@ HighlightZig::~HighlightZig() {}void HighlightZig::feed(std::string *r, std::string_view input) {- for (size_t i = 0; i < input.size();) {- wchar_t c = read_wchar(input, &i);+ for (size_t i = 0; i < input.size(); ++i) {+ wchar_t c;+ int b = input[i] & 255;+ if (!u_) {+ if (b < 0300) {+ c = b;+ } else {+ c_ = ThomPikeByte(b);+ u_ = ThomPikeLen(b) - 1;+ continue;+ }+ } else {+ c = c_ = ThomPikeMerge(c_, b);+ if (--u_)+ continue;+ }switch (t_) {Normal:diff --git a/llamafile/is_keyword_asm_prefix.c b/llamafile/is_keyword_asm_prefix.cnew file mode 100644index 00000000..6ec1f185--- /dev/null+++ b/llamafile/is_keyword_asm_prefix.c@@ -0,0 +1,287 @@+/* ANSI-C code produced by gperf version 3.1 */+/* Command-line: gperf --output-file=llamafile/is_keyword_asm_prefix.c llamafile/is_keyword_asm_prefix.gperf */+/* Computed positions: -k'1,5-6,$' */++#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 "llamafile/is_keyword_asm_prefix.gperf"++#include <string.h>+#include <libc/str/tab.h>+#define GPERF_DOWNCASE++#define TOTAL_KEYWORDS 30+#define MIN_WORD_LENGTH 2+#define MAX_WORD_LENGTH 8+#define MIN_HASH_VALUE 2+#define MAX_HASH_VALUE 70+/* maximum key range = 69, duplicates = 0 */++#ifndef GPERF_DOWNCASE+#define GPERF_DOWNCASE 1+static unsigned char gperf_downcase[256] =+ {+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,+ 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,+ 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,+ 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,+ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,+ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,+ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,+ 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,+ 255+ };+#endif++#ifndef GPERF_CASE_STRNCMP+#define GPERF_CASE_STRNCMP 1+static int+gperf_case_strncmp (register const char *s1, register const char *s2, register size_t n)+{+ for (; n > 0;)+ {+ unsigned char c1 = gperf_downcase[(unsigned char)*s1++];+ unsigned char c2 = gperf_downcase[(unsigned char)*s2++];+ if (c1 != 0 && c1 == c2)+ {+ n--;+ continue;+ }+ return (int)c1 - (int)c2;+ }+ return 0;+}+#endif++#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[] =+ {+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 0,+ 0, 0, 71, 71, 0, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 0, 10, 30, 15, 20,+ 10, 5, 71, 71, 71, 0, 0, 71, 71, 71,+ 5, 71, 5, 0, 71, 71, 71, 30, 0, 71,+ 15, 71, 71, 71, 71, 71, 71, 0, 10, 30,+ 15, 20, 10, 5, 71, 71, 71, 0, 0, 71,+ 71, 71, 5, 71, 5, 0, 71, 71, 71, 30,+ 0, 71, 15, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,+ 71, 71, 71, 71, 71, 71+ };+ register unsigned int hval = len;++ switch (hval)+ {+ default:+ hval += asso_values[(unsigned char)str[5]];+ /*FALLTHROUGH*/+ case 5:+ hval += asso_values[(unsigned char)str[4]];+ /*FALLTHROUGH*/+ case 4:+ case 3:+ case 2:+ case 1:+ hval += asso_values[(unsigned char)str[0]];+ break;+ }+ return hval + asso_values[(unsigned char)str[len - 1]];+}++const char *+is_keyword_asm_prefix (register const char *str, register size_t len)+{+ struct stringpool_t+ {+ char stringpool_str2[sizeof("ss")];+ char stringpool_str4[sizeof("lock")];+ char stringpool_str6[sizeof("addr32")];+ char stringpool_str7[sizeof("gs")];+ char stringpool_str8[sizeof("rex")];+ char stringpool_str10[sizeof("rex.x")];+ char stringpool_str12[sizeof("fs")];+ char stringpool_str13[sizeof("rep")];+ char stringpool_str16[sizeof("rex.rx")];+ char stringpool_str17[sizeof("ds")];+ char stringpool_str20[sizeof("rex.r")];+ char stringpool_str21[sizeof("data16")];+ char stringpool_str22[sizeof("es")];+ char stringpool_str24[sizeof("repz")];+ char stringpool_str27[sizeof("rex.rxb")];+ char stringpool_str29[sizeof("repe")];+ char stringpool_str30[sizeof("rex.b")];+ char stringpool_str31[sizeof("rex.xb")];+ char stringpool_str32[sizeof("cs")];+ char stringpool_str36[sizeof("rex.rb")];+ char stringpool_str40[sizeof("repnz")];+ char stringpool_str41[sizeof("rex.wx")];+ char stringpool_str47[sizeof("rex.wrx")];+ char stringpool_str50[sizeof("repne")];+ char stringpool_str51[sizeof("rex.wr")];+ char stringpool_str52[sizeof("rex.wxb")];+ char stringpool_str57[sizeof("rex.wrb")];+ char stringpool_str58[sizeof("rex.wrxb")];+ char stringpool_str61[sizeof("rex.wb")];+ char stringpool_str70[sizeof("rex.w")];+ };+ static const struct stringpool_t stringpool_contents =+ {+ "ss",+ "lock",+ "addr32",+ "gs",+ "rex",+ "rex.x",+ "fs",+ "rep",+ "rex.rx",+ "ds",+ "rex.r",+ "data16",+ "es",+ "repz",+ "rex.rxb",+ "repe",+ "rex.b",+ "rex.xb",+ "cs",+ "rex.rb",+ "repnz",+ "rex.wx",+ "rex.wrx",+ "repne",+ "rex.wr",+ "rex.wxb",+ "rex.wrb",+ "rex.wrxb",+ "rex.wb",+ "rex.w"+ };+ #define stringpool ((const char *) &stringpool_contents)+ static const int wordlist[] =+ {+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str2,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str4,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str6,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str7,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str8,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str10,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str12,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str13,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str16,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str17,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str20,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str21,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str22,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str24,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str27,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str29,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str30,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str31,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str32,+ -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str36,+ -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str40,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str41,+ -1, -1, -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str47,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str50,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str51,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str52,+ -1, -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str57,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str58,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str61,+ -1, -1, -1, -1, -1, -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str70+ };++ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)+ {+ register unsigned int key = hash (str, len);++ if (key <= MAX_HASH_VALUE)+ {+ register int o = wordlist[key];+ if (o >= 0)+ {+ register const char *s = o + stringpool;++ if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0')+ return s;+ }+ }+ }+ return 0;+}diff --git a/llamafile/is_keyword_asm_prefix.gperf b/llamafile/is_keyword_asm_prefix.gperfnew file mode 100644index 00000000..da566ac8--- /dev/null+++ b/llamafile/is_keyword_asm_prefix.gperf@@ -0,0 +1,42 @@+%{+#include <string.h>+#include <libc/str/tab.h>+#define GPERF_DOWNCASE+%}+%pic+%ignore-case+%compare-strncmp+%language=ANSI-C+%readonly-tables+%define lookup-function-name is_keyword_asm_prefix+%%+addr32+cs+data16+ds+es+fs+gs+lock+rep+repe+repne+repnz+repz+rex+rex.b+rex.r+rex.rb+rex.rx+rex.rxb+rex.w+rex.wb+rex.wr+rex.wrb+rex.wrx+rex.wrxb+rex.wx+rex.wxb+rex.x+rex.xb+ssdiff --git a/llamafile/is_keyword_asm_qualifier.c b/llamafile/is_keyword_asm_qualifier.cnew file mode 100644index 00000000..bf942c80--- /dev/null+++ b/llamafile/is_keyword_asm_qualifier.c@@ -0,0 +1,266 @@+/* ANSI-C code produced by gperf version 3.1 */+/* Command-line: gperf --output-file=llamafile/is_keyword_asm_qualifier.c llamafile/is_keyword_asm_qualifier.gperf */+/* Computed positions: -k'2,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 "llamafile/is_keyword_asm_qualifier.gperf"++#include <string.h>+#include <libc/str/tab.h>+#define GPERF_DOWNCASE++#define TOTAL_KEYWORDS 25+#define MIN_WORD_LENGTH 4+#define MAX_WORD_LENGTH 22+#define MIN_HASH_VALUE 4+#define MAX_HASH_VALUE 47+/* maximum key range = 44, duplicates = 0 */++#ifndef GPERF_DOWNCASE+#define GPERF_DOWNCASE 1+static unsigned char gperf_downcase[256] =+ {+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,+ 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,+ 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,+ 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,+ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,+ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,+ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,+ 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,+ 255+ };+#endif++#ifndef GPERF_CASE_STRNCMP+#define GPERF_CASE_STRNCMP 1+static int+gperf_case_strncmp (register const char *s1, register const char *s2, register size_t n)+{+ for (; n > 0;)+ {+ unsigned char c1 = gperf_downcase[(unsigned char)*s1++];+ unsigned char c2 = gperf_downcase[(unsigned char)*s2++];+ if (c1 != 0 && c1 == c2)+ {+ n--;+ continue;+ }+ return (int)c1 - (int)c2;+ }+ return 0;+}+#endif++#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[] =+ {+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 5, 48, 5, 48,+ 0, 20, 0, 5, 10, 48, 48, 5, 5, 8,+ 0, 5, 25, 0, 0, 15, 30, 48, 48, 48,+ 25, 48, 48, 48, 48, 48, 5, 48, 5, 48,+ 5, 48, 0, 20, 0, 5, 10, 48, 48, 5,+ 5, 8, 0, 5, 25, 0, 0, 15, 30, 48,+ 48, 48, 25, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,+ 48, 48, 48, 48, 48, 48, 48+ };+ register unsigned int hval = len;++ switch (hval)+ {+ default:+ hval += asso_values[(unsigned char)str[4]+1];+ /*FALLTHROUGH*/+ case 4:+ case 3:+ case 2:+ hval += asso_values[(unsigned char)str[1]];+ break;+ }+ return hval;+}++const char *+is_keyword_asm_qualifier (register const char *str, register size_t len)+{+ struct stringpool_t+ {+ char stringpool_str4[sizeof("@plt")];+ char stringpool_str5[sizeof("@size")];+ char stringpool_str6[sizeof("@tlsgd")];+ char stringpool_str7[sizeof("@pltoff")];+ char stringpool_str9[sizeof("@progbits")];+ char stringpool_str10[sizeof("@note")];+ char stringpool_str11[sizeof("@tlsld")];+ char stringpool_str12[sizeof("@dtpoff")];+ char stringpool_str14[sizeof("@function")];+ char stringpool_str15[sizeof("@object")];+ char stringpool_str17[sizeof("@dtpmod")];+ char stringpool_str19[sizeof("comdat")];+ char stringpool_str21[sizeof("@fini_array")];+ char stringpool_str22[sizeof("@nobits")];+ char stringpool_str24[sizeof("@got")];+ char stringpool_str26[sizeof("@tpoff")];+ char stringpool_str27[sizeof("@gotoff")];+ char stringpool_str29[sizeof(":req")];+ char stringpool_str31[sizeof("@init_array")];+ char stringpool_str32[sizeof("@unwind")];+ char stringpool_str34[sizeof("@gotpcrel")];+ char stringpool_str37[sizeof("@notype")];+ char stringpool_str42[sizeof(":vararg")];+ char stringpool_str44[sizeof("@gottpoff")];+ char stringpool_str47[sizeof("@gnu_indirect_function")];+ };+ static const struct stringpool_t stringpool_contents =+ {+ "@plt",+ "@size",+ "@tlsgd",+ "@pltoff",+ "@progbits",+ "@note",+ "@tlsld",+ "@dtpoff",+ "@function",+ "@object",+ "@dtpmod",+ "comdat",+ "@fini_array",+ "@nobits",+ "@got",+ "@tpoff",+ "@gotoff",+ ":req",+ "@init_array",+ "@unwind",+ "@gotpcrel",+ "@notype",+ ":vararg",+ "@gottpoff",+ "@gnu_indirect_function"+ };+ #define stringpool ((const char *) &stringpool_contents)+ static const int wordlist[] =+ {+ -1, -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str4,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str5,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str6,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str7,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str9,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str10,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str11,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str12,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str14,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str15,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str17,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str19,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str21,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str22,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str24,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str26,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str27,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str29,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str31,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str32,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str34,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str37,+ -1, -1, -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str42,+ -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str44,+ -1, -1,+ (int)(size_t)&((struct stringpool_t *)0)->stringpool_str47+ };++ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)+ {+ register unsigned int key = hash (str, len);++ if (key <= MAX_HASH_VALUE)+ {+ register int o = wordlist[key];+ if (o >= 0)+ {+ register const char *s = o + stringpool;++ if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0')+ return s;+ }+ }+ }+ return 0;+}diff --git a/llamafile/is_keyword_asm_qualifier.gperf b/llamafile/is_keyword_asm_qualifier.gperfnew file mode 100644index 00000000..0969ba6f--- /dev/null+++ b/llamafile/is_keyword_asm_qualifier.gperf@@ -0,0 +1,37 @@+%{+#include <string.h>+#include <libc/str/tab.h>+#define GPERF_DOWNCASE+%}+%pic+%ignore-case+%compare-strncmp+%language=ANSI-C+%readonly-tables+%define lookup-function-name is_keyword_asm_qualifier+%%+:req+:vararg+@dtpmod+@dtpoff+@fini_array+@function+@gnu_indirect_function+@got+@gotoff+@gotpcrel+@gottpoff+@init_array+@nobits+@note+@notype+@object+@plt+@pltoff+@progbits+@size+@tlsgd+@tlsld+@tpoff+@unwind+comdatdiff --git a/llamafile/string.cpp b/llamafile/string.cppindex 1eff49c0..c988dfa0 100644--- a/llamafile/string.cpp+++ b/llamafile/string.cpp@@ -19,28 +19,6 @@#include <cosmo.h>-wchar_t read_wchar(const std::string_view &s, size_t *i) {- wint_t c = s[(*i)++] & 255;- if (c >= 0300) {- wint_t a = ThomPikeByte(c);- size_t m = ThomPikeLen(c) - 1;- if (*i + m <= s.size()) {- for (int j = 0;;) {- wint_t b = s[*i + j] & 255;- if (!ThomPikeCont(b))- break;- a = ThomPikeMerge(a, b);- if (++j == m) {- c = a;- *i += j;- break;- }- }- }- }- return c;-}-void append_wchar(std::string *r, wchar_t c) {if (isascii(c)) {*r += c;diff --git a/llamafile/string.h b/llamafile/string.hindex 996c0a82..227100ab 100644--- a/llamafile/string.h+++ b/llamafile/string.h@@ -19,4 +19,3 @@#include <string>void append_wchar(std::string *, wchar_t);-wchar_t read_wchar(const std::string_view &, size_t *);