From 36c5d038ae72137716fdc6ad595384d0ac59a6a4 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Tue, 5 Nov 2024 05:36:52 -0800 Subject: [PATCH] Make D syntax highlighting better --- llamafile/highlight.cpp | 2 +- llamafile/highlight.h | 1 + llamafile/is_keyword_d_constant.gperf | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 llamafile/is_keyword_d_constant.gperf diff --git a/llamafile/highlight.cpp b/llamafile/highlight.cpp index 574adaa197..12fa085009 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 a2fadd579e..4e0c02fa26 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_constant.gperf b/llamafile/is_keyword_d_constant.gperf new file mode 100644 index 0000000000..3a710c94c4 --- /dev/null +++ b/llamafile/is_keyword_d_constant.gperf @@ -0,0 +1,18 @@ +%{ +#include +%} +%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