Skip to content

Distribute and run LLMs with a single file.

Make D syntax highlighting better

Justine Tunney0068a3711d79
diff --git a/llamafile/highlight.cpp b/llamafile/highlight.cpp
index 574adaa1..12fa0850 100644
--- a/llamafile/highlight.cpp
+++ b/llamafile/highlight.cpp
@@ -163,7 +163,7 @@ Highlight *Highlight::create(const std::string_view &lang) {
return new HighlightSwift;
if (lang == "d")
- return new HighlightC(is_keyword_d);
+ return new HighlightC(is_keyword_d, nullptr, nullptr, is_keyword_d_constant);
if (lang == "r")
return new HighlightR;
diff --git a/llamafile/highlight.h b/llamafile/highlight.h
index a2fadd57..4e0c02fa 100644
--- a/llamafile/highlight.h
+++ b/llamafile/highlight.h
@@ -105,6 +105,7 @@ is_keyword_f is_keyword_swift_type;
is_keyword_f is_keyword_swift_builtin;
is_keyword_f is_keyword_swift_constant;
is_keyword_f is_keyword_d;
+is_keyword_f is_keyword_d_constant;
is_keyword_f is_keyword_zig;
is_keyword_f is_keyword_zig_type;
is_keyword_f is_keyword_zig_builtin;
diff --git a/llamafile/is_keyword_d.gperf b/llamafile/is_keyword_d.gperf
index eecd1619..f4e0d06f 100644
--- a/llamafile/is_keyword_d.gperf
+++ b/llamafile/is_keyword_d.gperf
@@ -50,7 +50,6 @@ else
enum
export
extern
-false
final
finally
float
@@ -78,7 +77,6 @@ mixin
module
new
nothrow
-null
out
override
package
@@ -101,7 +99,6 @@ synchronized
template
this
throw
-true
try
typeid
typeof
diff --git a/llamafile/is_keyword_d_constant.gperf b/llamafile/is_keyword_d_constant.gperf
new file mode 100644
index 00000000..3a710c94
--- /dev/null
+++ b/llamafile/is_keyword_d_constant.gperf
@@ -0,0 +1,18 @@
+%{
+#include <string.h>
+%}
+%pic
+%compare-strncmp
+%language=ANSI-C
+%readonly-tables
+%define lookup-function-name is_keyword_d_constant
+%%
+__FILE_FULL_PATH__
+__FILE__
+__FUNCTION__
+__LINE__
+__MODULE__
+__PRETTY_FUNCTION__
+false
+null
+true