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