Commit | Line | Data |
---|---|---|
130c507e | 1 | ;;; cc-langs.el --- language specific settings for CC Mode |
785eecbb | 2 | |
0386b551 AM |
3 | ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation, |
4 | ;; Inc. | |
785eecbb | 5 | |
d9e94c22 MS |
6 | ;; Authors: 1998- Martin Stjernholm |
7 | ;; 1992-1999 Barry A. Warsaw | |
785eecbb RS |
8 | ;; 1987 Dave Detlefs and Stewart Clamen |
9 | ;; 1985 Richard M. Stallman | |
0ec8351b | 10 | ;; Maintainer: bug-cc-mode@gnu.org |
785eecbb | 11 | ;; Created: 22-Apr-1997 (split from cc-mode.el) |
81eb2ff9 | 12 | ;; Version: See cc-mode.el |
785eecbb RS |
13 | ;; Keywords: c languages oop |
14 | ||
15 | ;; This file is part of GNU Emacs. | |
16 | ||
17 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
18 | ;; it under the terms of the GNU General Public License as published by | |
19 | ;; the Free Software Foundation; either version 2, or (at your option) | |
20 | ;; any later version. | |
21 | ||
22 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | ;; GNU General Public License for more details. | |
26 | ||
27 | ;; You should have received a copy of the GNU General Public License | |
0386b551 | 28 | ;; along with this program; see the file COPYING. If not, write to |
3a35cf56 LK |
29 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
30 | ;; Boston, MA 02110-1301, USA. | |
785eecbb | 31 | |
3afbc435 PJ |
32 | ;;; Commentary: |
33 | ||
d9e94c22 MS |
34 | ;; HACKERS NOTE: There's heavy macro magic here. If you need to make |
35 | ;; changes in this or other files containing `c-lang-defconst' but | |
36 | ;; don't want to read through the longer discussion below then read | |
37 | ;; this: | |
38 | ;; | |
39 | ;; o A change in a `c-lang-defconst' or `c-lang-defvar' will not take | |
40 | ;; effect if the file containing the mode init function (typically | |
41 | ;; cc-mode.el) is byte compiled. | |
42 | ;; o To make changes show in font locking you need to reevaluate the | |
43 | ;; `*-font-lock-keywords-*' constants, which normally is easiest to | |
44 | ;; do with M-x eval-buffer in cc-fonts.el. | |
45 | ;; o In either case it's necessary to reinitialize the mode to make | |
46 | ;; the changes show in an existing buffer. | |
47 | ||
48 | ;;; Introduction to the language dependent variable system: | |
49 | ;; | |
50 | ;; This file contains all the language dependent variables, except | |
51 | ;; those specific for font locking which reside in cc-fonts.el. As | |
52 | ;; far as possible, all the differences between the languages that CC | |
53 | ;; Mode supports are described with these variables only, so that the | |
54 | ;; code can be shared. | |
55 | ;; | |
56 | ;; The language constant system (see cc-defs.el) is used to specify | |
57 | ;; various language dependent info at a high level, such as lists of | |
58 | ;; keywords, and then from them generate - at compile time - the | |
59 | ;; various regexps and other low-level structures actually employed in | |
60 | ;; the code at runtime. | |
61 | ;; | |
62 | ;; This system is also designed to make it easy for developers of | |
63 | ;; derived modes to customize the source constants for new language | |
64 | ;; variants, without having to keep up with the exact regexps etc that | |
65 | ;; are used in each CC Mode version. It's possible from an external | |
66 | ;; package to add a new language by inheriting an existing one, and | |
67 | ;; then change specific constants as necessary for the new language. | |
68 | ;; The old values for those constants (and the values of all the other | |
69 | ;; high-level constants) may be used to build the new ones, and those | |
70 | ;; new values will in turn be used by the low-level definitions here | |
71 | ;; to build the runtime constants appropriately for the new language | |
72 | ;; in the current version of CC Mode. | |
73 | ;; | |
74 | ;; Like elsewhere in CC Mode, the existence of a doc string signifies | |
75 | ;; that a language constant is part of the external API, and that it | |
76 | ;; therefore can be used with a high confidence that it will continue | |
77 | ;; to work with future versions of CC Mode. Even so, it's not | |
78 | ;; unlikely that such constants will change meaning slightly as this | |
79 | ;; system is refined further; a certain degree of dependence on the CC | |
80 | ;; Mode version is unavoidable when hooking in at this level. Also | |
81 | ;; note that there's still work to be done to actually use these | |
82 | ;; constants everywhere inside CC Mode; there are still hardcoded | |
83 | ;; values in many places in the code. | |
84 | ;; | |
85 | ;; Separate packages will also benefit from the compile time | |
86 | ;; evaluation; the byte compiled file(s) for them will contain the | |
87 | ;; compiled runtime constants ready for use by (the byte compiled) CC | |
88 | ;; Mode, and the source definitions in this file don't have to be | |
89 | ;; loaded then. However, if a byte compiled package is loaded that | |
90 | ;; has been compiled with a different version of CC Mode than the one | |
91 | ;; currently loaded, then the compiled-in values will be discarded and | |
92 | ;; new ones will be built when the mode is initialized. That will | |
93 | ;; automatically trig a load of the file(s) containing the source | |
94 | ;; definitions (i.e. this file and/or cc-fonts.el) if necessary. | |
95 | ;; | |
96 | ;; A small example of a derived mode is available at | |
97 | ;; <http://cc-mode.sourceforge.net/derived-mode-ex.el>. It also | |
98 | ;; contains some useful hints for derived mode developers. | |
99 | ||
100 | ;;; Using language variables: | |
101 | ;; | |
102 | ;; The `c-lang-defvar' forms in this file comprise the language | |
103 | ;; variables that CC Mode uses. It does not work to use | |
104 | ;; `c-lang-defvar' anywhere else (which isn't much of a limitation | |
105 | ;; since these variables sole purpose is to interface with the CC Mode | |
106 | ;; core functions). The values in these `c-lang-defvar's are not | |
107 | ;; evaluated right away but instead collected to a single large `setq' | |
108 | ;; that can be inserted for a particular language with the | |
109 | ;; `c-init-language-vars' macro. | |
110 | ||
111 | ;; This file is only required at compile time, or when not running | |
112 | ;; from byte compiled files, or when the source definitions for the | |
113 | ;; language constants are requested. | |
114 | ||
3afbc435 PJ |
115 | ;;; Code: |
116 | ||
51f606de GM |
117 | (eval-when-compile |
118 | (let ((load-path | |
130c507e GM |
119 | (if (and (boundp 'byte-compile-dest-file) |
120 | (stringp byte-compile-dest-file)) | |
121 | (cons (file-name-directory byte-compile-dest-file) load-path) | |
51f606de | 122 | load-path))) |
d9e94c22 | 123 | (load "cc-bytecomp" nil t))) |
51f606de | 124 | |
130c507e GM |
125 | (cc-require 'cc-defs) |
126 | (cc-require 'cc-vars) | |
a6739a05 | 127 | |
0386b551 | 128 | |
9a737a1f MS |
129 | ;; This file is not always loaded. See note above. |
130 | (cc-external-require 'cl) | |
131 | ||
785eecbb | 132 | \f |
d9e94c22 | 133 | ;;; Setup for the `c-lang-defvar' system. |
a66cd3ee MS |
134 | |
135 | (eval-and-compile | |
d9e94c22 MS |
136 | ;; These are used to collect the init forms from the subsequent |
137 | ;; `c-lang-defvar'. They are used to build the lambda in | |
138 | ;; `c-make-init-lang-vars-fun' below. | |
2eb455ab MS |
139 | (defvar c-lang-variable-inits nil) |
140 | (defvar c-lang-variable-inits-tail nil) | |
141 | (setq c-lang-variable-inits (list nil) | |
142 | c-lang-variable-inits-tail c-lang-variable-inits)) | |
d9e94c22 MS |
143 | |
144 | (defmacro c-lang-defvar (var val &optional doc) | |
0386b551 AM |
145 | "Declares the buffer local variable VAR to get the value VAL. VAL is |
146 | evaluated and assigned at mode initialization. More precisely, VAL is | |
147 | evaluated and bound to VAR when the result from the macro | |
d9e94c22 MS |
148 | `c-init-language-vars' is evaluated. |
149 | ||
150 | `c-lang-const' is typically used in VAL to get the right value for the | |
151 | language being initialized, and such calls will be macro expanded to | |
0386b551 | 152 | the evaluated constant value at compile time." |
d9e94c22 MS |
153 | |
154 | (when (and (not doc) | |
155 | (eq (car-safe val) 'c-lang-const) | |
156 | (eq (nth 1 val) var) | |
157 | (not (nth 2 val))) | |
158 | ;; Special case: If there's no docstring and the value is a | |
159 | ;; simple (c-lang-const foo) where foo is the same name as VAR | |
160 | ;; then take the docstring from the language constant foo. | |
161 | (setq doc (get (intern (symbol-name (nth 1 val)) c-lang-constants) | |
162 | 'variable-documentation))) | |
163 | (or (stringp doc) | |
164 | (setq doc nil)) | |
165 | ||
166 | (let ((elem (assq var (cdr c-lang-variable-inits)))) | |
167 | (if elem | |
168 | (setcdr elem (list val doc)) | |
169 | (setcdr c-lang-variable-inits-tail (list (list var val doc))) | |
170 | (setq c-lang-variable-inits-tail (cdr c-lang-variable-inits-tail)))) | |
171 | ||
172 | ;; Return the symbol, like the other def* forms. | |
173 | `',var) | |
174 | ||
175 | (put 'c-lang-defvar 'lisp-indent-function 'defun) | |
176 | (eval-after-load "edebug" | |
177 | '(def-edebug-spec c-lang-defvar | |
178 | (&define name def-form &optional stringp))) | |
c55676a1 | 179 | |
0386b551 AM |
180 | (eval-when-compile |
181 | ;; Some helper functions used when building the language constants. | |
182 | ||
183 | (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate) | |
184 | ;; Used to filter operators from the list OPS in a DWIM:ey way: | |
185 | ;; OPS either has the structure of `c-operators', as a single | |
186 | ;; group in `c-operators', or is a plain list of operators. | |
187 | ;; OPGROUP-FILTER is used filter out the operator groups. It can | |
188 | ;; be t to choose all groups, a list of the group type symbols to | |
189 | ;; accept, or a function which will be called with the group | |
190 | ;; symbol for each group and should return non-nil for those to | |
191 | ;; include. OP-FILTER filters the individual operators in each | |
192 | ;; group. It can be t to choose all operators, a regexp to test | |
193 | ;; against each operator, or a function which will be called for | |
194 | ;; each operator and should return non-nil for those to include. | |
195 | ;; If XLATE is given, it's a function which is called for each | |
196 | ;; matching operator and its return value is collected instead. | |
197 | ;; If it returns a list, the elements are spliced directly into | |
198 | ;; the final result, which is returned as a list with duplicates | |
199 | ;; removed using `equal'. `c-mode-syntax-table' for the current | |
200 | ;; mode is in effect during the whole procedure. | |
201 | (unless (listp (car-safe ops)) | |
202 | (setq ops (list ops))) | |
203 | (cond ((eq opgroup-filter t) | |
204 | (setq opgroup-filter (lambda (opgroup) t))) | |
205 | ((not (functionp opgroup-filter)) | |
206 | (setq opgroup-filter `(lambda (opgroup) | |
207 | (memq opgroup ',opgroup-filter))))) | |
208 | (cond ((eq op-filter t) | |
209 | (setq op-filter (lambda (op) t))) | |
210 | ((stringp op-filter) | |
211 | (setq op-filter `(lambda (op) | |
212 | (string-match ,op-filter op))))) | |
213 | (unless xlate | |
214 | (setq xlate 'identity)) | |
215 | (c-with-syntax-table (c-lang-const c-mode-syntax-table) | |
216 | (delete-duplicates | |
217 | (mapcan (lambda (opgroup) | |
218 | (when (if (symbolp (car opgroup)) | |
219 | (when (funcall opgroup-filter (car opgroup)) | |
220 | (setq opgroup (cdr opgroup)) | |
221 | t) | |
222 | t) | |
223 | (mapcan (lambda (op) | |
224 | (when (funcall op-filter op) | |
225 | (let ((res (funcall xlate op))) | |
226 | (if (listp res) res (list res))))) | |
227 | opgroup))) | |
228 | ops) | |
229 | :test 'equal)))) | |
230 | ||
51f606de | 231 | \f |
d9e94c22 MS |
232 | ;;; Various mode specific values that aren't language related. |
233 | ||
234 | (c-lang-defconst c-mode-menu | |
235 | ;; The definition for the mode menu. The menu title is prepended to | |
236 | ;; this before it's fed to `easy-menu-define'. | |
237 | t `(["Comment Out Region" comment-region | |
238 | (c-fn-region-is-active-p)] | |
239 | ["Uncomment Region" (comment-region (region-beginning) | |
240 | (region-end) '(4)) | |
241 | (c-fn-region-is-active-p)] | |
242 | ["Indent Expression" c-indent-exp | |
243 | (memq (char-after) '(?\( ?\[ ?\{))] | |
244 | ["Indent Line or Region" c-indent-line-or-region t] | |
245 | ["Fill Comment Paragraph" c-fill-paragraph t] | |
246 | "----" | |
247 | ["Backward Statement" c-beginning-of-statement t] | |
248 | ["Forward Statement" c-end-of-statement t] | |
249 | ,@(when (c-lang-const c-opt-cpp-prefix) | |
250 | ;; Only applicable if there's a cpp preprocessor. | |
251 | `(["Up Conditional" c-up-conditional t] | |
252 | ["Backward Conditional" c-backward-conditional t] | |
253 | ["Forward Conditional" c-forward-conditional t] | |
254 | "----" | |
255 | ["Macro Expand Region" c-macro-expand | |
256 | (c-fn-region-is-active-p)] | |
257 | ["Backslashify" c-backslash-region | |
258 | (c-fn-region-is-active-p)])) | |
259 | "----" | |
260 | ("Toggle..." | |
261 | ["Syntactic indentation" c-toggle-syntactic-indentation t] | |
0386b551 | 262 | ["Auto newline" c-toggle-auto-newline t] |
d9e94c22 | 263 | ["Hungry delete" c-toggle-hungry-state t]))) |
a66cd3ee | 264 | |
d9e94c22 MS |
265 | \f |
266 | ;;; Syntax tables. | |
267 | ||
268 | (defun c-populate-syntax-table (table) | |
269 | "Populate the given syntax table as necessary for a C-like language. | |
270 | This includes setting ' and \" as string delimiters, and setting up | |
271 | the comment syntax to handle both line style \"//\" and block style | |
272 | \"/*\" \"*/\" comments." | |
273 | ||
274 | (modify-syntax-entry ?_ "_" table) | |
275 | (modify-syntax-entry ?\\ "\\" table) | |
276 | (modify-syntax-entry ?+ "." table) | |
277 | (modify-syntax-entry ?- "." table) | |
278 | (modify-syntax-entry ?= "." table) | |
279 | (modify-syntax-entry ?% "." table) | |
280 | (modify-syntax-entry ?< "." table) | |
281 | (modify-syntax-entry ?> "." table) | |
282 | (modify-syntax-entry ?& "." table) | |
283 | (modify-syntax-entry ?| "." table) | |
284 | (modify-syntax-entry ?\' "\"" table) | |
285 | (modify-syntax-entry ?\240 "." table) | |
286 | ||
287 | ;; Set up block and line oriented comments. The new C | |
288 | ;; standard mandates both comment styles even in C, so since | |
289 | ;; all languages now require dual comments, we make this the | |
290 | ;; default. | |
291 | (cond | |
292 | ;; XEmacs | |
293 | ((memq '8-bit c-emacs-features) | |
294 | (modify-syntax-entry ?/ ". 1456" table) | |
295 | (modify-syntax-entry ?* ". 23" table)) | |
296 | ;; Emacs | |
297 | ((memq '1-bit c-emacs-features) | |
298 | (modify-syntax-entry ?/ ". 124b" table) | |
299 | (modify-syntax-entry ?* ". 23" table)) | |
300 | ;; incompatible | |
301 | (t (error "CC Mode is incompatible with this version of Emacs"))) | |
302 | ||
303 | (modify-syntax-entry ?\n "> b" table) | |
304 | ;; Give CR the same syntax as newline, for selective-display | |
305 | (modify-syntax-entry ?\^m "> b" table)) | |
306 | ||
307 | (c-lang-defconst c-make-mode-syntax-table | |
308 | "Functions that generates the mode specific syntax tables. | |
309 | The syntax tables aren't stored directly since they're quite large." | |
310 | t `(lambda () | |
311 | (let ((table (make-syntax-table))) | |
312 | (c-populate-syntax-table table) | |
313 | ;; Mode specific syntaxes. | |
314 | ,(cond ((c-major-mode-is 'objc-mode) | |
0386b551 AM |
315 | ;; Let '@' be part of symbols in ObjC to cope with |
316 | ;; its compiler directives as single keyword tokens. | |
317 | ;; This is then necessary since it's assumed that | |
318 | ;; every keyword is a single symbol. | |
d9e94c22 MS |
319 | `(modify-syntax-entry ?@ "_" table)) |
320 | ((c-major-mode-is 'pike-mode) | |
321 | `(modify-syntax-entry ?@ "." table))) | |
322 | table))) | |
323 | ||
324 | (c-lang-defconst c-mode-syntax-table | |
325 | ;; The syntax tables in evaluated form. Only used temporarily when | |
326 | ;; the constants in this file are evaluated. | |
327 | t (funcall (c-lang-const c-make-mode-syntax-table))) | |
328 | ||
f75ef66d | 329 | (c-lang-defconst c++-make-template-syntax-table |
d9e94c22 MS |
330 | ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as |
331 | ;; parenthesis characters. Used temporarily when template argument | |
332 | ;; lists are parsed. Note that this encourages incorrect parsing of | |
333 | ;; templates since they might contain normal operators that uses the | |
334 | ;; '<' and '>' characters. Therefore this syntax table might go | |
335 | ;; away when CC Mode handles templates correctly everywhere. | |
336 | t nil | |
337 | c++ `(lambda () | |
338 | (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) | |
339 | (modify-syntax-entry ?< "(>" table) | |
340 | (modify-syntax-entry ?> ")<" table) | |
341 | table))) | |
342 | (c-lang-defvar c++-template-syntax-table | |
f75ef66d MS |
343 | (and (c-lang-const c++-make-template-syntax-table) |
344 | (funcall (c-lang-const c++-make-template-syntax-table)))) | |
d9e94c22 MS |
345 | |
346 | (c-lang-defconst c-identifier-syntax-modifications | |
347 | "A list that describes the modifications that should be done to the | |
348 | mode syntax table to get a syntax table that matches all identifiers | |
349 | and keywords as words. | |
350 | ||
351 | The list is just like the one used in `font-lock-defaults': Each | |
352 | element is a cons where the car is the character to modify and the cdr | |
353 | the new syntax, as accepted by `modify-syntax-entry'." | |
354 | ;; The $ character is not allowed in most languages (one exception | |
355 | ;; is Java which allows it for legacy reasons) but we still classify | |
356 | ;; it as an indentifier character since it's often used in various | |
357 | ;; machine generated identifiers. | |
358 | t '((?_ . "w") (?$ . "w")) | |
359 | objc (append '((?@ . "w")) | |
360 | (c-lang-const c-identifier-syntax-modifications)) | |
361 | awk '((?_ . "w"))) | |
362 | (c-lang-defvar c-identifier-syntax-modifications | |
363 | (c-lang-const c-identifier-syntax-modifications)) | |
364 | ||
365 | (c-lang-defvar c-identifier-syntax-table | |
366 | (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table"))) | |
367 | (mods c-identifier-syntax-modifications) | |
368 | mod) | |
369 | (while mods | |
370 | (setq mod (car mods) | |
371 | mods (cdr mods)) | |
372 | (modify-syntax-entry (car mod) (cdr mod) table)) | |
373 | table) | |
374 | "Syntax table built on the mode syntax table but additionally | |
375 | classifies symbol constituents like '_' and '$' as word constituents, | |
376 | so that all identifiers are recognized as words.") | |
377 | ||
378 | \f | |
379 | ;;; Lexer-level syntax (identifiers, tokens etc). | |
380 | ||
381 | (c-lang-defconst c-symbol-start | |
382 | "Regexp that matches the start of a symbol, i.e. any identifier or | |
383 | keyword. It's unspecified how far it matches. Does not contain a \\| | |
384 | operator at the top level." | |
385 | t (concat "[" c-alpha "_]") | |
0386b551 | 386 | objc (concat "[" c-alpha "@]") |
d9e94c22 MS |
387 | pike (concat "[" c-alpha "_`]")) |
388 | (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start)) | |
389 | ||
390 | (c-lang-defconst c-symbol-chars | |
391 | "Set of characters that can be part of a symbol. | |
392 | This is on the form that fits inside [ ] in a regexp." | |
393 | ;; Pike note: With the backquote identifiers this would include most | |
394 | ;; operator chars too, but they are handled with other means instead. | |
395 | t (concat c-alnum "_$") | |
396 | objc (concat c-alnum "_$@")) | |
a66cd3ee | 397 | |
a66cd3ee | 398 | (c-lang-defconst c-symbol-key |
0386b551 AM |
399 | "Regexp matching identifiers and keywords (with submatch 0). Assumed |
400 | to match if `c-symbol-start' matches on the same position." | |
d9e94c22 MS |
401 | t (concat (c-lang-const c-symbol-start) |
402 | "[" (c-lang-const c-symbol-chars) "]*") | |
403 | pike (concat | |
404 | ;; Use the value from C here since the operator backquote is | |
405 | ;; covered by the other alternative. | |
406 | (c-lang-const c-symbol-key c) | |
407 | "\\|" | |
408 | (c-make-keywords-re nil | |
409 | (c-lang-const c-overloadable-operators)))) | |
410 | (c-lang-defvar c-symbol-key (c-lang-const c-symbol-key)) | |
411 | ||
412 | (c-lang-defconst c-symbol-key-depth | |
413 | ;; Number of regexp grouping parens in `c-symbol-key'. | |
0386b551 | 414 | t (regexp-opt-depth (c-lang-const c-symbol-key))) |
d9e94c22 MS |
415 | |
416 | (c-lang-defconst c-nonsymbol-chars | |
417 | "This is the set of chars that can't be part of a symbol, i.e. the | |
418 | negation of `c-symbol-chars'." | |
419 | t (concat "^" (c-lang-const c-symbol-chars))) | |
420 | (c-lang-defvar c-nonsymbol-chars (c-lang-const c-nonsymbol-chars)) | |
421 | ||
422 | (c-lang-defconst c-nonsymbol-key | |
423 | "Regexp that matches any character that can't be part of a symbol. | |
424 | It's usually appended to other regexps to avoid matching a prefix. | |
425 | It's assumed to not contain any submatchers." | |
426 | ;; The same thing regarding Unicode identifiers applies here as to | |
427 | ;; `c-symbol-key'. | |
428 | t (concat "[" (c-lang-const c-nonsymbol-chars) "]")) | |
429 | ||
0386b551 AM |
430 | (c-lang-defconst c-identifier-ops |
431 | "The operators that make up fully qualified identifiers. nil in | |
432 | languages that don't have such things. See `c-operators' for a | |
433 | description of the format. Binary operators can concatenate symbols, | |
434 | e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers, | |
435 | e.g. \"~\" in \"~A::B\". Other types of operators aren't supported. | |
436 | ||
437 | This value is by default merged into `c-operators'." | |
d9e94c22 | 438 | t nil |
0386b551 AM |
439 | c++ '((prefix "~" "??-" "compl") |
440 | (right-assoc "::") | |
441 | (prefix "::")) | |
2a15eb73 MS |
442 | ;; Java has "." to concatenate identifiers but it's also used for |
443 | ;; normal indexing. There's special code in the Java font lock | |
444 | ;; rules to fontify qualified identifiers based on the standard | |
445 | ;; naming conventions. We still define "." here to make | |
446 | ;; `c-forward-name' move over as long names as possible which is | |
447 | ;; necessary to e.g. handle throws clauses correctly. | |
0386b551 AM |
448 | java '((left-assoc ".")) |
449 | idl '((left-assoc "::") | |
450 | (prefix "::")) | |
451 | pike '((left-assoc "::") | |
452 | (prefix "::") | |
453 | (left-assoc "."))) | |
454 | ||
455 | (c-lang-defconst c-opt-identifier-concat-key | |
456 | ;; Appendable adorned regexp matching the operators that join | |
457 | ;; symbols to fully qualified identifiers, or nil in languages that | |
458 | ;; don't have such things. | |
459 | ;; | |
460 | ;; This was a docstring constant in 5.30. It still works but is now | |
461 | ;; considered internal - change `c-identifier-ops' instead. | |
462 | t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops) | |
463 | '(left-assoc right-assoc) | |
464 | t))) | |
465 | (when ops | |
466 | (c-make-keywords-re 'appendable ops)))) | |
d9e94c22 MS |
467 | (c-lang-defvar c-opt-identifier-concat-key |
468 | (c-lang-const c-opt-identifier-concat-key) | |
469 | 'dont-doc) | |
470 | ||
0386b551 AM |
471 | (c-lang-defconst c-opt-identifier-concat-key-depth |
472 | ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'. | |
473 | t (regexp-opt-depth (c-lang-const c-opt-identifier-concat-key))) | |
474 | ||
475 | (c-lang-defconst c-opt-identifier-prefix-key | |
476 | ;; Appendable adorned regexp matching operators that might precede | |
477 | ;; an identifier and that are part of the identifier in that case. | |
478 | ;; nil in languages without such things. | |
479 | t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops) | |
480 | '(prefix) | |
481 | t))) | |
482 | (when ops | |
483 | (c-make-keywords-re 'appendable ops)))) | |
484 | ||
485 | (c-lang-defconst c-after-id-concat-ops | |
486 | "Operators that can occur after a binary operator on `c-identifier-ops' | |
487 | in identifiers. nil in languages that don't have such things. | |
488 | ||
489 | Operators here should also have appropriate entries in `c-operators' - | |
490 | it's not taken care of by default." | |
491 | t nil | |
492 | ;; '~' for destructors in C++, '*' for member pointers. | |
493 | c++ '("~" "*") | |
494 | ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur | |
495 | ;; in import declarations. (This will also match bogus things like | |
496 | ;; "foo.*bar" but we don't bother.) | |
497 | java '("*")) | |
498 | ||
d9e94c22 | 499 | (c-lang-defconst c-opt-after-id-concat-key |
0386b551 AM |
500 | ;; Regexp that must match the token after |
501 | ;; `c-opt-identifier-concat-key' for it to be considered an | |
502 | ;; identifier concatenation operator (which e.g. causes the | |
503 | ;; preceding identifier to be fontified as a reference). Assumed to | |
504 | ;; be a string if `c-opt-identifier-concat-key' is. | |
505 | ;; | |
506 | ;; This was a docstring constant in 5.30. It still works but is now | |
507 | ;; considered internal - change `c-after-id-concat-ops' instead. | |
508 | t (concat (c-lang-const c-symbol-start) | |
509 | (if (c-lang-const c-after-id-concat-ops) | |
510 | (concat "\\|" (c-make-keywords-re 'appendable | |
511 | (c-lang-const c-after-id-concat-ops))) | |
512 | ""))) | |
d9e94c22 MS |
513 | |
514 | (c-lang-defconst c-identifier-start | |
0386b551 AM |
515 | "Regexp that matches the start of an (optionally qualified) identifier. |
516 | It should also match all keywords. It's unspecified how far it | |
517 | matches." | |
518 | t (concat (c-lang-const c-symbol-start) | |
519 | (if (c-lang-const c-opt-identifier-prefix-key) | |
520 | (concat "\\|" | |
521 | (c-lang-const c-opt-identifier-prefix-key)) | |
522 | ""))) | |
d9e94c22 MS |
523 | (c-lang-defvar c-identifier-start (c-lang-const c-identifier-start)) |
524 | ||
525 | (c-lang-defconst c-identifier-key | |
526 | "Regexp matching a fully qualified identifier, like \"A::B::c\" in | |
527 | C++. It does not recognize the full range of syntactic whitespace | |
0386b551 AM |
528 | between the tokens; `c-forward-name' has to be used for that. It |
529 | should also not match identifiers containing parenthesis groupings, | |
530 | e.g. identifiers with template arguments such as \"A<X,Y>\" in C++." | |
531 | ;; This regexp is more complex than strictly necessary to ensure | |
532 | ;; that it can be matched with a minimum of backtracking. | |
533 | t (concat (if (c-lang-const c-opt-identifier-prefix-key) | |
534 | (concat | |
535 | "\\(" | |
536 | (c-lang-const c-opt-identifier-prefix-key) | |
537 | (c-lang-const c-simple-ws) "*" | |
d9e94c22 | 538 | "\\)?") |
0386b551 AM |
539 | "") |
540 | "\\(" (c-lang-const c-symbol-key) "\\)" | |
541 | (if (c-lang-const c-opt-identifier-concat-key) | |
542 | (concat | |
543 | "\\(" | |
544 | (c-lang-const c-simple-ws) "*" | |
545 | (c-lang-const c-opt-identifier-concat-key) | |
546 | (c-lang-const c-simple-ws) "*" | |
547 | (if (c-lang-const c-after-id-concat-ops) | |
548 | (concat | |
549 | "\\(" | |
550 | (c-make-keywords-re 'appendable | |
551 | (c-lang-const c-after-id-concat-ops)) | |
552 | (concat | |
553 | ;; For flexibility, consider the symbol match | |
554 | ;; optional if we've hit a | |
555 | ;; `c-after-id-concat-ops' operator. This is | |
556 | ;; also necessary to handle the "*" that can | |
557 | ;; end import declaration identifiers in Java. | |
558 | "\\(" | |
559 | (c-lang-const c-simple-ws) "*" | |
560 | "\\(" (c-lang-const c-symbol-key) "\\)" | |
561 | "\\)?") | |
562 | "\\|" | |
d9e94c22 | 563 | "\\(" (c-lang-const c-symbol-key) "\\)" |
0386b551 AM |
564 | "\\)") |
565 | (concat "\\(" (c-lang-const c-symbol-key) "\\)")) | |
566 | "\\)*") | |
567 | ""))) | |
d9e94c22 MS |
568 | (c-lang-defvar c-identifier-key (c-lang-const c-identifier-key)) |
569 | ||
570 | (c-lang-defconst c-identifier-last-sym-match | |
0386b551 AM |
571 | ;; This was a docstring constant in 5.30 but it's no longer used. |
572 | ;; It's only kept to avoid breaking third party code. | |
573 | ;; | |
574 | ;; Used to identify the submatch in `c-identifier-key' that | |
575 | ;; surrounds the last symbol in the qualified identifier. It's a | |
576 | ;; list of submatch numbers, of which the first that has a match is | |
577 | ;; taken. It's assumed that at least one does when the regexp has | |
578 | ;; matched. | |
579 | t nil) | |
580 | ||
581 | (c-lang-defconst c-string-escaped-newlines | |
582 | "Set if the language support backslash escaped newlines inside string | |
583 | literals." | |
584 | t nil | |
585 | (c c++ objc pike) t) | |
586 | (c-lang-defvar c-string-escaped-newlines | |
587 | (c-lang-const c-string-escaped-newlines)) | |
588 | ||
589 | (c-lang-defconst c-multiline-string-start-char | |
590 | "Set if the language supports multiline string literals without escaped | |
591 | newlines. If t, all string literals are multiline. If a character, | |
592 | only literals where the open quote is immediately preceded by that | |
593 | literal are multiline." | |
594 | t nil | |
595 | pike ?#) | |
596 | (c-lang-defvar c-multiline-string-start-char | |
597 | (c-lang-const c-multiline-string-start-char)) | |
d9e94c22 MS |
598 | |
599 | (c-lang-defconst c-opt-cpp-prefix | |
600 | "Regexp matching the prefix of a cpp directive in the languages that | |
601 | normally use that macro preprocessor. Tested at bol or at boi. | |
602 | Assumed to not contain any submatches or \\| operators." | |
0386b551 AM |
603 | ;; TODO (ACM, 2005-04-01). Amend the following to recognise escaped NLs; |
604 | ;; amend all uses of c-opt-cpp-prefix which count regexp-depth. | |
d9e94c22 MS |
605 | t "\\s *#\\s *" |
606 | (java awk) nil) | |
607 | (c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix)) | |
608 | ||
609 | (c-lang-defconst c-opt-cpp-start | |
610 | "Regexp matching the prefix of a cpp directive including the directive | |
611 | name, or nil in languages without preprocessor support. The first | |
612 | submatch surrounds the directive name." | |
613 | t (if (c-lang-const c-opt-cpp-prefix) | |
614 | (concat (c-lang-const c-opt-cpp-prefix) | |
615 | "\\([" c-alnum "]+\\)")) | |
616 | ;; Pike, being a scripting language, recognizes hash-bangs too. | |
617 | pike (concat (c-lang-const c-opt-cpp-prefix) | |
618 | "\\([" c-alnum "]+\\|!\\)")) | |
619 | (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start)) | |
620 | ||
0386b551 AM |
621 | (c-lang-defconst c-cpp-message-directives |
622 | "List of cpp directives (without the prefix) that are followed by a | |
623 | string message." | |
624 | t (if (c-lang-const c-opt-cpp-prefix) | |
625 | '("error")) | |
626 | pike '("error" "warning")) | |
627 | ||
628 | (c-lang-defconst c-cpp-include-directives | |
629 | "List of cpp directives (without the prefix) that are followed by a | |
630 | file name in angle brackets or quotes." | |
631 | t (if (c-lang-const c-opt-cpp-prefix) | |
632 | '("include")) | |
633 | objc '("include" "import")) | |
634 | ||
635 | (c-lang-defconst c-opt-cpp-macro-define | |
636 | "Cpp directive (without the prefix) that is followed by a macro | |
637 | definition, or nil if the language doesn't have any." | |
638 | t (if (c-lang-const c-opt-cpp-prefix) | |
639 | "define")) | |
640 | ||
641 | (c-lang-defconst c-opt-cpp-macro-define-start | |
642 | ;; Regexp matching everything up to the macro body of a cpp define, | |
643 | ;; or the end of the logical line if there is none. Set if | |
644 | ;; c-opt-cpp-macro-define is. | |
645 | t (if (c-lang-const c-opt-cpp-macro-define) | |
646 | (concat (c-lang-const c-opt-cpp-prefix) | |
647 | (c-lang-const c-opt-cpp-macro-define) | |
648 | "[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?" | |
649 | "\\([ \t]\\|\\\\\n\\)*"))) | |
650 | (c-lang-defvar c-opt-cpp-macro-define-start | |
651 | (c-lang-const c-opt-cpp-macro-define-start)) | |
652 | ||
653 | (c-lang-defconst c-cpp-expr-directives | |
654 | "List if cpp directives (without the prefix) that are followed by an | |
655 | expression." | |
656 | t (if (c-lang-const c-opt-cpp-prefix) | |
657 | '("if" "elif"))) | |
658 | ||
659 | (c-lang-defconst c-cpp-expr-functions | |
660 | "List of functions in cpp expressions." | |
d9e94c22 MS |
661 | t (if (c-lang-const c-opt-cpp-prefix) |
662 | '("defined")) | |
663 | pike '("defined" "efun" "constant")) | |
664 | ||
846f5040 MS |
665 | (c-lang-defconst c-assignment-operators |
666 | "List of all assignment operators." | |
667 | t '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=") | |
668 | java (append (c-lang-const c-assignment-operators) | |
669 | '(">>>=")) | |
670 | c++ (append (c-lang-const c-assignment-operators) | |
0386b551 | 671 | '("and_eq" "or_eq" "xor_eq" "??!=" "??'=")) |
846f5040 MS |
672 | idl nil) |
673 | ||
d9e94c22 MS |
674 | (c-lang-defconst c-operators |
675 | "List describing all operators, along with their precedence and | |
676 | associativity. The order in the list corresponds to the precedence of | |
677 | the operators: The operators in each element is a group with the same | |
678 | precedence, and the group has higher precedence than the groups in all | |
679 | following elements. The car of each element describes the type of of | |
680 | the operator group, and the cdr is a list of the operator tokens in | |
681 | it. The operator group types are: | |
682 | ||
683 | 'prefix Unary prefix operators. | |
684 | 'postfix Unary postfix operators. | |
0386b551 AM |
685 | 'postfix-if-paren |
686 | Unary postfix operators if and only if the chars have | |
687 | parenthesis syntax. | |
d9e94c22 MS |
688 | 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c). |
689 | 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)). | |
690 | 'right-assoc-sequence | |
691 | Right associative operator that constitutes of a | |
692 | sequence of tokens that separate expressions. All the | |
693 | tokens in the group are in this case taken as | |
694 | describing the sequence in one such operator, and the | |
695 | order between them is therefore significant. | |
696 | ||
697 | Operators containing a character with paren syntax are taken to match | |
698 | with a corresponding open/close paren somewhere else. A postfix | |
699 | operator with close paren syntax is taken to end a postfix expression | |
700 | started somewhere earlier, rather than start a new one at point. Vice | |
701 | versa for prefix operators with open paren syntax. | |
702 | ||
703 | Note that operators like \".\" and \"->\" which in language references | |
704 | often are described as postfix operators are considered binary here, | |
705 | since CC Mode treats every identifier as an expression." | |
706 | ||
707 | ;; There's currently no code in CC Mode that exploit all the info | |
708 | ;; in this variable; precedence, associativity etc are present as a | |
709 | ;; preparation for future work. | |
710 | ||
711 | t `(;; Preprocessor. | |
712 | ,@(when (c-lang-const c-opt-cpp-prefix) | |
713 | `((prefix "#" | |
714 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
715 | '("%:" "??="))) | |
716 | (left-assoc "##" | |
717 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
718 | '("%:%:" "??=??="))))) | |
719 | ||
0386b551 AM |
720 | ;; Primary. |
721 | ,@(c-lang-const c-identifier-ops) | |
d9e94c22 | 722 | ,@(cond ((c-major-mode-is 'c++-mode) |
0386b551 | 723 | `((postfix-if-paren "<" ">"))) ; Templates. |
d9e94c22 | 724 | ((c-major-mode-is 'pike-mode) |
0386b551 | 725 | `((prefix "global" "predef"))) |
d9e94c22 | 726 | ((c-major-mode-is 'java-mode) |
0386b551 | 727 | `((prefix "super")))) |
d9e94c22 MS |
728 | |
729 | ;; Postfix. | |
730 | ,@(when (c-major-mode-is 'c++-mode) | |
731 | ;; The following need special treatment. | |
732 | `((prefix "dynamic_cast" "static_cast" | |
733 | "reinterpret_cast" "const_cast" "typeid"))) | |
734 | (left-assoc "." | |
735 | ,@(unless (c-major-mode-is 'java-mode) | |
736 | '("->"))) | |
737 | (postfix "++" "--" "[" "]" "(" ")" | |
738 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
739 | '("<:" ":>" "??(" "??)"))) | |
740 | ||
741 | ;; Unary. | |
742 | (prefix "++" "--" "+" "-" "!" "~" | |
743 | ,@(when (c-major-mode-is 'c++-mode) '("not" "compl")) | |
744 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
745 | '("*" "&" "sizeof" "??-")) | |
746 | ,@(when (c-major-mode-is 'objc-mode) | |
747 | '("@selector" "@protocol" "@encode")) | |
748 | ;; The following need special treatment. | |
749 | ,@(cond ((c-major-mode-is 'c++-mode) | |
750 | '("new" "delete")) | |
751 | ((c-major-mode-is 'java-mode) | |
752 | '("new")) | |
753 | ((c-major-mode-is 'pike-mode) | |
754 | '("class" "lambda" "catch" "throw" "gauge"))) | |
755 | "(" ")" ; Cast. | |
756 | ,@(when (c-major-mode-is 'pike-mode) | |
757 | '("[" "]"))) ; Type cast. | |
758 | ||
759 | ;; Member selection. | |
760 | ,@(when (c-major-mode-is 'c++-mode) | |
761 | `((left-assoc ".*" "->*"))) | |
762 | ||
763 | ;; Multiplicative. | |
764 | (left-assoc "*" "/" "%") | |
765 | ||
766 | ;; Additive. | |
767 | (left-assoc "+" "-") | |
768 | ||
769 | ;; Shift. | |
770 | (left-assoc "<<" ">>" | |
771 | ,@(when (c-major-mode-is 'java-mode) | |
772 | '(">>>"))) | |
773 | ||
774 | ;; Relational. | |
775 | (left-assoc "<" ">" "<=" ">=" | |
776 | ,@(when (c-major-mode-is 'java-mode) | |
777 | '("instanceof"))) | |
778 | ||
779 | ;; Equality. | |
780 | (left-assoc "==" "!=" | |
781 | ,@(when (c-major-mode-is 'c++-mode) '("not_eq"))) | |
782 | ||
783 | ;; Bitwise and. | |
784 | (left-assoc "&" | |
785 | ,@(when (c-major-mode-is 'c++-mode) '("bitand"))) | |
786 | ||
787 | ;; Bitwise exclusive or. | |
788 | (left-assoc "^" | |
789 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
790 | '("??'")) | |
791 | ,@(when (c-major-mode-is 'c++-mode) '("xor"))) | |
792 | ||
793 | ;; Bitwise or. | |
794 | (left-assoc "|" | |
795 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
796 | '("??!")) | |
797 | ,@(when (c-major-mode-is 'c++-mode) '("bitor"))) | |
798 | ||
799 | ;; Logical and. | |
800 | (left-assoc "&&" | |
801 | ,@(when (c-major-mode-is 'c++-mode) '("and"))) | |
802 | ||
803 | ;; Logical or. | |
804 | (left-assoc "||" | |
805 | ,@(when (c-major-mode-is '(c-mode c++-mode)) | |
806 | '("??!??!")) | |
807 | ,@(when (c-major-mode-is 'c++-mode) '("or"))) | |
808 | ||
809 | ;; Conditional. | |
810 | (right-assoc-sequence "?" ":") | |
811 | ||
812 | ;; Assignment. | |
846f5040 | 813 | (right-assoc ,@(c-lang-const c-assignment-operators)) |
d9e94c22 MS |
814 | |
815 | ;; Exception. | |
816 | ,@(when (c-major-mode-is 'c++-mode) | |
817 | '((prefix "throw"))) | |
818 | ||
819 | ;; Sequence. | |
820 | (left-assoc ",")) | |
821 | ||
822 | ;; IDL got its own definition since it has a much smaller operator | |
823 | ;; set than the other languages. | |
824 | idl `(;; Preprocessor. | |
825 | (prefix "#") | |
826 | (left-assoc "##") | |
0386b551 AM |
827 | ;; Primary. |
828 | ,@(c-lang-const c-identifier-ops) | |
d9e94c22 MS |
829 | ;; Unary. |
830 | (prefix "+" "-" "~") | |
831 | ;; Multiplicative. | |
832 | (left-assoc "*" "/" "%") | |
833 | ;; Additive. | |
834 | (left-assoc "+" "-") | |
835 | ;; Shift. | |
836 | (left-assoc "<<" ">>") | |
837 | ;; And. | |
838 | (left-assoc "&") | |
839 | ;; Xor. | |
840 | (left-assoc "^") | |
841 | ;; Or. | |
842 | (left-assoc "|"))) | |
843 | ||
844 | (c-lang-defconst c-operator-list | |
845 | ;; The operators as a flat list (without duplicates). | |
0386b551 | 846 | t (c-filter-ops (c-lang-const c-operators) t t)) |
d9e94c22 MS |
847 | |
848 | (c-lang-defconst c-overloadable-operators | |
0386b551 AM |
849 | "List of the operators that are overloadable, in their \"identifier |
850 | form\". See also `c-op-identitier-prefix'." | |
d9e94c22 | 851 | t nil |
d9e94c22 MS |
852 | c++ '("new" "delete" ;; Can be followed by "[]" but we ignore that. |
853 | "+" "-" "*" "/" "%" | |
854 | "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl" | |
855 | "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^=" | |
856 | "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq" | |
857 | "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">=" | |
858 | "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->" | |
859 | "()" "[]" "<::>" "??(??)") | |
860 | ;; These work like identifiers in Pike. | |
861 | pike '("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~" | |
862 | "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+" | |
863 | "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%" | |
864 | "`+=")) | |
865 | ||
866 | (c-lang-defconst c-overloadable-operators-regexp | |
867 | ;; Regexp tested after an "operator" token in C++. | |
868 | t nil | |
869 | c++ (c-make-keywords-re nil (c-lang-const c-overloadable-operators))) | |
870 | (c-lang-defvar c-overloadable-operators-regexp | |
871 | (c-lang-const c-overloadable-operators-regexp)) | |
872 | ||
0386b551 AM |
873 | (c-lang-defconst c-opt-op-identitier-prefix |
874 | "Regexp matching the token before the ones in | |
875 | `c-overloadable-operators' when operators are specified in their | |
876 | \"identifier form\". This typically matches \"operator\" in C++ where | |
877 | operator functions are specified as e.g. \"operator +\". It's nil in | |
878 | languages without operator functions or where the complete operator | |
879 | identifier is listed in `c-overloadable-operators'. | |
880 | ||
881 | This regexp is assumed to not match any non-operator identifier." | |
882 | t nil | |
883 | c++ (c-make-keywords-re t '("operator"))) | |
884 | (c-lang-defvar c-opt-op-identitier-prefix | |
885 | (c-lang-const c-opt-op-identitier-prefix)) | |
886 | ||
d9e94c22 MS |
887 | (c-lang-defconst c-other-op-syntax-tokens |
888 | "List of the tokens made up of characters in the punctuation or | |
889 | parenthesis syntax classes that have uses other than as expression | |
890 | operators." | |
891 | t '("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//") | |
892 | (c c++ pike) (append '("#" "##" ; Used by cpp. | |
893 | "::" "...") | |
894 | (c-lang-const c-other-op-syntax-tokens)) | |
0386b551 AM |
895 | (c c++) (append '("*") (c-lang-const c-other-op-syntax-tokens)) |
896 | c++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:") | |
897 | (c-lang-const c-other-op-syntax-tokens)) | |
d9e94c22 MS |
898 | objc (append '("#" "##" ; Used by cpp. |
899 | "+" "-") (c-lang-const c-other-op-syntax-tokens)) | |
900 | idl (append '("#" "##") ; Used by cpp. | |
901 | (c-lang-const c-other-op-syntax-tokens)) | |
902 | pike (append '("..") | |
903 | (c-lang-const c-other-op-syntax-tokens) | |
904 | (c-lang-const c-overloadable-operators)) | |
905 | awk '("{" "}" "(" ")" "[" "]" ";" "," "=" "/")) | |
906 | ||
0386b551 AM |
907 | (c-lang-defconst c-all-op-syntax-tokens |
908 | ;; List of all tokens in the punctuation and parenthesis syntax | |
909 | ;; classes. | |
910 | t (delete-duplicates (append (c-lang-const c-other-op-syntax-tokens) | |
911 | (c-lang-const c-operator-list)) | |
912 | :test 'string-equal)) | |
913 | ||
914 | (c-lang-defconst c-nonsymbol-token-char-list | |
915 | ;; List containing all chars not in the word, symbol or | |
916 | ;; syntactically irrelevant syntax classes, i.e. all punctuation, | |
917 | ;; parenthesis and string delimiter chars. | |
918 | t (c-with-syntax-table (c-lang-const c-mode-syntax-table) | |
919 | ;; Only go through the chars in the printable ASCII range. No | |
920 | ;; language so far has 8-bit or widestring operators. | |
921 | (let (list (char 32)) | |
922 | (while (< char 127) | |
923 | (or (memq (char-syntax char) '(?w ?_ ?< ?> ?\ )) | |
924 | (setq list (cons (c-int-to-char char) list))) | |
925 | (setq char (1+ char))) | |
926 | list))) | |
927 | ||
d9e94c22 MS |
928 | (c-lang-defconst c-nonsymbol-token-regexp |
929 | ;; Regexp matching all tokens in the punctuation and parenthesis | |
930 | ;; syntax classes. Note that this also matches ".", which can start | |
931 | ;; a float. | |
932 | t (c-make-keywords-re nil | |
0386b551 AM |
933 | (c-filter-ops (c-lang-const c-all-op-syntax-tokens) |
934 | t | |
935 | "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'"))) | |
d9e94c22 MS |
936 | (c-lang-defvar c-nonsymbol-token-regexp |
937 | (c-lang-const c-nonsymbol-token-regexp)) | |
938 | ||
846f5040 MS |
939 | (c-lang-defconst c-assignment-op-regexp |
940 | ;; Regexp matching all assignment operators and only them. The | |
941 | ;; beginning of the first submatch is used to detect the end of the | |
942 | ;; token, along with the end of the whole match. | |
943 | t (if (c-lang-const c-assignment-operators) | |
944 | (concat | |
945 | ;; Need special case for "=" since it's a prefix of "==". | |
946 | "=\\([^=]\\|$\\)" | |
947 | "\\|" | |
948 | (c-make-keywords-re nil | |
949 | (set-difference (c-lang-const c-assignment-operators) | |
950 | '("=") | |
951 | :test 'string-equal))) | |
952 | "\\<\\>")) | |
953 | (c-lang-defvar c-assignment-op-regexp | |
954 | (c-lang-const c-assignment-op-regexp)) | |
955 | ||
0386b551 AM |
956 | (c-lang-defconst c-<>-multichar-token-regexp |
957 | ;; Regexp matching all tokens containing "<" or ">" which are longer | |
958 | ;; than one char. | |
959 | t (c-make-keywords-re nil | |
960 | (c-filter-ops (c-lang-const c-all-op-syntax-tokens) | |
961 | t | |
962 | ".[<>]\\|[<>]."))) | |
963 | (c-lang-defvar c-<>-multichar-token-regexp | |
964 | (c-lang-const c-<>-multichar-token-regexp)) | |
965 | ||
d9e94c22 MS |
966 | (c-lang-defconst c-<-op-cont-regexp |
967 | ;; Regexp matching the second and subsequent characters of all | |
968 | ;; multicharacter tokens that begin with "<". | |
969 | t (c-make-keywords-re nil | |
0386b551 AM |
970 | (c-filter-ops (c-lang-const c-all-op-syntax-tokens) |
971 | t | |
972 | "\\`<." | |
973 | (lambda (op) (substring op 1))))) | |
d9e94c22 MS |
974 | (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) |
975 | ||
976 | (c-lang-defconst c->-op-cont-regexp | |
977 | ;; Regexp matching the second and subsequent characters of all | |
978 | ;; multicharacter tokens that begin with ">". | |
979 | t (c-make-keywords-re nil | |
0386b551 AM |
980 | (c-filter-ops (c-lang-const c-all-op-syntax-tokens) |
981 | t | |
982 | "\\`>." | |
983 | (lambda (op) (substring op 1))))) | |
d9e94c22 MS |
984 | (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp)) |
985 | ||
986 | (c-lang-defconst c-stmt-delim-chars | |
987 | ;; The characters that should be considered to bound statements. To | |
988 | ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to | |
989 | ;; begin with "^" to negate the set. If ? : operators should be | |
990 | ;; detected then the string must end with "?:". | |
991 | t "^;{}?:" | |
0386b551 | 992 | awk "^;{}#\n\r?:") ; The newline chars gets special treatment. |
d9e94c22 MS |
993 | (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars)) |
994 | ||
995 | (c-lang-defconst c-stmt-delim-chars-with-comma | |
996 | ;; Variant of `c-stmt-delim-chars' that additionally contains ','. | |
997 | t "^;,{}?:" | |
998 | awk "^;,{}\n\r?:") ; The newline chars gets special treatment. | |
999 | (c-lang-defvar c-stmt-delim-chars-with-comma | |
1000 | (c-lang-const c-stmt-delim-chars-with-comma)) | |
1001 | ||
1002 | \f | |
1003 | ;;; Syntactic whitespace. | |
1004 | ||
0386b551 AM |
1005 | (c-lang-defconst c-simple-ws |
1006 | "Regexp matching an ordinary whitespace character. | |
1007 | Does not contain a \\| operator at the top level." | |
1008 | ;; "\\s " is not enough since it doesn't match line breaks. | |
1009 | t "\\(\\s \\|[\n\r]\\)") | |
1010 | ||
1011 | (c-lang-defconst c-simple-ws-depth | |
1012 | ;; Number of regexp grouping parens in `c-simple-ws'. | |
1013 | t (regexp-opt-depth (c-lang-const c-simple-ws))) | |
1014 | ||
1015 | (c-lang-defconst c-line-comment-starter | |
1016 | "String that starts line comments, or nil if such don't exist. | |
1017 | Line comments are always terminated by newlines. At least one of | |
1018 | `c-block-comment-starter' and this one is assumed to be set. | |
1019 | ||
1020 | Note that it's currently not enough to set this to support a new | |
1021 | comment style. Other stuff like the syntax table must also be set up | |
1022 | properly." | |
1023 | t "//" | |
1024 | awk "#") | |
1025 | (c-lang-defvar c-line-comment-starter (c-lang-const c-line-comment-starter)) | |
1026 | ||
1027 | (c-lang-defconst c-block-comment-starter | |
1028 | "String that starts block comments, or nil if such don't exist. | |
1029 | Block comments are ended by `c-block-comment-ender', which is assumed | |
1030 | to be set if this is. At least one of `c-line-comment-starter' and | |
1031 | this one is assumed to be set. | |
1032 | ||
1033 | Note that it's currently not enough to set this to support a new | |
1034 | comment style. Other stuff like the syntax table must also be set up | |
1035 | properly." | |
1036 | t "/*" | |
1037 | awk nil) | |
1038 | ||
1039 | (c-lang-defconst c-block-comment-ender | |
1040 | "String that ends block comments, or nil if such don't exist. | |
1041 | ||
1042 | Note that it's currently not enough to set this to support a new | |
1043 | comment style. Other stuff like the syntax table must also be set up | |
1044 | properly." | |
1045 | t "*/" | |
1046 | awk nil) | |
1047 | ||
d9e94c22 MS |
1048 | (c-lang-defconst c-comment-start-regexp |
1049 | ;; Regexp to match the start of any type of comment. | |
0386b551 AM |
1050 | t (let ((re (c-make-keywords-re nil |
1051 | (list (c-lang-const c-line-comment-starter) | |
1052 | (c-lang-const c-block-comment-starter))))) | |
1053 | (if (memq 'gen-comment-delim c-emacs-features) | |
1054 | (concat re "\\|\\s!") | |
1055 | re))) | |
d9e94c22 MS |
1056 | (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp)) |
1057 | ||
0386b551 AM |
1058 | ;;;; Added by ACM, 2003/9/18. |
1059 | (c-lang-defconst c-block-comment-start-regexp | |
1060 | ;; Regexp which matches the start of a block comment (if such exists in the | |
1061 | ;; language) | |
1062 | t (if (c-lang-const c-block-comment-starter) | |
1063 | (regexp-quote (c-lang-const c-block-comment-starter)) | |
1064 | "\\<\\>")) | |
1065 | (c-lang-defvar c-block-comment-start-regexp | |
1066 | (c-lang-const c-block-comment-start-regexp)) | |
1067 | ||
d9e94c22 MS |
1068 | (c-lang-defconst c-literal-start-regexp |
1069 | ;; Regexp to match the start of comments and string literals. | |
1070 | t (concat (c-lang-const c-comment-start-regexp) | |
1071 | "\\|" | |
1072 | (if (memq 'gen-string-delim c-emacs-features) | |
1073 | "\"|" | |
1074 | "\""))) | |
1075 | (c-lang-defvar c-literal-start-regexp (c-lang-const c-literal-start-regexp)) | |
1076 | ||
1077 | (c-lang-defconst c-doc-comment-start-regexp | |
1078 | "Regexp to match the start of documentation comments." | |
1079 | t "\\<\\>" | |
1080 | ;; From font-lock.el: `doxygen' uses /*! while others use /**. | |
1081 | (c c++ objc) "/\\*[*!]" | |
1082 | java "/\\*\\*" | |
1083 | pike "/[/*]!") | |
1084 | (c-lang-defvar c-doc-comment-start-regexp | |
1085 | (c-lang-const c-doc-comment-start-regexp)) | |
1086 | ||
1087 | (c-lang-defconst comment-start | |
1088 | "String that starts comments inserted with M-; etc. | |
1089 | `comment-start' is initialized from this." | |
0386b551 AM |
1090 | ;; Default: Prefer line comments to block comments, and pad with a space. |
1091 | t (concat (or (c-lang-const c-line-comment-starter) | |
1092 | (c-lang-const c-block-comment-starter)) | |
1093 | " ") | |
1094 | ;; In C we still default to the block comment style since line | |
1095 | ;; comments aren't entirely portable. | |
1096 | c "/* ") | |
d9e94c22 MS |
1097 | (c-lang-defvar comment-start (c-lang-const comment-start) |
1098 | 'dont-doc) | |
1099 | ||
1100 | (c-lang-defconst comment-end | |
1101 | "String that ends comments inserted with M-; etc. | |
1102 | `comment-end' is initialized from this." | |
0386b551 AM |
1103 | ;; Default: Use block comment style if comment-start uses block |
1104 | ;; comments, and pad with a space in that case. | |
1105 | t (if (string-match (concat "\\`\\(" | |
1106 | (c-lang-const c-block-comment-start-regexp) | |
1107 | "\\)") | |
1108 | (c-lang-const comment-start)) | |
1109 | (concat " " (c-lang-const c-block-comment-ender)) | |
1110 | "")) | |
d9e94c22 MS |
1111 | (c-lang-defvar comment-end (c-lang-const comment-end) |
1112 | 'dont-doc) | |
1113 | ||
1114 | (c-lang-defconst comment-start-skip | |
1115 | "Regexp to match the start of a comment plus everything up to its body. | |
1116 | `comment-start-skip' is initialized from this." | |
0386b551 AM |
1117 | ;; Default: Allow the last char of the comment starter(s) to be |
1118 | ;; repeated, then allow any amount of horizontal whitespace. | |
1119 | t (concat "\\(" | |
1120 | (c-concat-separated | |
1121 | (mapcar (lambda (cs) | |
1122 | (when cs | |
1123 | (concat (regexp-quote cs) "+"))) | |
1124 | (list (c-lang-const c-line-comment-starter) | |
1125 | (c-lang-const c-block-comment-starter))) | |
1126 | "\\|") | |
1127 | "\\)\\s *")) | |
d9e94c22 MS |
1128 | (c-lang-defvar comment-start-skip (c-lang-const comment-start-skip) |
1129 | 'dont-doc) | |
1130 | ||
f75ef66d | 1131 | (c-lang-defconst c-syntactic-ws-start |
0386b551 AM |
1132 | ;; Regexp matching any sequence that can start syntactic whitespace. |
1133 | ;; The only uncertain case is '#' when there are cpp directives. | |
1134 | t (concat "\\s \\|" | |
1135 | (c-make-keywords-re nil | |
1136 | (append (list (c-lang-const c-line-comment-starter) | |
1137 | (c-lang-const c-block-comment-starter) | |
1138 | (when (c-lang-const c-opt-cpp-prefix) | |
1139 | "#")) | |
1140 | '("\n" "\r"))) | |
1141 | "\\|\\\\[\n\r]" | |
1142 | (when (memq 'gen-comment-delim c-emacs-features) | |
1143 | "\\|\\s!"))) | |
1144 | (c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start)) | |
d9e94c22 | 1145 | |
f75ef66d | 1146 | (c-lang-defconst c-syntactic-ws-end |
0386b551 AM |
1147 | ;; Regexp matching any single character that might end syntactic whitespace. |
1148 | t (concat "\\s \\|" | |
1149 | (c-make-keywords-re nil | |
1150 | (append (when (c-lang-const c-block-comment-ender) | |
1151 | (list | |
1152 | (string | |
1153 | (elt (c-lang-const c-block-comment-ender) | |
1154 | (1- (length | |
1155 | (c-lang-const c-block-comment-ender))))))) | |
1156 | '("\n" "\r"))) | |
1157 | (when (memq 'gen-comment-delim c-emacs-features) | |
1158 | "\\|\\s!"))) | |
1159 | (c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end)) | |
1160 | ||
1161 | (c-lang-defconst c-unterminated-block-comment-regexp | |
1162 | ;; Regexp matching an unterminated block comment that doesn't | |
1163 | ;; contain line breaks, or nil in languages without block comments. | |
1164 | ;; Does not contain a \| operator at the top level. | |
1165 | t (when (c-lang-const c-block-comment-starter) | |
1166 | (concat | |
1167 | (regexp-quote (c-lang-const c-block-comment-starter)) | |
1168 | ;; It's messy to cook together a regexp that matches anything | |
1169 | ;; but c-block-comment-ender. | |
1170 | (let ((end (c-lang-const c-block-comment-ender))) | |
1171 | (cond ((= (length end) 1) | |
1172 | (concat "[^" end "\n\r]*")) | |
1173 | ((= (length end) 2) | |
1174 | (concat "[^" (substring end 0 1) "\n\r]*" | |
1175 | "\\(" | |
1176 | (regexp-quote (substring end 0 1)) "+" | |
1177 | "[^" | |
1178 | ;; The quoting rules inside char classes are silly. :P | |
1179 | (cond ((= (elt end 0) (elt end 1)) | |
1180 | (concat (substring end 0 1) "\n\r")) | |
1181 | ((= (elt end 1) ?\]) | |
1182 | (concat (substring end 1 2) "\n\r" | |
1183 | (substring end 0 1))) | |
1184 | (t | |
1185 | (concat (substring end 0 1) "\n\r" | |
1186 | (substring end 1 2)))) | |
1187 | "]" | |
1188 | "[^" (substring end 0 1) "\n\r]*" | |
1189 | "\\)*")) | |
1190 | (t | |
1191 | (error "Can't handle a block comment ender of length %s" | |
1192 | (length end)))))))) | |
1193 | ||
1194 | (c-lang-defconst c-block-comment-regexp | |
1195 | ;; Regexp matching a block comment that doesn't contain line breaks, | |
1196 | ;; or nil in languages without block comments. The reason we don't | |
1197 | ;; allow line breaks is to avoid going very far and risk running out | |
1198 | ;; of regexp stack; this regexp is intended to handle only short | |
1199 | ;; comments that might be put in the middle of limited constructs | |
1200 | ;; like declarations. Does not contain a \| operator at the top | |
1201 | ;; level. | |
1202 | t (when (c-lang-const c-unterminated-block-comment-regexp) | |
1203 | (concat | |
1204 | (c-lang-const c-unterminated-block-comment-regexp) | |
1205 | (let ((end (c-lang-const c-block-comment-ender))) | |
1206 | (cond ((= (length end) 1) | |
1207 | (regexp-quote end)) | |
1208 | ((= (length end) 2) | |
1209 | (concat (regexp-quote (substring end 0 1)) "+" | |
1210 | (regexp-quote (substring end 1 2)))) | |
1211 | (t | |
1212 | (error "Can't handle a block comment ender of length %s" | |
1213 | (length end)))))))) | |
d9e94c22 MS |
1214 | |
1215 | (c-lang-defconst c-nonwhite-syntactic-ws | |
1216 | ;; Regexp matching a piece of syntactic whitespace that isn't a | |
1217 | ;; sequence of simple whitespace characters. As opposed to | |
1218 | ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp | |
1219 | ;; directives as syntactic whitespace. | |
0386b551 AM |
1220 | t (c-concat-separated |
1221 | (list (when (c-lang-const c-line-comment-starter) | |
1222 | (concat (regexp-quote (c-lang-const c-line-comment-starter)) | |
1223 | "[^\n\r]*[\n\r]")) | |
1224 | (c-lang-const c-block-comment-regexp) | |
1225 | "\\\\[\n\r]" | |
1226 | (when (memq 'gen-comment-delim c-emacs-features) | |
1227 | "\\s!\\S!*\\s!")) | |
1228 | "\\|")) | |
d9e94c22 MS |
1229 | |
1230 | (c-lang-defconst c-syntactic-ws | |
1231 | ;; Regexp matching syntactic whitespace, including possibly the | |
1232 | ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws', | |
1233 | ;; this doesn't regard cpp directives as syntactic whitespace. Does | |
1234 | ;; not contain a \| operator at the top level. | |
0386b551 AM |
1235 | t (concat (c-lang-const c-simple-ws) "*" |
1236 | "\\(" | |
1237 | (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws) "\\)" | |
1238 | (c-lang-const c-simple-ws) "*") | |
1239 | "\\)*")) | |
d9e94c22 MS |
1240 | |
1241 | (c-lang-defconst c-syntactic-ws-depth | |
1242 | ;; Number of regexp grouping parens in `c-syntactic-ws'. | |
0386b551 | 1243 | t (regexp-opt-depth (c-lang-const c-syntactic-ws))) |
d9e94c22 MS |
1244 | |
1245 | (c-lang-defconst c-nonempty-syntactic-ws | |
1246 | ;; Regexp matching syntactic whitespace, which is at least one | |
1247 | ;; character long. As opposed to `c-(forward|backward)-syntactic-ws', | |
1248 | ;; this doesn't regard cpp directives as syntactic whitespace. Does | |
1249 | ;; not contain a \| operator at the top level. | |
0386b551 AM |
1250 | t (concat "\\(" |
1251 | (c-lang-const c-simple-ws) | |
1252 | "\\|" | |
d9e94c22 MS |
1253 | (c-lang-const c-nonwhite-syntactic-ws) |
1254 | "\\)+")) | |
1255 | ||
1256 | (c-lang-defconst c-nonempty-syntactic-ws-depth | |
1257 | ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'. | |
0386b551 | 1258 | t (regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws))) |
d9e94c22 MS |
1259 | |
1260 | (c-lang-defconst c-single-line-syntactic-ws | |
1261 | ;; Regexp matching syntactic whitespace without any line breaks. As | |
1262 | ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't | |
1263 | ;; regard cpp directives as syntactic whitespace. Does not contain | |
1264 | ;; a \| operator at the top level. | |
0386b551 AM |
1265 | t (if (c-lang-const c-block-comment-regexp) |
1266 | (concat "\\s *\\(" | |
1267 | (c-lang-const c-block-comment-regexp) | |
1268 | "\\s *\\)*") | |
1269 | "\\s *")) | |
d9e94c22 MS |
1270 | |
1271 | (c-lang-defconst c-single-line-syntactic-ws-depth | |
1272 | ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'. | |
0386b551 | 1273 | t (regexp-opt-depth (c-lang-const c-single-line-syntactic-ws))) |
d9e94c22 | 1274 | |
0386b551 | 1275 | (c-lang-defconst c-syntactic-eol |
d9e94c22 MS |
1276 | ;; Regexp that matches when there is no syntactically significant |
1277 | ;; text before eol. Macros are regarded as syntactically | |
1278 | ;; significant text here. | |
0386b551 AM |
1279 | t (concat (c-lang-const c-single-line-syntactic-ws) |
1280 | ;; Match eol (possibly inside a block comment or preceded | |
1281 | ;; by a line continuation backslash), or the beginning of a | |
1282 | ;; line comment. Note: This has to be modified for awk | |
1283 | ;; where line comments start with '#'. | |
1284 | "\\(" | |
1285 | (c-concat-separated | |
1286 | (list (when (c-lang-const c-line-comment-starter) | |
1287 | (regexp-quote (c-lang-const c-line-comment-starter))) | |
1288 | (when (c-lang-const c-unterminated-block-comment-regexp) | |
1289 | (concat (c-lang-const c-unterminated-block-comment-regexp) | |
1290 | "$")) | |
1291 | "\\\\$" | |
d9e94c22 | 1292 | "$") |
0386b551 AM |
1293 | "\\|") |
1294 | "\\)")) | |
1295 | (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) | |
1296 | ||
1297 | \f | |
1298 | ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK). | |
1299 | (c-lang-defconst c-at-vsemi-p-fn | |
1300 | "Contains a function \"Is there a virtual semicolon at POS or point?\". | |
1301 | Such a function takes one optional parameter, a buffer position (defaults to | |
1302 | point), and returns NIL or t. This variable contains NIL for languages which | |
1303 | don't have EOL terminated statements. " | |
1304 | t nil | |
1305 | awk 'c-awk-at-vsemi-p) | |
1306 | (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn)) | |
1307 | ||
1308 | (c-lang-defconst c-vsemi-status-unknown-p-fn | |
1309 | "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\". | |
1310 | The (admittedly kludgey) purpose of such a function is to prevent an infinite | |
1311 | recursion in c-beginning-of-statement-1 when point starts at a `while' token. | |
1312 | The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1, | |
1313 | even indirectly. This variable contains NIL for languages which don't have | |
1314 | EOL terminated statements." | |
1315 | t nil | |
1316 | awk 'c-awk-vsemi-status-unknown-p) | |
1317 | (c-lang-defvar c-vsemi-status-unknown-p-fn | |
1318 | (c-lang-const c-vsemi-status-unknown-p-fn)) | |
d9e94c22 MS |
1319 | |
1320 | \f | |
1321 | ;;; In-comment text handling. | |
1322 | ||
1323 | (c-lang-defconst c-paragraph-start | |
1324 | "Regexp to append to `paragraph-start'." | |
1325 | t "$" | |
1326 | java "\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc. | |
1327 | pike "\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc. | |
1328 | (c-lang-defvar c-paragraph-start (c-lang-const c-paragraph-start)) | |
1329 | ||
1330 | (c-lang-defconst c-paragraph-separate | |
1331 | "Regexp to append to `paragraph-separate'." | |
1332 | t "$" | |
1333 | pike (c-lang-const c-paragraph-start)) | |
1334 | (c-lang-defvar c-paragraph-separate (c-lang-const c-paragraph-separate)) | |
1335 | ||
1336 | \f | |
1337 | ;;; Keyword lists. | |
1338 | ||
1339 | ;; Note: All and only all language constants containing keyword lists | |
1340 | ;; should end with "-kwds"; they're automatically collected into the | |
1341 | ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc. | |
1342 | ||
a66cd3ee | 1343 | (c-lang-defconst c-primitive-type-kwds |
d9e94c22 MS |
1344 | "Primitive type keywords. As opposed to the other keyword lists, the |
1345 | keywords listed here are fontified with the type face instead of the | |
1346 | keyword face. | |
1347 | ||
1348 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1349 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1350 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1351 | will be handled. | |
1352 | ||
1353 | Do not try to modify this list for end user customizations; the | |
1354 | `*-font-lock-extra-types' variable, where `*' is the mode prefix, is | |
1355 | the appropriate place for that." | |
1356 | t '("char" "double" "float" "int" "long" "short" "signed" | |
1357 | "unsigned" "void") | |
1358 | c (append | |
1359 | '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99. | |
1360 | (c-lang-const c-primitive-type-kwds)) | |
1361 | c++ (append | |
1362 | '("bool" "wchar_t") | |
1363 | (c-lang-const c-primitive-type-kwds)) | |
1364 | ;; Objective-C extends C, but probably not the new stuff in C99. | |
1365 | objc (append | |
1366 | '("id" "Class" "SEL" "IMP" "BOOL") | |
1367 | (c-lang-const c-primitive-type-kwds)) | |
a66cd3ee | 1368 | java '("boolean" "byte" "char" "double" "float" "int" "long" "short" "void") |
d9e94c22 MS |
1369 | idl '("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float" |
1370 | "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring" | |
1371 | ;; In CORBA PSDL: | |
1372 | "ref" | |
1373 | ;; The following can't really end a type, but we have to specify them | |
1374 | ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It | |
1375 | ;; doesn't matter that much. | |
1376 | "unsigned" "strong") | |
1377 | pike '(;; this_program isn't really a keyword, but it's practically | |
1378 | ;; used as a builtin type. | |
1379 | "array" "float" "function" "int" "mapping" "mixed" "multiset" | |
1380 | "object" "program" "string" "this_program" "void")) | |
1381 | ||
1382 | (c-lang-defconst c-primitive-type-key | |
1383 | ;; An adorned regexp that matches `c-primitive-type-kwds'. | |
1384 | t (c-make-keywords-re t (c-lang-const c-primitive-type-kwds))) | |
1385 | (c-lang-defvar c-primitive-type-key (c-lang-const c-primitive-type-key)) | |
1386 | ||
1387 | (c-lang-defconst c-primitive-type-prefix-kwds | |
1388 | "Keywords that might act as prefixes for primitive types. Assumed to | |
1389 | be a subset of `c-primitive-type-kwds'." | |
1390 | t nil | |
1391 | (c c++) '("long" "short" "signed" "unsigned") | |
1392 | idl '("long" "unsigned" | |
1393 | ;; In CORBA PSDL: | |
1394 | "strong")) | |
1395 | ||
1396 | (c-lang-defconst c-type-prefix-kwds | |
1397 | "Keywords where the following name - if any - is a type name, and | |
1398 | where the keyword together with the symbol works as a type in | |
1399 | declarations. | |
1400 | ||
1401 | Note that an alternative if the second part doesn't hold is | |
1402 | `c-type-list-kwds'. Keywords on this list are typically also present | |
1403 | on one of the `*-decl-kwds' lists." | |
1404 | t nil | |
1405 | c '("struct" "union" "enum") | |
1406 | c++ (append '("class" "typename") | |
1407 | (c-lang-const c-type-prefix-kwds c))) | |
1408 | ||
1409 | (c-lang-defconst c-type-prefix-key | |
1410 | ;; Adorned regexp matching `c-type-prefix-kwds'. | |
1411 | t (c-make-keywords-re t (c-lang-const c-type-prefix-kwds))) | |
1412 | (c-lang-defvar c-type-prefix-key (c-lang-const c-type-prefix-key)) | |
1413 | ||
1414 | (c-lang-defconst c-type-modifier-kwds | |
1415 | "Type modifier keywords. These can occur almost anywhere in types | |
1416 | but they don't build a type of themselves. Unlike the keywords on | |
1417 | `c-primitive-type-kwds', they are fontified with the keyword face and | |
1418 | not the type face." | |
1419 | t nil | |
1420 | c '("const" "restrict" "volatile") | |
1421 | c++ '("const" "volatile" "throw") | |
1422 | objc '("const" "volatile")) | |
1423 | ||
1424 | (c-lang-defconst c-opt-type-modifier-key | |
1425 | ;; Adorned regexp matching `c-type-modifier-kwds', or nil in | |
1426 | ;; languages without such keywords. | |
1427 | t (and (c-lang-const c-type-modifier-kwds) | |
1428 | (c-make-keywords-re t (c-lang-const c-type-modifier-kwds)))) | |
1429 | (c-lang-defvar c-opt-type-modifier-key (c-lang-const c-opt-type-modifier-key)) | |
1430 | ||
1431 | (c-lang-defconst c-opt-type-component-key | |
1432 | ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and | |
1433 | ;; `c-type-modifier-kwds', or nil in languages without any of them. | |
1434 | t (and (or (c-lang-const c-primitive-type-prefix-kwds) | |
1435 | (c-lang-const c-type-modifier-kwds)) | |
1436 | (c-make-keywords-re t | |
1437 | (append (c-lang-const c-primitive-type-prefix-kwds) | |
1438 | (c-lang-const c-type-modifier-kwds))))) | |
1439 | (c-lang-defvar c-opt-type-component-key | |
1440 | (c-lang-const c-opt-type-component-key)) | |
1441 | ||
0386b551 AM |
1442 | (c-lang-defconst c-type-start-kwds |
1443 | ;; All keywords that can start a type (i.e. are either a type prefix | |
1444 | ;; or a complete type). | |
1445 | t (delete-duplicates (append (c-lang-const c-primitive-type-kwds) | |
1446 | (c-lang-const c-type-prefix-kwds) | |
1447 | (c-lang-const c-type-modifier-kwds)) | |
1448 | :test 'string-equal)) | |
1449 | ||
d9e94c22 MS |
1450 | (c-lang-defconst c-class-decl-kwds |
1451 | "Keywords introducing declarations where the following block (if any) | |
1452 | contains another declaration level that should be considered a class. | |
1453 | ||
1454 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1455 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1456 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1457 | will be handled. | |
1458 | ||
1459 | Note that presence on this list does not automatically treat the | |
1460 | following identifier as a type; the keyword must also be present on | |
1461 | `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that." | |
1462 | t nil | |
1463 | c '("struct" "union") | |
1464 | c++ '("class" "struct" "union") | |
1465 | objc '("struct" "union" | |
1466 | "@interface" "@implementation" "@protocol") | |
a66cd3ee | 1467 | java '("class" "interface") |
d9e94c22 MS |
1468 | idl '("component" "eventtype" "exception" "home" "interface" "struct" |
1469 | "union" "valuetype" | |
1470 | ;; In CORBA PSDL: | |
1471 | "storagehome" "storagetype" | |
1472 | ;; In CORBA CIDL: | |
1473 | "catalog" "executor" "manages" "segment") | |
a66cd3ee MS |
1474 | pike '("class")) |
1475 | ||
a66cd3ee | 1476 | (c-lang-defconst c-class-key |
d9e94c22 MS |
1477 | ;; Regexp matching the start of a class. |
1478 | t (c-make-keywords-re t (c-lang-const c-class-decl-kwds))) | |
1479 | (c-lang-defvar c-class-key (c-lang-const c-class-key)) | |
1480 | ||
1481 | (c-lang-defconst c-brace-list-decl-kwds | |
1482 | "Keywords introducing declarations where the following block (if | |
1483 | any) is a brace list. | |
1484 | ||
1485 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1486 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1487 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1488 | will be handled." | |
1489 | t '("enum") | |
1490 | (java awk) nil) | |
1491 | ||
1492 | (c-lang-defconst c-brace-list-key | |
1493 | ;; Regexp matching the start of declarations where the following | |
1494 | ;; block is a brace list. | |
1495 | t (c-make-keywords-re t (c-lang-const c-brace-list-decl-kwds))) | |
1496 | (c-lang-defvar c-brace-list-key (c-lang-const c-brace-list-key)) | |
1497 | ||
1498 | (c-lang-defconst c-other-block-decl-kwds | |
3efc2cd7 | 1499 | "Keywords where the following block (if any) contains another |
0386b551 AM |
1500 | declaration level that should not be considered a class. For every |
1501 | keyword here, CC Mode will add a set of special syntactic symbols for | |
1502 | those blocks. E.g. if the keyword is \"foo\" then there will be | |
1503 | `foo-open', `foo-close', and `infoo' symbols. | |
1504 | ||
1505 | The intention is that this category should be used for block | |
1506 | constructs that aren't related to object orientation concepts like | |
1507 | classes (which thus also include e.g. interfaces, templates, | |
1508 | contracts, structs, etc). The more pragmatic distinction is that | |
1509 | while most want some indentation inside classes, it's fairly common | |
1510 | that they don't want it in some of these constructs, so it should be | |
1511 | simple to configure that differently from classes. See also | |
1512 | `c-class-decl-kwds'. | |
d9e94c22 MS |
1513 | |
1514 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1515 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1516 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1517 | will be handled." | |
1518 | t nil | |
0386b551 | 1519 | (c objc) '("extern") |
a66cd3ee | 1520 | c++ '("namespace" "extern") |
d9e94c22 MS |
1521 | idl '("module" |
1522 | ;; In CORBA CIDL: | |
1523 | "composition")) | |
a66cd3ee | 1524 | |
a66cd3ee | 1525 | (c-lang-defconst c-other-decl-block-key |
d9e94c22 MS |
1526 | ;; Regexp matching the start of blocks besides classes that contain |
1527 | ;; another declaration level. | |
1528 | t (c-make-keywords-re t (c-lang-const c-other-block-decl-kwds))) | |
1529 | (c-lang-defvar c-other-decl-block-key (c-lang-const c-other-decl-block-key)) | |
1530 | ||
1531 | (c-lang-defconst c-typedef-decl-kwds | |
0386b551 AM |
1532 | "Keywords introducing declarations where the identifier(s) being |
1533 | declared are types. | |
d9e94c22 MS |
1534 | |
1535 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1536 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1537 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1538 | will be handled." | |
0386b551 AM |
1539 | ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds' |
1540 | ;; (since e.g. "Foo" is a type that's being defined in "class Foo | |
1541 | ;; {...}"). | |
1542 | t (append (c-lang-const c-class-decl-kwds) | |
1543 | (c-lang-const c-brace-list-decl-kwds)) | |
1544 | ;; Languages that have a "typedef" construct. | |
1545 | (c c++ objc idl pike) (append (c-lang-const c-typedef-decl-kwds) | |
1546 | '("typedef")) | |
1547 | ;; Unlike most other languages, exception names are not handled as | |
1548 | ;; types in IDL since they only can occur in "raises" specs. | |
1549 | idl (delete "exception" (append (c-lang-const c-typedef-decl-kwds) nil))) | |
d9e94c22 MS |
1550 | |
1551 | (c-lang-defconst c-typeless-decl-kwds | |
0386b551 AM |
1552 | "Keywords introducing declarations where the \(first) identifier |
1553 | \(declarator) follows directly after the keyword, without any type. | |
d9e94c22 MS |
1554 | |
1555 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1556 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1557 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1558 | will be handled." | |
0386b551 AM |
1559 | ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds' |
1560 | ;; (since e.g. "Foo" is the identifier being defined in "class Foo | |
1561 | ;; {...}"). | |
1562 | t (append (c-lang-const c-class-decl-kwds) | |
1563 | (c-lang-const c-brace-list-decl-kwds)) | |
1564 | ;; Note: "manages" for CORBA CIDL clashes with its presence on | |
1565 | ;; `c-type-list-kwds' for IDL. | |
1566 | idl (append (c-lang-const c-typeless-decl-kwds) | |
1567 | '("factory" "finder" "native" | |
1568 | ;; In CORBA PSDL: | |
1569 | "key" "stores" | |
1570 | ;; In CORBA CIDL: | |
1571 | "facet")) | |
1572 | pike (append (c-lang-const c-class-decl-kwds) | |
1573 | '("constant"))) | |
d9e94c22 MS |
1574 | |
1575 | (c-lang-defconst c-modifier-kwds | |
1576 | "Keywords that can prefix normal declarations of identifiers | |
0386b551 | 1577 | \(and typically act as flags). Things like argument declarations |
d9e94c22 MS |
1578 | inside function headers are also considered declarations in this |
1579 | sense. | |
1580 | ||
1581 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1582 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1583 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1584 | will be handled." | |
1585 | t nil | |
1586 | (c c++) '("auto" "extern" "inline" "register" "static") | |
1587 | c++ (append '("explicit" "friend" "mutable" "template" "using" "virtual") | |
1588 | (c-lang-const c-modifier-kwds)) | |
1589 | objc '("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static") | |
1590 | ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead. | |
1591 | idl '("abstract" "attribute" "const" "consumes" "custom" "emits" "import" | |
1592 | "in" "inout" "local" "multiple" "oneway" "out" "private" "provides" | |
1593 | "public" "publishes" "readonly" "typeid" "typeprefix" "uses" | |
1594 | ;; In CORBA PSDL: | |
1595 | "primary" "state" | |
1596 | ;; In CORBA CIDL: | |
1597 | "bindsTo" "delegatesTo" "implements" "proxy" "storedOn") | |
1598 | ;; Note: "const" is not used in Java, but it's still a reserved keyword. | |
1599 | java '("abstract" "const" "final" "native" "private" "protected" "public" | |
1600 | "static" "strictfp" "synchronized" "transient" "volatile") | |
1601 | pike '("final" "inline" "local" "nomask" "optional" "private" "protected" | |
1602 | "public" "static" "variant")) | |
a66cd3ee | 1603 | |
d9e94c22 MS |
1604 | (c-lang-defconst c-other-decl-kwds |
1605 | "Keywords that can start or prefix any declaration level construct, | |
1606 | besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds', | |
1607 | `c-other-block-decl-kwds', `c-typedef-decl-kwds', | |
0386b551 | 1608 | `c-typeless-decl-kwds' and `c-modifier-kwds'. |
d9e94c22 MS |
1609 | |
1610 | If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', | |
1611 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1612 | `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses | |
1613 | will be handled." | |
1614 | t nil | |
d9e94c22 MS |
1615 | objc '("@class" "@end" "@defs") |
1616 | java '("import" "package") | |
1617 | pike '("import" "inherit")) | |
1618 | ||
0386b551 AM |
1619 | (c-lang-defconst c-decl-start-kwds |
1620 | "Keywords that always start declarations, wherever they occur. | |
1621 | This can be used for declarations that aren't recognized by the normal | |
1622 | combination of `c-decl-prefix-re' and `c-decl-start-re'." | |
1623 | t nil | |
1624 | ;; Classes can be declared anywhere in a Pike expression. | |
1625 | pike '("class")) | |
1626 | ||
1627 | (c-lang-defconst c-decl-hangon-kwds | |
1628 | "Keywords that can occur anywhere in a declaration level construct. | |
1629 | This is used for self-contained things that can be tacked on anywhere | |
1630 | on a declaration and that should be ignored to be able to recognize it | |
1631 | correctly. Typical cases are compiler extensions like | |
1632 | \"__attribute__\" or \"__declspec\": | |
1633 | ||
1634 | __declspec(noreturn) void foo(); | |
1635 | class __declspec(dllexport) classname {...}; | |
1636 | void foo() __attribute__((noreturn)); | |
1637 | ||
1638 | Note that unrecognized plain symbols are skipped anyway if they occur | |
1639 | before the type, so such things are not necessary to mention here. | |
1640 | Mentioning them here is necessary only if they can occur in other | |
1641 | places, or if they are followed by a construct that must be skipped | |
1642 | over \(like the parens in the \"__attribute__\" and \"__declspec\" | |
1643 | examples above). In the last case, they alse need to be present on | |
1644 | one of `c-type-list-kwds', `c-ref-list-kwds', | |
1645 | `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds', | |
1646 | `c-<>-type-kwds', or `c-<>-arglist-kwds'." | |
1647 | ;; NB: These are currently not recognized in all parts of a | |
1648 | ;; declaration. Specifically, they aren't recognized in the middle | |
1649 | ;; of multi-token types, inside declarators, and between the | |
1650 | ;; identifier and the arglist paren of a function declaration. | |
1651 | ;; | |
1652 | ;; FIXME: This ought to be user customizable since compiler stuff | |
1653 | ;; like this usually is wrapped in project specific macros. (It'd | |
1654 | ;; of course be even better if we could cope without knowing this.) | |
1655 | t nil | |
1656 | (c c++) '(;; GCC extension. | |
1657 | "__attribute__" | |
1658 | ;; MSVC extension. | |
1659 | "__declspec")) | |
1660 | ||
1661 | (c-lang-defconst c-decl-hangon-key | |
1662 | ;; Adorned regexp matching `c-decl-hangon-kwds'. | |
1663 | t (c-make-keywords-re t (c-lang-const c-decl-hangon-kwds))) | |
1664 | (c-lang-defvar c-decl-hangon-key (c-lang-const c-decl-hangon-key)) | |
1665 | ||
1666 | (c-lang-defconst c-prefix-spec-kwds | |
1667 | ;; All keywords that can occur in the preamble of a declaration. | |
1668 | ;; They typically occur before the type, but they are also matched | |
1669 | ;; after presumptive types since we often can't be sure that | |
1670 | ;; something is a type or just some sort of macro in front of the | |
1671 | ;; declaration. They might be ambiguous with types or type | |
1672 | ;; prefixes. | |
1673 | t (delete-duplicates (append (c-lang-const c-class-decl-kwds) | |
1674 | (c-lang-const c-brace-list-decl-kwds) | |
1675 | (c-lang-const c-other-block-decl-kwds) | |
1676 | (c-lang-const c-typedef-decl-kwds) | |
1677 | (c-lang-const c-typeless-decl-kwds) | |
1678 | (c-lang-const c-modifier-kwds) | |
1679 | (c-lang-const c-other-decl-kwds) | |
1680 | (c-lang-const c-decl-start-kwds) | |
1681 | (c-lang-const c-decl-hangon-kwds)) | |
1682 | :test 'string-equal)) | |
1683 | ||
1684 | (c-lang-defconst c-prefix-spec-kwds-re | |
1685 | ;; Adorned regexp of `c-prefix-spec-kwds'. | |
1686 | t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))) | |
1687 | (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re)) | |
1688 | ||
d9e94c22 | 1689 | (c-lang-defconst c-specifier-key |
0386b551 AM |
1690 | ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that |
1691 | ;; aren't ambiguous with types or type prefixes. | |
d9e94c22 | 1692 | t (c-make-keywords-re t |
0386b551 AM |
1693 | (set-difference (c-lang-const c-prefix-spec-kwds) |
1694 | (c-lang-const c-type-start-kwds) | |
d9e94c22 MS |
1695 | :test 'string-equal))) |
1696 | (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key)) | |
a66cd3ee | 1697 | |
0386b551 AM |
1698 | (c-lang-defconst c-postfix-spec-kwds |
1699 | ;; Keywords that can occur after argument list of a function header | |
1700 | ;; declaration, i.e. in the "K&R region". | |
1701 | t (append (c-lang-const c-postfix-decl-spec-kwds) | |
1702 | (c-lang-const c-decl-hangon-kwds))) | |
1703 | ||
1704 | (c-lang-defconst c-not-decl-init-keywords | |
1705 | ;; Adorned regexp matching all keywords that can't appear at the | |
1706 | ;; start of a declaration. | |
1707 | t (c-make-keywords-re t | |
1708 | (set-difference (c-lang-const c-keywords) | |
1709 | (append (c-lang-const c-type-start-kwds) | |
1710 | (c-lang-const c-prefix-spec-kwds)) | |
1711 | :test 'string-equal))) | |
1712 | (c-lang-defvar c-not-decl-init-keywords | |
1713 | (c-lang-const c-not-decl-init-keywords)) | |
1714 | ||
d9e94c22 | 1715 | (c-lang-defconst c-protection-kwds |
0386b551 | 1716 | "Access protection label keywords in classes." |
d9e94c22 MS |
1717 | t nil |
1718 | c++ '("private" "protected" "public") | |
1719 | objc '("@private" "@protected" "@public")) | |
a66cd3ee | 1720 | |
d9e94c22 MS |
1721 | (c-lang-defconst c-block-decls-with-vars |
1722 | "Keywords introducing declarations that can contain a block which | |
1723 | might be followed by variable declarations, e.g. like \"foo\" in | |
1724 | \"class Foo { ... } foo;\". So if there is a block in a declaration | |
1725 | like that, it ends with the following ';' and not right away. | |
130c507e | 1726 | |
d9e94c22 MS |
1727 | The keywords on list are assumed to also be present on one of the |
1728 | `*-decl-kwds' lists." | |
1729 | t nil | |
1730 | (c objc) '("struct" "union" "enum" "typedef") | |
1731 | c++ '("class" "struct" "union" "enum" "typedef")) | |
1732 | ||
1733 | (c-lang-defconst c-opt-block-decls-with-vars-key | |
1734 | ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in | |
1735 | ;; languages without such constructs. | |
1736 | t (and (c-lang-const c-block-decls-with-vars) | |
1737 | (c-make-keywords-re t (c-lang-const c-block-decls-with-vars)))) | |
1738 | (c-lang-defvar c-opt-block-decls-with-vars-key | |
1739 | (c-lang-const c-opt-block-decls-with-vars-key)) | |
1740 | ||
1741 | (c-lang-defconst c-postfix-decl-spec-kwds | |
1742 | "Keywords introducing extra declaration specifiers in the region | |
1743 | between the header and the body \(i.e. the \"K&R-region\") in | |
1744 | declarations." | |
1745 | t nil | |
d9e94c22 MS |
1746 | java '("extends" "implements" "throws") |
1747 | idl '("context" "getraises" "manages" "primarykey" "raises" "setraises" | |
1748 | "supports" | |
1749 | ;; In CORBA PSDL: | |
1750 | "as" "const" "implements" "of" "ref")) | |
1751 | ||
1752 | (c-lang-defconst c-nonsymbol-sexp-kwds | |
1753 | "Keywords that may be followed by a nonsymbol sexp before whatever | |
1754 | construct it's part of continues." | |
1755 | t nil | |
1756 | (c c++ objc) '("extern")) | |
1757 | ||
1758 | (c-lang-defconst c-type-list-kwds | |
1759 | "Keywords that may be followed by a comma separated list of type | |
1760 | identifiers, where each optionally can be prefixed by keywords. (Can | |
1761 | also be used for the special case when the list can contain only one | |
1762 | element.) | |
1763 | ||
1764 | Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no | |
1765 | reason to put keywords on this list if they are on `c-type-prefix-kwds'. | |
1766 | There's also no reason to add keywords that prefixes a normal | |
1767 | declaration consisting of a type followed by a declarator (list), so | |
1768 | the keywords on `c-modifier-kwds' should normally not be listed here | |
0386b551 | 1769 | either. |
d9e94c22 MS |
1770 | |
1771 | Note: Use `c-typeless-decl-kwds' for keywords followed by a function | |
1772 | or variable identifier (that's being defined)." | |
0386b551 | 1773 | t nil |
fa14078b | 1774 | c++ '("operator") |
0386b551 AM |
1775 | objc '("@class") |
1776 | java '("import" "new" "extends" "implements" "throws") | |
1777 | idl '("manages" "native" "primarykey" "supports" | |
1778 | ;; In CORBA PSDL: | |
1779 | "as" "implements" "of" "scope") | |
1780 | pike '("inherit")) | |
d9e94c22 MS |
1781 | |
1782 | (c-lang-defconst c-ref-list-kwds | |
1783 | "Keywords that may be followed by a comma separated list of | |
1784 | reference (i.e. namespace/scope/module) identifiers, where each | |
1785 | optionally can be prefixed by keywords. (Can also be used for the | |
1786 | special case when the list can contain only one element.) Assumed to | |
1787 | be mutually exclusive with `c-type-list-kwds'. | |
1788 | ||
1789 | Note: Use `c-typeless-decl-kwds' for keywords followed by a function | |
1790 | or variable identifier (that's being defined)." | |
1791 | t nil | |
1792 | c++ '("namespace") | |
1793 | java '("package") | |
1794 | idl '("import" "module" | |
1795 | ;; In CORBA CIDL: | |
1796 | "composition") | |
1797 | pike '("import")) | |
1798 | ||
1799 | (c-lang-defconst c-colon-type-list-kwds | |
1800 | "Keywords that may be followed (not necessarily directly) by a colon | |
1801 | and then a comma separated list of type identifiers, where each | |
1802 | optionally can be prefixed by keywords. (Can also be used for the | |
1803 | special case when the list can contain only one element.)" | |
1804 | t nil | |
1805 | c++ '("class" "struct") | |
1806 | idl '("component" "eventtype" "home" "interface" "valuetype" | |
1807 | ;; In CORBA PSDL: | |
1808 | "storagehome" "storagetype")) | |
1809 | ||
1810 | (c-lang-defconst c-colon-type-list-re | |
1811 | "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip | |
1812 | forward to the colon. The end of the match is assumed to be directly | |
0386b551 AM |
1813 | after the colon, so the regexp should end with \":\". Must be a |
1814 | regexp if `c-colon-type-list-kwds' isn't nil." | |
d9e94c22 MS |
1815 | t (if (c-lang-const c-colon-type-list-kwds) |
1816 | ;; Disallow various common punctuation chars that can't come | |
1817 | ;; before the ":" that starts the inherit list after "class" | |
1818 | ;; or "struct" in C++. (Also used as default for other | |
1819 | ;; languages.) | |
1820 | "[^\]\[{}();,/#=:]*:")) | |
1821 | (c-lang-defvar c-colon-type-list-re (c-lang-const c-colon-type-list-re)) | |
1822 | ||
1823 | (c-lang-defconst c-paren-nontype-kwds | |
1824 | "Keywords that may be followed by a parenthesis expression that doesn't | |
1825 | contain type identifiers." | |
1826 | t nil | |
0386b551 AM |
1827 | (c c++) '(;; GCC extension. |
1828 | "__attribute__" | |
1829 | ;; MSVC extension. | |
1830 | "__declspec")) | |
d9e94c22 MS |
1831 | |
1832 | (c-lang-defconst c-paren-type-kwds | |
1833 | "Keywords that may be followed by a parenthesis expression containing | |
1834 | type identifiers separated by arbitrary tokens." | |
1835 | t nil | |
1836 | c++ '("throw") | |
1837 | objc '("@defs") | |
1838 | idl '("switch") | |
1839 | pike '("array" "function" "int" "mapping" "multiset" "object" "program")) | |
1840 | ||
1841 | (c-lang-defconst c-paren-any-kwds | |
1842 | t (delete-duplicates (append (c-lang-const c-paren-nontype-kwds) | |
1843 | (c-lang-const c-paren-type-kwds)) | |
1844 | :test 'string-equal)) | |
1845 | ||
1846 | (c-lang-defconst c-<>-type-kwds | |
1847 | "Keywords that may be followed by an angle bracket expression | |
1848 | containing type identifiers separated by \",\". The difference from | |
1849 | `c-<>-arglist-kwds' is that unknown names are taken to be types and | |
1850 | not other identifiers. `c-recognize-<>-arglists' is assumed to be set | |
1851 | if this isn't nil." | |
1852 | t nil | |
1853 | objc '("id") | |
1854 | idl '("sequence" | |
1855 | ;; In CORBA PSDL: | |
1856 | "ref")) | |
1857 | ||
1858 | (c-lang-defconst c-<>-arglist-kwds | |
1859 | "Keywords that can be followed by a C++ style template arglist; see | |
1860 | `c-recognize-<>-arglists' for details. That language constant is | |
1861 | assumed to be set if this isn't nil." | |
1862 | t nil | |
1863 | c++ '("template") | |
1864 | idl '("fixed" "string" "wstring")) | |
1865 | ||
1866 | (c-lang-defconst c-<>-sexp-kwds | |
1867 | ;; All keywords that can be followed by an angle bracket sexp. | |
1868 | t (delete-duplicates (append (c-lang-const c-<>-type-kwds) | |
1869 | (c-lang-const c-<>-arglist-kwds)) | |
1870 | :test 'string-equal)) | |
1871 | ||
1872 | (c-lang-defconst c-opt-<>-sexp-key | |
1873 | ;; Adorned regexp matching keywords that can be followed by an angle | |
846f5040 | 1874 | ;; bracket sexp. Always set when `c-recognize-<>-arglists' is. |
d9e94c22 MS |
1875 | t (if (c-lang-const c-recognize-<>-arglists) |
1876 | (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds)))) | |
1877 | (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key)) | |
1878 | ||
1879 | (c-lang-defconst c-brace-id-list-kwds | |
1880 | "Keywords that may be followed by a brace block containing a comma | |
1881 | separated list of identifier definitions, i.e. like the list of | |
1882 | identifiers that follows the type in a normal declaration." | |
1883 | t (c-lang-const c-brace-list-decl-kwds)) | |
a66cd3ee | 1884 | |
a66cd3ee | 1885 | (c-lang-defconst c-block-stmt-1-kwds |
d9e94c22 MS |
1886 | "Statement keywords followed directly by a substatement." |
1887 | t '("do" "else") | |
1888 | c++ '("do" "else" "try") | |
1889 | java '("do" "else" "finally" "try") | |
1890 | idl nil) | |
a66cd3ee | 1891 | |
a66cd3ee | 1892 | (c-lang-defconst c-block-stmt-1-key |
d9e94c22 MS |
1893 | ;; Regexp matching the start of any statement followed directly by a |
1894 | ;; substatement (doesn't match a bare block, however). | |
1895 | t (c-make-keywords-re t (c-lang-const c-block-stmt-1-kwds))) | |
1896 | (c-lang-defvar c-block-stmt-1-key (c-lang-const c-block-stmt-1-key)) | |
a66cd3ee | 1897 | |
a66cd3ee | 1898 | (c-lang-defconst c-block-stmt-2-kwds |
d9e94c22 MS |
1899 | "Statement keywords followed by a paren sexp and then by a substatement." |
1900 | t '("for" "if" "switch" "while") | |
1901 | c++ '("for" "if" "switch" "while" "catch") | |
a66cd3ee | 1902 | java '("for" "if" "switch" "while" "catch" "synchronized") |
d9e94c22 MS |
1903 | idl nil |
1904 | pike '("for" "if" "switch" "while" "foreach") | |
1905 | awk '("for" "if" "while")) | |
a66cd3ee | 1906 | |
a66cd3ee | 1907 | (c-lang-defconst c-block-stmt-2-key |
d9e94c22 MS |
1908 | ;; Regexp matching the start of any statement followed by a paren sexp |
1909 | ;; and then by a substatement. | |
1910 | t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds))) | |
1911 | (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key)) | |
a66cd3ee | 1912 | |
0386b551 AM |
1913 | (c-lang-defconst c-block-stmt-kwds |
1914 | ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'. | |
1915 | t (delete-duplicates (append (c-lang-const c-block-stmt-1-kwds) | |
1916 | (c-lang-const c-block-stmt-2-kwds)) | |
1917 | :test 'string-equal)) | |
1918 | ||
a66cd3ee | 1919 | (c-lang-defconst c-opt-block-stmt-key |
d9e94c22 MS |
1920 | ;; Regexp matching the start of any statement that has a |
1921 | ;; substatement (except a bare block). Nil in languages that | |
1922 | ;; don't have such constructs. | |
1923 | t (if (or (c-lang-const c-block-stmt-1-kwds) | |
1924 | (c-lang-const c-block-stmt-2-kwds)) | |
1925 | (c-make-keywords-re t | |
1926 | (append (c-lang-const c-block-stmt-1-kwds) | |
1927 | (c-lang-const c-block-stmt-2-kwds))))) | |
1928 | (c-lang-defvar c-opt-block-stmt-key (c-lang-const c-opt-block-stmt-key)) | |
1929 | ||
a66cd3ee | 1930 | (c-lang-defconst c-simple-stmt-kwds |
d9e94c22 MS |
1931 | "Statement keywords followed by an expression or nothing." |
1932 | t '("break" "continue" "goto" "return") | |
a66cd3ee MS |
1933 | ;; Note: `goto' is not valid in Java, but the keyword is still reserved. |
1934 | java '("break" "continue" "goto" "return" "throw") | |
d9e94c22 MS |
1935 | idl nil |
1936 | pike '("break" "continue" "return") | |
1937 | awk '(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30 | |
1938 | "break" "continue" "return" "delete" "exit" "getline" "next" | |
1939 | "nextfile" "print" "printf")) | |
1940 | ||
1941 | (c-lang-defconst c-simple-stmt-key | |
1942 | ;; Adorned regexp matching `c-simple-stmt-kwds'. | |
1943 | t (c-make-keywords-re t (c-lang-const c-simple-stmt-kwds))) | |
1944 | (c-lang-defvar c-simple-stmt-key (c-lang-const c-simple-stmt-key)) | |
1945 | ||
1946 | (c-lang-defconst c-paren-stmt-kwds | |
1947 | "Statement keywords followed by a parenthesis expression that | |
1948 | nevertheless contains a list separated with ';' and not ','." | |
1949 | t '("for") | |
1950 | idl nil) | |
1951 | ||
1952 | (c-lang-defconst c-paren-stmt-key | |
1953 | ;; Adorned regexp matching `c-paren-stmt-kwds'. | |
1954 | t (c-make-keywords-re t (c-lang-const c-paren-stmt-kwds))) | |
1955 | (c-lang-defvar c-paren-stmt-key (c-lang-const c-paren-stmt-key)) | |
a66cd3ee | 1956 | |
a66cd3ee | 1957 | (c-lang-defconst c-asm-stmt-kwds |
d9e94c22 MS |
1958 | "Statement keywords followed by an assembler expression." |
1959 | t nil | |
1960 | (c c++) '("asm" "__asm__")) ;; Not standard, but common. | |
a66cd3ee | 1961 | |
a66cd3ee | 1962 | (c-lang-defconst c-opt-asm-stmt-key |
d9e94c22 MS |
1963 | ;; Regexp matching the start of an assembler statement. Nil in |
1964 | ;; languages that don't support that. | |
1965 | t (if (c-lang-const c-asm-stmt-kwds) | |
1966 | (c-make-keywords-re t (c-lang-const c-asm-stmt-kwds)))) | |
1967 | (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key)) | |
1968 | ||
1969 | (c-lang-defconst c-label-kwds | |
0386b551 | 1970 | "Keywords introducing colon terminated labels in blocks." |
d9e94c22 MS |
1971 | t '("case" "default") |
1972 | awk nil) | |
1973 | ||
0386b551 AM |
1974 | (c-lang-defconst c-label-kwds-regexp |
1975 | ;; Adorned regexp matching any keyword that introduces a label. | |
1976 | t (c-make-keywords-re t (c-lang-const c-label-kwds))) | |
1977 | (c-lang-defvar c-label-kwds-regexp (c-lang-const c-label-kwds-regexp)) | |
1978 | ||
d9e94c22 MS |
1979 | (c-lang-defconst c-before-label-kwds |
1980 | "Keywords that might be followed by a label identifier." | |
1981 | t '("goto") | |
1982 | (java pike) (append '("break" "continue") | |
1983 | (c-lang-const c-before-label-kwds)) | |
1984 | idl nil | |
1985 | awk nil) | |
130c507e | 1986 | |
d9e94c22 MS |
1987 | (c-lang-defconst c-constant-kwds |
1988 | "Keywords for constants." | |
1989 | t nil | |
1990 | (c c++) '("NULL" ;; Not a keyword, but practically works as one. | |
1991 | "false" "true") ; Defined in C99. | |
1992 | objc '("nil" "Nil") | |
1993 | idl '("TRUE" "FALSE") | |
1994 | pike '("UNDEFINED")) ;; Not a keyword, but practically works as one. | |
1995 | ||
1996 | (c-lang-defconst c-primary-expr-kwds | |
1997 | "Keywords besides constants and operators that start primary expressions." | |
1998 | t nil | |
1999 | c++ '("operator" "this") | |
2000 | objc '("super" "self") | |
2001 | java '("this") | |
2002 | pike '("this")) ;; Not really a keyword, but practically works as one. | |
130c507e | 2003 | |
a66cd3ee | 2004 | (c-lang-defconst c-expr-kwds |
d9e94c22 MS |
2005 | ;; Keywords that can occur anywhere in expressions. Built from |
2006 | ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'. | |
2007 | t (delete-duplicates | |
2008 | (append (c-lang-const c-primary-expr-kwds) | |
0386b551 AM |
2009 | (c-filter-ops (c-lang-const c-operator-list) |
2010 | t | |
2011 | "\\`\\(\\w\\|\\s_\\)+\\'")) | |
d9e94c22 MS |
2012 | :test 'string-equal)) |
2013 | ||
2014 | (c-lang-defconst c-lambda-kwds | |
2015 | "Keywords that start lambda constructs, i.e. function definitions in | |
2016 | expressions." | |
2017 | t nil | |
2018 | pike '("lambda")) | |
a66cd3ee | 2019 | |
d9e94c22 MS |
2020 | (c-lang-defconst c-inexpr-block-kwds |
2021 | "Keywords that start constructs followed by statement blocks which can | |
2022 | be used in expressions \(the gcc extension for this in C and C++ is | |
0386b551 | 2023 | handled separately by `c-recognize-paren-inexpr-blocks')." |
d9e94c22 MS |
2024 | t nil |
2025 | pike '("catch" "gauge")) | |
a66cd3ee | 2026 | |
a66cd3ee | 2027 | (c-lang-defconst c-inexpr-class-kwds |
d9e94c22 MS |
2028 | "Keywords that can start classes inside expressions." |
2029 | t nil | |
a66cd3ee MS |
2030 | java '("new") |
2031 | pike '("class")) | |
2032 | ||
d9e94c22 MS |
2033 | (c-lang-defconst c-inexpr-brace-list-kwds |
2034 | "Keywords that can start brace list blocks inside expressions. | |
2035 | Note that Java specific rules are currently applied to tell this from | |
2036 | `c-inexpr-class-kwds'." | |
2037 | t nil | |
2038 | java '("new")) | |
2039 | ||
2040 | (c-lang-defconst c-opt-inexpr-brace-list-key | |
2041 | ;; Regexp matching the start of a brace list in an expression, or | |
2042 | ;; nil in languages that don't have such things. This should not | |
2043 | ;; match brace lists recognized through `c-special-brace-lists'. | |
2044 | t (and (c-lang-const c-inexpr-brace-list-kwds) | |
2045 | (c-make-keywords-re t (c-lang-const c-inexpr-brace-list-kwds)))) | |
2046 | (c-lang-defvar c-opt-inexpr-brace-list-key | |
2047 | (c-lang-const c-opt-inexpr-brace-list-key)) | |
a66cd3ee | 2048 | |
a66cd3ee | 2049 | (c-lang-defconst c-decl-block-key |
0386b551 AM |
2050 | ;; Regexp matching keywords in any construct that contain another |
2051 | ;; declaration level, i.e. that isn't followed by a function block | |
2052 | ;; or brace list. When the first submatch matches, it's an | |
2053 | ;; unambiguous construct, otherwise it's an ambiguous match that | |
2054 | ;; might also be the return type of a function declaration. | |
2055 | t (let* ((decl-kwds (append (c-lang-const c-class-decl-kwds) | |
2056 | (c-lang-const c-other-block-decl-kwds) | |
2057 | (c-lang-const c-inexpr-class-kwds))) | |
2058 | (unambiguous (set-difference decl-kwds | |
2059 | (c-lang-const c-type-start-kwds) | |
2060 | :test 'string-equal)) | |
2061 | (ambiguous (intersection decl-kwds | |
2062 | (c-lang-const c-type-start-kwds) | |
2063 | :test 'string-equal))) | |
2064 | (if ambiguous | |
2065 | (concat (c-make-keywords-re t unambiguous) | |
2066 | "\\|" | |
2067 | (c-make-keywords-re t ambiguous)) | |
2068 | (c-make-keywords-re t unambiguous)))) | |
d9e94c22 MS |
2069 | (c-lang-defvar c-decl-block-key (c-lang-const c-decl-block-key)) |
2070 | ||
a66cd3ee | 2071 | (c-lang-defconst c-bitfield-kwds |
d9e94c22 MS |
2072 | "Keywords that can introduce bitfields." |
2073 | t nil | |
2074 | (c c++ objc) '("char" "int" "long" "signed" "unsigned")) | |
a66cd3ee | 2075 | |
a66cd3ee | 2076 | (c-lang-defconst c-opt-bitfield-key |
d9e94c22 MS |
2077 | ;; Regexp matching the start of a bitfield (not uniquely), or nil in |
2078 | ;; languages without bitfield support. | |
2079 | t nil | |
2080 | (c c++) (c-make-keywords-re t (c-lang-const c-bitfield-kwds))) | |
2081 | (c-lang-defvar c-opt-bitfield-key (c-lang-const c-opt-bitfield-key)) | |
2082 | ||
2083 | (c-lang-defconst c-other-kwds | |
2084 | "Keywords not accounted for by any other `*-kwds' language constant." | |
2085 | t nil | |
2086 | idl '("truncatable" | |
2087 | ;; In CORBA CIDL: (These are declaration keywords that never | |
2088 | ;; can start a declaration.) | |
2089 | "entity" "process" "service" "session" "storage")) | |
2090 | ||
2091 | \f | |
2092 | ;;; Constants built from keywords. | |
2093 | ||
2094 | ;; Note: No `*-kwds' language constants may be defined below this point. | |
2095 | ||
2096 | (eval-and-compile | |
2097 | (defconst c-kwds-lang-consts | |
2098 | ;; List of all the language constants that contain keyword lists. | |
2099 | (let (list) | |
2100 | (mapatoms (lambda (sym) | |
2101 | (when (and (boundp sym) | |
2102 | (string-match "-kwds\\'" (symbol-name sym))) | |
2103 | ;; Make the list of globally interned symbols | |
2104 | ;; instead of ones interned in `c-lang-constants'. | |
2105 | (setq list (cons (intern (symbol-name sym)) list)))) | |
2106 | c-lang-constants) | |
2107 | list))) | |
a66cd3ee | 2108 | |
a66cd3ee | 2109 | (c-lang-defconst c-keywords |
d9e94c22 MS |
2110 | ;; All keywords as a list. |
2111 | t (delete-duplicates | |
2112 | (c-lang-defconst-eval-immediately | |
2113 | `(append ,@(mapcar (lambda (kwds-lang-const) | |
2114 | `(c-lang-const ,kwds-lang-const)) | |
2115 | c-kwds-lang-consts) | |
2116 | nil)) | |
2117 | :test 'string-equal)) | |
2118 | ||
a66cd3ee | 2119 | (c-lang-defconst c-keywords-regexp |
d9e94c22 MS |
2120 | ;; All keywords as an adorned regexp. |
2121 | t (c-make-keywords-re t (c-lang-const c-keywords))) | |
2122 | (c-lang-defvar c-keywords-regexp (c-lang-const c-keywords-regexp)) | |
2123 | ||
2124 | (c-lang-defconst c-keyword-member-alist | |
2125 | ;; An alist with all the keywords in the cars. The cdr for each | |
2126 | ;; keyword is a list of the symbols for the `*-kwds' lists that | |
2127 | ;; contains it. | |
2128 | t (let ((kwd-list-alist | |
2129 | (c-lang-defconst-eval-immediately | |
2130 | `(list ,@(mapcar (lambda (kwds-lang-const) | |
2131 | `(cons ',kwds-lang-const | |
2132 | (c-lang-const ,kwds-lang-const))) | |
2133 | c-kwds-lang-consts)))) | |
2134 | lang-const kwd-list kwd | |
2135 | result-alist elem) | |
2136 | (while kwd-list-alist | |
2137 | (setq lang-const (caar kwd-list-alist) | |
2138 | kwd-list (cdar kwd-list-alist) | |
2139 | kwd-list-alist (cdr kwd-list-alist)) | |
2140 | (while kwd-list | |
2141 | (setq kwd (car kwd-list) | |
2142 | kwd-list (cdr kwd-list)) | |
2143 | (unless (setq elem (assoc kwd result-alist)) | |
2144 | (setq result-alist (cons (setq elem (list kwd)) result-alist))) | |
2145 | (unless (memq lang-const (cdr elem)) | |
2146 | (setcdr elem (cons lang-const (cdr elem)))))) | |
2147 | result-alist)) | |
2148 | ||
2149 | (c-lang-defvar c-keywords-obarray | |
2150 | ;; An obarray containing all keywords as symbols. The property list | |
2151 | ;; of each symbol has a non-nil entry for the specific `*-kwds' | |
2152 | ;; lists it's a member of. | |
2153 | ;; | |
2154 | ;; E.g. to see whether the string str contains a keyword on | |
2155 | ;; `c-class-decl-kwds', one can do like this: | |
2156 | ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds) | |
2157 | ;; Which preferably is written using the associated functions in | |
2158 | ;; cc-engine: | |
2159 | ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds) | |
2160 | ||
2161 | ;; The obarray is not stored directly as a language constant since | |
2162 | ;; the printed representation for obarrays used in .elc files isn't | |
2163 | ;; complete. | |
2164 | ||
2165 | (let* ((alist (c-lang-const c-keyword-member-alist)) | |
2166 | kwd lang-const-list | |
2167 | (obarray (make-vector (* (length alist) 2) 0))) | |
2168 | (while alist | |
2169 | (setq kwd (caar alist) | |
2170 | lang-const-list (cdar alist) | |
2171 | alist (cdr alist)) | |
2172 | (setplist (intern kwd obarray) | |
2173 | ;; Emacs has an odd bug that causes `mapcan' to fail | |
0386b551 | 2174 | ;; with unintelligible errors. (XEmacs works.) |
d9e94c22 MS |
2175 | ;;(mapcan (lambda (lang-const) |
2176 | ;; (list lang-const t)) | |
2177 | ;; lang-const-list) | |
2178 | (apply 'nconc (mapcar (lambda (lang-const) | |
2179 | (list lang-const t)) | |
2180 | lang-const-list)))) | |
2181 | obarray)) | |
2182 | ||
2183 | (c-lang-defconst c-regular-keywords-regexp | |
0386b551 AM |
2184 | ;; Adorned regexp matching all keywords that should be fontified |
2185 | ;; with the keywords face. I.e. that aren't types or constants. | |
d9e94c22 MS |
2186 | t (c-make-keywords-re t |
2187 | (set-difference (c-lang-const c-keywords) | |
2188 | (append (c-lang-const c-primitive-type-kwds) | |
2189 | (c-lang-const c-constant-kwds)) | |
2190 | :test 'string-equal))) | |
2191 | (c-lang-defvar c-regular-keywords-regexp | |
2192 | (c-lang-const c-regular-keywords-regexp)) | |
2193 | ||
d9e94c22 MS |
2194 | (c-lang-defconst c-primary-expr-regexp |
2195 | ;; Regexp matching the start of any primary expression, i.e. any | |
2196 | ;; literal, symbol, prefix operator, and '('. It doesn't need to | |
2197 | ;; exclude keywords; they are excluded afterwards unless the second | |
2198 | ;; submatch matches. If the first but not the second submatch | |
2199 | ;; matches then it is an ambiguous primary expression; it could also | |
2200 | ;; be a match of e.g. an infix operator. (The case with ambiguous | |
2201 | ;; keyword operators isn't handled.) | |
2202 | ||
0386b551 AM |
2203 | t (let* ((prefix-ops |
2204 | (c-filter-ops (c-lang-const c-operators) | |
2205 | '(prefix) | |
2206 | (lambda (op) | |
2207 | ;; Filter out the special case prefix | |
2208 | ;; operators that are close parens. | |
2209 | (not (string-match "\\s)" op))))) | |
2210 | ||
2211 | (nonkeyword-prefix-ops | |
2212 | (c-filter-ops prefix-ops | |
2213 | t | |
2214 | "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'")) | |
2215 | ||
2216 | (in-or-postfix-ops | |
2217 | (c-filter-ops (c-lang-const c-operators) | |
2218 | '(postfix | |
2219 | postfix-if-paren | |
2220 | left-assoc | |
2221 | right-assoc | |
2222 | right-assoc-sequence) | |
2223 | t)) | |
2224 | ||
2225 | (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops | |
2226 | in-or-postfix-ops | |
2227 | :test 'string-equal)) | |
2228 | (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops | |
2229 | in-or-postfix-ops | |
2230 | :test 'string-equal))) | |
2231 | ||
2232 | (concat | |
2233 | "\\(" | |
2234 | ;; Take out all symbol class operators from `prefix-ops' and make the | |
2235 | ;; first submatch from them together with `c-primary-expr-kwds'. | |
2236 | (c-make-keywords-re t | |
2237 | (append (c-lang-const c-primary-expr-kwds) | |
2238 | (set-difference prefix-ops nonkeyword-prefix-ops | |
2239 | :test 'string-equal))) | |
2240 | ||
2241 | "\\|" | |
2242 | ;; Match all ambiguous operators. | |
2243 | (c-make-keywords-re nil | |
2244 | (intersection nonkeyword-prefix-ops in-or-postfix-ops | |
2245 | :test 'string-equal)) | |
2246 | "\\)" | |
d9e94c22 | 2247 | |
0386b551 AM |
2248 | "\\|" |
2249 | ;; Now match all other symbols. | |
2250 | (c-lang-const c-symbol-start) | |
d9e94c22 | 2251 | |
0386b551 AM |
2252 | "\\|" |
2253 | ;; The chars that can start integer and floating point | |
2254 | ;; constants. | |
2255 | "\\.?[0-9]" | |
d9e94c22 | 2256 | |
0386b551 AM |
2257 | "\\|" |
2258 | ;; The nonambiguous operators from `prefix-ops'. | |
2259 | (c-make-keywords-re nil | |
2260 | (set-difference nonkeyword-prefix-ops in-or-postfix-ops | |
2261 | :test 'string-equal)) | |
d9e94c22 | 2262 | |
0386b551 AM |
2263 | "\\|" |
2264 | ;; Match string and character literals. | |
2265 | "\\s\"" | |
2266 | (if (memq 'gen-string-delim c-emacs-features) | |
2267 | "\\|\\s|" | |
2268 | "")))) | |
d9e94c22 | 2269 | (c-lang-defvar c-primary-expr-regexp (c-lang-const c-primary-expr-regexp)) |
a66cd3ee | 2270 | |
d9e94c22 MS |
2271 | \f |
2272 | ;;; Additional constants for parser-level constructs. | |
2273 | ||
2274 | (c-lang-defconst c-decl-prefix-re | |
0386b551 AM |
2275 | "Regexp matching something that might precede a declaration, cast or |
2276 | label, such as the last token of a preceding statement or declaration. | |
2277 | This is used in the common situation where a declaration or cast | |
2278 | doesn't start with any specific token that can be searched for. | |
2279 | ||
2280 | The regexp should not match bob; that is done implicitly. It can't | |
2281 | require a match longer than one token. The end of the token is taken | |
2282 | to be at the end of the first submatch, which is assumed to always | |
2283 | match. It's undefined whether identifier syntax (see | |
2284 | `c-identifier-syntax-table') is in effect or not. This regexp is | |
2285 | assumed to be a superset of `c-label-prefix-re' if | |
2286 | `c-recognize-colon-labels' is set. | |
2287 | ||
2288 | Besides this, `c-decl-start-kwds' is used to find declarations. | |
2289 | ||
2290 | Note: This variable together with `c-decl-start-re' and | |
2291 | `c-decl-start-kwds' is only used to detect \"likely\" | |
2292 | declaration/cast/label starts. I.e. they might produce more matches | |
2293 | but should not miss anything (or else it's necessary to use text | |
2294 | properties - see the next note). Wherever they match, the following | |
2295 | construct is analyzed to see if it indeed is a declaration, cast or | |
2296 | label. That analysis is not cheap, so it's important that not too | |
2297 | many false matches are triggered. | |
2298 | ||
2299 | Note: If a declaration/cast/label start can't be detected with this | |
2300 | variable, it's necessary to use the `c-type' text property with the | |
2301 | value `c-decl-end' on the last char of the last token preceding the | |
2302 | declaration. See the comment blurb at the start of cc-engine.el for | |
2303 | more info." | |
2304 | ||
d9e94c22 MS |
2305 | ;; We match a sequence of characters to skip over things like \"};\" |
2306 | ;; more quickly. We match ")" in C for K&R region declarations, and | |
2307 | ;; in all languages except Java for when a cpp macro definition | |
2308 | ;; begins with a declaration. | |
2309 | t "\\([\{\}\(\);,]+\\)" | |
2310 | java "\\([\{\}\(;,]+\\)" | |
2311 | ;; Match "<" in C++ to get the first argument in a template arglist. | |
2312 | ;; In that case there's an additional check in `c-find-decl-spots' | |
2313 | ;; that it got open paren syntax. | |
0386b551 | 2314 | c++ "\\([\{\}\(\);,<]+\\)" |
d9e94c22 MS |
2315 | ;; Additionally match the protection directives in Objective-C. |
2316 | ;; Note that this doesn't cope with the longer directives, which we | |
2317 | ;; would have to match from start to end since they don't end with | |
2318 | ;; any easily recognized characters. | |
2319 | objc (concat "\\([\{\}\(\);,]+\\|" | |
2320 | (c-make-keywords-re nil (c-lang-const c-protection-kwds)) | |
2321 | "\\)") | |
d9e94c22 MS |
2322 | ;; Pike is like C but we also match "[" for multiple value |
2323 | ;; assignments and type casts. | |
2324 | pike "\\([\{\}\(\)\[;,]+\\)") | |
2325 | (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re) | |
2326 | 'dont-doc) | |
2327 | ||
0386b551 AM |
2328 | (c-lang-defconst c-decl-start-re |
2329 | "Regexp matching the start of any declaration, cast or label. | |
2330 | It's used on the token after the one `c-decl-prefix-re' matched. This | |
2331 | regexp should not try to match those constructs accurately as it's | |
2332 | only used as a sieve to avoid spending more time checking other | |
2333 | constructs." | |
2334 | t (c-lang-const c-identifier-start)) | |
2335 | (c-lang-defvar c-decl-start-re (c-lang-const c-decl-start-re)) | |
2336 | ||
2337 | (c-lang-defconst c-decl-prefix-or-start-re | |
2338 | ;; Regexp matching something that might precede or start a | |
2339 | ;; declaration, cast or label. | |
2340 | ;; | |
2341 | ;; If the first submatch matches, it's taken to match the end of a | |
2342 | ;; token that might precede such a construct, e.g. ';', '}' or '{'. | |
2343 | ;; It's built from `c-decl-prefix-re'. | |
2344 | ;; | |
2345 | ;; If the first submatch did not match, the match of the whole | |
2346 | ;; regexp is taken to be at the first token in the declaration. | |
2347 | ;; `c-decl-start-re' is not checked in this case. | |
2348 | ;; | |
2349 | ;; Design note: The reason the same regexp is used to match both | |
2350 | ;; tokens that precede declarations and start them is to avoid an | |
2351 | ;; extra regexp search from the previous declaration spot in | |
2352 | ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on | |
2353 | ;; that it finds all declaration/cast/label starts in approximately | |
2354 | ;; linear order, so we can't do the searches in two separate passes. | |
2355 | t (if (c-lang-const c-decl-start-kwds) | |
2356 | (concat (c-lang-const c-decl-prefix-re) | |
2357 | "\\|" | |
2358 | (c-make-keywords-re t (c-lang-const c-decl-start-kwds))) | |
2359 | (c-lang-const c-decl-prefix-re))) | |
2360 | (c-lang-defvar c-decl-prefix-or-start-re | |
2361 | (c-lang-const c-decl-prefix-or-start-re) | |
2362 | 'dont-doc) | |
2363 | ||
d9e94c22 MS |
2364 | (c-lang-defconst c-cast-parens |
2365 | ;; List containing the paren characters that can open a cast, or nil in | |
2366 | ;; languages without casts. | |
0386b551 AM |
2367 | t (c-filter-ops (c-lang-const c-operators) |
2368 | '(prefix) | |
2369 | "\\`\\s\(\\'" | |
2370 | (lambda (op) (elt op 0)))) | |
d9e94c22 MS |
2371 | (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens)) |
2372 | ||
0386b551 AM |
2373 | (c-lang-defconst c-block-prefix-disallowed-chars |
2374 | "List of syntactically relevant characters that never can occur before | |
2375 | the open brace in any construct that contains a brace block, e.g. in | |
2376 | the \"class Foo: public Bar\" part of: | |
2377 | ||
2378 | class Foo: public Bar {int x();} a, *b; | |
2379 | ||
2380 | If parens can occur, the chars inside those aren't filtered with this | |
2381 | list. | |
2382 | ||
2383 | '<' and '>' should be disallowed even if angle bracket arglists can | |
2384 | occur. That since the search function needs to stop at them anyway to | |
2385 | ensure they are given paren syntax. | |
2386 | ||
2387 | This is used to skip backward from the open brace to find the region | |
2388 | in which to look for a construct like \"class\", \"enum\", | |
2389 | \"namespace\" or whatever. That skipping should be as tight as | |
2390 | possible for good performance." | |
2391 | ||
2392 | ;; Default to all chars that only occurs in nonsymbol tokens outside | |
2393 | ;; identifiers. | |
2394 | t (set-difference | |
2395 | (c-lang-const c-nonsymbol-token-char-list) | |
2396 | (c-filter-ops (append (c-lang-const c-identifier-ops) | |
2397 | (list (cons nil | |
2398 | (c-lang-const c-after-id-concat-ops)))) | |
2399 | t | |
2400 | t | |
2401 | (lambda (op) | |
2402 | (let ((pos 0) res) | |
2403 | (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)" | |
2404 | op pos) | |
2405 | (setq res (cons (aref op (match-beginning 1)) res) | |
2406 | pos (match-end 0))) | |
2407 | res)))) | |
2408 | ||
2409 | ;; Allow cpp operatios (where applicable). | |
2410 | t (if (c-lang-const c-opt-cpp-prefix) | |
2411 | (set-difference (c-lang-const c-block-prefix-disallowed-chars) | |
2412 | '(?#)) | |
2413 | (c-lang-const c-block-prefix-disallowed-chars)) | |
2414 | ||
2415 | ;; Allow ':' for inherit list starters. | |
2416 | (c++ objc idl) (set-difference (c-lang-const c-block-prefix-disallowed-chars) | |
2417 | '(?:)) | |
2418 | ||
2419 | ;; Allow ',' for multiple inherits. | |
2420 | (c++ java) (set-difference (c-lang-const c-block-prefix-disallowed-chars) | |
2421 | '(?,)) | |
2422 | ||
2423 | ;; Allow parentheses for anonymous inner classes in Java and class | |
2424 | ;; initializer lists in Pike. | |
2425 | (java pike) (set-difference (c-lang-const c-block-prefix-disallowed-chars) | |
2426 | '(?\( ?\))) | |
2427 | ||
2428 | ;; Allow '"' for extern clauses (e.g. extern "C" {...}). | |
2429 | (c c++ objc) (set-difference (c-lang-const c-block-prefix-disallowed-chars) | |
2430 | '(?\" ?'))) | |
2431 | ||
2432 | (c-lang-defconst c-block-prefix-charset | |
2433 | ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable | |
2434 | ;; for `c-syntactic-skip-backward'. | |
2435 | t (c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars) t)) | |
2436 | (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset)) | |
2437 | ||
d9e94c22 | 2438 | (c-lang-defconst c-type-decl-prefix-key |
0386b551 AM |
2439 | "Regexp matching the declarator operators that might precede the |
2440 | identifier in a declaration, e.g. the \"*\" in \"char *argv\". This | |
2441 | regexp should match \"(\" if parentheses are valid in declarators. | |
2442 | The end of the first submatch is taken as the end of the operator. | |
2443 | Identifier syntax is in effect when this is matched \(see | |
2444 | `c-identifier-syntax-table')." | |
d9e94c22 | 2445 | t (if (c-lang-const c-type-modifier-kwds) |
0386b551 | 2446 | (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>") |
d9e94c22 MS |
2447 | ;; Default to a regexp that never matches. |
2448 | "\\<\\>") | |
0386b551 AM |
2449 | ;; Check that there's no "=" afterwards to avoid matching tokens |
2450 | ;; like "*=". | |
d9e94c22 MS |
2451 | (c objc) (concat "\\(" |
2452 | "[*\(]" | |
2453 | "\\|" | |
2454 | (c-lang-const c-type-decl-prefix-key) | |
2455 | "\\)" | |
2456 | "\\([^=]\\|$\\)") | |
2457 | c++ (concat "\\(" | |
2458 | "[*\(&]" | |
2459 | "\\|" | |
2460 | (concat "\\(" ; 2 | |
2461 | ;; If this matches there's special treatment in | |
2462 | ;; `c-font-lock-declarators' and | |
2463 | ;; `c-font-lock-declarations' that check for a | |
2464 | ;; complete name followed by ":: *". | |
2465 | (c-lang-const c-identifier-start) | |
2466 | "\\)") | |
2467 | "\\|" | |
2468 | (c-lang-const c-type-decl-prefix-key) | |
2469 | "\\)" | |
2470 | "\\([^=]\\|$\\)") | |
0386b551 | 2471 | pike "\\(\\*\\)\\([^=]\\|$\\)") |
d9e94c22 MS |
2472 | (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key) |
2473 | 'dont-doc) | |
2474 | ||
2475 | (c-lang-defconst c-type-decl-suffix-key | |
0386b551 AM |
2476 | "Regexp matching the declarator operators that might follow after the |
2477 | identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This | |
2478 | regexp should match \")\" if parentheses are valid in declarators. If | |
d9e94c22 MS |
2479 | it matches an open paren of some kind, the type declaration check |
2480 | continues at the corresponding close paren, otherwise the end of the | |
2481 | first submatch is taken as the end of the operator. Identifier syntax | |
2482 | is in effect when this is matched (see `c-identifier-syntax-table')." | |
2483 | ;; Default to a regexp that matches `c-type-modifier-kwds' and a | |
2484 | ;; function argument list parenthesis. | |
2485 | t (if (c-lang-const c-type-modifier-kwds) | |
2486 | (concat "\\(\(\\|" | |
0386b551 | 2487 | (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>" |
d9e94c22 MS |
2488 | "\\)") |
2489 | "\\(\(\\)") | |
2490 | (c c++ objc) (concat | |
2491 | "\\(" | |
2492 | "[\)\[\(]" | |
0386b551 AM |
2493 | (if (c-lang-const c-type-modifier-kwds) |
2494 | (concat | |
2495 | "\\|" | |
2496 | ;; "throw" in `c-type-modifier-kwds' is followed | |
2497 | ;; by a parenthesis list, but no extra measures | |
2498 | ;; are necessary to handle that. | |
2499 | (regexp-opt (c-lang-const c-type-modifier-kwds) t) | |
2500 | "\\>") | |
2501 | "") | |
d9e94c22 MS |
2502 | "\\)") |
2503 | (java idl) "\\([\[\(]\\)") | |
2504 | (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key) | |
2505 | 'dont-doc) | |
2506 | ||
2507 | (c-lang-defconst c-after-suffixed-type-decl-key | |
0386b551 | 2508 | "This regexp is matched after a declarator expression where |
d9e94c22 MS |
2509 | `c-type-decl-suffix-key' has matched. If it matches then the |
2510 | construct is taken as a declaration. It's typically used to match the | |
2511 | beginning of a function body or whatever might occur after the | |
2512 | function header in a function declaration or definition. It's | |
2513 | undefined whether identifier syntax (see `c-identifier-syntax-table') | |
2514 | is in effect or not. | |
2515 | ||
2516 | Note that it's used in cases like after \"foo (bar)\" so it should | |
2517 | only match when it's certain that it's a declaration, e.g \"{\" but | |
2518 | not \",\" or \";\"." | |
2519 | t "{" | |
2520 | ;; If K&R style declarations should be recognized then one could | |
2521 | ;; consider to match the start of any symbol since we want to match | |
2522 | ;; the start of the first declaration in the "K&R region". That | |
2523 | ;; could however produce false matches on code like "FOO(bar) x" | |
2524 | ;; where FOO is a cpp macro, so it's better to leave it out and rely | |
2525 | ;; on the other heuristics in that case. | |
0386b551 AM |
2526 | t (if (c-lang-const c-postfix-spec-kwds) |
2527 | ;; Add on the keywords in `c-postfix-spec-kwds'. | |
d9e94c22 MS |
2528 | (concat (c-lang-const c-after-suffixed-type-decl-key) |
2529 | "\\|" | |
0386b551 | 2530 | (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds))) |
d9e94c22 MS |
2531 | (c-lang-const c-after-suffixed-type-decl-key)) |
2532 | ;; Also match the colon that starts a base class initializer list in | |
2533 | ;; C++. That can be confused with a function call before the colon | |
2534 | ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't | |
2535 | ;; match before such a thing (as a declaration-level construct; | |
2536 | ;; matches inside arglist contexts are already excluded). | |
2537 | c++ "[{:]") | |
2538 | (c-lang-defvar c-after-suffixed-type-decl-key | |
2539 | (c-lang-const c-after-suffixed-type-decl-key) | |
2540 | 'dont-doc) | |
2541 | ||
2542 | (c-lang-defconst c-after-suffixed-type-maybe-decl-key | |
2543 | ;; Regexp that in addition to `c-after-suffixed-type-decl-key' | |
2544 | ;; matches ";" and ",". | |
2545 | t (concat "\\(" (c-lang-const c-after-suffixed-type-decl-key) "\\)" | |
2546 | "\\|[;,]")) | |
2547 | (c-lang-defvar c-after-suffixed-type-maybe-decl-key | |
2548 | (c-lang-const c-after-suffixed-type-maybe-decl-key)) | |
2549 | ||
2550 | (c-lang-defconst c-opt-type-concat-key | |
2551 | "Regexp matching operators that concatenate types, e.g. the \"|\" in | |
2552 | \"int|string\" in Pike. The end of the first submatch is taken as the | |
2553 | end of the operator. nil in languages without such operators. It's | |
2554 | undefined whether identifier syntax (see `c-identifier-syntax-table') | |
2555 | is in effect or not." | |
2556 | t nil | |
2557 | pike "\\([|.&]\\)\\($\\|[^|.&]\\)") | |
2558 | (c-lang-defvar c-opt-type-concat-key (c-lang-const c-opt-type-concat-key) | |
2559 | 'dont-doc) | |
2560 | ||
2561 | (c-lang-defconst c-opt-type-suffix-key | |
2562 | "Regexp matching operators that might follow after a type, or nil in | |
2563 | languages that don't have such operators. The end of the first | |
2564 | submatch is taken as the end of the operator. This should not match | |
2565 | things like C++ template arglists if `c-recognize-<>-arglists' is set. | |
2566 | It's undefined whether identifier syntax (see `c-identifier-syntax-table') | |
2567 | is in effect or not." | |
2568 | t nil | |
2569 | (c c++ objc pike) "\\(\\.\\.\\.\\)" | |
0386b551 | 2570 | java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)")) |
d9e94c22 MS |
2571 | (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key)) |
2572 | ||
2573 | (c-lang-defvar c-known-type-key | |
2574 | ;; Regexp matching the known type identifiers. This is initialized | |
2575 | ;; from the type keywords and `*-font-lock-extra-types'. The first | |
2576 | ;; submatch is the one that matches the type. Note that this regexp | |
2577 | ;; assumes that symbol constituents like '_' and '$' have word | |
2578 | ;; syntax. | |
0386b551 AM |
2579 | (let* ((extra-types |
2580 | (when (boundp (c-mode-symbol "font-lock-extra-types")) | |
2581 | (c-mode-var "font-lock-extra-types"))) | |
2582 | (regexp-strings | |
6faed041 AM |
2583 | (apply 'nconc |
2584 | (mapcar (lambda (re) | |
0386b551 AM |
2585 | (when (string-match "[][.*+?^$\\]" re) |
2586 | (list re))) | |
6faed041 | 2587 | extra-types))) |
0386b551 | 2588 | (plain-strings |
6faed041 AM |
2589 | (apply 'nconc |
2590 | (mapcar (lambda (re) | |
0386b551 AM |
2591 | (unless (string-match "[][.*+?^$\\]" re) |
2592 | (list re))) | |
6faed041 | 2593 | extra-types)))) |
d9e94c22 | 2594 | (concat "\\<\\(" |
0386b551 AM |
2595 | (c-concat-separated |
2596 | (append (list (c-make-keywords-re nil | |
2597 | (append (c-lang-const c-primitive-type-kwds) | |
2598 | plain-strings))) | |
2599 | regexp-strings) | |
2600 | "\\|") | |
d9e94c22 MS |
2601 | "\\)\\>"))) |
2602 | ||
2603 | (c-lang-defconst c-special-brace-lists | |
2604 | "List of open- and close-chars that makes up a pike-style brace list, | |
2605 |