Mercurial > emacs
comparison lisp/progmodes/cc-fonts.el @ 67252:04d2abb755d9
Update CC Mode to release 5.31.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Fri, 02 Dec 2005 12:30:36 +0000 |
parents | 629afbe74e61 |
children | dc49655f57ae 7beb78bc1f8e |
comparison
equal
deleted
inserted
replaced
67251:299942030b0e | 67252:04d2abb755d9 |
---|---|
1 ;;; cc-fonts.el --- font lock support for CC Mode | 1 ;;; cc-fonts.el --- font lock support for CC Mode |
2 | 2 |
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Authors: 2003- Alan Mackenzie | 5 ;; Authors: 2003- Alan Mackenzie |
6 ;; 2002- Martin Stjernholm | 6 ;; 2002- Martin Stjernholm |
7 ;; Maintainer: bug-cc-mode@gnu.org | 7 ;; Maintainer: bug-cc-mode@gnu.org |
8 ;; Created: 07-Jan-2002 | 8 ;; Created: 07-Jan-2002 |
28 | 28 |
29 ;;; Commentary: | 29 ;;; Commentary: |
30 | 30 |
31 ;; Some comments on the use of faces: | 31 ;; Some comments on the use of faces: |
32 ;; | 32 ;; |
33 ;; o `c-label-face-name' is either `font-lock-constant-face' (in Emacs | 33 ;; o `c-label-face-name' is either `font-lock-constant-face' (in |
34 ;; 20 and later), or `font-lock-reference-face'. | 34 ;; Emacs), or `font-lock-reference-face'. |
35 ;; | 35 ;; |
36 ;; o `c-constant-face-name', `c-reference-face-name' and | 36 ;; o `c-constant-face-name', `c-reference-face-name' and |
37 ;; `c-doc-markup-face-name' are essentially set up like | 37 ;; `c-doc-markup-face-name' are essentially set up like |
38 ;; `c-label-face-name'. | 38 ;; `c-label-face-name'. |
39 ;; | 39 ;; |
45 ;; `font-lock-doc-face' in Emacs 21 and later, or | 45 ;; `font-lock-doc-face' in Emacs 21 and later, or |
46 ;; `font-lock-comment-face' in older Emacs (that since source | 46 ;; `font-lock-comment-face' in older Emacs (that since source |
47 ;; documentation are actually comments in these languages, as opposed | 47 ;; documentation are actually comments in these languages, as opposed |
48 ;; to elisp). | 48 ;; to elisp). |
49 ;; | 49 ;; |
50 ;; o `c-invalid-face-name' is `font-lock-warning-face' in Emacs. In | |
51 ;; older XEmacs there's no corresponding standard face, so there | |
52 ;; it's mapped to a special `c-invalid-face'. | |
53 ;; | |
54 ;; TBD: We should probably provide real faces for the above uses and | 50 ;; TBD: We should probably provide real faces for the above uses and |
55 ;; instead initialize them from the standard faces. | 51 ;; instead initialize them from the standard faces. |
56 | 52 |
57 ;;; Code: | 53 ;;; Code: |
58 | 54 |
101 ;; during compilation. | 97 ;; during compilation. |
102 (cc-bytecomp-defvar c-preprocessor-face-name) | 98 (cc-bytecomp-defvar c-preprocessor-face-name) |
103 (cc-bytecomp-defvar c-reference-face-name) | 99 (cc-bytecomp-defvar c-reference-face-name) |
104 (cc-bytecomp-defun c-fontify-recorded-types-and-refs) | 100 (cc-bytecomp-defun c-fontify-recorded-types-and-refs) |
105 (cc-bytecomp-defun c-font-lock-declarators) | 101 (cc-bytecomp-defun c-font-lock-declarators) |
106 (cc-bytecomp-defun c-font-lock-objc-iip-decl) | |
107 (cc-bytecomp-defun c-font-lock-objc-method) | 102 (cc-bytecomp-defun c-font-lock-objc-method) |
108 (cc-bytecomp-defun c-font-lock-invalid-string) | 103 (cc-bytecomp-defun c-font-lock-invalid-string) |
109 | |
110 ;; Emacs 19 doesn't have `defface'. This "replacement" leaves a lot | |
111 ;; to be wished for but at least it avoids any errors. | |
112 (cc-eval-when-compile | |
113 (or (fboundp 'defface) | |
114 (cc-bytecomp-defmacro defface (face spec doc &rest args) | |
115 `(make-face ',face)))) | |
116 | 104 |
117 | 105 |
118 ;; Note that font-lock in XEmacs doesn't expand face names as | 106 ;; Note that font-lock in XEmacs doesn't expand face names as |
119 ;; variables, so we have to use the (eval . FORM) in the font lock | 107 ;; variables, so we have to use the (eval . FORM) in the font lock |
120 ;; matchers wherever we use these alias variables. | 108 ;; matchers wherever we use these alias variables. |
122 (defconst c-preprocessor-face-name | 110 (defconst c-preprocessor-face-name |
123 (cond ((c-face-name-p 'font-lock-preprocessor-face) | 111 (cond ((c-face-name-p 'font-lock-preprocessor-face) |
124 ;; XEmacs has a font-lock-preprocessor-face. | 112 ;; XEmacs has a font-lock-preprocessor-face. |
125 'font-lock-preprocessor-face) | 113 'font-lock-preprocessor-face) |
126 ((c-face-name-p 'font-lock-builtin-face) | 114 ((c-face-name-p 'font-lock-builtin-face) |
127 ;; In Emacs 20 and later font-lock-builtin-face has | 115 ;; In Emacs font-lock-builtin-face has traditionally been |
128 ;; traditionally been used for preprocessor directives. | 116 ;; used for preprocessor directives. |
129 'font-lock-builtin-face) | 117 'font-lock-builtin-face) |
130 (t | 118 (t |
131 'font-lock-reference-face))) | 119 'font-lock-reference-face))) |
132 | 120 |
133 (cc-bytecomp-defvar font-lock-constant-face) | 121 (cc-bytecomp-defvar font-lock-constant-face) |
148 'font-lock-reference-face))) | 136 'font-lock-reference-face))) |
149 | 137 |
150 (defconst c-constant-face-name | 138 (defconst c-constant-face-name |
151 (if (and (c-face-name-p 'font-lock-constant-face) | 139 (if (and (c-face-name-p 'font-lock-constant-face) |
152 (eq font-lock-constant-face 'font-lock-constant-face)) | 140 (eq font-lock-constant-face 'font-lock-constant-face)) |
153 ;; This doesn't exist in XEmacs <= 20 and some earlier versions | 141 ;; This doesn't exist in some earlier versions of XEmacs 21. |
154 ;; of XEmacs 21. | |
155 'font-lock-constant-face | 142 'font-lock-constant-face |
156 c-label-face-name)) | 143 c-label-face-name)) |
157 | 144 |
158 (defconst c-reference-face-name | 145 (defconst c-reference-face-name |
159 (if (and (c-face-name-p 'font-lock-reference-face) | 146 (with-no-warnings |
160 (eq font-lock-reference-face 'font-lock-reference-face)) | 147 (if (and (c-face-name-p 'font-lock-reference-face) |
161 ;; This is considered obsolete in Emacs 20 and later, but it | 148 (eq font-lock-reference-face 'font-lock-reference-face)) |
162 ;; still maps well to this use. (Another reason to do this is | 149 ;; This is considered obsolete in Emacs, but it still maps well |
163 ;; to get unique faces for the test suite.) | 150 ;; to this use. (Another reason to do this is to get unique |
164 'font-lock-reference-face | 151 ;; faces for the test suite.) |
165 c-label-face-name)) | 152 'font-lock-reference-face |
153 c-label-face-name))) | |
166 | 154 |
167 ;; This should not mapped to a face that also is used to fontify things | 155 ;; This should not mapped to a face that also is used to fontify things |
168 ;; that aren't comments or string literals. | 156 ;; that aren't comments or string literals. |
169 (defconst c-doc-face-name | 157 (defconst c-doc-face-name |
170 (cond ((c-face-name-p 'font-lock-doc-string-face) | 158 (cond ((c-face-name-p 'font-lock-doc-string-face) |
182 ;; pragmatic reason is to get unique faces for the test | 170 ;; pragmatic reason is to get unique faces for the test |
183 ;; suite.) | 171 ;; suite.) |
184 'font-lock-doc-markup-face | 172 'font-lock-doc-markup-face |
185 c-label-face-name)) | 173 c-label-face-name)) |
186 | 174 |
187 (defconst c-invalid-face-name | 175 (defconst c-negation-char-face-name |
188 (if (c-face-name-p 'font-lock-warning-face) | 176 (if (c-face-name-p 'font-lock-negation-char-face) |
189 ;; Emacs >= 20 and XEmacs >= 21 has a font-lock-warning-face. | 177 ;; Emacs 22 has a special face for negation chars. |
190 'font-lock-warning-face | 178 'font-lock-negation-char-face)) |
191 ;; Otherwise we provide a face. | |
192 'c-invalid-face)) | |
193 | |
194 (unless (c-face-name-p c-invalid-face-name) | |
195 (defconst c-invalid-face 'c-invalid-face) ; Necessary in Emacs 19. | |
196 ;; This face should be called `c-invalid' for consistency with the | |
197 ;; rest of emacs, but as it's only used in very old versions of Emacs, | |
198 ;; we leave it unchanged (the face-alias mechanism doesn't exist in | |
199 ;; those old versions). | |
200 (defface c-invalid-face | |
201 '((((class color) (background light)) (:foreground "red1")) | |
202 (((class color)) (:foreground "hotpink")) | |
203 (t (:inverse-video t))) | |
204 "Face used to highlight invalid syntax." | |
205 :group 'c-fonts)) | |
206 | |
207 ;; To make hard spaces visible an inverted version of | |
208 ;; `c-invalid-face-name' is used. Since font-lock in Emacs expands | |
209 ;; all face names in `font-lock-keywords' as variables we need to have | |
210 ;; a variable for it. | |
211 (defconst c-nonbreakable-space-face 'c-nonbreakable-space) | |
212 | 179 |
213 (cc-bytecomp-defun face-inverse-video-p) ; Only in Emacs. | 180 (cc-bytecomp-defun face-inverse-video-p) ; Only in Emacs. |
214 (cc-bytecomp-defun face-property-instance) ; Only in XEmacs. | 181 (cc-bytecomp-defun face-property-instance) ; Only in XEmacs. |
215 | 182 |
216 (defun c-make-inverse-face (oldface newface) | 183 (defun c-make-inverse-face (oldface newface) |
217 ;; Emacs and XEmacs have completely different face manipulation | 184 ;; Emacs and XEmacs have completely different face manipulation |
218 ;; routines. :P | 185 ;; routines. :P |
219 ;; | |
220 ;; This function does not do any hidden buffer changes | |
221 (copy-face oldface newface) | 186 (copy-face oldface newface) |
222 (cond ((fboundp 'face-inverse-video-p) | 187 (cond ((fboundp 'face-inverse-video-p) |
223 ;; Emacs 20 and later. This only looks at the inverse flag | 188 ;; Emacs. This only looks at the inverse flag in the current |
224 ;; in the current frame. Other display configurations might | 189 ;; frame. Other display configurations might be different, |
225 ;; be different, but it can only show if the same Emacs has | 190 ;; but it can only show if the same Emacs has frames on |
226 ;; frames on e.g. a color and a monochrome display | 191 ;; e.g. a color and a monochrome display simultaneously. |
227 ;; simultaneously. | |
228 (unless (face-inverse-video-p oldface) | 192 (unless (face-inverse-video-p oldface) |
229 (invert-face newface))) | 193 (invert-face newface))) |
230 ((fboundp 'face-property-instance) | 194 ((fboundp 'face-property-instance) |
231 ;; XEmacs. Same pitfall here. | 195 ;; XEmacs. Same pitfall here. |
232 (unless (face-property-instance oldface 'reverse) | 196 (unless (face-property-instance oldface 'reverse) |
233 (invert-face newface))) | 197 (invert-face newface))))) |
234 (t | |
235 ;; Emacs 19 has no inverse flag at all. Just inverse the | |
236 ;; face and hope it wasn't inversed already. | |
237 (invert-face newface)))) | |
238 | 198 |
239 (eval-and-compile | 199 (eval-and-compile |
240 ;; We need the following functions during compilation since they're | 200 ;; We need the following functions during compilation since they're |
241 ;; called when the `c-lang-defconst' initializers are evaluated. | 201 ;; called when the `c-lang-defconst' initializers are evaluated. |
242 ;; Define them at runtime too for the sake of derived modes. | 202 ;; Define them at runtime too for the sake of derived modes. |
245 ;; Put a face on a region (overriding any existing face) in the way | 205 ;; Put a face on a region (overriding any existing face) in the way |
246 ;; font-lock would do it. In XEmacs that means putting an | 206 ;; font-lock would do it. In XEmacs that means putting an |
247 ;; additional font-lock property, or else the font-lock package | 207 ;; additional font-lock property, or else the font-lock package |
248 ;; won't recognize it as fontified and might override it | 208 ;; won't recognize it as fontified and might override it |
249 ;; incorrectly. | 209 ;; incorrectly. |
210 ;; | |
211 ;; This function does a hidden buffer change. | |
250 (if (fboundp 'font-lock-set-face) | 212 (if (fboundp 'font-lock-set-face) |
251 ;; Note: This function has no docstring in XEmacs so it might be | 213 ;; Note: This function has no docstring in XEmacs so it might be |
252 ;; considered internal. | 214 ;; considered internal. |
253 `(font-lock-set-face ,from ,to ,face) | 215 `(font-lock-set-face ,from ,to ,face) |
254 `(put-text-property ,from ,to 'face ,face))) | 216 `(put-text-property ,from ,to 'face ,face))) |
255 | 217 |
256 (defmacro c-remove-font-lock-face (from to) | 218 (defmacro c-remove-font-lock-face (from to) |
257 ;; This is the inverse of `c-put-font-lock-face'. | 219 ;; This is the inverse of `c-put-font-lock-face'. |
220 ;; | |
221 ;; This function does a hidden buffer change. | |
258 (if (fboundp 'font-lock-remove-face) | 222 (if (fboundp 'font-lock-remove-face) |
259 `(font-lock-remove-face ,from ,to) | 223 `(font-lock-remove-face ,from ,to) |
260 `(remove-text-properties ,from ,to '(face nil)))) | 224 `(remove-text-properties ,from ,to '(face nil)))) |
261 | 225 |
262 (defmacro c-put-font-lock-string-face (from to) | 226 (defmacro c-put-font-lock-string-face (from to) |
263 ;; Put `font-lock-string-face' on a string. The surrounding | 227 ;; Put `font-lock-string-face' on a string. The surrounding |
264 ;; quotes are included in Emacs but not in XEmacs. The passed | 228 ;; quotes are included in Emacs but not in XEmacs. The passed |
265 ;; region should include them. | 229 ;; region should include them. |
230 ;; | |
231 ;; This function does a hidden buffer change. | |
266 (if (featurep 'xemacs) | 232 (if (featurep 'xemacs) |
267 `(c-put-font-lock-face (1+ ,from) (1- ,to) 'font-lock-string-face) | 233 `(c-put-font-lock-face (1+ ,from) (1- ,to) 'font-lock-string-face) |
268 `(c-put-font-lock-face ,from ,to 'font-lock-string-face))) | 234 `(c-put-font-lock-face ,from ,to 'font-lock-string-face))) |
269 | 235 |
270 (defmacro c-fontify-types-and-refs (varlist &rest body) | 236 (defmacro c-fontify-types-and-refs (varlist &rest body) |
271 ;; Like `let', but additionally activates `c-record-type-identifiers' | 237 ;; Like `let', but additionally activates `c-record-type-identifiers' |
272 ;; and `c-record-ref-identifiers', and fontifies the recorded ranges | 238 ;; and `c-record-ref-identifiers', and fontifies the recorded ranges |
273 ;; accordingly on exit. | 239 ;; accordingly on exit. |
240 ;; | |
241 ;; This function does hidden buffer changes. | |
274 `(let ((c-record-type-identifiers t) | 242 `(let ((c-record-type-identifiers t) |
275 c-record-ref-identifiers | 243 c-record-ref-identifiers |
276 ,@varlist) | 244 ,@varlist) |
277 (prog1 (progn ,@body) | 245 (prog1 (progn ,@body) |
278 (c-fontify-recorded-types-and-refs)))) | 246 (c-fontify-recorded-types-and-refs)))) |
279 (put 'c-fontify-types-and-refs 'lisp-indent-function 1) | 247 (put 'c-fontify-types-and-refs 'lisp-indent-function 1) |
280 (eval-after-load "edebug" '(def-edebug-spec c-fontify-types-and-refs let*)) | |
281 | 248 |
282 (defun c-skip-comments-and-strings (limit) | 249 (defun c-skip-comments-and-strings (limit) |
283 ;; If the point is within a region fontified as a comment or | 250 ;; If the point is within a region fontified as a comment or |
284 ;; string literal skip to the end of it or to LIMIT, whichever | 251 ;; string literal skip to the end of it or to LIMIT, whichever |
285 ;; comes first, and return t. Otherwise return nil. The match | 252 ;; comes first, and return t. Otherwise return nil. The match |
286 ;; data is not clobbered. | 253 ;; data is not clobbered. |
254 ;; | |
255 ;; This function might do hidden buffer changes. | |
287 (when (c-got-face-at (point) c-literal-faces) | 256 (when (c-got-face-at (point) c-literal-faces) |
288 (while (progn | 257 (while (progn |
289 (goto-char (next-single-property-change | 258 (goto-char (next-single-property-change |
290 (point) 'face nil limit)) | 259 (point) 'face nil limit)) |
291 (and (< (point) limit) | 260 (and (< (point) limit) |
292 (c-got-face-at (point) c-literal-faces)))) | 261 (c-got-face-at (point) c-literal-faces)))) |
293 t)) | 262 t)) |
263 | |
264 (defun c-make-syntactic-matcher (regexp) | |
265 ;; Returns a byte compiled function suitable for use in place of a | |
266 ;; regexp string in a `font-lock-keywords' matcher, except that | |
267 ;; only matches outside comments and string literals count. | |
268 ;; | |
269 ;; This function does not do any hidden buffer changes, but the | |
270 ;; generated functions will. (They are however used in places | |
271 ;; covered by the font-lock context.) | |
272 (byte-compile | |
273 `(lambda (limit) | |
274 (let (res) | |
275 (while (and (setq res (re-search-forward ,regexp limit t)) | |
276 (progn | |
277 (goto-char (match-beginning 0)) | |
278 (or (c-skip-comments-and-strings limit) | |
279 (progn | |
280 (goto-char (match-end 0)) | |
281 nil))))) | |
282 res)))) | |
294 | 283 |
295 (defun c-make-font-lock-search-function (regexp &rest highlights) | 284 (defun c-make-font-lock-search-function (regexp &rest highlights) |
296 ;; This function makes a byte compiled function that works much like | 285 ;; This function makes a byte compiled function that works much like |
297 ;; a matcher element in `font-lock-keywords'. It cuts out a little | 286 ;; a matcher element in `font-lock-keywords'. It cuts out a little |
298 ;; bit of the overhead compared to a real matcher. The main reason | 287 ;; bit of the overhead compared to a real matcher. The main reason |
313 ;; is always a form which must do all the fontification directly. | 302 ;; is always a form which must do all the fontification directly. |
314 ;; `limit' is a variable bound to the real limit in the context of | 303 ;; `limit' is a variable bound to the real limit in the context of |
315 ;; the anchored matcher forms. | 304 ;; the anchored matcher forms. |
316 ;; | 305 ;; |
317 ;; This function does not do any hidden buffer changes, but the | 306 ;; This function does not do any hidden buffer changes, but the |
318 ;; generated functions will. They are however used in places | 307 ;; generated functions will. (They are however used in places |
319 ;; covered by the font-lock context. | 308 ;; covered by the font-lock context.) |
320 | 309 |
321 ;; Note: Replace `byte-compile' with `eval' to debug the generated | 310 ;; Note: Replace `byte-compile' with `eval' to debug the generated |
322 ;; lambda easier. | 311 ;; lambda easier. |
323 (byte-compile | 312 (byte-compile |
324 `(lambda (limit) | 313 `(lambda (limit) |
325 (let (-match-end-pos- | 314 (let (;; The font-lock package in Emacs is known to clobber |
326 ;; The font-lock package in Emacs is known to clobber | |
327 ;; `parse-sexp-lookup-properties' (when it exists). | 315 ;; `parse-sexp-lookup-properties' (when it exists). |
328 (parse-sexp-lookup-properties | 316 (parse-sexp-lookup-properties |
329 (cc-eval-when-compile | 317 (cc-eval-when-compile |
330 (boundp 'parse-sexp-lookup-properties)))) | 318 (boundp 'parse-sexp-lookup-properties)))) |
331 (while (re-search-forward ,regexp limit t) | 319 (while (re-search-forward ,regexp limit t) |
332 (setq -match-end-pos- (point)) | |
333 (unless (progn | 320 (unless (progn |
334 (goto-char (match-beginning 0)) | 321 (goto-char (match-beginning 0)) |
335 (c-skip-comments-and-strings limit)) | 322 (c-skip-comments-and-strings limit)) |
336 (goto-char -match-end-pos-) | 323 (goto-char (match-end 0)) |
337 ,@(mapcar | 324 ,@(mapcar |
338 (lambda (highlight) | 325 (lambda (highlight) |
339 (if (integerp (car highlight)) | 326 (if (integerp (car highlight)) |
340 (progn | 327 (progn |
341 (unless (nth 2 highlight) | 328 (unless (eq (nth 2 highlight) t) |
342 (error | 329 (error |
343 "The override flag must currently be set in %s" | 330 "The override flag must currently be t in %s" |
344 highlight)) | 331 highlight)) |
345 (when (nth 3 highlight) | 332 (when (nth 3 highlight) |
346 (error | 333 (error |
347 "The laxmatch flag may currently not be set in %s" | 334 "The laxmatch flag may currently not be set in %s" |
348 highlight)) | 335 highlight)) |
357 `(progn | 344 `(progn |
358 ,(nth 1 highlight) | 345 ,(nth 1 highlight) |
359 (save-match-data ,(car highlight)) | 346 (save-match-data ,(car highlight)) |
360 ,(nth 2 highlight)))) | 347 ,(nth 2 highlight)))) |
361 highlights)))) | 348 highlights)))) |
362 nil)))) | 349 nil))) |
350 | |
351 (eval-after-load "edebug" | |
352 '(progn | |
353 (def-edebug-spec c-fontify-types-and-refs let*) | |
354 (def-edebug-spec c-make-syntactic-matcher t) | |
355 ;; If there are literal quoted or backquoted highlight specs in | |
356 ;; the call to `c-make-font-lock-search-function' then let's | |
357 ;; instrument the forms in them. | |
358 (def-edebug-spec c-make-font-lock-search-function | |
359 (form &rest &or ("quote" (&rest form)) ("`" (&rest form)) form))))) | |
363 | 360 |
364 (defun c-fontify-recorded-types-and-refs () | 361 (defun c-fontify-recorded-types-and-refs () |
365 ;; Converts the ranges recorded on `c-record-type-identifiers' and | 362 ;; Convert the ranges recorded on `c-record-type-identifiers' and |
366 ;; `c-record-ref-identifiers' to fontification. | 363 ;; `c-record-ref-identifiers' to fontification. |
364 ;; | |
365 ;; This function does hidden buffer changes. | |
367 (let (elem) | 366 (let (elem) |
368 (while (consp c-record-type-identifiers) | 367 (while (consp c-record-type-identifiers) |
369 (setq elem (car c-record-type-identifiers) | 368 (setq elem (car c-record-type-identifiers) |
370 c-record-type-identifiers (cdr c-record-type-identifiers)) | 369 c-record-type-identifiers (cdr c-record-type-identifiers)) |
371 (c-put-font-lock-face (car elem) (cdr elem) | 370 (c-put-font-lock-face (car elem) (cdr elem) |
386 ;; sets `font-lock-type-face' in languages where | 385 ;; sets `font-lock-type-face' in languages where |
387 ;; `c-recognize-<>-arglists' is set. | 386 ;; `c-recognize-<>-arglists' is set. |
388 | 387 |
389 t `(,@(when (c-lang-const c-opt-cpp-prefix) | 388 t `(,@(when (c-lang-const c-opt-cpp-prefix) |
390 (let* ((noncontinued-line-end "\\(\\=\\|\\(\\=\\|[^\\]\\)[\n\r]\\)") | 389 (let* ((noncontinued-line-end "\\(\\=\\|\\(\\=\\|[^\\]\\)[\n\r]\\)") |
391 (ncle-depth (c-regexp-opt-depth noncontinued-line-end)) | 390 (ncle-depth (regexp-opt-depth noncontinued-line-end)) |
392 (sws-depth (c-lang-const c-syntactic-ws-depth))) | 391 (sws-depth (c-lang-const c-syntactic-ws-depth)) |
392 (nsws-depth (c-lang-const c-nonempty-syntactic-ws-depth))) | |
393 | |
393 `(;; The stuff after #error and #warning is a message, so | 394 `(;; The stuff after #error and #warning is a message, so |
394 ;; fontify it as a string. | 395 ;; fontify it as a string. |
395 (,(concat noncontinued-line-end | 396 ,@(when (c-lang-const c-cpp-message-directives) |
397 (let* ((re (c-make-keywords-re nil | |
398 (c-lang-const c-cpp-message-directives))) | |
399 (re-depth (regexp-opt-depth re))) | |
400 `((,(concat noncontinued-line-end | |
401 (c-lang-const c-opt-cpp-prefix) | |
402 re | |
403 "\\s +\\(.*\\)$") | |
404 ,(+ ncle-depth re-depth 1) font-lock-string-face)))) | |
405 | |
406 ;; Fontify filenames in #include <...> as strings. | |
407 ,@(when (c-lang-const c-cpp-include-directives) | |
408 (let* ((re (c-make-keywords-re nil | |
409 (c-lang-const c-cpp-include-directives))) | |
410 (re-depth (regexp-opt-depth re))) | |
411 `((,(concat noncontinued-line-end | |
412 (c-lang-const c-opt-cpp-prefix) | |
413 re | |
414 (c-lang-const c-syntactic-ws) | |
415 "\\(<[^>\n\r]*>?\\)") | |
416 (,(+ ncle-depth re-depth sws-depth 1) | |
417 font-lock-string-face) | |
418 | |
419 ;; Use an anchored matcher to put paren syntax | |
420 ;; on the brackets. | |
421 (,(byte-compile | |
422 `(lambda (limit) | |
423 (let ((beg (match-beginning | |
424 ,(+ ncle-depth re-depth sws-depth 1))) | |
425 (end (1- (match-end ,(+ ncle-depth re-depth | |
426 sws-depth 1))))) | |
427 (if (eq (char-after end) ?>) | |
428 (progn | |
429 (c-mark-<-as-paren beg) | |
430 (c-mark->-as-paren end)) | |
431 (c-clear-char-property beg 'syntax-table))) | |
432 nil))))))) | |
433 | |
434 ;; #define. | |
435 ,@(when (c-lang-const c-opt-cpp-macro-define) | |
436 `((,(c-make-font-lock-search-function | |
437 (concat | |
438 noncontinued-line-end | |
396 (c-lang-const c-opt-cpp-prefix) | 439 (c-lang-const c-opt-cpp-prefix) |
397 "\\(error\\|warning\\)\\>\\s *\\(.*\\)$") | 440 (c-lang-const c-opt-cpp-macro-define) |
398 ,(+ ncle-depth 2) font-lock-string-face) | 441 (c-lang-const c-nonempty-syntactic-ws) |
399 | 442 "\\(" (c-lang-const ; 1 + ncle + nsws |
400 ;; Fontify filenames in #include <...> as strings. | 443 c-symbol-key) "\\)" |
401 (,(concat noncontinued-line-end | 444 (concat "\\(" ; 2 + ncle + nsws + c-sym-key |
402 (c-lang-const c-opt-cpp-prefix) | 445 ;; Macro with arguments - a "function". |
403 "\\(import\\|include\\)\\>" | 446 "\\(\(\\)" ; 3 + ncle + nsws + c-sym-key |
404 (c-lang-const c-syntactic-ws) | 447 "\\|" |
405 "\\(<[^>\n\r]*>?\\)") | 448 ;; Macro without arguments - a "variable". |
406 (,(+ ncle-depth sws-depth 2) | 449 "\\([^\(]\\|$\\)" |
407 font-lock-string-face) | 450 "\\)")) |
408 | 451 `((if (match-beginning |
409 ;; Use an anchored matcher to put paren syntax on the brackets. | 452 ,(+ 3 ncle-depth nsws-depth |
410 (,(byte-compile | 453 (c-lang-const c-symbol-key-depth))) |
411 `(lambda (limit) | 454 |
412 (let ((beg-pos | 455 ;; "Function". Fontify the name and the arguments. |
413 (match-beginning ,(+ ncle-depth sws-depth 2))) | 456 (save-restriction |
414 (end-pos | 457 (c-put-font-lock-face |
415 (1- (match-end ,(+ ncle-depth sws-depth 2))))) | 458 (match-beginning ,(+ 1 ncle-depth nsws-depth)) |
416 (if (eq (char-after end-pos) ?>) | 459 (match-end ,(+ 1 ncle-depth nsws-depth)) |
417 (progn | 460 'font-lock-function-name-face) |
418 (c-mark-<-as-paren beg-pos) | 461 (goto-char |
419 (c-mark->-as-paren end-pos)) | 462 (match-end |
420 (c-clear-char-property beg-pos 'syntax-table))) | 463 ,(+ 3 ncle-depth nsws-depth |
421 nil)))) | 464 (c-lang-const c-symbol-key-depth)))) |
422 | 465 |
423 ;; #define. | 466 (narrow-to-region (point-min) limit) |
424 (,(c-make-font-lock-search-function | 467 (while (and |
425 (concat | 468 (progn |
426 noncontinued-line-end | 469 (c-forward-syntactic-ws) |
427 (c-lang-const c-opt-cpp-prefix) | 470 (looking-at c-symbol-key)) |
428 "define\\>" | 471 (progn |
429 (c-lang-const c-syntactic-ws) | 472 (c-put-font-lock-face |
430 "\\(" (c-lang-const c-symbol-key) "\\)" ; 1 + ncle + sws | 473 (match-beginning 0) (match-end 0) |
431 (concat "\\(" ; 2 + ncle + sws + c-sym-key | 474 'font-lock-variable-name-face) |
432 ;; Macro with arguments - a "function". | 475 (goto-char (match-end 0)) |
433 "\\(\(\\)" ; 3 + ncle + sws + c-sym-key | 476 (c-forward-syntactic-ws) |
434 "\\|" | 477 (eq (char-after) ?,))) |
435 ;; Macro without arguments - a "variable". | 478 (forward-char))) |
436 "\\([^\(]\\|$\\)" | 479 |
437 "\\)")) | 480 ;; "Variable". |
438 `((if (match-beginning ,(+ 3 ncle-depth sws-depth | 481 (c-put-font-lock-face |
439 (c-lang-const c-symbol-key-depth))) | 482 (match-beginning ,(+ 1 ncle-depth nsws-depth)) |
440 ;; "Function". Fontify the name and the arguments. | 483 (match-end ,(+ 1 ncle-depth nsws-depth)) |
441 (save-restriction | 484 'font-lock-variable-name-face))))))) |
442 (c-put-font-lock-face | |
443 (match-beginning ,(+ 1 ncle-depth sws-depth)) | |
444 (match-end ,(+ 1 ncle-depth sws-depth)) | |
445 'font-lock-function-name-face) | |
446 (goto-char (match-end | |
447 ,(+ 3 ncle-depth sws-depth | |
448 (c-lang-const c-symbol-key-depth)))) | |
449 | |
450 (narrow-to-region (point-min) limit) | |
451 (while (and | |
452 (progn | |
453 (c-forward-syntactic-ws) | |
454 (looking-at c-symbol-key)) | |
455 (progn | |
456 (c-put-font-lock-face | |
457 (match-beginning 0) (match-end 0) | |
458 'font-lock-variable-name-face) | |
459 (goto-char (match-end 0)) | |
460 (c-forward-syntactic-ws) | |
461 (eq (char-after) ?,))) | |
462 (forward-char))) | |
463 | |
464 ;; "Variable". | |
465 (c-put-font-lock-face | |
466 (match-beginning ,(+ 1 ncle-depth sws-depth)) | |
467 (match-end ,(+ 1 ncle-depth sws-depth)) | |
468 'font-lock-variable-name-face))))) | |
469 | 485 |
470 ;; Fontify cpp function names in preprocessor | 486 ;; Fontify cpp function names in preprocessor |
471 ;; expressions in #if and #elif. | 487 ;; expressions in #if and #elif. |
472 ,(when (c-lang-const c-cpp-defined-fns) | 488 ,@(when (and (c-lang-const c-cpp-expr-directives) |
473 `(,(c-make-font-lock-search-function | 489 (c-lang-const c-cpp-expr-functions)) |
474 (concat noncontinued-line-end | 490 (let ((ced-re (c-make-keywords-re t |
475 (c-lang-const c-opt-cpp-prefix) | 491 (c-lang-const c-cpp-expr-directives))) |
476 "\\(if\\|elif\\)\\>" ; 1 + ncle-depth | 492 (cef-re (c-make-keywords-re t |
477 ;; Match the whole logical line to look | 493 (c-lang-const c-cpp-expr-functions)))) |
478 ;; for the functions in. | 494 `((,(c-make-font-lock-search-function |
479 "\\(\\\\\\(.\\|[\n\r]\\)\\|[^\n\r]\\)*") | 495 (concat noncontinued-line-end |
480 `((let ((limit (match-end 0))) | 496 (c-lang-const c-opt-cpp-prefix) |
481 (while (re-search-forward | 497 ced-re ; 1 + ncle-depth |
482 ,(concat "\\<\\(" | 498 ;; Match the whole logical line to look |
483 (c-regexp-opt | 499 ;; for the functions in. |
484 (c-lang-const c-cpp-defined-fns) | 500 "\\(\\\\\\(.\\|[\n\r]\\)\\|[^\n\r]\\)*") |
485 nil) | 501 `((let ((limit (match-end 0))) |
486 "\\)\\>" | 502 (while (re-search-forward ,cef-re limit 'move) |
487 "\\s *\(?") | 503 (c-put-font-lock-face (match-beginning 1) |
488 limit 'move) | 504 (match-end 1) |
489 (c-put-font-lock-face (match-beginning 1) | 505 c-preprocessor-face-name))) |
490 (match-end 1) | 506 (goto-char (match-end ,(1+ ncle-depth))))))))) |
491 c-preprocessor-face-name))) | |
492 (goto-char (match-end ,(1+ ncle-depth))))))) | |
493 | 507 |
494 ;; Fontify the directive names. | 508 ;; Fontify the directive names. |
495 (,(c-make-font-lock-search-function | 509 (,(c-make-font-lock-search-function |
496 (concat noncontinued-line-end | 510 (concat noncontinued-line-end |
497 "\\(" | 511 "\\(" |
498 (c-lang-const c-opt-cpp-prefix) | 512 (c-lang-const c-opt-cpp-prefix) |
499 "[" (c-lang-const c-symbol-chars) "]+" | 513 "[" (c-lang-const c-symbol-chars) "]+" |
500 "\\)") | 514 "\\)") |
501 `(,(1+ ncle-depth) c-preprocessor-face-name t))) | 515 `(,(1+ ncle-depth) c-preprocessor-face-name t))) |
502 | 516 |
503 ;; fontify the n in ifndef | 517 (eval . (list ,(c-make-syntactic-matcher |
504 (,(concat noncontinued-line-end | 518 (concat noncontinued-line-end |
505 (c-lang-const c-opt-cpp-prefix) | 519 (c-lang-const c-opt-cpp-prefix) |
506 "if\\(n\\)def\\>") | 520 "if\\(n\\)def\\>")) |
507 ,(+ ncle-depth 1) font-lock-negation-char-face prepend) | 521 ,(+ ncle-depth 1) |
522 c-negation-char-face-name | |
523 'append)) | |
508 ))) | 524 ))) |
509 | 525 |
510 ,@(when (c-major-mode-is 'pike-mode) | 526 ,@(when (c-major-mode-is 'pike-mode) |
527 ;; Recognize hashbangs in Pike. | |
511 `((eval . (list "\\`#![^\n\r]*" | 528 `((eval . (list "\\`#![^\n\r]*" |
512 0 c-preprocessor-face-name)))) | 529 0 c-preprocessor-face-name)))) |
513 | 530 |
514 ;; Make hard spaces visible through an inverted `c-invalid-face-name'. | 531 ;; Make hard spaces visible through an inverted `font-lock-warning-face'. |
515 (eval . (list | 532 (eval . (list |
516 "\240" | 533 "\240" |
517 0 (progn | 534 0 (progn |
518 (unless (c-face-name-p c-nonbreakable-space-face) | 535 (unless (c-face-name-p 'c-nonbreakable-space-face) |
519 (c-make-inverse-face c-invalid-face-name | 536 (c-make-inverse-face 'font-lock-warning-face |
520 c-nonbreakable-space-face)) | 537 'c-nonbreakable-space-face)) |
521 'c-nonbreakable-space-face))) | 538 ''c-nonbreakable-space-face))) |
522 )) | 539 )) |
523 | 540 |
524 (defun c-font-lock-invalid-string () | 541 (defun c-font-lock-invalid-string () |
525 ;; Assuming the point is after the opening character of a string, | 542 ;; Assuming the point is after the opening character of a string, |
526 ;; fontify that char with `c-invalid-face-name' if the string | 543 ;; fontify that char with `font-lock-warning-face' if the string |
527 ;; decidedly isn't terminated properly. | 544 ;; decidedly isn't terminated properly. |
545 ;; | |
546 ;; This function does hidden buffer changes. | |
528 (let ((start (1- (point)))) | 547 (let ((start (1- (point)))) |
529 (save-excursion | 548 (save-excursion |
530 (and (nth 3 (parse-partial-sexp start (c-point 'eol))) | 549 (and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start) |
531 (if (c-major-mode-is '(c-mode c++-mode objc-mode pike-mode)) | 550 (if (integerp c-multiline-string-start-char) |
551 ;; There's no multiline string start char before the | |
552 ;; string, so newlines aren't allowed. | |
553 (not (eq (char-before start) c-multiline-string-start-char)) | |
554 ;; Multiline strings are allowed anywhere if | |
555 ;; c-multiline-string-start-char is t. | |
556 (not c-multiline-string-start-char)) | |
557 (if c-string-escaped-newlines | |
532 ;; There's no \ before the newline. | 558 ;; There's no \ before the newline. |
533 (not (eq (char-before (point)) ?\\)) | 559 (not (eq (char-before (point)) ?\\)) |
534 ;; Quoted newlines aren't supported. | 560 ;; Escaped newlines aren't supported. |
535 t) | 561 t) |
536 (if (c-major-mode-is 'pike-mode) | 562 (c-put-font-lock-face start (1+ start) 'font-lock-warning-face))))) |
537 ;; There's no # before the string, so newlines | |
538 ;; aren't allowed. | |
539 (not (eq (char-before start) ?#)) | |
540 t) | |
541 (c-put-font-lock-face start (1+ start) c-invalid-face-name))))) | |
542 | 563 |
543 (c-lang-defconst c-basic-matchers-before | 564 (c-lang-defconst c-basic-matchers-before |
544 "Font lock matchers for basic keywords, labels, references and various | 565 "Font lock matchers for basic keywords, labels, references and various |
545 other easily recognizable things that should be fontified before generic | 566 other easily recognizable things that should be fontified before generic |
546 casts and declarations are fontified. Used on level 2 and higher." | 567 casts and declarations are fontified. Used on level 2 and higher." |
564 ;; Fontify keyword constants. | 585 ;; Fontify keyword constants. |
565 ,@(when (c-lang-const c-constant-kwds) | 586 ,@(when (c-lang-const c-constant-kwds) |
566 (let ((re (c-make-keywords-re nil (c-lang-const c-constant-kwds)))) | 587 (let ((re (c-make-keywords-re nil (c-lang-const c-constant-kwds)))) |
567 (if (c-major-mode-is 'pike-mode) | 588 (if (c-major-mode-is 'pike-mode) |
568 ;; No symbol is a keyword after "->" in Pike. | 589 ;; No symbol is a keyword after "->" in Pike. |
569 `((eval . (list ,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" | 590 `((eval . (list ,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)" |
570 "\\<\\(" re "\\)\\>") | 591 "\\<\\(" re "\\)\\>") |
571 3 c-constant-face-name))) | 592 2 c-constant-face-name))) |
572 `((eval . (list ,(concat "\\<\\(" re "\\)\\>") | 593 `((eval . (list ,(concat "\\<\\(" re "\\)\\>") |
573 1 c-constant-face-name)))))) | 594 1 c-constant-face-name)))))) |
574 | 595 |
575 ;; Fontify all keywords except the primitive types. | 596 ;; Fontify all keywords except the primitive types. |
576 ,(if (c-major-mode-is 'pike-mode) | 597 ,(if (c-major-mode-is 'pike-mode) |
577 ;; No symbol is a keyword after "->" in Pike. | 598 ;; No symbol is a keyword after "->" in Pike. |
578 `(,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" | 599 `(,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)" |
579 "\\<" (c-lang-const c-regular-keywords-regexp)) | 600 "\\<" (c-lang-const c-regular-keywords-regexp)) |
580 3 font-lock-keyword-face) | 601 2 font-lock-keyword-face) |
581 `(,(concat "\\<" (c-lang-const c-regular-keywords-regexp)) | 602 `(,(concat "\\<" (c-lang-const c-regular-keywords-regexp)) |
582 1 font-lock-keyword-face)) | 603 1 font-lock-keyword-face)) |
583 | 604 |
584 ;; Fontify leading identifiers in fully qualified names like | 605 ;; Fontify leading identifiers in fully qualified names like |
585 ;; "foo::bar" in languages that supports such things. | 606 ;; "foo::bar" in languages that supports such things. |
594 ;; fontified as references. | 615 ;; fontified as references. |
595 `(,(c-make-font-lock-search-function | 616 `(,(c-make-font-lock-search-function |
596 ;; Search for class identifiers preceded by ".". The | 617 ;; Search for class identifiers preceded by ".". The |
597 ;; anchored matcher takes it from there. | 618 ;; anchored matcher takes it from there. |
598 (concat (c-lang-const c-opt-identifier-concat-key) | 619 (concat (c-lang-const c-opt-identifier-concat-key) |
599 "[ \t\n\r\f\v]*" | 620 (c-lang-const c-simple-ws) "*" |
600 (concat "\\(" | 621 (concat "\\(" |
601 "[" c-upper "][" (c-lang-const c-symbol-chars) "]*" | 622 "[" c-upper "]" |
623 "[" (c-lang-const c-symbol-chars) "]*" | |
602 "\\|" | 624 "\\|" |
603 "\\*" | 625 "\\*" |
604 "\\)")) | 626 "\\)")) |
605 `((let (id-end) | 627 `((let (id-end) |
606 (goto-char (1+ (match-beginning 0))) | 628 (goto-char (1+ (match-beginning 0))) |
610 (c-backward-syntactic-ws) | 632 (c-backward-syntactic-ws) |
611 (setq id-end (point)) | 633 (setq id-end (point)) |
612 (< (skip-chars-backward | 634 (< (skip-chars-backward |
613 ,(c-lang-const c-symbol-chars)) 0)) | 635 ,(c-lang-const c-symbol-chars)) 0)) |
614 (not (get-text-property (point) 'face))) | 636 (not (get-text-property (point) 'face))) |
615 (c-put-font-lock-face (point) id-end c-reference-face-name) | 637 (c-put-font-lock-face (point) id-end |
638 c-reference-face-name) | |
616 (c-backward-syntactic-ws))) | 639 (c-backward-syntactic-ws))) |
617 nil | 640 nil |
618 (goto-char (match-end 0))))) | 641 (goto-char (match-end 0))))) |
619 | 642 |
620 `((,(byte-compile | 643 `((,(byte-compile |
621 ;; Must use a function here since we match longer than we | 644 ;; Must use a function here since we match longer than |
622 ;; want to move before doing a new search. This is not | 645 ;; we want to move before doing a new search. This is |
623 ;; necessary for XEmacs >= 20 since it restarts the search | 646 ;; not necessary for XEmacs since it restarts the |
624 ;; from the end of the first highlighted submatch (something | 647 ;; search from the end of the first highlighted |
625 ;; that causes problems in other places). | 648 ;; submatch (something that causes problems in other |
649 ;; places). | |
626 `(lambda (limit) | 650 `(lambda (limit) |
627 (while (re-search-forward | 651 (while (re-search-forward |
628 ,(concat "\\(\\<" ; 1 | 652 ,(concat "\\(\\<" ; 1 |
629 "\\(" (c-lang-const c-symbol-key) "\\)" ; 2 | 653 "\\(" (c-lang-const c-symbol-key) "\\)" ; 2 |
630 "[ \t\n\r\f\v]*" | 654 (c-lang-const c-simple-ws) "*" |
631 (c-lang-const c-opt-identifier-concat-key) | 655 (c-lang-const c-opt-identifier-concat-key) |
632 "[ \t\n\r\f\v]*" | 656 (c-lang-const c-simple-ws) "*" |
633 "\\)" | 657 "\\)" |
634 "\\(" | 658 "\\(" |
635 (c-lang-const c-opt-after-id-concat-key) | 659 (c-lang-const c-opt-after-id-concat-key) |
636 "\\)") | 660 "\\)") |
637 limit t) | 661 limit t) |
658 (let ((c-promote-possible-types t)) | 682 (let ((c-promote-possible-types t)) |
659 (c-forward-type)))) | 683 (c-forward-type)))) |
660 (if (> (point) limit) (goto-char limit))))) | 684 (if (> (point) limit) (goto-char limit))))) |
661 | 685 |
662 ;; The @interface/@implementation/@protocol directives. | 686 ;; The @interface/@implementation/@protocol directives. |
663 (,(concat "\\<" | 687 ,(c-make-font-lock-search-function |
664 (c-regexp-opt | 688 (concat "\\<" |
689 (regexp-opt | |
665 '("@interface" "@implementation" "@protocol") | 690 '("@interface" "@implementation" "@protocol") |
666 t) | 691 t) |
667 "\\>") | 692 "\\>") |
668 (,(byte-compile | 693 '((c-fontify-types-and-refs |
669 (lambda (limit) | 694 (;; The font-lock package in Emacs is known to clobber |
670 (let (;; The font-lock package in Emacs is known to clobber | 695 ;; `parse-sexp-lookup-properties' (when it exists). |
671 ;; `parse-sexp-lookup-properties' (when it exists). | 696 (parse-sexp-lookup-properties |
672 (parse-sexp-lookup-properties | 697 (cc-eval-when-compile |
673 (cc-eval-when-compile | 698 (boundp 'parse-sexp-lookup-properties)))) |
674 (boundp 'parse-sexp-lookup-properties)))) | 699 (c-forward-objc-directive) |
675 (save-restriction | 700 nil) |
676 (narrow-to-region (point-min) limit) | 701 (goto-char (match-beginning 0)))))) |
677 (c-font-lock-objc-iip-decl))) | 702 |
678 nil)))))) | 703 (eval . (list "\\(!\\)[^=]" 1 c-negation-char-face-name)) |
679 | |
680 ("\\(!\\)[^=]" 1 font-lock-negation-char-face) | |
681 )) | 704 )) |
682 | 705 |
683 (defun c-font-lock-complex-decl-prepare (limit) | 706 (defun c-font-lock-complex-decl-prepare (limit) |
684 ;; Called before any of the matchers in `c-complex-decl-matchers'. | 707 ;; Called before any of the matchers in `c-complex-decl-matchers'. |
685 ;; Nil is always returned. | 708 ;; Nil is always returned. |
709 ;; | |
710 ;; This function does hidden buffer changes. | |
686 | 711 |
687 ;;(message "c-font-lock-complex-decl-prepare %s %s" (point) limit) | 712 ;;(message "c-font-lock-complex-decl-prepare %s %s" (point) limit) |
688 | 713 |
689 ;; Clear the list of found types if we start from the start of the | 714 ;; Clear the list of found types if we start from the start of the |
690 ;; buffer, to make it easier to get rid of misspelled types and | 715 ;; buffer, to make it easier to get rid of misspelled types and |
716 | 741 |
717 nil) | 742 nil) |
718 | 743 |
719 (defun c-font-lock-<>-arglists (limit) | 744 (defun c-font-lock-<>-arglists (limit) |
720 ;; Fontify types and references in names containing angle bracket | 745 ;; Fontify types and references in names containing angle bracket |
721 ;; arglists from the point to LIMIT. This will also fontify cases | 746 ;; arglists from the point to LIMIT. Note that |
722 ;; like normal function calls on the form "foo (a < b, c > d)", but | 747 ;; `c-font-lock-declarations' already has handled many of them. Nil |
723 ;; `c-font-lock-declarations' will undo that later. Nil is always | 748 ;; is always returned. |
724 ;; returned. | 749 ;; |
750 ;; This function might do hidden buffer changes. | |
725 | 751 |
726 (let (;; The font-lock package in Emacs is known to clobber | 752 (let (;; The font-lock package in Emacs is known to clobber |
727 ;; `parse-sexp-lookup-properties' (when it exists). | 753 ;; `parse-sexp-lookup-properties' (when it exists). |
728 (parse-sexp-lookup-properties | 754 (parse-sexp-lookup-properties |
729 (cc-eval-when-compile | 755 (cc-eval-when-compile |
730 (boundp 'parse-sexp-lookup-properties))) | 756 (boundp 'parse-sexp-lookup-properties))) |
731 id-start id-end pos kwd-sym) | 757 (c-parse-and-markup-<>-arglists t) |
758 c-restricted-<>-arglists | |
759 id-start id-end id-face pos kwd-sym) | |
732 | 760 |
733 (while (and (< (point) limit) | 761 (while (and (< (point) limit) |
734 (re-search-forward c-opt-<>-arglist-start limit t)) | 762 (re-search-forward c-opt-<>-arglist-start limit t)) |
735 | 763 |
736 (setq id-start (match-beginning 1) | 764 (setq id-start (match-beginning 1) |
737 id-end (match-end 1) | 765 id-end (match-end 1) |
738 pos (point)) | 766 pos (point)) |
739 | 767 |
740 (goto-char id-start) | 768 (goto-char id-start) |
741 (unless (c-skip-comments-and-strings limit) | 769 (unless (c-skip-comments-and-strings limit) |
742 (setq kwd-sym nil) | 770 (setq kwd-sym nil |
743 (if (or (not (eq (get-text-property id-start 'face) | 771 c-restricted-<>-arglists nil |
744 'font-lock-keyword-face)) | 772 id-face (get-text-property id-start 'face)) |
745 (when (looking-at c-opt-<>-sexp-key) | 773 |
746 (setq kwd-sym (c-keyword-sym (match-string 1))))) | 774 (if (cond |
775 ((eq id-face 'font-lock-type-face) | |
776 ;; The identifier got the type face so it has already been | |
777 ;; handled in `c-font-lock-declarations'. | |
778 nil) | |
779 | |
780 ((eq id-face 'font-lock-keyword-face) | |
781 (when (looking-at c-opt-<>-sexp-key) | |
782 ;; There's a special keyword before the "<" that tells | |
783 ;; that it's an angle bracket arglist. | |
784 (setq kwd-sym (c-keyword-sym (match-string 1))))) | |
785 | |
786 (t | |
787 ;; There's a normal identifier before the "<". If we're not in | |
788 ;; a declaration context then we set `c-restricted-<>-arglists' | |
789 ;; to avoid recognizing templates in function calls like "foo (a | |
790 ;; < b, c > d)". | |
791 (c-backward-syntactic-ws) | |
792 (when (and (memq (char-before) '(?\( ?,)) | |
793 (not (eq (get-text-property (1- (point)) 'c-type) | |
794 'c-decl-arg-start))) | |
795 (setq c-restricted-<>-arglists t)) | |
796 t)) | |
797 | |
747 (progn | 798 (progn |
748 (goto-char (1- pos)) | 799 (goto-char (1- pos)) |
749 ;; Check for comment/string both at the identifier and | 800 ;; Check for comment/string both at the identifier and |
750 ;; at the "<". | 801 ;; at the "<". |
751 (unless (c-skip-comments-and-strings limit) | 802 (unless (c-skip-comments-and-strings limit) |
752 | 803 |
753 (when (c-forward-<>-arglist (c-keyword-member kwd-sym | 804 (c-fontify-types-and-refs () |
754 'c-<>-type-kwds) | 805 (when (c-forward-<>-arglist (c-keyword-member |
755 t) | 806 kwd-sym 'c-<>-type-kwds)) |
756 (when (and c-opt-identifier-concat-key | 807 (when (and c-opt-identifier-concat-key |
757 (not (get-text-property id-start 'face))) | 808 (not (get-text-property id-start 'face))) |
758 (c-forward-syntactic-ws) | 809 (c-forward-syntactic-ws) |
759 (if (looking-at c-opt-identifier-concat-key) | 810 (if (looking-at c-opt-identifier-concat-key) |
811 (c-put-font-lock-face id-start id-end | |
812 c-reference-face-name) | |
760 (c-put-font-lock-face id-start id-end | 813 (c-put-font-lock-face id-start id-end |
761 c-reference-face-name) | 814 'font-lock-type-face))))) |
762 (c-put-font-lock-face id-start id-end | |
763 'font-lock-type-face)))) | |
764 | 815 |
765 (goto-char pos))) | 816 (goto-char pos))) |
766 (goto-char pos))))) | 817 (goto-char pos))))) |
767 nil) | 818 nil) |
768 | 819 |
771 ;; declaration, fontify it. If LIST is non-nil, fontify also all | 822 ;; declaration, fontify it. If LIST is non-nil, fontify also all |
772 ;; following declarators in a comma separated list (e.g. "foo" and | 823 ;; following declarators in a comma separated list (e.g. "foo" and |
773 ;; "bar" in "int foo = 17, bar;"). Stop at LIMIT. If TYPES is | 824 ;; "bar" in "int foo = 17, bar;"). Stop at LIMIT. If TYPES is |
774 ;; non-nil, fontify all identifiers as types. Nil is always | 825 ;; non-nil, fontify all identifiers as types. Nil is always |
775 ;; returned. | 826 ;; returned. |
827 ;; | |
828 ;; This function might do hidden buffer changes. | |
776 | 829 |
777 ;;(message "c-font-lock-declarators from %s to %s" (point) limit) | 830 ;;(message "c-font-lock-declarators from %s to %s" (point) limit) |
778 (c-fontify-types-and-refs | 831 (c-fontify-types-and-refs |
779 ((pos (point)) next-pos id-start id-end | 832 ((pos (point)) next-pos id-start id-end |
780 paren-depth | 833 paren-depth |
787 (< (point) limit) | 840 (< (point) limit) |
788 | 841 |
789 (let (got-identifier) | 842 (let (got-identifier) |
790 (setq paren-depth 0) | 843 (setq paren-depth 0) |
791 ;; Skip over type decl prefix operators. (Note similar | 844 ;; Skip over type decl prefix operators. (Note similar |
792 ;; code in `c-font-lock-declarations'.) | 845 ;; code in `c-forward-decl-or-cast-1'.) |
793 (while (and (looking-at c-type-decl-prefix-key) | 846 (while (and (looking-at c-type-decl-prefix-key) |
794 (if (and (c-major-mode-is 'c++-mode) | 847 (if (and (c-major-mode-is 'c++-mode) |
795 (match-beginning 2)) | 848 (match-beginning 2)) |
796 ;; If the second submatch matches in C++ then | 849 ;; If the second submatch matches in C++ then |
797 ;; we're looking at an identifier that's a | 850 ;; we're looking at an identifier that's a |
828 (or (= paren-depth 0) | 881 (or (= paren-depth 0) |
829 (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) | 882 (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) |
830 | 883 |
831 (<= (point) limit) | 884 (<= (point) limit) |
832 | 885 |
886 (progn | |
887 (when (looking-at c-decl-hangon-key) | |
888 (c-forward-keyword-clause 1)) | |
889 (<= (point) limit)) | |
890 | |
833 ;; Search syntactically to the end of the declarator (";", | 891 ;; Search syntactically to the end of the declarator (";", |
834 ;; ",", a closen paren, eob etc) or to the beginning of an | 892 ;; ",", a closen paren, eob etc) or to the beginning of an |
835 ;; initializer or function prototype ("=" or "\\s\("). | 893 ;; initializer or function prototype ("=" or "\\s\("). |
836 ;; Note that the open paren will match array specs in | 894 ;; Note that the open paren will match array specs in |
837 ;; square brackets, and we treat them as initializers too. | 895 ;; square brackets, and we treat them as initializers too. |
881 (and (if (and (eq got-init ?=) | 939 (and (if (and (eq got-init ?=) |
882 (= (c-forward-token-2 1 nil limit) 0) | 940 (= (c-forward-token-2 1 nil limit) 0) |
883 (looking-at "{")) | 941 (looking-at "{")) |
884 (c-safe (c-forward-sexp) t) | 942 (c-safe (c-forward-sexp) t) |
885 t) | 943 t) |
944 ;; FIXME: Should look for c-decl-end markers here; | |
945 ;; we might go far into the following declarations | |
946 ;; in e.g. ObjC mode (see e.g. methods-4.m). | |
886 (c-syntactic-re-search-forward "[;,{]" limit 'move t) | 947 (c-syntactic-re-search-forward "[;,{]" limit 'move t) |
887 (backward-char))) | 948 (backward-char))) |
888 | 949 |
889 (t (c-forward-syntactic-ws limit))) | 950 (t (c-forward-syntactic-ws limit))) |
890 | 951 |
903 (list nil | 964 (list nil |
904 font-lock-type-face | 965 font-lock-type-face |
905 c-reference-face-name | 966 c-reference-face-name |
906 font-lock-keyword-face)) | 967 font-lock-keyword-face)) |
907 | 968 |
908 ;; Macro used inside `c-font-lock-declarations'. It ought to be a | |
909 ;; defsubst or perhaps even a defun, but it contains lots of free | |
910 ;; variables that refer to things inside `c-font-lock-declarations'. | |
911 (defmacro c-fl-shift-type-backward (&optional short) | |
912 ;; `c-font-lock-declarations' can consume an arbitrary length list | |
913 ;; of types when parsing a declaration, which means that it | |
914 ;; sometimes consumes the identifier in the declaration as a type. | |
915 ;; This is used to "backtrack" and make the last type be treated | |
916 ;; as an identifier instead. | |
917 `(progn | |
918 ,(unless short | |
919 ;; These identifiers are bound only in the inner let. | |
920 '(setq identifier-type at-type | |
921 identifier-start type-start | |
922 identifier-end type-end)) | |
923 (if (setq at-type (if (eq prev-at-type 'prefix) | |
924 t | |
925 prev-at-type)) | |
926 (setq type-start prev-type-start | |
927 type-end prev-type-end) | |
928 (setq type-start start-pos | |
929 type-end start-pos)) | |
930 ,(unless short | |
931 ;; These identifiers are bound only in the inner let. | |
932 '(setq start type-end | |
933 got-parens nil | |
934 got-identifier t | |
935 got-suffix t | |
936 got-suffix-after-parens t | |
937 paren-depth 0)))) | |
938 | |
939 (defun c-font-lock-declarations (limit) | 969 (defun c-font-lock-declarations (limit) |
940 ;; Fontify all the declarations and casts from the point to LIMIT. | 970 ;; Fontify all the declarations, casts and labels from the point to LIMIT. |
941 ;; Assumes that strings and comments have been fontified already. | 971 ;; Assumes that strings and comments have been fontified already. Nil is |
942 ;; Nil is always returned. | 972 ;; always returned. |
943 ;; | 973 ;; |
944 ;; This function can make hidden buffer changes, but the font-lock | 974 ;; This function might do hidden buffer changes. |
945 ;; context covers that. | |
946 | 975 |
947 ;;(message "c-font-lock-declarations search from %s to %s" (point) limit) | 976 ;;(message "c-font-lock-declarations search from %s to %s" (point) limit) |
948 | 977 |
949 (save-restriction | 978 (save-restriction |
950 (let (start-pos | 979 (let (;; The position where `c-find-decl-spots' stopped. |
951 c-restricted-<>-arglists | 980 start-pos |
952 ;; Nonzero if the `c-decl-prefix-re' match is in an arglist context, | 981 ;; 'decl if we're in an arglist containing declarations (but |
953 ;; as opposed to a statement-level context. The major difference is | 982 ;; if `c-recognize-paren-inits' is set it might also be an |
954 ;; that "," works as declaration delimiter in an arglist context, | 983 ;; initializer arglist), '<> if the arglist is of angle |
955 ;; whereas it only separates declarators in the same declaration in | 984 ;; bracket type, 'arglist if it's some other arglist, or nil |
956 ;; a statement context. If it's nonzero then the value is the | 985 ;; if not in an arglist at all. |
957 ;; matched char, e.g. ?\( or ?,. | 986 context |
958 arglist-match | 987 ;; The position of the next token after the closing paren of |
959 ;; 'decl if we're in an arglist containing declarations (but if | 988 ;; the last detected cast. |
960 ;; `c-recognize-paren-inits' is set it might also be an initializer | |
961 ;; arglist), '<> if the arglist is of angle bracket type, 'other if | |
962 ;; it's some other arglist, or nil if not in an arglist at all. | |
963 arglist-type | |
964 ;; Set to the result of `c-forward-type'. | |
965 at-type | |
966 ;; These record the start and end of the type or possible type found | |
967 ;; by `c-forward-type'. `type-start' is at the start of the first | |
968 ;; type token, and `type-end' is at the start of the first token | |
969 ;; after the type (and after any specifiers). | |
970 type-start type-end | |
971 ;; These store `at-type', `type-start' and `type-end' of the | |
972 ;; identifier before the one in those variables. The previous | |
973 ;; identifier might turn out to be the real type in a declaration if | |
974 ;; the last one has to be the declarator in it. If `prev-at-type' | |
975 ;; is nil then the other variables have undefined values. | |
976 prev-at-type prev-type-start prev-type-end | |
977 ;; Whether we've found a declaration or a cast. We might know this | |
978 ;; before we've found the type in it. | |
979 at-decl-or-cast | |
980 ;; Set when we need to back up to parse this as a declaration but | |
981 ;; not as a cast. | |
982 backup-if-not-cast | |
983 ;; Set if we've found a "typedef" specifier. The identifiers in the | |
984 ;; declaration are then fontified as types. | |
985 at-typedef | |
986 ;; Set if we've found a specifier that can start a declaration where | |
987 ;; there's no type. | |
988 maybe-typeless | |
989 ;; The position of the next token after the closing paren of the | |
990 ;; last fontified cast. | |
991 last-cast-end | 989 last-cast-end |
992 ;; The same for the currently investigated cast. | 990 ;; The result from `c-forward-decl-or-cast-1'. |
993 cast-end | 991 decl-or-cast |
994 ;; The maximum of the end positions of all the checked type decl | 992 ;; The maximum of the end positions of all the checked type |
995 ;; expressions in the successfully identified declarations. The | 993 ;; decl expressions in the successfully identified |
996 ;; position might be either before or after the syntactic whitespace | 994 ;; declarations. The position might be either before or |
997 ;; following the last token in the type decl expression. | 995 ;; after the syntactic whitespace following the last token |
996 ;; in the type decl expression. | |
998 (max-type-decl-end 0) | 997 (max-type-decl-end 0) |
999 ;; Same as `max-type-decl-*', but used when we're before | 998 ;; Same as `max-type-decl-*', but used when we're before |
1000 ;; `token-pos'. | 999 ;; `token-pos'. |
1001 (max-type-decl-end-before-token 0) | 1000 (max-type-decl-end-before-token 0) |
1002 ;; Allow recording of identifier ranges in `c-forward-type' etc for | 1001 ;; Set according to the context to direct the heuristics for |
1003 ;; later fontification. Not using `c-fontify-types-and-refs' here | 1002 ;; recognizing C++ templates. |
1004 ;; since the ranges should be fontified selectively only when a | 1003 c-restricted-<>-arglists |
1005 ;; declaration or cast has been successfully recognized. | 1004 ;; Turn on recording of identifier ranges in |
1006 c-record-type-identifiers | 1005 ;; `c-forward-decl-or-cast-1' and `c-forward-label' for |
1006 ;; later fontification. | |
1007 (c-record-type-identifiers t) | |
1007 c-record-ref-identifiers | 1008 c-record-ref-identifiers |
1009 ;; Make `c-forward-type' calls mark up template arglists if | |
1010 ;; it finds any. That's necessary so that we later will | |
1011 ;; stop inside them to fontify types there. | |
1012 (c-parse-and-markup-<>-arglists t) | |
1008 ;; The font-lock package in Emacs is known to clobber | 1013 ;; The font-lock package in Emacs is known to clobber |
1009 ;; `parse-sexp-lookup-properties' (when it exists). | 1014 ;; `parse-sexp-lookup-properties' (when it exists). |
1010 (parse-sexp-lookup-properties | 1015 (parse-sexp-lookup-properties |
1011 (cc-eval-when-compile | 1016 (cc-eval-when-compile |
1012 (boundp 'parse-sexp-lookup-properties)))) | 1017 (boundp 'parse-sexp-lookup-properties)))) |
1022 ;; font-lock will put the limit at the beginning of the second line | 1027 ;; font-lock will put the limit at the beginning of the second line |
1023 ;; here, and if we go past it we'll fontify "my_variable" as a type and | 1028 ;; here, and if we go past it we'll fontify "my_variable" as a type and |
1024 ;; "some_other_variable" as an identifier, and the latter will not | 1029 ;; "some_other_variable" as an identifier, and the latter will not |
1025 ;; correct itself until the second line is changed. To avoid that we | 1030 ;; correct itself until the second line is changed. To avoid that we |
1026 ;; narrow to the limit if the region to fontify is a single line. | 1031 ;; narrow to the limit if the region to fontify is a single line. |
1027 (when (<= limit (c-point 'bonl)) | 1032 (narrow-to-region |
1028 (narrow-to-region | 1033 (point-min) |
1029 (point-min) | 1034 (if (<= limit (c-point 'bonl)) |
1030 (save-excursion | 1035 (save-excursion |
1031 ;; Narrow after any operator chars following the limit though, since | 1036 ;; Narrow after any operator chars following the limit though, |
1032 ;; those characters can be useful in recognizing a declaration (in | 1037 ;; since those characters can be useful in recognizing a |
1033 ;; particular the '{' that opens a function body after the header). | 1038 ;; declaration (in particular the '{' that opens a function body |
1034 (goto-char limit) | 1039 ;; after the header). |
1035 (skip-chars-forward c-nonsymbol-chars) | 1040 (goto-char limit) |
1036 (point)))) | 1041 (skip-chars-forward c-nonsymbol-chars) |
1042 (point)) | |
1043 limit)) | |
1037 | 1044 |
1038 (c-find-decl-spots | 1045 (c-find-decl-spots |
1039 limit | 1046 limit |
1040 c-identifier-start | 1047 c-decl-start-re |
1041 c-font-lock-maybe-decl-faces | 1048 c-font-lock-maybe-decl-faces |
1042 | 1049 |
1043 (lambda (match-pos inside-macro) | 1050 (lambda (match-pos inside-macro) |
1044 (catch 'false-alarm | 1051 (setq start-pos (point)) |
1045 ;; Don't do anything more if we're looking at a keyword | 1052 (when |
1046 ;; that can't start a declaration. | 1053 ;; The result of the form below is true when we don't recognize a |
1047 (when (and (eq (get-text-property (point) 'face) | 1054 ;; declaration or cast. |
1048 'font-lock-keyword-face) | 1055 (if (and (eq (get-text-property (point) 'face) |
1049 (looking-at c-not-decl-init-keywords)) | 1056 'font-lock-keyword-face) |
1050 (throw 'false-alarm t)) | 1057 (looking-at c-not-decl-init-keywords)) |
1051 | 1058 ;; Don't do anything more if we're looking at a keyword that |
1052 ;; Set `arglist-match' and `arglist-type'. Look for "<" for the | 1059 ;; can't start a declaration. |
1053 ;; sake of C++-style template arglists. | 1060 t |
1054 (setq arglist-match (char-before match-pos)) | 1061 |
1055 (if (memq arglist-match '(?\( ?, ?\[ ?<)) | 1062 ;; Set `context'. Look for "<" for the sake of C++-style template |
1056 | 1063 ;; arglists. |
1057 ;; Find out the type of the arglist. | 1064 (if (memq (char-before match-pos) '(?\( ?, ?\[ ?<)) |
1058 (if (<= match-pos (point-min)) | 1065 |
1059 (setq arglist-type 'other) | 1066 ;; Find out the type of the arglist. |
1060 (let ((type (c-get-char-property (1- match-pos) 'c-type))) | 1067 (if (<= match-pos (point-min)) |
1061 (cond ((eq type 'c-decl-arg-start) | 1068 (setq context 'arglist) |
1062 ;; Got a cached hit in a declaration arglist. | 1069 (let ((type (c-get-char-property (1- match-pos) 'c-type))) |
1063 (setq arglist-type 'decl)) | 1070 (cond ((eq type 'c-decl-arg-start) |
1064 ((or (eq type 'c-<>-arg-sep) | 1071 ;; Got a cached hit in a declaration arglist. |
1065 (eq arglist-match ?<)) | 1072 (setq context 'decl)) |
1066 ;; Inside an angle bracket arglist. | 1073 ((or (eq type 'c-<>-arg-sep) |
1067 (setq arglist-type '<>)) | 1074 (eq (char-before match-pos) ?<)) |
1068 (type | 1075 ;; Inside an angle bracket arglist. |
1069 ;; Got a cached hit in some other type of arglist. | 1076 (setq context '<>)) |
1070 (setq arglist-type 'other)) | 1077 (type |
1071 ((if inside-macro | 1078 ;; Got a cached hit in some other type of arglist. |
1072 (< match-pos max-type-decl-end-before-token) | 1079 (setq context 'arglist)) |
1073 (< match-pos max-type-decl-end)) | 1080 ((if inside-macro |
1074 ;; The point is within the range of a previously | 1081 (< match-pos max-type-decl-end-before-token) |
1075 ;; encountered type decl expression, so the arglist | 1082 (< match-pos max-type-decl-end)) |
1076 ;; is probably one that contains declarations. | 1083 ;; The point is within the range of a previously |
1077 ;; However, if `c-recognize-paren-inits' is set it | 1084 ;; encountered type decl expression, so the arglist |
1078 ;; might also be an initializer arglist. | 1085 ;; is probably one that contains declarations. |
1079 (setq arglist-type 'decl) | 1086 ;; However, if `c-recognize-paren-inits' is set it |
1080 ;; The result of this check is cached with a char | 1087 ;; might also be an initializer arglist. |
1081 ;; property on the match token, so that we can look | 1088 (setq context 'decl) |
1082 ;; it up again when refontifying single lines in a | 1089 ;; The result of this check is cached with a char |
1083 ;; multiline declaration. | 1090 ;; property on the match token, so that we can look |
1084 (c-put-char-property (1- match-pos) | 1091 ;; it up again when refontifying single lines in a |
1085 'c-type 'c-decl-arg-start)) | 1092 ;; multiline declaration. |
1086 (t | 1093 (c-put-char-property (1- match-pos) |
1087 (setq arglist-type 'other))))) | 1094 'c-type 'c-decl-arg-start)) |
1088 | 1095 (t |
1089 (setq arglist-match nil | 1096 (setq context 'arglist))))) |
1090 arglist-type nil)) | 1097 |
1091 | 1098 (setq context nil)) |
1092 (setq at-type nil | 1099 |
1093 at-decl-or-cast nil | 1100 ;; If we're in a normal arglist context we don't want to |
1094 backup-if-not-cast nil | 1101 ;; recognize commas in nested angle bracket arglists since |
1095 at-typedef nil | 1102 ;; those commas could be part of our own arglist. |
1096 maybe-typeless nil | 1103 (setq c-restricted-<>-arglists (and c-recognize-<>-arglists |
1097 c-record-type-identifiers t | 1104 (eq context 'arglist)) |
1098 c-record-ref-identifiers nil | 1105 |
1099 ;; `start-pos' is used below to point to the start of the | 1106 ;; Now analyze the construct. |
1100 ;; first type, i.e. after any leading specifiers. It might | 1107 decl-or-cast (c-forward-decl-or-cast-1 |
1101 ;; also point at the beginning of the preceding syntactic | 1108 match-pos context last-cast-end)) |
1102 ;; whitespace. | 1109 |
1103 start-pos (point) | 1110 (if (not decl-or-cast) |
1104 ;; If we're in a normal arglist context we don't want to | 1111 ;; False alarm. Return t to go on to the next check. |
1105 ;; recognize commas in nested angle bracket arglists since | 1112 t |
1106 ;; those commas could be part of our own arglist. | 1113 |
1107 c-restricted-<>-arglists | 1114 (if (eq decl-or-cast 'cast) |
1108 (and c-recognize-<>-arglists | 1115 ;; Save the position after the previous cast so we can feed |
1109 (eq arglist-type 'other))) | 1116 ;; it to `c-forward-decl-or-cast-1' in the next round. That |
1110 | 1117 ;; helps it discover cast chains like "(a) (b) c". |
1111 (when (and c-restricted-<>-arglists | 1118 (setq last-cast-end (point)) |
1112 (/= arglist-match ?,)) | 1119 |
1113 ;; We're standing at the start of a normal arglist so remove any | 1120 ;; Set `max-type-decl-end' or `max-type-decl-end-before-token' |
1114 ;; angle bracket arglists containing commas that's been | 1121 ;; under the assumption that we're after the first type decl |
1115 ;; recognized inside it by the preceding slightly opportunistic | 1122 ;; expression in the declaration now. That's not really true; |
1116 ;; scan in `c-font-lock-<>-arglists'. | 1123 ;; we could also be after a parenthesized initializer |
1117 (while (and (c-syntactic-re-search-forward | 1124 ;; expression in C++, but this is only used as a last resort |
1118 c-opt-<>-arglist-start-in-paren nil t t) | 1125 ;; to slant ambiguous expression/declarations, and overall |
1119 (match-beginning 1)) | 1126 ;; it's worth the risk to occasionally fontify an expression |
1120 (backward-char) | 1127 ;; as a declaration in an initializer expression compared to |
1121 (when (save-match-data | 1128 ;; getting ambiguous things in normal function prototypes |
1122 (and (c-get-char-property (point) 'syntax-table) | 1129 ;; fontified as expressions. |
1123 (not (c-forward-<>-arglist nil t)))) | 1130 (if inside-macro |
1124 (c-remove-font-lock-face (match-beginning 2) (match-end 2)))) | 1131 (when (> (point) max-type-decl-end-before-token) |
1125 (goto-char start-pos)) | 1132 (setq max-type-decl-end-before-token (point))) |
1126 | 1133 (when (> (point) max-type-decl-end) |
1127 ;; Check for a type, but be prepared to skip over leading | 1134 (setq max-type-decl-end (point)))) |
1128 ;; specifiers like "static". Unknown symbols are treated as | 1135 |
1129 ;; possible types, but they could also be specifiers disguised | 1136 ;; Back up to the type to fontify the declarator(s). |
1130 ;; through macros like __INLINE__, so we recognize both types and | 1137 (goto-char (car decl-or-cast)) |
1131 ;; known specifiers after them too. | 1138 |
1132 (while (let ((start (point)) | 1139 (let ((decl-list |
1133 (res (unless (eq at-type t) | 1140 (if context |
1134 ;; Don't look for a type if we already found a | 1141 ;; Should normally not fontify a list of |
1135 ;; positive one; we only loop for the | 1142 ;; declarators inside an arglist, but the first |
1136 ;; `c-specifier-key' check then. | 1143 ;; argument in the ';' separated list of a "for" |
1137 (c-forward-type)))) | 1144 ;; statement is an exception. |
1138 | 1145 (when (eq (char-before match-pos) ?\() |
1139 (when res | 1146 (save-excursion |
1140 ;; Found a known or possible type or a prefix of a known | 1147 (goto-char (1- match-pos)) |
1141 ;; type. | 1148 (c-backward-syntactic-ws) |
1142 | 1149 (and (c-simple-skip-symbol-backward) |
1143 (when at-type | 1150 (looking-at c-paren-stmt-key)))) |
1144 ;; Got two identifiers with nothing but whitespace | 1151 t))) |
1145 ;; between them. That can only happen in | 1152 |
1146 ;; declarations. | 1153 ;; Fix the `c-decl-id-start' or `c-decl-type-start' property |
1147 (setq at-decl-or-cast t) | 1154 ;; before the first declarator if it's a list. |
1148 | 1155 ;; `c-font-lock-declarators' handles the rest. |
1149 (when (eq at-type 'found) | 1156 (when decl-list |
1150 ;; If the previous identifier is a found type we | 1157 (save-excursion |
1151 ;; record it as a real one; it might be some sort of | 1158 (c-backward-syntactic-ws) |
1152 ;; alias for a prefix like "unsigned". | 1159 (unless (bobp) |
1153 (save-excursion | 1160 (c-put-char-property (1- (point)) 'c-type |
1154 (goto-char type-start) | 1161 (if (cdr decl-or-cast) |
1155 (let ((c-promote-possible-types t)) | 1162 'c-decl-type-start |
1156 (c-forward-type))))) | 1163 'c-decl-id-start))))) |
1157 | 1164 |
1158 (setq prev-at-type at-type | 1165 (c-font-lock-declarators |
1159 prev-type-start type-start | 1166 (point-max) decl-list (cdr decl-or-cast)))) |
1160 prev-type-end type-end | 1167 |
1161 at-type res | 1168 ;; A cast or declaration has been successfully identified, so do |
1162 type-start start | 1169 ;; all the fontification of types and refs that's been recorded. |
1163 type-end (point)) | 1170 (c-fontify-recorded-types-and-refs) |
1164 | 1171 nil)) |
1165 ;; If the type isn't known we continue so that we'll | 1172 |
1166 ;; jump over all specifiers and type identifiers. The | 1173 ;; It was a false alarm. Check if we're in a label instead. |
1167 ;; reason to do this for a known type prefix is to make | 1174 (goto-char start-pos) |
1168 ;; things like "unsigned INT16" work. | 1175 (when (c-forward-label t match-pos nil) |
1169 (setq res (not (eq res t)))) | 1176 ;; Can't use `c-fontify-types-and-refs' here since we |
1170 | 1177 ;; should use the label face. |
1171 (if (looking-at c-specifier-key) | 1178 (let (elem) |
1172 ;; Found a known specifier keyword. The specifier | 1179 (while c-record-ref-identifiers |
1173 ;; keywords are restrictive, so we check for them | 1180 (setq elem (car c-record-ref-identifiers) |
1174 ;; anywhere inside or around the type(s). We thereby | 1181 c-record-ref-identifiers (cdr c-record-ref-identifiers)) |
1175 ;; avoid having special cases for specifiers like MSVC | 1182 (c-put-font-lock-face (car elem) (cdr elem) |
1176 ;; '__declspec' which can come after the type. | 1183 c-label-face-name))) |
1177 (progn | 1184 ;; `c-forward-label' probably has added a `c-decl-end' |
1178 (setq at-decl-or-cast t) | 1185 ;; marker, so return t to `c-find-decl-spots' to signal |
1179 (let ((kwd-sym (c-keyword-sym (match-string 1)))) | 1186 ;; that. |
1180 (when (c-keyword-member | 1187 t)))) |
1181 kwd-sym 'c-typedef-decl-kwds) | |
1182 (setq at-typedef t)) | |
1183 (when (c-keyword-member | |
1184 kwd-sym 'c-typeless-decl-kwds) | |
1185 (setq maybe-typeless t))) | |
1186 (c-forward-keyword-clause) | |
1187 ;; Move type-end forward if we've passed a type, | |
1188 ;; otherwise move start-pos forward. | |
1189 (if at-type | |
1190 (setq type-end (point)) | |
1191 (setq start-pos (point)))) | |
1192 | |
1193 res))) | |
1194 | |
1195 (cond | |
1196 ((eq at-type 'prefix) | |
1197 ;; A prefix type is itself a primitive type when it's not | |
1198 ;; followed by another type. | |
1199 (setq at-type t)) | |
1200 | |
1201 ((not at-type) | |
1202 ;; Got no type but set things up to continue anyway to handle the | |
1203 ;; various cases when a declaration doesn't start with a type. | |
1204 (setq type-end start-pos)) | |
1205 | |
1206 ((and (eq at-type 'maybe) | |
1207 (c-major-mode-is 'c++-mode)) | |
1208 ;; If it's C++ then check if the last "type" ends on the form | |
1209 ;; "foo::foo" or "foo::~foo", i.e. if it's the name of a | |
1210 ;; (con|de)structor. | |
1211 (save-excursion | |
1212 (let (name end-2 end-1) | |
1213 (goto-char type-end) | |
1214 (c-backward-syntactic-ws) | |
1215 (setq end-2 (point)) | |
1216 (when (and | |
1217 (c-simple-skip-symbol-backward) | |
1218 (progn | |
1219 (setq name | |
1220 (buffer-substring-no-properties (point) end-2)) | |
1221 ;; Cheating in the handling of syntactic ws below. | |
1222 (< (skip-chars-backward ":~ \t\n\r\v\f") 0)) | |
1223 (progn | |
1224 (setq end-1 (point)) | |
1225 (c-simple-skip-symbol-backward)) | |
1226 (>= (point) type-start) | |
1227 (equal (buffer-substring-no-properties (point) end-1) | |
1228 name)) | |
1229 ;; It is a (con|de)structor name. In that case the | |
1230 ;; declaration is typeless so zap out any preceding | |
1231 ;; identifier(s) that we might have taken as types. | |
1232 (goto-char type-start) | |
1233 (setq at-type nil | |
1234 prev-at-type nil | |
1235 type-end type-start)))))) | |
1236 | |
1237 ;; Check for and step over a type decl expression after the thing | |
1238 ;; that is or might be a type. This can't be skipped since we need | |
1239 ;; the correct end position of the declarator for | |
1240 ;; `max-type-decl-end-*'. | |
1241 (let ((start (point)) (paren-depth 0) pos | |
1242 ;; True if there's a non-open-paren match of | |
1243 ;; `c-type-decl-prefix-key'. | |
1244 got-prefix | |
1245 ;; True if the declarator is surrounded by a parenthesis pair. | |
1246 got-parens | |
1247 ;; True if there is an identifier in the declarator. | |
1248 got-identifier | |
1249 ;; True if there's a non-close-paren match of | |
1250 ;; `c-type-decl-suffix-key'. | |
1251 got-suffix | |
1252 ;; True if there's a prefix or suffix match outside the | |
1253 ;; outermost paren pair that surrounds the declarator. | |
1254 got-prefix-before-parens | |
1255 got-suffix-after-parens | |
1256 ;; True if we've parsed the type decl to a token that | |
1257 ;; is known to end declarations in this context. | |
1258 at-decl-end | |
1259 ;; The earlier values of `at-type', `type-start' and | |
1260 ;; `type-end' if we've shifted the type backwards. | |
1261 identifier-type identifier-start identifier-end) | |
1262 (goto-char type-end) | |
1263 | |
1264 ;; Skip over type decl prefix operators. (Note similar code in | |
1265 ;; `c-font-lock-declarators'.) | |
1266 (while (and (looking-at c-type-decl-prefix-key) | |
1267 (if (and (c-major-mode-is 'c++-mode) | |
1268 (match-beginning 2)) | |
1269 ;; If the second submatch matches in C++ then | |
1270 ;; we're looking at an identifier that's a prefix | |
1271 ;; only if it specifies a member pointer. | |
1272 (when (setq got-identifier (c-forward-name)) | |
1273 (if (looking-at "\\(::\\)") | |
1274 ;; We only check for a trailing "::" and | |
1275 ;; let the "*" that should follow be | |
1276 ;; matched in the next round. | |
1277 (progn (setq got-identifier nil) t) | |
1278 ;; It turned out to be the real identifier, | |
1279 ;; so stop. | |
1280 nil)) | |
1281 t)) | |
1282 (if (eq (char-after) ?\() | |
1283 (progn | |
1284 (setq paren-depth (1+ paren-depth)) | |
1285 (forward-char)) | |
1286 (unless got-prefix-before-parens | |
1287 (setq got-prefix-before-parens (= paren-depth 0))) | |
1288 (setq got-prefix t) | |
1289 (goto-char (match-end 1))) | |
1290 (c-forward-syntactic-ws)) | |
1291 (setq got-parens (> paren-depth 0)) | |
1292 | |
1293 ;; Skip over an identifier. | |
1294 (or got-identifier | |
1295 (and (looking-at c-identifier-start) | |
1296 (setq got-identifier (c-forward-name)))) | |
1297 | |
1298 ;; Skip over type decl suffix operators. | |
1299 (while (if (looking-at c-type-decl-suffix-key) | |
1300 (if (eq (char-after) ?\)) | |
1301 (when (> paren-depth 0) | |
1302 (setq paren-depth (1- paren-depth)) | |
1303 (forward-char) | |
1304 t) | |
1305 (when (if (save-match-data (looking-at "\\s\(")) | |
1306 (c-safe (c-forward-sexp 1) t) | |
1307 (goto-char (match-end 1)) | |
1308 t) | |
1309 (unless got-suffix-after-parens | |
1310 (setq got-suffix-after-parens (= paren-depth 0))) | |
1311 (setq got-suffix t))) | |
1312 ;; No suffix matched. We might have matched the | |
1313 ;; identifier as a type and the open paren of a function | |
1314 ;; arglist as a type decl prefix. In that case we | |
1315 ;; should "backtrack": Reinterpret the last type as the | |
1316 ;; identifier, move out of the arglist and continue | |
1317 ;; searching for suffix operators. | |
1318 ;; | |
1319 ;; Do this even if there's no preceding type, to cope | |
1320 ;; with old style function declarations in K&R C, | |
1321 ;; (con|de)structors in C++ and `c-typeless-decl-kwds' | |
1322 ;; style declarations. That isn't applicable in an | |
1323 ;; arglist context, though. | |
1324 (when (and (= paren-depth 1) | |
1325 (not got-prefix-before-parens) | |
1326 (not (eq at-type t)) | |
1327 (or prev-at-type | |
1328 maybe-typeless | |
1329 (when c-recognize-typeless-decls | |
1330 (not arglist-type))) | |
1331 (setq pos (c-up-list-forward (point))) | |
1332 (eq (char-before pos) ?\))) | |
1333 (c-fl-shift-type-backward) | |
1334 (goto-char pos) | |
1335 t)) | |
1336 (c-forward-syntactic-ws)) | |
1337 | |
1338 (when (and maybe-typeless | |
1339 (not got-identifier) | |
1340 (not got-prefix) | |
1341 at-type | |
1342 (not (eq at-type t))) | |
1343 ;; Have found no identifier but `c-typeless-decl-kwds' has | |
1344 ;; matched so we know we're inside a declaration. The | |
1345 ;; preceding type must be the identifier instead. | |
1346 (c-fl-shift-type-backward)) | |
1347 | |
1348 (setq | |
1349 at-decl-or-cast | |
1350 (catch 'at-decl-or-cast | |
1351 | |
1352 (when (> paren-depth 0) | |
1353 ;; Encountered something inside parens that isn't matched by | |
1354 ;; the `c-type-decl-*' regexps, so it's not a type decl | |
1355 ;; expression. Try to skip out to the same paren depth to | |
1356 ;; not confuse the cast check below. | |
1357 (c-safe (goto-char (scan-lists (point) 1 paren-depth))) | |
1358 (throw 'at-decl-or-cast nil)) | |
1359 | |
1360 (setq at-decl-end | |
1361 (looking-at (cond ((eq arglist-type '<>) "[,>]") | |
1362 (arglist-type "[,\)]") | |
1363 (t "[,;]")))) | |
1364 | |
1365 ;; Now we've collected info about various characteristics of | |
1366 ;; the construct we're looking at. Below follows a decision | |
1367 ;; tree based on that. It's ordered to check more certain | |
1368 ;; signs before less certain ones. | |
1369 | |
1370 (if got-identifier | |
1371 (progn | |
1372 | |
1373 (when (and (or at-type maybe-typeless) | |
1374 (not (or got-prefix got-parens))) | |
1375 ;; Got another identifier directly after the type, so | |
1376 ;; it's a declaration. | |
1377 (throw 'at-decl-or-cast t)) | |
1378 | |
1379 (when (and got-parens | |
1380 (not got-prefix) | |
1381 (not got-suffix-after-parens) | |
1382 (or prev-at-type maybe-typeless)) | |
1383 ;; Got a declaration of the form "foo bar (gnu);" | |
1384 ;; where we've recognized "bar" as the type and "gnu" | |
1385 ;; as the declarator. In this case it's however more | |
1386 ;; likely that "bar" is the declarator and "gnu" a | |
1387 ;; function argument or initializer (if | |
1388 ;; `c-recognize-paren-inits' is set), since the parens | |
1389 ;; around "gnu" would be superfluous if it's a | |
1390 ;; declarator. Shift the type one step backward. | |
1391 (c-fl-shift-type-backward))) | |
1392 | |
1393 ;; Found no identifier. | |
1394 | |
1395 (if prev-at-type | |
1396 (when (or (= (point) start) | |
1397 (and got-suffix | |
1398 (not got-prefix) | |
1399 (not got-parens))) | |
1400 ;; Got two types after each other, so if this isn't a | |
1401 ;; cast then the latter probably is the identifier and | |
1402 ;; we should back up to the previous type. | |
1403 (setq backup-if-not-cast t) | |
1404 (throw 'at-decl-or-cast t)) | |
1405 | |
1406 (when (eq at-type t) | |
1407 ;; If the type is known we know that there can't be any | |
1408 ;; identifier somewhere else, and it's only in | |
1409 ;; declarations in e.g. function prototypes and in casts | |
1410 ;; that the identifier may be left out. | |
1411 (throw 'at-decl-or-cast t)) | |
1412 | |
1413 (when (= (point) start) | |
1414 ;; Only got a single identifier (parsed as a type so | |
1415 ;; far). | |
1416 (if (and | |
1417 ;; Check that the identifier isn't at the start of | |
1418 ;; an expression. | |
1419 at-decl-end | |
1420 (cond | |
1421 ((eq arglist-type 'decl) | |
1422 ;; Inside an arglist that contains declarations. | |
1423 ;; If K&R style declarations and parenthesis | |
1424 ;; style initializers aren't allowed then the | |
1425 ;; single identifier must be a type, else we | |
1426 ;; require that it's known or found (primitive | |
1427 ;; types are handled above). | |
1428 (or (and (not c-recognize-knr-p) | |
1429 (not c-recognize-paren-inits)) | |
1430 (memq at-type '(known found)))) | |
1431 ((eq arglist-type '<>) | |
1432 ;; Inside a template arglist. Accept known and | |
1433 ;; found types; other identifiers could just as | |
1434 ;; well be constants in C++. | |
1435 (memq at-type '(known found))))) | |
1436 (throw 'at-decl-or-cast t) | |
1437 (throw 'at-decl-or-cast nil)))) | |
1438 | |
1439 (if (and | |
1440 got-parens | |
1441 (not got-prefix) | |
1442 (not arglist-type) | |
1443 (not (eq at-type t)) | |
1444 (or | |
1445 prev-at-type | |
1446 maybe-typeless | |
1447 (when c-recognize-typeless-decls | |
1448 (or (not got-suffix) | |
1449 (not (looking-at | |
1450 c-after-suffixed-type-maybe-decl-key)))))) | |
1451 ;; Got an empty paren pair and a preceding type that | |
1452 ;; probably really is the identifier. Shift the type | |
1453 ;; backwards to make the last one the identifier. This | |
1454 ;; is analogous to the "backtracking" done inside the | |
1455 ;; `c-type-decl-suffix-key' loop above. | |
1456 ;; | |
1457 ;; Exception: In addition to the conditions in that | |
1458 ;; "backtracking" code, do not shift backward if we're | |
1459 ;; not looking at either `c-after-suffixed-type-decl-key' | |
1460 ;; or "[;,]". Since there's no preceding type, the | |
1461 ;; shift would mean that the declaration is typeless. | |
1462 ;; But if the regexp doesn't match then we will simply | |
1463 ;; fall through in the tests below and not recognize it | |
1464 ;; at all, so it's better to try it as an abstract | |
1465 ;; declarator instead. | |
1466 (c-fl-shift-type-backward) | |
1467 | |
1468 ;; Still no identifier. | |
1469 | |
1470 (when (and got-prefix (or got-parens got-suffix)) | |
1471 ;; Require `got-prefix' together with either | |
1472 ;; `got-parens' or `got-suffix' to recognize it as an | |
1473 ;; abstract declarator: `got-parens' only is probably an | |
1474 ;; empty function call. `got-suffix' only can build an | |
1475 ;; ordinary expression together with the preceding | |
1476 ;; identifier which we've taken as a type. We could | |
1477 ;; actually accept on `got-prefix' only, but that can | |
1478 ;; easily occur temporarily while writing an expression | |
1479 ;; so we avoid that case anyway. We could do a better | |
1480 ;; job if we knew the point when the fontification was | |
1481 ;; invoked. | |
1482 (throw 'at-decl-or-cast t)))) | |
1483 | |
1484 (when at-decl-or-cast | |
1485 ;; By now we've located the type in the declaration that we | |
1486 ;; know we're in. | |
1487 (throw 'at-decl-or-cast t)) | |
1488 | |
1489 (when (and got-identifier | |
1490 (not arglist-type) | |
1491 (looking-at c-after-suffixed-type-decl-key) | |
1492 (if (and got-parens | |
1493 (not got-prefix) | |
1494 (not got-suffix) | |
1495 (not (eq at-type t))) | |
1496 ;; Shift the type backward in the case that | |
1497 ;; there's a single identifier inside parens. | |
1498 ;; That can only occur in K&R style function | |
1499 ;; declarations so it's more likely that it | |
1500 ;; really is a function call. Therefore we | |
1501 ;; only do this after | |
1502 ;; `c-after-suffixed-type-decl-key' has | |
1503 ;; matched. | |
1504 (progn (c-fl-shift-type-backward) t) | |
1505 got-suffix-after-parens)) | |
1506 ;; A declaration according to | |
1507 ;; `c-after-suffixed-type-decl-key'. | |
1508 (throw 'at-decl-or-cast t)) | |
1509 | |
1510 (when (and (or got-prefix (not got-parens)) | |
1511 (memq at-type '(t known))) | |
1512 ;; It's a declaration if a known type precedes it and it | |
1513 ;; can't be a function call. | |
1514 (throw 'at-decl-or-cast t)) | |
1515 | |
1516 ;; If we get here we can't tell if this is a type decl or a | |
1517 ;; normal expression by looking at it alone. (That's under | |
1518 ;; the assumption that normal expressions always can look like | |
1519 ;; type decl expressions, which isn't really true but the | |
1520 ;; cases where it doesn't hold are so uncommon (e.g. some | |
1521 ;; placements of "const" in C++) it's not worth the effort to | |
1522 ;; look for them.) | |
1523 | |
1524 (unless (or at-decl-end (looking-at "=[^=]")) | |
1525 ;; If this is a declaration it should end here or its | |
1526 ;; initializer(*) should start here, so check for allowed | |
1527 ;; separation tokens. Note that this rule doesn't work | |
1528 ;; e.g. with a K&R arglist after a function header. | |
1529 ;; | |
1530 ;; *) Don't check for C++ style initializers using parens | |
1531 ;; since those already have been matched as suffixes. | |
1532 (throw 'at-decl-or-cast nil)) | |
1533 | |
1534 ;; Below are tests that only should be applied when we're | |
1535 ;; certain to not have parsed halfway through an expression. | |
1536 | |
1537 (when (memq at-type '(t known)) | |
1538 ;; The expression starts with a known type so treat it as a | |
1539 ;; declaration. | |
1540 (throw 'at-decl-or-cast t)) | |
1541 | |
1542 (when (and (c-major-mode-is 'c++-mode) | |
1543 ;; In C++ we check if the identifier is a known | |
1544 ;; type, since (con|de)structors use the class name | |
1545 ;; as identifier. We've always shifted over the | |
1546 ;; identifier as a type and then backed up again in | |
1547 ;; this case. | |
1548 identifier-type | |
1549 (or (memq identifier-type '(found known)) | |
1550 (and (eq (char-after identifier-start) ?~) | |
1551 ;; `at-type' probably won't be 'found for | |
1552 ;; destructors since the "~" is then part | |
1553 ;; of the type name being checked against | |
1554 ;; the list of known types, so do a check | |
1555 ;; without that operator. | |
1556 (or (save-excursion | |
1557 (goto-char (1+ identifier-start)) | |
1558 (c-forward-syntactic-ws) | |
1559 (c-with-syntax-table | |
1560 c-identifier-syntax-table | |
1561 (looking-at c-known-type-key))) | |
1562 (c-check-type (1+ identifier-start) | |
1563 identifier-end))))) | |
1564 (throw 'at-decl-or-cast t)) | |
1565 | |
1566 (if got-identifier | |
1567 (progn | |
1568 (when (and got-prefix-before-parens | |
1569 at-type | |
1570 (or at-decl-end (looking-at "=[^=]")) | |
1571 (not arglist-type) | |
1572 (not got-suffix)) | |
1573 ;; Got something like "foo * bar;". Since we're not | |
1574 ;; inside an arglist it would be a meaningless | |
1575 ;; expression because the result isn't used. We | |
1576 ;; therefore choose to recognize it as a declaration. | |
1577 ;; Do not allow a suffix since it could then be a | |
1578 ;; function call. | |
1579 (throw 'at-decl-or-cast t)) | |
1580 | |
1581 (when (and (or got-suffix-after-parens | |
1582 (looking-at "=[^=]")) | |
1583 (eq at-type 'found) | |
1584 (not (eq arglist-type 'other))) | |
1585 ;; Got something like "a (*b) (c);" or "a (b) = c;". | |
1586 ;; It could be an odd expression or it could be a | |
1587 ;; declaration. Treat it as a declaration if "a" has | |
1588 ;; been used as a type somewhere else (if it's a known | |
1589 ;; type we won't get here). | |
1590 (throw 'at-decl-or-cast t))) | |
1591 | |
1592 (when (and arglist-type | |
1593 (or got-prefix | |
1594 (and (eq arglist-type 'decl) | |
1595 (not c-recognize-paren-inits) | |
1596 (or got-parens got-suffix)))) | |
1597 ;; Got a type followed by an abstract declarator. If | |
1598 ;; `got-prefix' is set it's something like "a *" without | |
1599 ;; anything after it. If `got-parens' or `got-suffix' is | |
1600 ;; set it's "a()", "a[]", "a()[]", or similar, which we | |
1601 ;; accept only if the context rules out expressions. | |
1602 (throw 'at-decl-or-cast t))) | |
1603 | |
1604 ;; If we had a complete symbol table here (which rules out | |
1605 ;; `c-found-types') we should return t due to the | |
1606 ;; disambiguation rule (in at least C++) that anything that | |
1607 ;; can be parsed as a declaration is a declaration. Now we're | |
1608 ;; being more defensive and prefer to highlight things like | |
1609 ;; "foo (bar);" as a declaration only if we're inside an | |
1610 ;; arglist that contains declarations. | |
1611 (eq arglist-type 'decl)))) | |
1612 | |
1613 ;; Point is now after the type decl expression. | |
1614 | |
1615 (cond | |
1616 ;; Check for a cast. | |
1617 ((save-excursion | |
1618 (and | |
1619 c-cast-parens | |
1620 | |
1621 ;; Should be the first type/identifier in a cast paren. | |
1622 (memq arglist-match c-cast-parens) | |
1623 | |
1624 ;; The closing paren should follow. | |
1625 (progn | |
1626 (c-forward-syntactic-ws) | |
1627 (looking-at "\\s\)")) | |
1628 | |
1629 ;; There should be a primary expression after it. | |
1630 (let (pos) | |
1631 (forward-char) | |
1632 (c-forward-syntactic-ws) | |
1633 (setq cast-end (point)) | |
1634 (and (looking-at c-primary-expr-regexp) | |
1635 (progn | |
1636 (setq pos (match-end 0)) | |
1637 (or | |
1638 ;; Check if the expression begins with a prefix | |
1639 ;; keyword. | |
1640 (match-beginning 2) | |
1641 (if (match-beginning 1) | |
1642 ;; Expression begins with an ambiguous operator. | |
1643 ;; Treat it as a cast if it's a type decl or if | |
1644 ;; we've recognized the type somewhere else. | |
1645 (or at-decl-or-cast | |
1646 (memq at-type '(t known found))) | |
1647 ;; Unless it's a keyword, it's the beginning of a | |
1648 ;; primary expression. | |
1649 (not (looking-at c-keywords-regexp))))) | |
1650 ;; If `c-primary-expr-regexp' matched a nonsymbol | |
1651 ;; token, check that it matched a whole one so that we | |
1652 ;; don't e.g. confuse the operator '-' with '->'. It's | |
1653 ;; ok if it matches further, though, since it e.g. can | |
1654 ;; match the float '.5' while the operator regexp only | |
1655 ;; matches '.'. | |
1656 (or (not (looking-at c-nonsymbol-token-regexp)) | |
1657 (<= (match-end 0) pos)))) | |
1658 | |
1659 ;; There should either be a cast before it or something that | |
1660 ;; isn't an identifier or close paren. | |
1661 (/= match-pos 0) | |
1662 (progn | |
1663 (goto-char (1- match-pos)) | |
1664 (or (eq (point) last-cast-end) | |
1665 (progn | |
1666 (c-backward-syntactic-ws) | |
1667 (if (< (skip-syntax-backward "w_") 0) | |
1668 ;; It's a symbol. Accept it only if it's one of | |
1669 ;; the keywords that can precede an expression | |
1670 ;; (without surrounding parens). | |
1671 (looking-at c-simple-stmt-key) | |
1672 (and | |
1673 ;; Check that it isn't a close paren (block close | |
1674 ;; is ok, though). | |
1675 (not (memq (char-before) '(?\) ?\]))) | |
1676 ;; Check that it isn't a nonsymbol identifier. | |
1677 (not (c-on-identifier))))))))) | |
1678 | |
1679 ;; Handle the cast. | |
1680 (setq last-cast-end cast-end) | |
1681 (when (and at-type (not (eq at-type t))) | |
1682 (let ((c-promote-possible-types t)) | |
1683 (goto-char type-start) | |
1684 (c-forward-type)))) | |
1685 | |
1686 (at-decl-or-cast | |
1687 ;; We're at a declaration. Highlight the type and the following | |
1688 ;; declarators. | |
1689 | |
1690 (when backup-if-not-cast | |
1691 (c-fl-shift-type-backward t)) | |
1692 | |
1693 (when (and (eq arglist-type 'decl) (looking-at ",")) | |
1694 ;; Make sure to propagate the `c-decl-arg-start' property to | |
1695 ;; the next argument if it's set in this one, to cope with | |
1696 ;; interactive refontification. | |
1697 (c-put-char-property (point) 'c-type 'c-decl-arg-start)) | |
1698 | |
1699 ;; Set `max-type-decl-end' or `max-type-decl-end-before-token' | |
1700 ;; under the assumption that we're after the first type decl | |
1701 ;; expression in the declaration now. That's not really true; we | |
1702 ;; could also be after a parenthesized initializer expression in | |
1703 ;; C++, but this is only used as a last resort to slant ambiguous | |
1704 ;; expression/declarations, and overall it's worth the risk to | |
1705 ;; occasionally fontify an expression as a declaration in an | |
1706 ;; initializer expression compared to getting ambiguous things in | |
1707 ;; normal function prototypes fontified as expressions. | |
1708 (if inside-macro | |
1709 (when (> (point) max-type-decl-end-before-token) | |
1710 (setq max-type-decl-end-before-token (point))) | |
1711 (when (> (point) max-type-decl-end) | |
1712 (setq max-type-decl-end (point)))) | |
1713 | |
1714 (when (and at-type (not (eq at-type t))) | |
1715 (let ((c-promote-possible-types t)) | |
1716 (goto-char type-start) | |
1717 (c-forward-type))) | |
1718 | |
1719 (goto-char type-end) | |
1720 | |
1721 (let ((decl-list | |
1722 (if arglist-type | |
1723 ;; Should normally not fontify a list of declarators | |
1724 ;; inside an arglist, but the first argument in the | |
1725 ;; ';' separated list of a "for" statement is an | |
1726 ;; exception. | |
1727 (when (and (eq arglist-match ?\() (/= match-pos 0)) | |
1728 (save-excursion | |
1729 (goto-char (1- match-pos)) | |
1730 (c-backward-syntactic-ws) | |
1731 (and (c-simple-skip-symbol-backward) | |
1732 (looking-at c-paren-stmt-key)))) | |
1733 t))) | |
1734 | |
1735 ;; Fix the `c-decl-id-start' or `c-decl-type-start' property | |
1736 ;; before the first declarator if it's a list. | |
1737 ;; `c-font-lock-declarators' handles the rest. | |
1738 (when decl-list | |
1739 (save-excursion | |
1740 (c-backward-syntactic-ws) | |
1741 (unless (bobp) | |
1742 (c-put-char-property (1- (point)) 'c-type | |
1743 (if at-typedef | |
1744 'c-decl-type-start | |
1745 'c-decl-id-start))))) | |
1746 | |
1747 (c-font-lock-declarators (point-max) decl-list at-typedef))) | |
1748 | |
1749 (t | |
1750 ;; False alarm. Skip the fontification done below. | |
1751 (throw 'false-alarm t))) | |
1752 | |
1753 ;; A cast or declaration has been successfully identified, so do | |
1754 ;; all the fontification of types and refs that's been recorded by | |
1755 ;; the calls to `c-forward-type' and `c-forward-name' above. | |
1756 (c-fontify-recorded-types-and-refs) | |
1757 nil))) | |
1758 | 1188 |
1759 nil))) | 1189 nil))) |
1760 | 1190 |
1761 (c-lang-defconst c-simple-decl-matchers | 1191 (c-lang-defconst c-simple-decl-matchers |
1762 "Simple font lock matchers for types and declarations. These are used | 1192 "Simple font lock matchers for types and declarations. These are used |
1792 (goto-char (match-end 1)))))) | 1222 (goto-char (match-end 1)))))) |
1793 | 1223 |
1794 ;; Fontify types preceded by `c-type-prefix-kwds' and the | 1224 ;; Fontify types preceded by `c-type-prefix-kwds' and the |
1795 ;; identifiers in the declarations they might start. | 1225 ;; identifiers in the declarations they might start. |
1796 ,@(when (c-lang-const c-type-prefix-kwds) | 1226 ,@(when (c-lang-const c-type-prefix-kwds) |
1797 (let ((prefix-re (c-make-keywords-re nil | 1227 (let* ((prefix-re (c-make-keywords-re nil |
1798 (c-lang-const c-type-prefix-kwds)))) | 1228 (c-lang-const c-type-prefix-kwds))) |
1229 (type-match (+ 2 | |
1230 (regexp-opt-depth prefix-re) | |
1231 (c-lang-const c-simple-ws-depth)))) | |
1799 `((,(c-make-font-lock-search-function | 1232 `((,(c-make-font-lock-search-function |
1800 (concat "\\<\\(" prefix-re "\\)" | 1233 (concat "\\<\\(" prefix-re "\\)" ; 1 |
1801 "[ \t\n\r\f\v]+" | 1234 (c-lang-const c-simple-ws) "+" |
1802 "\\(" (c-lang-const c-symbol-key) "\\)") | 1235 (concat "\\(" ; 2 + prefix-re + c-simple-ws |
1803 `(,(+ (c-regexp-opt-depth prefix-re) 2) | 1236 (c-lang-const c-symbol-key) |
1237 "\\)")) | |
1238 `(,type-match | |
1804 'font-lock-type-face t) | 1239 'font-lock-type-face t) |
1805 '((c-font-lock-declarators limit t nil) | 1240 `((c-font-lock-declarators limit t nil) |
1806 (save-match-data | 1241 (save-match-data |
1807 (goto-char (match-end 2)) | 1242 (goto-char (match-end ,type-match)) |
1808 (c-forward-syntactic-ws)) | 1243 (c-forward-syntactic-ws)) |
1809 (goto-char (match-end 2)))))))) | 1244 (goto-char (match-end ,type-match)))))))) |
1810 | 1245 |
1811 ;; Fontify special declarations that lacks a type. | 1246 ;; Fontify special declarations that lacks a type. |
1812 ,@(when (c-lang-const c-typeless-decl-kwds) | 1247 ,@(when (c-lang-const c-typeless-decl-kwds) |
1813 `((,(c-make-font-lock-search-function | 1248 `((,(c-make-font-lock-search-function |
1814 (concat "\\<\\(" | 1249 (concat "\\<\\(" |
1815 (c-regexp-opt (c-lang-const c-typeless-decl-kwds)) | 1250 (regexp-opt (c-lang-const c-typeless-decl-kwds)) |
1816 "\\)\\>") | 1251 "\\)\\>") |
1817 '((c-font-lock-declarators limit t nil) | 1252 '((c-font-lock-declarators limit t nil) |
1818 (save-match-data | 1253 (save-match-data |
1819 (goto-char (match-end 1)) | 1254 (goto-char (match-end 1)) |
1820 (c-forward-syntactic-ws)) | 1255 (c-forward-syntactic-ws)) |
1821 (goto-char (match-end 1))))))) | 1256 (goto-char (match-end 1))))))) |
1822 )) | 1257 |
1258 ;; Fontify generic colon labels in languages that support them. | |
1259 ,@(when (c-lang-const c-recognize-colon-labels) | |
1260 `(c-font-lock-labels)))) | |
1823 | 1261 |
1824 (c-lang-defconst c-complex-decl-matchers | 1262 (c-lang-defconst c-complex-decl-matchers |
1825 "Complex font lock matchers for types and declarations. Used on level | 1263 "Complex font lock matchers for types and declarations. Used on level |
1826 3 and higher." | 1264 3 and higher." |
1827 | 1265 |
1828 t `(;; Initialize some things before the search functions below. | 1266 t `(;; Initialize some things before the search functions below. |
1829 c-font-lock-complex-decl-prepare | 1267 c-font-lock-complex-decl-prepare |
1830 | |
1831 ;; Fontify angle bracket arglists like templates in C++. | |
1832 ,@(when (c-lang-const c-recognize-<>-arglists) | |
1833 `(c-font-lock-<>-arglists)) | |
1834 | 1268 |
1835 ,@(if (c-major-mode-is 'objc-mode) | 1269 ,@(if (c-major-mode-is 'objc-mode) |
1836 ;; Fontify method declarations in Objective-C, but first | 1270 ;; Fontify method declarations in Objective-C, but first |
1837 ;; we have to put the `c-decl-end' `c-type' property on | 1271 ;; we have to put the `c-decl-end' `c-type' property on |
1838 ;; all the @-style directives that haven't been handled in | 1272 ;; all the @-style directives that haven't been handled in |
1845 (append (c-lang-const c-protection-kwds) | 1279 (append (c-lang-const c-protection-kwds) |
1846 (c-lang-const c-other-decl-kwds) | 1280 (c-lang-const c-other-decl-kwds) |
1847 nil))) | 1281 nil))) |
1848 '((c-put-char-property (1- (match-end 1)) | 1282 '((c-put-char-property (1- (match-end 1)) |
1849 'c-type 'c-decl-end))) | 1283 'c-type 'c-decl-end))) |
1850 | 1284 c-font-lock-objc-methods)) |
1851 c-font-lock-objc-methods) | 1285 |
1852 | 1286 ;; Fontify all declarations, casts and normal labels. |
1853 (when (c-lang-const c-opt-access-key) | |
1854 `(,(c-make-font-lock-search-function | |
1855 (c-lang-const c-opt-access-key) | |
1856 '((c-put-char-property (1- (match-end 0)) | |
1857 'c-type 'c-decl-end)))))) | |
1858 | |
1859 ;; Fontify all declarations and casts. | |
1860 c-font-lock-declarations | 1287 c-font-lock-declarations |
1288 | |
1289 ;; Fontify angle bracket arglists like templates in C++. | |
1290 ,@(when (c-lang-const c-recognize-<>-arglists) | |
1291 `(c-font-lock-<>-arglists)) | |
1861 | 1292 |
1862 ;; The first two rules here mostly find occurences that | 1293 ;; The first two rules here mostly find occurences that |
1863 ;; `c-font-lock-declarations' has found already, but not | 1294 ;; `c-font-lock-declarations' has found already, but not |
1864 ;; declarations containing blocks in the type (see note below). | 1295 ;; declarations containing blocks in the type (see note below). |
1865 ;; It's also useful to fontify these everywhere to show e.g. when | 1296 ;; It's also useful to fontify these everywhere to show e.g. when |
1868 ;; Fontify basic types. | 1299 ;; Fontify basic types. |
1869 ,(let ((re (c-make-keywords-re nil | 1300 ,(let ((re (c-make-keywords-re nil |
1870 (c-lang-const c-primitive-type-kwds)))) | 1301 (c-lang-const c-primitive-type-kwds)))) |
1871 (if (c-major-mode-is 'pike-mode) | 1302 (if (c-major-mode-is 'pike-mode) |
1872 ;; No symbol is a keyword after "->" in Pike. | 1303 ;; No symbol is a keyword after "->" in Pike. |
1873 `(,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" | 1304 `(,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)" |
1874 "\\<\\(" re "\\)\\>") | 1305 "\\<\\(" re "\\)\\>") |
1875 3 font-lock-type-face) | 1306 2 font-lock-type-face) |
1876 `(,(concat "\\<\\(" re "\\)\\>") | 1307 `(,(concat "\\<\\(" re "\\)\\>") |
1877 1 'font-lock-type-face))) | 1308 1 'font-lock-type-face))) |
1878 | 1309 |
1879 ;; Fontify types preceded by `c-type-prefix-kwds'. | 1310 ;; Fontify types preceded by `c-type-prefix-kwds'. |
1880 ,@(when (c-lang-const c-type-prefix-kwds) | 1311 ,@(when (c-lang-const c-type-prefix-kwds) |
1898 "\\)\\>") | 1329 "\\)\\>") |
1899 limit t) | 1330 limit t) |
1900 (unless (c-skip-comments-and-strings limit) | 1331 (unless (c-skip-comments-and-strings limit) |
1901 (c-forward-syntactic-ws) | 1332 (c-forward-syntactic-ws) |
1902 ;; Handle prefix declaration specifiers. | 1333 ;; Handle prefix declaration specifiers. |
1903 (when (looking-at c-specifier-key) | 1334 (when (looking-at c-prefix-spec-kwds-re) |
1904 (c-forward-keyword-clause)) | 1335 (c-forward-keyword-clause 1)) |
1905 ,(if (c-major-mode-is 'c++-mode) | 1336 ,(if (c-major-mode-is 'c++-mode) |
1906 `(when (and (c-forward-type) | 1337 `(when (and (c-forward-type) |
1907 (eq (char-after) ?=)) | 1338 (eq (char-after) ?=)) |
1908 ;; In C++ we additionally check for a "class | 1339 ;; In C++ we additionally check for a "class |
1909 ;; X = Y" construct which is used in | 1340 ;; X = Y" construct which is used in |
1947 `(("\\<new\\>" | 1378 `(("\\<new\\>" |
1948 (c-font-lock-c++-new)))) | 1379 (c-font-lock-c++-new)))) |
1949 )) | 1380 )) |
1950 | 1381 |
1951 (defun c-font-lock-labels (limit) | 1382 (defun c-font-lock-labels (limit) |
1952 ;; Fontify all the declarations from the point to LIMIT. Assumes | 1383 ;; Fontify all statement labels from the point to LIMIT. Assumes |
1953 ;; that strings and comments have been fontified already. Nil is | 1384 ;; that strings and comments have been fontified already. Nil is |
1954 ;; always returned. | 1385 ;; always returned. |
1955 ;; | 1386 ;; |
1956 ;; This function can make hidden buffer changes, but the font-lock | 1387 ;; Note: This function is only used on decoration level 2; this is |
1957 ;; context covers that. | 1388 ;; taken care of directly by the gargantuan |
1389 ;; `c-font-lock-declarations' on higher levels. | |
1390 ;; | |
1391 ;; This function might do hidden buffer changes. | |
1958 | 1392 |
1959 (let (continue-pos id-start | 1393 (let (continue-pos id-start |
1960 ;; The font-lock package in Emacs is known to clobber | 1394 ;; The font-lock package in Emacs is known to clobber |
1961 ;; `parse-sexp-lookup-properties' (when it exists). | 1395 ;; `parse-sexp-lookup-properties' (when it exists). |
1962 (parse-sexp-lookup-properties | 1396 (parse-sexp-lookup-properties |
2025 (c-put-char-property (1- (point)) 'c-type | 1459 (c-put-char-property (1- (point)) 'c-type |
2026 'c-decl-id-start) | 1460 'c-decl-id-start) |
2027 (c-forward-syntactic-ws)) | 1461 (c-forward-syntactic-ws)) |
2028 (goto-char (match-end 0))))))) | 1462 (goto-char (match-end 0))))))) |
2029 | 1463 |
2030 ;; Fontify labels in languages that supports them. | 1464 ;; Fontify labels after goto etc. |
2031 ,@(when (c-lang-const c-label-key) | 1465 ,@(when (c-lang-const c-before-label-kwds) |
2032 | 1466 `(;; (Got three different interpretation levels here, |
2033 `(;; Fontify labels after goto etc. | |
2034 ;; (Got three different interpretation levels here, | |
2035 ;; which makes it a bit complicated: 1) The backquote | 1467 ;; which makes it a bit complicated: 1) The backquote |
2036 ;; stuff is expanded when compiled or loaded, 2) the | 1468 ;; stuff is expanded when compiled or loaded, 2) the |
2037 ;; eval form is evaluated at font-lock setup (to | 1469 ;; eval form is evaluated at font-lock setup (to |
2038 ;; substitute c-label-face-name correctly), and 3) the | 1470 ;; substitute c-label-face-name correctly), and 3) the |
2039 ;; resulting structure is interpreted during | 1471 ;; resulting structure is interpreted during |
2046 ,(concat "\\<\\(" c-before-label-re "\\)\\>" | 1478 ,(concat "\\<\\(" c-before-label-re "\\)\\>" |
2047 "\\s *" | 1479 "\\s *" |
2048 "\\(" ; identifier-offset | 1480 "\\(" ; identifier-offset |
2049 (c-lang-const c-symbol-key) | 1481 (c-lang-const c-symbol-key) |
2050 "\\)") | 1482 "\\)") |
2051 (list ,(+ (c-regexp-opt-depth c-before-label-re) 2) | 1483 (list ,(+ (regexp-opt-depth c-before-label-re) 2) |
2052 c-label-face-name nil t)))) | 1484 c-label-face-name nil t)))))) |
2053 | |
2054 ;; Fontify normal labels. | |
2055 c-font-lock-labels)) | |
2056 | 1485 |
2057 ;; Fontify the clauses after various keywords. | 1486 ;; Fontify the clauses after various keywords. |
2058 ,@(when (or (c-lang-const c-type-list-kwds) | 1487 ,@(when (or (c-lang-const c-type-list-kwds) |
2059 (c-lang-const c-ref-list-kwds) | 1488 (c-lang-const c-ref-list-kwds) |
2060 (c-lang-const c-colon-type-list-kwds) | 1489 (c-lang-const c-colon-type-list-kwds) |
2066 (c-lang-const c-ref-list-kwds) | 1495 (c-lang-const c-ref-list-kwds) |
2067 (c-lang-const c-colon-type-list-kwds) | 1496 (c-lang-const c-colon-type-list-kwds) |
2068 (c-lang-const c-paren-type-kwds))) | 1497 (c-lang-const c-paren-type-kwds))) |
2069 "\\)\\>") | 1498 "\\)\\>") |
2070 '((c-fontify-types-and-refs ((c-promote-possible-types t)) | 1499 '((c-fontify-types-and-refs ((c-promote-possible-types t)) |
2071 (c-forward-keyword-clause) | 1500 (c-forward-keyword-clause 1) |
2072 (if (> (point) limit) (goto-char limit)))))))) | 1501 (if (> (point) limit) (goto-char limit)))))))) |
2073 )) | 1502 )) |
2074 | 1503 |
2075 (c-lang-defconst c-matchers-1 | 1504 (c-lang-defconst c-matchers-1 |
2076 t (c-lang-const c-cpp-matchers)) | 1505 t (c-lang-const c-cpp-matchers)) |
2133 ;; `*-font-lock-keywords-*' variables. Older font-lock packages | 1562 ;; `*-font-lock-keywords-*' variables. Older font-lock packages |
2134 ;; define a default value for `*-font-lock-keywords' which we want | 1563 ;; define a default value for `*-font-lock-keywords' which we want |
2135 ;; to override, but we should otoh avoid clobbering a user setting. | 1564 ;; to override, but we should otoh avoid clobbering a user setting. |
2136 ;; This heuristic for that isn't perfect, but I can't think of any | 1565 ;; This heuristic for that isn't perfect, but I can't think of any |
2137 ;; better. /mast | 1566 ;; better. /mast |
2138 ;; | |
2139 ;; This function does not do any hidden buffer changes. | |
2140 (when (and (boundp def-var) | 1567 (when (and (boundp def-var) |
2141 (memq (symbol-value def-var) | 1568 (memq (symbol-value def-var) |
2142 (cons nil | 1569 (cons nil |
2143 (mapcar | 1570 (mapcar |
2144 (lambda (suffix) | 1571 (lambda (suffix) |
2191 ;; a string or comment, and if so try to fontify the type in the | 1618 ;; a string or comment, and if so try to fontify the type in the |
2192 ;; allocation expression. Nil is always returned. | 1619 ;; allocation expression. Nil is always returned. |
2193 ;; | 1620 ;; |
2194 ;; As usual, C++ takes the prize in coming up with a hard to parse | 1621 ;; As usual, C++ takes the prize in coming up with a hard to parse |
2195 ;; syntax. :P | 1622 ;; syntax. :P |
1623 ;; | |
1624 ;; This function might do hidden buffer changes. | |
2196 | 1625 |
2197 (unless (c-skip-comments-and-strings limit) | 1626 (unless (c-skip-comments-and-strings limit) |
2198 (save-excursion | 1627 (save-excursion |
2199 (catch 'false-alarm | 1628 (catch 'false-alarm |
2200 ;; A "new" keyword is followed by one to three expressions, where | 1629 ;; A "new" keyword is followed by one to three expressions, where |
2336 (c-compose-keywords-list c++-font-lock-keywords)) | 1765 (c-compose-keywords-list c++-font-lock-keywords)) |
2337 | 1766 |
2338 | 1767 |
2339 ;;; Objective-C. | 1768 ;;; Objective-C. |
2340 | 1769 |
2341 (defun c-font-lock-objc-iip-decl () | |
2342 ;; Assuming the point is after an "@interface", "@implementation", | |
2343 ;; "@protocol" declaration, fontify all the types in the directive. | |
2344 ;; Return t if the directive was fully recognized. Point will then | |
2345 ;; be at the end of it. | |
2346 | |
2347 (c-fontify-types-and-refs | |
2348 (start-char | |
2349 (c-promote-possible-types t) | |
2350 ;; Turn off recognition of angle bracket arglists while parsing | |
2351 ;; types here since the protocol reference list might then be | |
2352 ;; considered part of the preceding name or superclass-name. | |
2353 c-recognize-<>-arglists) | |
2354 (catch 'break | |
2355 | |
2356 ;; Handle the name of the class itself. | |
2357 (c-forward-syntactic-ws) | |
2358 (unless (c-forward-type) (throw 'break nil)) | |
2359 | |
2360 ;; Look for ": superclass-name" or "( category-name )". | |
2361 (when (looking-at "[:\(]") | |
2362 (setq start-char (char-after)) | |
2363 (forward-char) | |
2364 (c-forward-syntactic-ws) | |
2365 (unless (c-forward-type) (throw 'break nil)) | |
2366 (when (eq start-char ?\() | |
2367 (unless (eq (char-after) ?\)) (throw 'break nil)) | |
2368 (forward-char) | |
2369 (c-forward-syntactic-ws))) | |
2370 | |
2371 ;; Look for a protocol reference list. | |
2372 (when (if (eq (char-after) ?<) | |
2373 (progn | |
2374 (setq c-recognize-<>-arglists t) | |
2375 (c-forward-<>-arglist t t)) | |
2376 t) | |
2377 (c-put-char-property (1- (point)) 'c-type 'c-decl-end) | |
2378 t)))) | |
2379 | |
2380 (defun c-font-lock-objc-method () | 1770 (defun c-font-lock-objc-method () |
2381 ;; Assuming the point is after the + or - that starts an Objective-C | 1771 ;; Assuming the point is after the + or - that starts an Objective-C |
2382 ;; method declaration, fontify it. This must be done before normal | 1772 ;; method declaration, fontify it. This must be done before normal |
2383 ;; casts, declarations and labels are fontified since they will get | 1773 ;; casts, declarations and labels are fontified since they will get |
2384 ;; false matches in these things. | 1774 ;; false matches in these things. |
1775 ;; | |
1776 ;; This function might do hidden buffer changes. | |
2385 | 1777 |
2386 (c-fontify-types-and-refs | 1778 (c-fontify-types-and-refs |
2387 ((first t) | 1779 ((first t) |
2388 (c-promote-possible-types t)) | 1780 (c-promote-possible-types t)) |
2389 | 1781 |
2428 (setq first nil)))) | 1820 (setq first nil)))) |
2429 | 1821 |
2430 (defun c-font-lock-objc-methods (limit) | 1822 (defun c-font-lock-objc-methods (limit) |
2431 ;; Fontify method declarations in Objective-C. Nil is always | 1823 ;; Fontify method declarations in Objective-C. Nil is always |
2432 ;; returned. | 1824 ;; returned. |
1825 ;; | |
1826 ;; This function might do hidden buffer changes. | |
2433 | 1827 |
2434 (let (;; The font-lock package in Emacs is known to clobber | 1828 (let (;; The font-lock package in Emacs is known to clobber |
2435 ;; `parse-sexp-lookup-properties' (when it exists). | 1829 ;; `parse-sexp-lookup-properties' (when it exists). |
2436 (parse-sexp-lookup-properties | 1830 (parse-sexp-lookup-properties |
2437 (cc-eval-when-compile | 1831 (cc-eval-when-compile |
2603 ;; comment enders for block comment are not. | 1997 ;; comment enders for block comment are not. |
2604 ;; | 1998 ;; |
2605 ;; Note that faces added through KEYWORDS should never replace the | 1999 ;; Note that faces added through KEYWORDS should never replace the |
2606 ;; existing `c-doc-face-name' face since the existence of that face | 2000 ;; existing `c-doc-face-name' face since the existence of that face |
2607 ;; is used as a flag in other code to skip comments. | 2001 ;; is used as a flag in other code to skip comments. |
2002 ;; | |
2003 ;; This function might do hidden buffer changes. | |
2608 | 2004 |
2609 (let (comment-beg region-beg) | 2005 (let (comment-beg region-beg) |
2610 (if (eq (get-text-property (point) 'face) | 2006 (if (eq (get-text-property (point) 'face) |
2611 'font-lock-comment-face) | 2007 'font-lock-comment-face) |
2612 ;; Handle the case when the fontified region starts inside a | 2008 ;; Handle the case when the fontified region starts inside a |
2684 ;; Used to fontify invalid markup in doc comments after the correct | 2080 ;; Used to fontify invalid markup in doc comments after the correct |
2685 ;; ones have been fontified: Find the first occurence of REGEXP | 2081 ;; ones have been fontified: Find the first occurence of REGEXP |
2686 ;; between the point and LIMIT that only is fontified with | 2082 ;; between the point and LIMIT that only is fontified with |
2687 ;; `c-doc-face-name'. If a match is found then submatch 0 surrounds | 2083 ;; `c-doc-face-name'. If a match is found then submatch 0 surrounds |
2688 ;; the first char and t is returned, otherwise nil is returned. | 2084 ;; the first char and t is returned, otherwise nil is returned. |
2085 ;; | |
2086 ;; This function might do hidden buffer changes. | |
2689 (let (start) | 2087 (let (start) |
2690 (while (if (re-search-forward regexp limit t) | 2088 (while (if (re-search-forward regexp limit t) |
2691 (not (eq (get-text-property | 2089 (not (eq (get-text-property |
2692 (setq start (match-beginning 0)) 'face) | 2090 (setq start (match-beginning 0)) 'face) |
2693 c-doc-face-name)) | 2091 c-doc-face-name)) |
2695 (when start | 2093 (when start |
2696 (store-match-data (list (copy-marker start) | 2094 (store-match-data (list (copy-marker start) |
2697 (copy-marker (1+ start)))) | 2095 (copy-marker (1+ start)))) |
2698 t))) | 2096 t))) |
2699 | 2097 |
2098 ;; GtkDoc patterns contributed by Masatake YAMATO <jet@gyve.org>. | |
2099 | |
2100 (defconst gtkdoc-font-lock-doc-comments | |
2101 (let ((symbol "[a-zA-Z0-9_]+") | |
2102 (header "^ \\* ")) | |
2103 `((,(concat header "\\(" symbol "\\):[ \t]*$") | |
2104 1 ,c-doc-markup-face-name prepend nil) | |
2105 (,(concat symbol "()") | |
2106 0 ,c-doc-markup-face-name prepend nil) | |
2107 (,(concat header "\\(" "@" symbol "\\):") | |
2108 1 ,c-doc-markup-face-name prepend nil) | |
2109 (,(concat "[#%]" symbol) | |
2110 0 ,c-doc-markup-face-name prepend nil)) | |
2111 )) | |
2112 | |
2113 (defconst gtkdoc-font-lock-doc-protection | |
2114 `(("< \\(public\\|private\\|protected\\) >" | |
2115 1 ,c-doc-markup-face-name prepend nil))) | |
2116 | |
2117 (defconst gtkdoc-font-lock-keywords | |
2118 `((,(lambda (limit) | |
2119 (c-font-lock-doc-comments "/\\*\\*$" limit | |
2120 gtkdoc-font-lock-doc-comments) | |
2121 (c-font-lock-doc-comments "/\\*< " limit | |
2122 gtkdoc-font-lock-doc-protection) | |
2123 )))) | |
2124 | |
2125 ;; Javadoc. | |
2126 | |
2700 (defconst javadoc-font-lock-doc-comments | 2127 (defconst javadoc-font-lock-doc-comments |
2701 `(("{@[a-z]+[^}\n\r]*}" ; "{@foo ...}" markup. | 2128 `(("{@[a-z]+[^}\n\r]*}" ; "{@foo ...}" markup. |
2702 0 ,c-doc-markup-face-name prepend nil) | 2129 0 ,c-doc-markup-face-name prepend nil) |
2703 ("^\\(/\\*\\)?[ \t*]*\\(@[a-z]+\\)" ; "@foo ..." markup. | 2130 ("^\\(/\\*\\)?\\(\\s \\|\\*\\)*\\(@[a-z]+\\)" ; "@foo ..." markup. |
2704 2 ,c-doc-markup-face-name prepend nil) | 2131 3 ,c-doc-markup-face-name prepend nil) |
2705 (,(concat "</?\\sw" ; HTML tags. | 2132 (,(concat "</?\\sw" ; HTML tags. |
2706 "\\(" | 2133 "\\(" |
2707 (concat "\\sw\\|\\s \\|[=\n\r*.:]\\|" | 2134 (concat "\\sw\\|\\s \\|[=\n\r*.:]\\|" |
2708 "\"[^\"]*\"\\|'[^']*'") | 2135 "\"[^\"]*\"\\|'[^']*'") |
2709 "\\)*>") | 2136 "\\)*>") |
2713 ;; Fontify remaining markup characters as invalid. Note | 2140 ;; Fontify remaining markup characters as invalid. Note |
2714 ;; that the Javadoc spec is hazy about when "@" is | 2141 ;; that the Javadoc spec is hazy about when "@" is |
2715 ;; allowed in non-markup use. | 2142 ;; allowed in non-markup use. |
2716 (,(lambda (limit) | 2143 (,(lambda (limit) |
2717 (c-find-invalid-doc-markup "[<>&]\\|{@" limit)) | 2144 (c-find-invalid-doc-markup "[<>&]\\|{@" limit)) |
2718 0 ,c-invalid-face-name prepend nil))) | 2145 0 'font-lock-warning-face prepend nil))) |
2719 | 2146 |
2720 (defconst javadoc-font-lock-keywords | 2147 (defconst javadoc-font-lock-keywords |
2721 `((,(lambda (limit) | 2148 `((,(lambda (limit) |
2722 (c-font-lock-doc-comments "/\\*\\*" limit | 2149 (c-font-lock-doc-comments "/\\*\\*" limit |
2723 javadoc-font-lock-doc-comments))))) | 2150 javadoc-font-lock-doc-comments))))) |
2151 | |
2152 ;; Pike autodoc. | |
2724 | 2153 |
2725 (defconst autodoc-decl-keywords | 2154 (defconst autodoc-decl-keywords |
2726 ;; Adorned regexp matching the keywords that introduce declarations | 2155 ;; Adorned regexp matching the keywords that introduce declarations |
2727 ;; in Pike Autodoc. | 2156 ;; in Pike Autodoc. |
2728 (cc-eval-when-compile | 2157 (cc-eval-when-compile |
2734 (c-make-keywords-re t '("@elem" "@member") 'pike-mode))) | 2163 (c-make-keywords-re t '("@elem" "@member") 'pike-mode))) |
2735 | 2164 |
2736 (defun autodoc-font-lock-line-markup (limit) | 2165 (defun autodoc-font-lock-line-markup (limit) |
2737 ;; Fontify all line oriented keywords between the point and LIMIT. | 2166 ;; Fontify all line oriented keywords between the point and LIMIT. |
2738 ;; Nil is always returned. | 2167 ;; Nil is always returned. |
2168 ;; | |
2169 ;; This function might do hidden buffer changes. | |
2739 | 2170 |
2740 (let ((line-re (concat "^\\(\\(/\\*!\\|\\s *\\(" | 2171 (let ((line-re (concat "^\\(\\(/\\*!\\|\\s *\\(" |
2741 c-current-comment-prefix | 2172 c-current-comment-prefix |
2742 "\\)\\)\\s *\\)@[A-Za-z_-]+\\(\\s \\|$\\)")) | 2173 "\\)\\)\\s *\\)@[A-Za-z_-]+\\(\\s \\|$\\)")) |
2743 (markup-faces (list c-doc-markup-face-name c-doc-face-name))) | 2174 (markup-faces (list c-doc-markup-face-name c-doc-face-name))) |
2763 (end-of-line) | 2194 (end-of-line) |
2764 (setq end (point)) | 2195 (setq end (point)) |
2765 (and (eq (char-before) ?@) | 2196 (and (eq (char-before) ?@) |
2766 (not (eobp)) | 2197 (not (eobp)) |
2767 (progn (forward-char) | 2198 (progn (forward-char) |
2768 (skip-chars-forward " \t") | 2199 (skip-syntax-forward " ") |
2769 (looking-at c-current-comment-prefix)))) | 2200 (looking-at c-current-comment-prefix)))) |
2770 (goto-char (match-end 0)) | 2201 (goto-char (match-end 0)) |
2771 (c-remove-font-lock-face pos (1- end)) | 2202 (c-remove-font-lock-face pos (1- end)) |
2772 (c-put-font-lock-face (1- end) end markup-faces) | 2203 (c-put-font-lock-face (1- end) end markup-faces) |
2773 (setq pos (point))) | 2204 (setq pos (point))) |
2802 (progn (end-of-line) (point)) | 2233 (progn (end-of-line) (point)) |
2803 markup-faces) | 2234 markup-faces) |
2804 (and (eq (char-before) ?@) | 2235 (and (eq (char-before) ?@) |
2805 (not (eobp)) | 2236 (not (eobp)) |
2806 (progn (forward-char) | 2237 (progn (forward-char) |
2807 (skip-chars-forward " \t") | 2238 (skip-syntax-forward " ") |
2808 (looking-at c-current-comment-prefix)))) | 2239 (looking-at c-current-comment-prefix)))) |
2809 (goto-char (match-end 0)))))) | 2240 (goto-char (match-end 0)))))) |
2810 | 2241 |
2811 nil) | 2242 nil) |
2812 | 2243 |
2816 0 ,c-doc-markup-face-name prepend nil) | 2247 0 ,c-doc-markup-face-name prepend nil) |
2817 (autodoc-font-lock-line-markup) | 2248 (autodoc-font-lock-line-markup) |
2818 ;; Fontify remaining markup characters as invalid. | 2249 ;; Fontify remaining markup characters as invalid. |
2819 (,(lambda (limit) | 2250 (,(lambda (limit) |
2820 (c-find-invalid-doc-markup "@" limit)) | 2251 (c-find-invalid-doc-markup "@" limit)) |
2821 0 ,c-invalid-face-name prepend nil) | 2252 0 'font-lock-warning-face prepend nil) |
2822 )) | 2253 )) |
2823 | 2254 |
2824 (defun autodoc-font-lock-keywords () | 2255 (defun autodoc-font-lock-keywords () |
2825 ;; Note that we depend on that `c-current-comment-prefix' has got | 2256 ;; Note that we depend on that `c-current-comment-prefix' has got |
2826 ;; its proper value here. | 2257 ;; its proper value here. |
2258 ;; | |
2259 ;; This function might do hidden buffer changes. | |
2827 | 2260 |
2828 ;; The `c-type' text property with `c-decl-end' is used to mark the | 2261 ;; The `c-type' text property with `c-decl-end' is used to mark the |
2829 ;; end of the `autodoc-decl-keywords' occurrences to fontify the | 2262 ;; end of the `autodoc-decl-keywords' occurrences to fontify the |
2830 ;; following declarations. | 2263 ;; following declarations. |
2831 (setq c-type-decl-end-used t) | 2264 (setq c-type-decl-end-used t) |
2844 (eval-after-load "cc-awk" ; Evaluate while loading cc-fonts | 2277 (eval-after-load "cc-awk" ; Evaluate while loading cc-fonts |
2845 `(defconst awk-font-lock-keywords ; Evaluate after loading cc-awk | 2278 `(defconst awk-font-lock-keywords ; Evaluate after loading cc-awk |
2846 ',(eval-when-compile ; Evaluate while compiling cc-fonts | 2279 ',(eval-when-compile ; Evaluate while compiling cc-fonts |
2847 (list | 2280 (list |
2848 ;; Function names. | 2281 ;; Function names. |
2849 '("^[ \t]*\\(func\\(tion\\)?\\)\\>[ \t]*\\(\\sw+\\)?" | 2282 '("^\\s *\\(func\\(tion\\)?\\)\\>\\s *\\(\\sw+\\)?" |
2850 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) | 2283 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) |
2851 ;; | 2284 ;; |
2852 ;; Variable names. | 2285 ;; Variable names. |
2853 (cons | 2286 (cons |
2854 (concat "\\<" | 2287 (concat "\\<" |
2855 (c-regexp-opt | 2288 (regexp-opt |
2856 '("ARGC" "ARGIND" "ARGV" "BINMODE" "CONVFMT" "ENVIRON" | 2289 '("ARGC" "ARGIND" "ARGV" "BINMODE" "CONVFMT" "ENVIRON" |
2857 "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" | 2290 "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" |
2858 "LINT" "NF" "NR" "OFMT" "OFS" "ORS" "PROCINFO" "RLENGTH" | 2291 "LINT" "NF" "NR" "OFMT" "OFS" "ORS" "PROCINFO" "RLENGTH" |
2859 "RS" "RSTART" "RT" "SUBSEP" "TEXTDOMAIN") t) "\\>") | 2292 "RS" "RSTART" "RT" "SUBSEP" "TEXTDOMAIN") t) "\\>") |
2860 'font-lock-variable-name-face) | 2293 'font-lock-variable-name-face) |
2861 | 2294 |
2862 ;; Special file names. (acm, 2002/7/22) | 2295 ;; Special file names. (acm, 2002/7/22) |
2863 ;; The following regexp was created by first evaluating this in GNU Emacs 21.1: | 2296 ;; The following regexp was created by first evaluating this in GNU Emacs 21.1: |
2864 ;; (c-regexp-opt '("/dev/stdin" "/dev/stdout" "/dev/stderr" "/dev/fd/n" "/dev/pid" | 2297 ;; (regexp-opt '("/dev/stdin" "/dev/stdout" "/dev/stderr" "/dev/fd/n" "/dev/pid" |
2865 ;; "/dev/ppid" "/dev/pgrpid" "/dev/user") 'words) | 2298 ;; "/dev/ppid" "/dev/pgrpid" "/dev/user") 'words) |
2866 ;; , removing the "?:" from each "\\(?:" (for backward compatibility with older Emacsen) | 2299 ;; , removing the "?:" from each "\\(?:" (for backward compatibility with older Emacsen) |
2867 ;; , replacing the "n" in "dev/fd/n" with "[0-9]+" | 2300 ;; , replacing the "n" in "dev/fd/n" with "[0-9]+" |
2868 ;; , removing the unwanted \\< at the beginning, and finally filling out the | 2301 ;; , removing the unwanted \\< at the beginning, and finally filling out the |
2869 ;; regexp so that a " must come before, and either a " or heuristic stuff after. | 2302 ;; regexp so that a " must come before, and either a " or heuristic stuff after. |
2873 std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ | 2306 std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ |
2874 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" | 2307 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" |
2875 (1 font-lock-variable-name-face t) | 2308 (1 font-lock-variable-name-face t) |
2876 (8 font-lock-variable-name-face t t)) | 2309 (8 font-lock-variable-name-face t t)) |
2877 ;; Do the same (almost) with | 2310 ;; Do the same (almost) with |
2878 ;; (c-regexp-opt '("/inet/tcp/lport/rhost/rport" "/inet/udp/lport/rhost/rport" | 2311 ;; (regexp-opt '("/inet/tcp/lport/rhost/rport" "/inet/udp/lport/rhost/rport" |
2879 ;; "/inet/raw/lport/rhost/rport") 'words) | 2312 ;; "/inet/raw/lport/rhost/rport") 'words) |
2880 ;; This cannot be combined with the above pattern, because the match number | 2313 ;; This cannot be combined with the above pattern, because the match number |
2881 ;; for the (optional) closing \" would then exceed 9. | 2314 ;; for the (optional) closing \" would then exceed 9. |
2882 '("\\(\"/inet/\\(\\(raw\\|\\(tc\\|ud\\)p\\)/lport/rhost/rport\\)\\)\\>\ | 2315 '("\\(\"/inet/\\(\\(raw\\|\\(tc\\|ud\\)p\\)/lport/rhost/rport\\)\\)\\>\ |
2883 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" | 2316 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" |
2884 (1 font-lock-variable-name-face t) | 2317 (1 font-lock-variable-name-face t) |
2885 (6 font-lock-variable-name-face t t)) | 2318 (6 font-lock-variable-name-face t t)) |
2886 | 2319 |
2887 ;; Keywords. | 2320 ;; Keywords. |
2888 (concat "\\<" | 2321 (concat "\\<" |
2889 (c-regexp-opt | 2322 (regexp-opt |
2890 '("BEGIN" "END" "break" "continue" "delete" "do" "else" | 2323 '("BEGIN" "END" "break" "continue" "delete" "do" "else" |
2891 "exit" "for" "getline" "if" "in" "next" "nextfile" | 2324 "exit" "for" "getline" "if" "in" "next" "nextfile" |
2892 "return" "while") | 2325 "return" "while") |
2893 t) "\\>") | 2326 t) "\\>") |
2894 | 2327 |
2895 ;; Builtins. | 2328 ;; Builtins. |
2896 `(eval . (list | 2329 `(eval . (list |
2897 ,(concat | 2330 ,(concat |
2898 "\\<" | 2331 "\\<" |
2899 (c-regexp-opt | 2332 (regexp-opt |
2900 '("adump" "and" "asort" "atan2" "bindtextdomain" "close" | 2333 '("adump" "and" "asort" "atan2" "bindtextdomain" "close" |
2901 "compl" "cos" "dcgettext" "exp" "extension" "fflush" | 2334 "compl" "cos" "dcgettext" "exp" "extension" "fflush" |
2902 "gensub" "gsub" "index" "int" "length" "log" "lshift" | 2335 "gensub" "gsub" "index" "int" "length" "log" "lshift" |
2903 "match" "mktime" "or" "print" "printf" "rand" "rshift" | 2336 "match" "mktime" "or" "print" "printf" "rand" "rshift" |
2904 "sin" "split" "sprintf" "sqrt" "srand" "stopme" | 2337 "sin" "split" "sprintf" "sqrt" "srand" "stopme" |
2907 "\\>") | 2340 "\\>") |
2908 0 c-preprocessor-face-name)) | 2341 0 c-preprocessor-face-name)) |
2909 | 2342 |
2910 ;; gawk debugging keywords. (acm, 2002/7/21) | 2343 ;; gawk debugging keywords. (acm, 2002/7/21) |
2911 ;; (Removed, 2003/6/6. These functions are now fontified as built-ins) | 2344 ;; (Removed, 2003/6/6. These functions are now fontified as built-ins) |
2912 ;; (list (concat "\\<" (c-regexp-opt '("adump" "stopme") t) "\\>") | 2345 ;; (list (concat "\\<" (regexp-opt '("adump" "stopme") t) "\\>") |
2913 ;; 0 'font-lock-warning-face) | 2346 ;; 0 'font-lock-warning-face) |
2914 | 2347 |
2915 ;; User defined functions with an apparent spurious space before the | 2348 ;; User defined functions with an apparent spurious space before the |
2916 ;; opening parenthesis. acm, 2002/5/30. | 2349 ;; opening parenthesis. acm, 2002/5/30. |
2917 `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "[ \t]" | 2350 `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "\\s " |
2918 c-awk-escaped-nls*-with-space* "(") | 2351 c-awk-escaped-nls*-with-space* "(") |
2919 (0 'font-lock-warning-face)) | 2352 (0 'font-lock-warning-face)) |
2920 | 2353 |
2921 ;; Space after \ in what looks like an escaped newline. 2002/5/31 | 2354 ;; Space after \ in what looks like an escaped newline. 2002/5/31 |
2922 '("\\\\[ \t]+$" 0 font-lock-warning-face t) | 2355 '("\\\\\\s +$" 0 font-lock-warning-face t) |
2923 | 2356 |
2924 ;; Unbalanced string (") or regexp (/) delimiters. 2002/02/16. | 2357 ;; Unbalanced string (") or regexp (/) delimiters. 2002/02/16. |
2925 '("\\s|" 0 font-lock-warning-face t nil) | 2358 '("\\s|" 0 font-lock-warning-face t nil) |
2926 ;; gawk 3.1 localizable strings ( _"translate me!"). 2002/5/21 | 2359 ;; gawk 3.1 localizable strings ( _"translate me!"). 2002/5/21 |
2927 '("\\(_\\)\\s|" 1 font-lock-warning-face) | 2360 '("\\(_\\)\\s|" 1 font-lock-warning-face) |