emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/zig-mode 859a4dc 071/104: Use rx macro and add more possib


From: ELPA Syncer
Subject: [nongnu] elpa/zig-mode 859a4dc 071/104: Use rx macro and add more possibilities for type annotations
Date: Sun, 29 Aug 2021 11:37:05 -0400 (EDT)

branch: elpa/zig-mode
commit 859a4dc4b71c6556bd3fadf61e0239ae72360aa2
Author: joachimschmidt557 <joachim.schmidt557@outlook.com>
Commit: joachimschmidt557 <joachim.schmidt557@outlook.com>

    Use rx macro and add more possibilities for type annotations
---
 zig-mode.el | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/zig-mode.el b/zig-mode.el
index f3b4c14..44e1179 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -128,23 +128,24 @@ If given a SOURCE, execute the CMD on it."
                         (compilation-mode))
                   (revert-buffer :ignore-auto :noconfirm)))))))
 
-(defun zig-re-word (inner)
-  "Construct a regular expression for the word INNER."
-  (concat "\\<" inner "\\>"))
+(defconst zig-re-identifier
+  (rx (any "_" word)
+      (* (any "_" word digit))))
 
-(defun zig-re-grab (inner)
-  "Construct a group regular expression for INNER."
-  (concat "\\(" inner "\\)"))
+(defconst zig-re-type
+  (rx (* (| "?" "[_]" "*" "[]"))
+      (regexp zig-re-identifier)))
 
-(defconst zig-re-identifier "[[:word:]_][[:word:]_[:digit:]]*")
 (defconst zig-re-type-annotation
-  (concat (zig-re-grab zig-re-identifier)
-          "[[:space:]]*:[[:space:]]*"
-          (zig-re-grab zig-re-identifier)))
+  (rx (group (regexp zig-re-identifier))
+      (* (any space)) ":" (* (any space))
+      (group (regexp zig-re-type))))
 
 (defun zig-re-definition (dtype)
   "Construct a regular expression for definitions of type DTYPE."
-  (concat (zig-re-word dtype) "[[:space:]]+" (zig-re-grab zig-re-identifier)))
+  (rx bow (literal dtype) eow
+      (+ (any space))
+      (group (regexp zig-re-identifier))))
 
 (defconst zig-mode-syntax-table
   (let ((table (make-syntax-table)))
@@ -383,10 +384,10 @@ If given a SOURCE, execute the CMD on it."
 ;;; Imenu support
 (defun zig-re-structure-def-imenu (stype)
   "Construct a regular expression for strucutres definitions of type STYPE."
-  (concat (zig-re-word "const") "[[:space:]]+"
-          (zig-re-grab zig-re-identifier)
-          ".*"
-          (zig-re-word stype)))
+  (rx bow "const" eow (+ (any space))
+      (group (regexp zig-re-identifier))
+      (* not-newline)
+      bow (literal stype) eow))
 
 (defvar zig-imenu-generic-expression
   (append (mapcar (lambda (x)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]