From 39a0c02e354c616db1b6d2d14e14f6b87985d5bc Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Thu, 28 Aug 2025 17:11:44 -0500 Subject: [PATCH] Better --- lisp/llvm-lib/my-llvm-mode.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lisp/llvm-lib/my-llvm-mode.el b/lisp/llvm-lib/my-llvm-mode.el index ac7669f..030bd04 100644 --- a/lisp/llvm-lib/my-llvm-mode.el +++ b/lisp/llvm-lib/my-llvm-mode.el @@ -11,13 +11,17 @@ (defvar llvm-mode-syntax-table (let ((table (make-syntax-table))) - (modify-syntax-entry ?% "_" table) + (modify-syntax-entry ?% "-" table) (modify-syntax-entry ?. "_" table) + (modify-syntax-entry ?- "_" table) + (modify-syntax-entry ?: "-" table) (modify-syntax-entry ?\; "< " table) (modify-syntax-entry ?\n "> " table) (modify-syntax-entry ?/ ". 124b" table) (modify-syntax-entry ?* ". 23" table) - table) + ;; (setq llvm-mode-syntax-table table) + table + ) "Syntax table used while in LLVM mode.") (defvar llvm-font-lock-keyword-words @@ -81,14 +85,14 @@ (,(regexp-opt '("nnan" "ninf" "nsz" "arcp" "contract" "afn" "reassoc" "fast") 'symbols) . font-lock-keyword-face) ;; Use-list order directives (,(regexp-opt '("uselistorder" "uselistorder_bb") 'symbols) . font-lock-keyword-face) - (,(rx "@" symbol-start (+? nonl) symbol-end) . font-lock-function-name-face) + (,(rx "@" symbol-start (+? (or (syntax symbol) (syntax word))) symbol-end) . font-lock-function-name-face) ;; Integer literals ("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face) )) (defvar llvm-pre-opcode-attributes (rx symbol-start - (or "nnan" "ninf" "nsz" "arcp" "contract" "afn" "reassoc" "fast" "nsw" "nuw") + (or "nnan" "ninf" "nsz" "arcp" "contract" "afn" "reassoc" "fast" "nsw" "nuw" "mc-replicate") symbol-end)) (defvar llvm-font-lock-keywords @@ -116,7 +120,7 @@ (+ (or alphanumeric (any "_.")))) . font-lock-variable-name-face) ;; Variables - (,(rx symbol-start (any "%$") (+ (or alphanumeric (any "_.")))) . font-lock-variable-name-face) + (,(rx (any "%$") symbol-start (+? (or (syntax symbol) (syntax word))) symbol-end) . font-lock-variable-name-face) ;; Attributes (,(rx "!" (+ (or alphanumeric (any "._")))) . 'shadow) ;; Machine Opcodes @@ -141,16 +145,19 @@ "type" "label" "opaque" "token") symbol-end) . font-lock-type-face) + ;; Other Attributes + (,(rx (or "renamable" "killed " "implicit-def" "implicit" "debug-location" "nsw" "nuw" "align" "dead" "early-clobber")) . 'shadow) + + ,@llvm-font-lock-keyword-words + + (,(rx "$" (+ (or (syntax symbol) (syntax word))) symbol-end) . 'font-lock-variable-use-face) + ;; Floating point constants ("\\b[-+]?[0-9]+.[0-9]*\\([eE][-+]?[0-9]+\\)?\\b" . font-lock-preprocessor-face) ;; Hex constants ("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face) ;; Integer literals ("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face) - ;; Other Attributes - (,(rx (or "renamable" "killed " "implicit-def" "implicit" "debug-location" "nsw" "nuw" "align" "dead")) . 'shadow) - - ,@llvm-font-lock-keyword-words ) "Syntax highlighting for LLVM.")