@@ -130,23 +130,24 @@ If given a SOURCE, execute the CMD on it."
130
130
(compilation-mode ))
131
131
(revert-buffer :ignore-auto :noconfirm )))))))
132
132
133
- (defun zig-re-word ( inner )
134
- " Construct a regular expression for the word INNER. "
135
- ( concat " \\ < " inner " \\ > " ))
133
+ (defconst zig-re-identifier
134
+ ( rx (any " _ " word)
135
+ ( * (any " _ " word digit)) ))
136
136
137
- (defun zig-re-grab ( inner )
138
- " Construct a group regular expression for INNER. "
139
- ( concat " \\ ( " inner " \\ ) " ))
137
+ (defconst zig-re-type
138
+ ( rx ( * (| " ? " " [_] " " * " " [] " ))
139
+ (regexp zig-re-identifier) ))
140
140
141
- (defconst zig-re-identifier " [[:word:]_][[:word:]_[:digit:]]*" )
142
141
(defconst zig-re-type-annotation
143
- (concat (zig-re-grab zig-re-identifier)
144
- " [[:space:]]*:[[: space:]]* "
145
- (zig-re-grab zig-re-identifier )))
142
+ (rx (group (regexp zig-re-identifier) )
143
+ ( * (any space)) " : " ( * (any space))
144
+ (group (regexp zig-re-type) )))
146
145
147
146
(defun zig-re-definition (dtype )
148
147
" Construct a regular expression for definitions of type DTYPE."
149
- (concat (zig-re-word dtype) " [[:space:]]+" (zig-re-grab zig-re-identifier)))
148
+ (rx bow (literal dtype) eow
149
+ (+ (any space))
150
+ (group (regexp zig-re-identifier))))
150
151
151
152
(defconst zig-mode-syntax-table
152
153
(let ((table (make-syntax-table )))
@@ -385,10 +386,10 @@ If given a SOURCE, execute the CMD on it."
385
386
; ;; Imenu support
386
387
(defun zig-re-structure-def-imenu (stype )
387
388
" Construct a regular expression for strucutres definitions of type STYPE."
388
- (concat (zig-re-word " const" ) " [[:space:]]+ "
389
- (zig-re-grab zig-re-identifier)
390
- " .* "
391
- (zig-re-word stype)))
389
+ (rx bow " const" eow ( + (any space))
390
+ (group (regexp zig-re-identifier) )
391
+ ( * not-newline)
392
+ bow (literal stype) eow ))
392
393
393
394
(defvar zig-imenu-generic-expression
394
395
(append (mapcar (lambda (x )
0 commit comments