Optimise font locking in long enum definitions.
[emacs.git] / lisp / progmodes / cc-langs.el
blobfafbfb7055290b36a0d4f6d80a973e16391477ef
1 ;;; cc-langs.el --- language specific settings for CC Mode
3 ;; Copyright (C) 1985, 1987, 1992-2012 Free Software Foundation, Inc.
5 ;; Authors: 2002- Alan Mackenzie
6 ;; 1998- Martin Stjernholm
7 ;; 1992-1999 Barry A. Warsaw
8 ;; 1987 Dave Detlefs
9 ;; 1987 Stewart Clamen
10 ;; 1985 Richard M. Stallman
11 ;; Maintainer: bug-cc-mode@gnu.org
12 ;; Created: 22-Apr-1997 (split from cc-mode.el)
13 ;; Keywords: c languages
14 ;; Package: cc-mode
16 ;; This file is part of GNU Emacs.
18 ;; GNU Emacs is free software: you can redistribute it and/or modify
19 ;; it under the terms of the GNU General Public License as published by
20 ;; the Free Software Foundation, either version 3 of the License, or
21 ;; (at your option) any later version.
23 ;; GNU Emacs is distributed in the hope that it will be useful,
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;; GNU General Public License for more details.
28 ;; You should have received a copy of the GNU General Public License
29 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31 ;;; Commentary:
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:
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.
47 ;;; Introduction to the language dependent variable system:
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.
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.
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.
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.
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.
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.
99 ;;; Using language variables:
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.
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.
114 ;;; Code:
116 ;; For Emacs < 22.2.
117 (eval-and-compile
118 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
120 (eval-when-compile
121 (let ((load-path
122 (if (and (boundp 'byte-compile-dest-file)
123 (stringp byte-compile-dest-file))
124 (cons (file-name-directory byte-compile-dest-file) load-path)
125 load-path)))
126 (load "cc-bytecomp" nil t)))
128 (cc-require 'cc-defs)
129 (cc-require 'cc-vars)
132 ;; This file is not always loaded. See note above.
133 (cc-external-require 'cl)
136 ;;; Setup for the `c-lang-defvar' system.
138 (eval-and-compile
139 ;; These are used to collect the init forms from the subsequent
140 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
141 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
142 ;; and `make-variable-buffer-local's in cc-engine and
143 ;; `make-local-variable's in `c-init-language-vars-for'.
144 (defvar c-lang-variable-inits nil)
145 (defvar c-lang-variable-inits-tail nil)
146 (setq c-lang-variable-inits (list nil)
147 c-lang-variable-inits-tail c-lang-variable-inits)
148 (defvar c-emacs-variable-inits nil)
149 (defvar c-emacs-variable-inits-tail nil)
150 (setq c-emacs-variable-inits (list nil)
151 c-emacs-variable-inits-tail c-emacs-variable-inits))
153 (defmacro c-lang-defvar (var val &optional doc)
154 "Declares the buffer local variable VAR to get the value VAL. VAL is
155 evaluated and assigned at mode initialization. More precisely, VAL is
156 evaluated and bound to VAR when the result from the macro
157 `c-init-language-vars' is evaluated.
159 `c-lang-const' is typically used in VAL to get the right value for the
160 language being initialized, and such calls will be macro expanded to
161 the evaluated constant value at compile time."
163 (when (and (not doc)
164 (eq (car-safe val) 'c-lang-const)
165 (eq (nth 1 val) var)
166 (not (nth 2 val)))
167 ;; Special case: If there's no docstring and the value is a
168 ;; simple (c-lang-const foo) where foo is the same name as VAR
169 ;; then take the docstring from the language constant foo.
170 (setq doc (get (intern (symbol-name (nth 1 val)) c-lang-constants)
171 'variable-documentation)))
172 (or (stringp doc)
173 (setq doc nil))
175 (let ((elem (assq var (cdr c-lang-variable-inits))))
176 (if elem
177 (setcdr elem (list val doc))
178 (setcdr c-lang-variable-inits-tail (list (list var val doc)))
179 (setq c-lang-variable-inits-tail (cdr c-lang-variable-inits-tail))))
181 ;; Return the symbol, like the other def* forms.
182 `',var)
184 (defmacro c-lang-setvar (var val)
185 "Causes the variable VAR to be made buffer local and to get set to the
186 value VAL. VAL is evaluated and assigned at mode initialization. More
187 precisely, VAL is evaluated and bound to VAR when the result from the
188 macro `c-init-language-vars' is evaluated. VAR is typically a standard
189 Emacs variable like `comment-start'.
191 `c-lang-const' is typically used in VAL to get the right value for the
192 language being initialized, and such calls will be macro expanded to
193 the evaluated constant value at compile time."
194 (let ((elem (assq var (cdr c-emacs-variable-inits))))
195 (if elem
196 (setcdr elem (list val)) ; Maybe remove "list", sometime. 2006-07-19
197 (setcdr c-emacs-variable-inits-tail (list (list var val)))
198 (setq c-emacs-variable-inits-tail (cdr c-emacs-variable-inits-tail))))
200 ;; Return the symbol, like the other def* forms.
201 `',var)
203 (put 'c-lang-defvar 'lisp-indent-function 'defun)
204 ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
206 (def-edebug-spec c-lang-defvar
207 (&define name def-form &optional stringp)) ;)
209 ;; Suppress "might not be defined at runtime" warning.
210 ;; This file is only used when compiling other cc files.
211 (declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys))
212 (declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest))
213 (declare-function cl-macroexpand-all "cl-extra" (form &optional env))
215 (eval-and-compile
216 ;; Some helper functions used when building the language constants.
218 (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
219 ;; Extract a subset of the operators in the list OPS in a DWIM:ey
220 ;; way. The return value is a plain list of operators:
222 ;; OPS either has the structure of `c-operators', is a single
223 ;; group in `c-operators', or is a plain list of operators.
225 ;; OPGROUP-FILTER specifies how to select the operator groups. It
226 ;; can be t to choose all groups, a list of group type symbols
227 ;; (such as 'prefix) to accept, or a function which will be called
228 ;; with the group symbol for each group and should return non-nil
229 ;; if that group is to be included.
231 ;; If XLATE is given, it's a function which is called for each
232 ;; matching operator and its return value is collected instead.
233 ;; If it returns a list, the elements are spliced directly into
234 ;; the final result, which is returned as a list with duplicates
235 ;; removed using `equal'.
237 ;; `c-mode-syntax-table' for the current mode is in effect during
238 ;; the whole procedure.
239 (unless (listp (car-safe ops))
240 (setq ops (list ops)))
241 (cond ((eq opgroup-filter t)
242 (setq opgroup-filter (lambda (opgroup) t)))
243 ((not (functionp opgroup-filter))
244 (setq opgroup-filter `(lambda (opgroup)
245 (memq opgroup ',opgroup-filter)))))
246 (cond ((eq op-filter t)
247 (setq op-filter (lambda (op) t)))
248 ((stringp op-filter)
249 (setq op-filter `(lambda (op)
250 (string-match ,op-filter op)))))
251 (unless xlate
252 (setq xlate 'identity))
253 (c-with-syntax-table (c-lang-const c-mode-syntax-table)
254 (delete-duplicates
255 (mapcan (lambda (opgroup)
256 (when (if (symbolp (car opgroup))
257 (when (funcall opgroup-filter (car opgroup))
258 (setq opgroup (cdr opgroup))
261 (mapcan (lambda (op)
262 (when (funcall op-filter op)
263 (let ((res (funcall xlate op)))
264 (if (listp res) res (list res)))))
265 opgroup)))
266 ops)
267 :test 'equal))))
270 ;;; Various mode specific values that aren't language related.
272 (c-lang-defconst c-mode-menu
273 ;; The definition for the mode menu. The menu title is prepended to
274 ;; this before it's fed to `easy-menu-define'.
275 t `(["Comment Out Region" comment-region
276 (c-fn-region-is-active-p)]
277 ["Uncomment Region" (comment-region (region-beginning)
278 (region-end) '(4))
279 (c-fn-region-is-active-p)]
280 ["Indent Expression" c-indent-exp
281 (memq (char-after) '(?\( ?\[ ?\{))]
282 ["Indent Line or Region" c-indent-line-or-region t]
283 ["Fill Comment Paragraph" c-fill-paragraph t]
284 "----"
285 ["Backward Statement" c-beginning-of-statement t]
286 ["Forward Statement" c-end-of-statement t]
287 ,@(when (c-lang-const c-opt-cpp-prefix)
288 ;; Only applicable if there's a cpp preprocessor.
289 `(["Up Conditional" c-up-conditional t]
290 ["Backward Conditional" c-backward-conditional t]
291 ["Forward Conditional" c-forward-conditional t]
292 "----"
293 ["Macro Expand Region" c-macro-expand
294 (c-fn-region-is-active-p)]
295 ["Backslashify" c-backslash-region
296 (c-fn-region-is-active-p)]))
297 "----"
298 ("Style..."
299 ["Set Style..." c-set-style t]
300 ["Show Current Style Name" (message
301 "Style Name: %s"
302 c-indentation-style) t]
303 ["Guess Style from this Buffer" c-guess-buffer-no-install t]
304 ["Install the Last Guessed Style..." c-guess-install
305 (and c-guess-guessed-offsets-alist
306 c-guess-guessed-basic-offset) ]
307 ["View the Last Guessed Style" c-guess-view
308 (and c-guess-guessed-offsets-alist
309 c-guess-guessed-basic-offset) ])
310 "----"
311 ("Toggle..."
312 ["Syntactic indentation" c-toggle-syntactic-indentation
313 :style toggle :selected c-syntactic-indentation]
314 ["Electric mode" c-toggle-electric-state
315 :style toggle :selected c-electric-flag]
316 ["Auto newline" c-toggle-auto-newline
317 :style toggle :selected c-auto-newline]
318 ["Hungry delete" c-toggle-hungry-state
319 :style toggle :selected c-hungry-delete-key]
320 ["Subword mode" subword-mode
321 :style toggle :selected (and (boundp 'subword-mode)
322 subword-mode)])))
325 ;;; Syntax tables.
327 (defun c-populate-syntax-table (table)
328 "Populate the given syntax table as necessary for a C-like language.
329 This includes setting ' and \" as string delimiters, and setting up
330 the comment syntax to handle both line style \"//\" and block style
331 \"/*\" \"*/\" comments."
333 (modify-syntax-entry ?_ "_" table)
334 (modify-syntax-entry ?\\ "\\" table)
335 (modify-syntax-entry ?+ "." table)
336 (modify-syntax-entry ?- "." table)
337 (modify-syntax-entry ?= "." table)
338 (modify-syntax-entry ?% "." table)
339 (modify-syntax-entry ?< "." table)
340 (modify-syntax-entry ?> "." table)
341 (modify-syntax-entry ?& "." table)
342 (modify-syntax-entry ?| "." table)
343 (modify-syntax-entry ?\' "\"" table)
344 (modify-syntax-entry ?\240 "." table)
346 ;; Set up block and line oriented comments. The new C
347 ;; standard mandates both comment styles even in C, so since
348 ;; all languages now require dual comments, we make this the
349 ;; default.
350 (cond
351 ;; XEmacs
352 ((memq '8-bit c-emacs-features)
353 (modify-syntax-entry ?/ ". 1456" table)
354 (modify-syntax-entry ?* ". 23" table))
355 ;; Emacs
356 ((memq '1-bit c-emacs-features)
357 (modify-syntax-entry ?/ ". 124b" table)
358 (modify-syntax-entry ?* ". 23" table))
359 ;; incompatible
360 (t (error "CC Mode is incompatible with this version of Emacs")))
362 (modify-syntax-entry ?\n "> b" table)
363 ;; Give CR the same syntax as newline, for selective-display
364 (modify-syntax-entry ?\^m "> b" table))
366 (c-lang-defconst c-make-mode-syntax-table
367 "Functions that generates the mode specific syntax tables.
368 The syntax tables aren't stored directly since they're quite large."
369 t `(lambda ()
370 (let ((table (make-syntax-table)))
371 (c-populate-syntax-table table)
372 ;; Mode specific syntaxes.
373 ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode))
374 ;; Let '@' be part of symbols in ObjC to cope with
375 ;; its compiler directives as single keyword tokens.
376 ;; This is then necessary since it's assumed that
377 ;; every keyword is a single symbol.
378 `(modify-syntax-entry ?@ "_" table))
379 ((c-major-mode-is 'pike-mode)
380 `(modify-syntax-entry ?@ "." table)))
381 table)))
383 (c-lang-defconst c-mode-syntax-table
384 ;; The syntax tables in evaluated form. Only used temporarily when
385 ;; the constants in this file are evaluated.
386 t (funcall (c-lang-const c-make-mode-syntax-table)))
388 (c-lang-defconst c++-make-template-syntax-table
389 ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
390 ;; parenthesis characters. Used temporarily when template argument
391 ;; lists are parsed. Note that this encourages incorrect parsing of
392 ;; templates since they might contain normal operators that uses the
393 ;; '<' and '>' characters. Therefore this syntax table might go
394 ;; away when CC Mode handles templates correctly everywhere.
395 t nil
396 (java c++) `(lambda ()
397 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
398 (modify-syntax-entry ?< "(>" table)
399 (modify-syntax-entry ?> ")<" table)
400 table)))
401 (c-lang-defvar c++-template-syntax-table
402 (and (c-lang-const c++-make-template-syntax-table)
403 (funcall (c-lang-const c++-make-template-syntax-table))))
405 (c-lang-defconst c-no-parens-syntax-table
406 ;; A variant of the standard syntax table which is used to find matching
407 ;; "<"s and ">"s which have been marked as parens using syntax table
408 ;; properties. The other paren characters (e.g. "{", ")" "]") are given a
409 ;; non-paren syntax here. so that the list commands will work on "< ... >"
410 ;; even when there's unbalanced other parens inside them.
412 ;; This variable is nil for languages which don't have template stuff.
413 t `(lambda ()
414 (if (c-lang-const c-recognize-<>-arglists)
415 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
416 (modify-syntax-entry ?\( "." table)
417 (modify-syntax-entry ?\) "." table)
418 (modify-syntax-entry ?\[ "." table)
419 (modify-syntax-entry ?\] "." table)
420 (modify-syntax-entry ?\{ "." table)
421 (modify-syntax-entry ?\} "." table)
422 table))))
423 (c-lang-defvar c-no-parens-syntax-table
424 (funcall (c-lang-const c-no-parens-syntax-table)))
426 (c-lang-defconst c-identifier-syntax-modifications
427 "A list that describes the modifications that should be done to the
428 mode syntax table to get a syntax table that matches all identifiers
429 and keywords as words.
431 The list is just like the one used in `font-lock-defaults': Each
432 element is a cons where the car is the character to modify and the cdr
433 the new syntax, as accepted by `modify-syntax-entry'."
434 ;; The $ character is not allowed in most languages (one exception
435 ;; is Java which allows it for legacy reasons) but we still classify
436 ;; it as an identifier character since it's often used in various
437 ;; machine generated identifiers.
438 t '((?_ . "w") (?$ . "w"))
439 (objc java) (append '((?@ . "w"))
440 (c-lang-const c-identifier-syntax-modifications))
441 awk '((?_ . "w")))
442 (c-lang-defvar c-identifier-syntax-modifications
443 (c-lang-const c-identifier-syntax-modifications))
445 (c-lang-defvar c-identifier-syntax-table
446 (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
447 (mods c-identifier-syntax-modifications)
448 mod)
449 (while mods
450 (setq mod (car mods)
451 mods (cdr mods))
452 (modify-syntax-entry (car mod) (cdr mod) table))
453 table)
454 "Syntax table built on the mode syntax table but additionally
455 classifies symbol constituents like '_' and '$' as word constituents,
456 so that all identifiers are recognized as words.")
458 (c-lang-defconst c-get-state-before-change-functions
459 ;; For documentation see the following c-lang-defvar of the same name.
460 ;; The value here may be a list of functions or a single function.
461 t nil
462 c++ '(c-extend-region-for-CPP c-before-change-check-<>-operators)
463 (c objc) 'c-extend-region-for-CPP
464 ;; java 'c-before-change-check-<>-operators
465 awk 'c-awk-record-region-clear-NL)
466 (c-lang-defvar c-get-state-before-change-functions
467 (let ((fs (c-lang-const c-get-state-before-change-functions)))
468 (if (listp fs)
470 (list fs)))
471 "If non-nil, a list of functions called from c-before-change-hook.
472 Typically these will record enough state to allow
473 `c-before-font-lock-function' to extend the region to fontify,
474 and may do such things as removing text-properties which must be
475 recalculated.
477 These functions will be run in the order given. Each of them
478 takes 2 parameters, the BEG and END supplied to every
479 before-change function; on entry, the buffer will have been
480 widened and match-data will have been saved; point is undefined
481 on both entry and exit; the return value is ignored.
483 The functions are called even when font locking isn't enabled.
485 When the mode is initialized, the functions are called with
486 parameters \(point-min) and \(point-max).")
488 (c-lang-defconst c-before-font-lock-functions
489 ;; For documentation see the following c-lang-defvar of the same name.
490 ;; The value here may be a list of functions or a single function.
491 t 'c-change-set-fl-decl-start
492 (c c++ objc) '(c-neutralize-syntax-in-and-mark-CPP
493 c-change-set-fl-decl-start)
494 awk 'c-awk-extend-and-syntax-tablify-region)
495 (c-lang-defvar c-before-font-lock-functions
496 (let ((fs (c-lang-const c-before-font-lock-functions)))
497 (if (listp fs)
499 (list fs)))
500 "If non-nil, a list of functions called just before font locking.
501 Typically they will extend the region about to be fontified \(see
502 below) and will set `syntax-table' text properties on the region.
504 These functions will be run in the order given. Each of them
505 takes 3 parameters, the BEG, END, and OLD-LEN supplied to every
506 after-change function; point is undefined on both entry and exit;
507 on entry, the buffer will have been widened and match-data will
508 have been saved; the return value is ignored.
510 The functions may extend the region to be fontified by setting the
511 buffer local variables c-new-BEG and c-new-END.
513 The functions are called even when font locking is disabled.
515 When the mode is initialized, these functions are called with
516 parameters \(point-min), \(point-max) and <buffer size>.")
518 (c-lang-defconst c-before-context-fontification-functions
519 awk nil
520 t 'c-context-set-fl-decl-start)
521 ;; For documentation see the following c-lang-defvar of the same name.
522 ;; The value here may be a list of functions or a single function.
523 (c-lang-defvar c-before-context-fontification-functions
524 (let ((fs (c-lang-const c-before-context-fontification-functions)))
525 (if (listp fs)
527 (list fs)))
528 "If non-nil, a list of functions called just before context (or
529 other non-change) fontification is done. Typically they will
530 extend the region.
532 These functions will be run in the order given. Each of them
533 takes 2 parameters, the BEG and END of the region to be
534 fontified. Point is undefined on both entry and exit. On entry,
535 the buffer will have been widened and match-data will have been
536 saved; the return value is a cons of the adjusted
537 region, (NEW-BEG . NEW-END).")
540 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
541 (c-lang-defconst c-at-vsemi-p-fn
542 "Contains a function \"Is there a virtual semicolon at POS or point?\".
543 Such a function takes one optional parameter, a buffer position (defaults to
544 point), and returns nil or t. This variable contains nil for languages which
545 don't have EOL terminated statements. "
546 t nil
547 (c c++ objc) 'c-at-macro-vsemi-p
548 awk 'c-awk-at-vsemi-p)
549 (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn))
551 (c-lang-defconst c-vsemi-status-unknown-p-fn
552 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
553 The (admittedly kludgy) purpose of such a function is to prevent an infinite
554 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
555 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
556 even indirectly. This variable contains nil for languages which don't have
557 EOL terminated statements."
558 t nil
559 (c c++ objc) 'c-macro-vsemi-status-unknown-p
560 awk 'c-awk-vsemi-status-unknown-p)
561 (c-lang-defvar c-vsemi-status-unknown-p-fn
562 (c-lang-const c-vsemi-status-unknown-p-fn))
565 ;;; Lexer-level syntax (identifiers, tokens etc).
567 (c-lang-defconst c-has-bitfields
568 "Whether the language has bitfield declarations."
569 t nil
570 (c c++ objc) t)
571 (c-lang-defvar c-has-bitfields (c-lang-const c-has-bitfields))
573 (c-lang-defconst c-symbol-start
574 "Regexp that matches the start of a symbol, i.e. any identifier or
575 keyword. It's unspecified how far it matches. Does not contain a \\|
576 operator at the top level."
577 t (concat "[" c-alpha "_]")
578 java (concat "[" c-alpha "_@]")
579 objc (concat "[" c-alpha "@]")
580 pike (concat "[" c-alpha "_`]"))
581 (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))
583 (c-lang-defconst c-symbol-chars
584 "Set of characters that can be part of a symbol.
585 This is of the form that fits inside [ ] in a regexp."
586 ;; Pike note: With the backquote identifiers this would include most
587 ;; operator chars too, but they are handled with other means instead.
588 t (concat c-alnum "_$")
589 objc (concat c-alnum "_$@"))
590 (c-lang-defvar c-symbol-chars (c-lang-const c-symbol-chars))
592 (c-lang-defconst c-symbol-key
593 "Regexp matching identifiers and keywords (with submatch 0). Assumed
594 to match if `c-symbol-start' matches on the same position."
595 t (concat (c-lang-const c-symbol-start)
596 "[" (c-lang-const c-symbol-chars) "]*")
597 pike (concat
598 ;; Use the value from C here since the operator backquote is
599 ;; covered by the other alternative.
600 (c-lang-const c-symbol-key c)
601 "\\|"
602 (c-make-keywords-re nil
603 (c-lang-const c-overloadable-operators))))
604 (c-lang-defvar c-symbol-key (c-lang-const c-symbol-key))
606 (c-lang-defconst c-symbol-key-depth
607 ;; Number of regexp grouping parens in `c-symbol-key'.
608 t (regexp-opt-depth (c-lang-const c-symbol-key)))
610 (c-lang-defconst c-nonsymbol-chars
611 "This is the set of chars that can't be part of a symbol, i.e. the
612 negation of `c-symbol-chars'."
613 t (concat "^" (c-lang-const c-symbol-chars)))
614 (c-lang-defvar c-nonsymbol-chars (c-lang-const c-nonsymbol-chars))
616 (c-lang-defconst c-nonsymbol-key
617 "Regexp that matches any character that can't be part of a symbol.
618 It's usually appended to other regexps to avoid matching a prefix.
619 It's assumed to not contain any submatchers."
620 ;; The same thing regarding Unicode identifiers applies here as to
621 ;; `c-symbol-key'.
622 t (concat "[" (c-lang-const c-nonsymbol-chars) "]"))
624 (c-lang-defconst c-identifier-ops
625 "The operators that make up fully qualified identifiers. nil in
626 languages that don't have such things. See `c-operators' for a
627 description of the format. Binary operators can concatenate symbols,
628 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
629 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
631 This value is by default merged into `c-operators'."
632 t nil
633 c++ '((prefix "~" "??-" "compl")
634 (right-assoc "::")
635 (prefix "::"))
636 ;; Java has "." to concatenate identifiers but it's also used for
637 ;; normal indexing. There's special code in the Java font lock
638 ;; rules to fontify qualified identifiers based on the standard
639 ;; naming conventions. We still define "." here to make
640 ;; `c-forward-name' move over as long names as possible which is
641 ;; necessary to e.g. handle throws clauses correctly.
642 java '((left-assoc "."))
643 idl '((left-assoc "::")
644 (prefix "::"))
645 pike '((left-assoc "::")
646 (prefix "::")
647 (left-assoc ".")))
649 (c-lang-defconst c-opt-identifier-concat-key
650 ;; Appendable adorned regexp matching the operators that join
651 ;; symbols to fully qualified identifiers, or nil in languages that
652 ;; don't have such things.
654 ;; This was a docstring constant in 5.30. It still works but is now
655 ;; considered internal - change `c-identifier-ops' instead.
656 t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
657 '(left-assoc right-assoc)
658 t)))
659 (when ops
660 (c-make-keywords-re 'appendable ops))))
661 (c-lang-defvar c-opt-identifier-concat-key
662 (c-lang-const c-opt-identifier-concat-key)
663 'dont-doc)
665 (c-lang-defconst c-opt-identifier-concat-key-depth
666 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
667 t (regexp-opt-depth (c-lang-const c-opt-identifier-concat-key)))
669 (c-lang-defconst c-opt-identifier-prefix-key
670 ;; Appendable adorned regexp matching operators that might precede
671 ;; an identifier and that are part of the identifier in that case.
672 ;; nil in languages without such things.
673 t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
674 '(prefix)
675 t)))
676 (when ops
677 (c-make-keywords-re 'appendable ops))))
679 (c-lang-defconst c-after-id-concat-ops
680 "Operators that can occur after a binary operator on `c-identifier-ops'
681 in identifiers. nil in languages that don't have such things.
683 Operators here should also have appropriate entries in `c-operators' -
684 it's not taken care of by default."
685 t nil
686 ;; '~' for destructors in C++, '*' for member pointers.
687 c++ '("~" "*")
688 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
689 ;; in import declarations. (This will also match bogus things like
690 ;; "foo.*bar" but we don't bother.)
691 java '("*"))
693 (c-lang-defconst c-opt-after-id-concat-key
694 ;; Regexp that must match the token after
695 ;; `c-opt-identifier-concat-key' for it to be considered an
696 ;; identifier concatenation operator (which e.g. causes the
697 ;; preceding identifier to be fontified as a reference). Assumed to
698 ;; be a string if `c-opt-identifier-concat-key' is.
700 ;; This was a docstring constant in 5.30. It still works but is now
701 ;; considered internal - change `c-after-id-concat-ops' instead.
702 t (concat (c-lang-const c-symbol-start)
703 (if (c-lang-const c-after-id-concat-ops)
704 (concat "\\|" (c-make-keywords-re 'appendable
705 (c-lang-const c-after-id-concat-ops)))
706 "")))
708 (c-lang-defconst c-identifier-start
709 "Regexp that matches the start of an (optionally qualified) identifier.
710 It should also match all keywords. It's unspecified how far it
711 matches."
712 t (concat (c-lang-const c-symbol-start)
713 (if (c-lang-const c-opt-identifier-prefix-key)
714 (concat "\\|"
715 (c-lang-const c-opt-identifier-prefix-key))
716 "")))
717 (c-lang-defvar c-identifier-start (c-lang-const c-identifier-start))
719 (c-lang-defconst c-identifier-key
720 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
721 C++. It does not recognize the full range of syntactic whitespace
722 between the tokens; `c-forward-name' has to be used for that. It
723 should also not match identifiers containing parenthesis groupings,
724 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
725 ;; This regexp is more complex than strictly necessary to ensure
726 ;; that it can be matched with a minimum of backtracking.
727 t (concat (if (c-lang-const c-opt-identifier-prefix-key)
728 (concat
729 "\\("
730 (c-lang-const c-opt-identifier-prefix-key)
731 (c-lang-const c-simple-ws) "*"
732 "\\)?")
734 "\\(" (c-lang-const c-symbol-key) "\\)"
735 (if (c-lang-const c-opt-identifier-concat-key)
736 (concat
737 "\\("
738 (c-lang-const c-simple-ws) "*"
739 (c-lang-const c-opt-identifier-concat-key)
740 (c-lang-const c-simple-ws) "*"
741 (if (c-lang-const c-after-id-concat-ops)
742 (concat
743 "\\("
744 (c-make-keywords-re 'appendable
745 (c-lang-const c-after-id-concat-ops))
746 (concat
747 ;; For flexibility, consider the symbol match
748 ;; optional if we've hit a
749 ;; `c-after-id-concat-ops' operator. This is
750 ;; also necessary to handle the "*" that can
751 ;; end import declaration identifiers in Java.
752 "\\("
753 (c-lang-const c-simple-ws) "*"
754 "\\(" (c-lang-const c-symbol-key) "\\)"
755 "\\)?")
756 "\\|"
757 "\\(" (c-lang-const c-symbol-key) "\\)"
758 "\\)")
759 (concat "\\(" (c-lang-const c-symbol-key) "\\)"))
760 "\\)*")
761 "")))
762 (c-lang-defvar c-identifier-key (c-lang-const c-identifier-key))
764 (c-lang-defconst c-identifier-last-sym-match
765 ;; This was a docstring constant in 5.30 but it's no longer used.
766 ;; It's only kept to avoid breaking third party code.
768 ;; Used to identify the submatch in `c-identifier-key' that
769 ;; surrounds the last symbol in the qualified identifier. It's a
770 ;; list of submatch numbers, of which the first that has a match is
771 ;; taken. It's assumed that at least one does when the regexp has
772 ;; matched.
773 t nil)
775 (c-lang-defconst c-string-escaped-newlines
776 "Set if the language support backslash escaped newlines inside string
777 literals."
778 t nil
779 (c c++ objc pike) t)
780 (c-lang-defvar c-string-escaped-newlines
781 (c-lang-const c-string-escaped-newlines))
783 (c-lang-defconst c-multiline-string-start-char
784 "Set if the language supports multiline string literals without escaped
785 newlines. If t, all string literals are multiline. If a character,
786 only literals where the open quote is immediately preceded by that
787 literal are multiline."
788 t nil
789 pike ?#)
790 (c-lang-defvar c-multiline-string-start-char
791 (c-lang-const c-multiline-string-start-char))
793 (c-lang-defconst c-opt-cpp-symbol
794 "The symbol which starts preprocessor constructs when in the margin."
795 t "#"
796 (java awk) nil)
797 (c-lang-defvar c-opt-cpp-symbol (c-lang-const c-opt-cpp-symbol))
799 (c-lang-defconst c-opt-cpp-prefix
800 "Regexp matching the prefix of a cpp directive in the languages that
801 normally use that macro preprocessor. Tested at bol or at boi.
802 Assumed to not contain any submatches or \\| operators."
803 ;; TODO (ACM, 2005-04-01). Amend the following to recognize escaped NLs;
804 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
805 t "\\s *#\\s *"
806 (java awk) nil)
807 (c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix))
809 (c-lang-defconst c-anchored-cpp-prefix
810 "Regexp matching the prefix of a cpp directive anchored to BOL,
811 in the languages that have a macro preprocessor."
812 t (if (c-lang-const c-opt-cpp-prefix)
813 (concat "^" (c-lang-const c-opt-cpp-prefix))))
814 (c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
816 (c-lang-defconst c-opt-cpp-start
817 "Regexp matching the prefix of a cpp directive including the directive
818 name, or nil in languages without preprocessor support. The first
819 submatch surrounds the directive name."
820 t (if (c-lang-const c-opt-cpp-prefix)
821 (concat (c-lang-const c-opt-cpp-prefix)
822 "\\([" c-alnum "]+\\)"))
823 ;; Pike, being a scripting language, recognizes hash-bangs too.
824 pike (concat (c-lang-const c-opt-cpp-prefix)
825 "\\([" c-alnum "]+\\|!\\)"))
826 (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start))
828 (c-lang-defconst c-cpp-message-directives
829 "List of cpp directives (without the prefix) that are followed by a
830 string message."
831 t (if (c-lang-const c-opt-cpp-prefix)
832 '("error"))
833 (c c++ objc pike) '("error" "warning"))
835 (c-lang-defconst c-cpp-include-directives
836 "List of cpp directives (without the prefix) that are followed by a
837 file name in angle brackets or quotes."
838 t (if (c-lang-const c-opt-cpp-prefix)
839 '("include"))
840 objc '("include" "import"))
842 (c-lang-defconst c-opt-cpp-macro-define
843 "Cpp directive (without the prefix) that is followed by a macro
844 definition, or nil if the language doesn't have any."
845 t (if (c-lang-const c-opt-cpp-prefix)
846 "define"))
847 (c-lang-defvar c-opt-cpp-macro-define
848 (c-lang-const c-opt-cpp-macro-define))
850 (c-lang-defconst c-opt-cpp-macro-define-start
851 ;; Regexp matching everything up to the macro body of a cpp define, or the
852 ;; end of the logical line if there is none. Submatch 1 is the name of the
853 ;; macro. Set if c-opt-cpp-macro-define is.
854 t (if (c-lang-const c-opt-cpp-macro-define)
855 (concat (c-lang-const c-opt-cpp-prefix)
856 (c-lang-const c-opt-cpp-macro-define)
857 "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(\([^\)]*\)\\)?"
858 ;; ^ ^ #defined name
859 "\\([ \t]\\|\\\\\n\\)*")))
860 (c-lang-defvar c-opt-cpp-macro-define-start
861 (c-lang-const c-opt-cpp-macro-define-start))
863 (c-lang-defconst c-opt-cpp-macro-define-id
864 ;; Regexp matching everything up to the end of the identifier defined
865 ;; by a cpp define.
866 t (if (c-lang-const c-opt-cpp-macro-define)
867 (concat (c-lang-const c-opt-cpp-prefix) ; #
868 (c-lang-const c-opt-cpp-macro-define) ; define
869 "[ \t]+\\(\\sw\\|_\\)+")))
870 (c-lang-defvar c-opt-cpp-macro-define-id
871 (c-lang-const c-opt-cpp-macro-define-id))
873 (c-lang-defconst c-cpp-expr-directives
874 "List of cpp directives (without the prefix) that are followed by an
875 expression."
876 t (if (c-lang-const c-opt-cpp-prefix)
877 '("if" "elif")))
879 (c-lang-defconst c-cpp-expr-intro-re
880 "Regexp which matches the start of a CPP directive which contains an
881 expression, or nil if there aren't any in the language."
882 t (if (c-lang-const c-cpp-expr-directives)
883 (concat
884 (c-lang-const c-opt-cpp-prefix)
885 (c-make-keywords-re t (c-lang-const c-cpp-expr-directives)))))
886 (c-lang-defvar c-cpp-expr-intro-re
887 (c-lang-const c-cpp-expr-intro-re))
889 (c-lang-defconst c-cpp-expr-functions
890 "List of functions in cpp expressions."
891 t (if (c-lang-const c-opt-cpp-prefix)
892 '("defined"))
893 pike '("defined" "efun" "constant"))
895 (c-lang-defconst c-assignment-operators
896 "List of all assignment operators."
897 t '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
898 java (append (c-lang-const c-assignment-operators)
899 '(">>>="))
900 c++ (append (c-lang-const c-assignment-operators)
901 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
902 idl nil)
904 (c-lang-defconst c-operators
905 "List describing all operators, along with their precedence and
906 associativity. The order in the list corresponds to the precedence of
907 the operators: The operators in each element are a group with the same
908 precedence, and the group has higher precedence than the groups in all
909 following elements. The car of each element describes the type of the
910 operator group, and the cdr is a list of the operator tokens in it.
911 The operator group types are:
913 'prefix Unary prefix operators.
914 'postfix Unary postfix operators.
915 'postfix-if-paren
916 Unary postfix operators if and only if the chars have
917 parenthesis syntax.
918 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
919 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
920 'right-assoc-sequence
921 Right associative operator that constitutes of a
922 sequence of tokens that separate expressions. All the
923 tokens in the group are in this case taken as
924 describing the sequence in one such operator, and the
925 order between them is therefore significant.
927 Operators containing a character with paren syntax are taken to match
928 with a corresponding open/close paren somewhere else. A postfix
929 operator with close paren syntax is taken to end a postfix expression
930 started somewhere earlier, rather than start a new one at point. Vice
931 versa for prefix operators with open paren syntax.
933 Note that operators like \".\" and \"->\" which in language references
934 often are described as postfix operators are considered binary here,
935 since CC Mode treats every identifier as an expression."
937 ;; There's currently no code in CC Mode that exploit all the info
938 ;; in this variable; precedence, associativity etc are present as a
939 ;; preparation for future work.
941 t `(;; Preprocessor.
942 ,@(when (c-lang-const c-opt-cpp-prefix)
943 `((prefix "#"
944 ,@(when (c-major-mode-is '(c-mode c++-mode))
945 '("%:" "??=")))
946 (left-assoc "##"
947 ,@(when (c-major-mode-is '(c-mode c++-mode))
948 '("%:%:" "??=??=")))))
950 ;; Primary.
951 ,@(c-lang-const c-identifier-ops)
952 ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode))
953 `((postfix-if-paren "<" ">"))) ; Templates.
954 ((c-major-mode-is 'pike-mode)
955 `((prefix "global" "predef")))
956 ((c-major-mode-is 'java-mode)
957 `((prefix "super"))))
959 ;; Postfix.
960 ,@(when (c-major-mode-is 'c++-mode)
961 ;; The following need special treatment.
962 `((prefix "dynamic_cast" "static_cast"
963 "reinterpret_cast" "const_cast" "typeid")))
964 (left-assoc "."
965 ,@(unless (c-major-mode-is 'java-mode)
966 '("->")))
967 (postfix "++" "--" "[" "]" "(" ")"
968 ,@(when (c-major-mode-is '(c-mode c++-mode))
969 '("<:" ":>" "??(" "??)")))
971 ;; Unary.
972 (prefix "++" "--" "+" "-" "!" "~"
973 ,@(when (c-major-mode-is 'c++-mode) '("not" "compl"))
974 ,@(when (c-major-mode-is '(c-mode c++-mode))
975 '("*" "&" "sizeof" "??-"))
976 ,@(when (c-major-mode-is 'objc-mode)
977 '("@selector" "@protocol" "@encode"))
978 ;; The following need special treatment.
979 ,@(cond ((c-major-mode-is 'c++-mode)
980 '("new" "delete"))
981 ((c-major-mode-is 'java-mode)
982 '("new"))
983 ((c-major-mode-is 'pike-mode)
984 '("class" "lambda" "catch" "throw" "gauge")))
985 "(" ")" ; Cast.
986 ,@(when (c-major-mode-is 'pike-mode)
987 '("[" "]"))) ; Type cast.
989 ;; Member selection.
990 ,@(when (c-major-mode-is 'c++-mode)
991 `((left-assoc ".*" "->*")))
993 ;; Multiplicative.
994 (left-assoc "*" "/" "%")
996 ;; Additive.
997 (left-assoc "+" "-")
999 ;; Shift.
1000 (left-assoc "<<" ">>"
1001 ,@(when (c-major-mode-is 'java-mode)
1002 '(">>>")))
1004 ;; Relational.
1005 (left-assoc "<" ">" "<=" ">="
1006 ,@(when (c-major-mode-is 'java-mode)
1007 '("instanceof")))
1009 ;; Equality.
1010 (left-assoc "==" "!="
1011 ,@(when (c-major-mode-is 'c++-mode) '("not_eq")))
1013 ;; Bitwise and.
1014 (left-assoc "&"
1015 ,@(when (c-major-mode-is 'c++-mode) '("bitand")))
1017 ;; Bitwise exclusive or.
1018 (left-assoc "^"
1019 ,@(when (c-major-mode-is '(c-mode c++-mode))
1020 '("??'"))
1021 ,@(when (c-major-mode-is 'c++-mode) '("xor")))
1023 ;; Bitwise or.
1024 (left-assoc "|"
1025 ,@(when (c-major-mode-is '(c-mode c++-mode))
1026 '("??!"))
1027 ,@(when (c-major-mode-is 'c++-mode) '("bitor")))
1029 ;; Logical and.
1030 (left-assoc "&&"
1031 ,@(when (c-major-mode-is 'c++-mode) '("and")))
1033 ;; Logical or.
1034 (left-assoc "||"
1035 ,@(when (c-major-mode-is '(c-mode c++-mode))
1036 '("??!??!"))
1037 ,@(when (c-major-mode-is 'c++-mode) '("or")))
1039 ;; Conditional.
1040 (right-assoc-sequence "?" ":")
1042 ;; Assignment.
1043 (right-assoc ,@(c-lang-const c-assignment-operators))
1045 ;; Exception.
1046 ,@(when (c-major-mode-is 'c++-mode)
1047 '((prefix "throw")))
1049 ;; Sequence.
1050 (left-assoc ","))
1052 ;; IDL got its own definition since it has a much smaller operator
1053 ;; set than the other languages.
1054 idl `(;; Preprocessor.
1055 (prefix "#")
1056 (left-assoc "##")
1057 ;; Primary.
1058 ,@(c-lang-const c-identifier-ops)
1059 ;; Unary.
1060 (prefix "+" "-" "~")
1061 ;; Multiplicative.
1062 (left-assoc "*" "/" "%")
1063 ;; Additive.
1064 (left-assoc "+" "-")
1065 ;; Shift.
1066 (left-assoc "<<" ">>")
1067 ;; And.
1068 (left-assoc "&")
1069 ;; Xor.
1070 (left-assoc "^")
1071 ;; Or.
1072 (left-assoc "|")))
1074 (c-lang-defconst c-operator-list
1075 ;; The operators as a flat list (without duplicates).
1076 t (c-filter-ops (c-lang-const c-operators) t t))
1078 (c-lang-defconst c-overloadable-operators
1079 "List of the operators that are overloadable, in their \"identifier
1080 form\". See also `c-op-identifier-prefix'."
1081 t nil
1082 c++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
1083 "+" "-" "*" "/" "%"
1084 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
1085 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
1086 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
1087 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
1088 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
1089 "()" "[]" "<::>" "??(??)")
1090 ;; These work like identifiers in Pike.
1091 pike '("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
1092 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
1093 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
1094 "`+="))
1096 (c-lang-defconst c-overloadable-operators-regexp
1097 ;; Regexp tested after an "operator" token in C++.
1098 t nil
1099 c++ (c-make-keywords-re nil (c-lang-const c-overloadable-operators)))
1100 (c-lang-defvar c-overloadable-operators-regexp
1101 (c-lang-const c-overloadable-operators-regexp))
1103 (c-lang-defconst c-opt-op-identifier-prefix
1104 "Regexp matching the token before the ones in
1105 `c-overloadable-operators' when operators are specified in their
1106 \"identifier form\". This typically matches \"operator\" in C++ where
1107 operator functions are specified as e.g. \"operator +\". It's nil in
1108 languages without operator functions or where the complete operator
1109 identifier is listed in `c-overloadable-operators'.
1111 This regexp is assumed to not match any non-operator identifier."
1112 t nil
1113 c++ (c-make-keywords-re t '("operator")))
1114 (c-lang-defvar c-opt-op-identifier-prefix
1115 (c-lang-const c-opt-op-identifier-prefix))
1117 ;; Note: the following alias is an old name which was a mis-spelling. It has
1118 ;; been corrected above and throughout cc-engine.el. It will be removed at
1119 ;; some release very shortly in the future. ACM, 2006-04-14.
1120 (defvaralias 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix)
1121 (make-obsolete-variable 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix
1122 "CC Mode 5.31.4, 2006-04-14")
1124 (c-lang-defconst c-other-op-syntax-tokens
1125 "List of the tokens made up of characters in the punctuation or
1126 parenthesis syntax classes that have uses other than as expression
1127 operators."
1128 t '("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
1129 (c c++ pike) (append '("#" "##" ; Used by cpp.
1130 "::" "...")
1131 (c-lang-const c-other-op-syntax-tokens))
1132 (c c++) (append '("*") (c-lang-const c-other-op-syntax-tokens))
1133 c++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
1134 (c-lang-const c-other-op-syntax-tokens))
1135 objc (append '("#" "##" ; Used by cpp.
1136 "+" "-") (c-lang-const c-other-op-syntax-tokens))
1137 idl (append '("#" "##") ; Used by cpp.
1138 (c-lang-const c-other-op-syntax-tokens))
1139 pike (append '("..")
1140 (c-lang-const c-other-op-syntax-tokens)
1141 (c-lang-const c-overloadable-operators))
1142 awk '("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
1144 (c-lang-defconst c-all-op-syntax-tokens
1145 ;; List of all tokens in the punctuation and parenthesis syntax
1146 ;; classes.
1147 t (delete-duplicates (append (c-lang-const c-other-op-syntax-tokens)
1148 (c-lang-const c-operator-list))
1149 :test 'string-equal))
1151 (c-lang-defconst c-nonsymbol-token-char-list
1152 ;; List containing all chars not in the word, symbol or
1153 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
1154 ;; parenthesis and string delimiter chars.
1155 t (c-with-syntax-table (c-lang-const c-mode-syntax-table)
1156 ;; Only go through the chars in the printable ASCII range. No
1157 ;; language so far has 8-bit or widestring operators.
1158 (let (list (char 32))
1159 (while (< char 127)
1160 (or (memq (char-syntax char) '(?w ?_ ?< ?> ?\ ))
1161 (setq list (cons (c-int-to-char char) list)))
1162 (setq char (1+ char)))
1163 list)))
1165 (c-lang-defconst c-nonsymbol-token-regexp
1166 ;; Regexp matching all tokens in the punctuation and parenthesis
1167 ;; syntax classes. Note that this also matches ".", which can start
1168 ;; a float.
1169 t (c-make-keywords-re nil
1170 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
1172 "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
1173 (c-lang-defvar c-nonsymbol-token-regexp
1174 (c-lang-const c-nonsymbol-token-regexp))
1176 (c-lang-defconst c-assignment-op-regexp
1177 ;; Regexp matching all assignment operators and only them. The
1178 ;; beginning of the first submatch is used to detect the end of the
1179 ;; token, along with the end of the whole match.
1180 t (if (c-lang-const c-assignment-operators)
1181 (concat
1182 ;; Need special case for "=" since it's a prefix of "==".
1183 "=\\([^=]\\|$\\)"
1184 "\\|"
1185 (c-make-keywords-re nil
1186 (set-difference (c-lang-const c-assignment-operators)
1187 '("=")
1188 :test 'string-equal)))
1189 "\\<\\>"))
1190 (c-lang-defvar c-assignment-op-regexp
1191 (c-lang-const c-assignment-op-regexp))
1193 (c-lang-defconst c-<>-multichar-token-regexp
1194 ;; Regexp matching all tokens containing "<" or ">" which are longer
1195 ;; than one char.
1196 t (c-make-keywords-re nil
1197 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
1199 ".[<>]\\|[<>].")))
1200 (c-lang-defvar c-<>-multichar-token-regexp
1201 (c-lang-const c-<>-multichar-token-regexp))
1203 (c-lang-defconst c-<-op-cont-regexp
1204 ;; Regexp matching the second and subsequent characters of all
1205 ;; multicharacter tokens that begin with "<".
1206 t (c-make-keywords-re nil
1207 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
1209 "\\`<."
1210 (lambda (op) (substring op 1)))))
1212 (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
1214 (c-lang-defconst c->-op-cont-regexp
1215 ;; Regexp matching the second and subsequent characters of all
1216 ;; multicharacter tokens that begin with ">".
1217 t (c-make-keywords-re nil
1218 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
1220 "\\`>."
1221 (lambda (op) (substring op 1))))
1222 java (c-make-keywords-re nil
1223 (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
1225 "\\`>[^>]\\|\\`>>[^>]"
1226 (lambda (op) (substring op 1)))))
1228 (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
1230 (c-lang-defconst c-stmt-delim-chars
1231 ;; The characters that should be considered to bound statements. To
1232 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1233 ;; begin with "^" to negate the set. If ? : operators should be
1234 ;; detected then the string must end with "?:".
1235 t "^;{}?:")
1236 (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars))
1238 (c-lang-defconst c-stmt-delim-chars-with-comma
1239 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1240 t "^;,{}?:")
1241 (c-lang-defvar c-stmt-delim-chars-with-comma
1242 (c-lang-const c-stmt-delim-chars-with-comma))
1245 ;;; Syntactic whitespace.
1247 (c-lang-defconst c-simple-ws
1248 "Regexp matching an ordinary whitespace character.
1249 Does not contain a \\| operator at the top level."
1250 ;; "\\s " is not enough since it doesn't match line breaks.
1251 t "\\(\\s \\|[\n\r]\\)")
1253 (c-lang-defconst c-simple-ws-depth
1254 ;; Number of regexp grouping parens in `c-simple-ws'.
1255 t (regexp-opt-depth (c-lang-const c-simple-ws)))
1257 (c-lang-defconst c-line-comment-starter
1258 "String that starts line comments, or nil if such don't exist.
1259 Line comments are always terminated by newlines. At least one of
1260 `c-block-comment-starter' and this one is assumed to be set.
1262 Note that it's currently not enough to set this to support a new
1263 comment style. Other stuff like the syntax table must also be set up
1264 properly."
1265 t "//"
1266 awk "#")
1267 (c-lang-defvar c-line-comment-starter (c-lang-const c-line-comment-starter))
1269 (c-lang-defconst c-block-comment-starter
1270 "String that starts block comments, or nil if such don't exist.
1271 Block comments are ended by `c-block-comment-ender', which is assumed
1272 to be set if this is. At least one of `c-line-comment-starter' and
1273 this one is assumed to be set.
1275 Note that it's currently not enough to set this to support a new
1276 comment style. Other stuff like the syntax table must also be set up
1277 properly."
1278 t "/*"
1279 awk nil)
1281 (c-lang-defconst c-block-comment-ender
1282 "String that ends block comments, or nil if such don't exist.
1284 Note that it's currently not enough to set this to support a new
1285 comment style. Other stuff like the syntax table must also be set up
1286 properly."
1287 t "*/"
1288 awk nil)
1290 (c-lang-defconst c-comment-start-regexp
1291 ;; Regexp to match the start of any type of comment.
1292 t (let ((re (c-make-keywords-re nil
1293 (list (c-lang-const c-line-comment-starter)
1294 (c-lang-const c-block-comment-starter)))))
1295 (if (memq 'gen-comment-delim c-emacs-features)
1296 (concat re "\\|\\s!")
1297 re)))
1298 (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp))
1300 (c-lang-defconst c-block-comment-start-regexp
1301 ;; Regexp which matches the start of a block comment (if such exists in the
1302 ;; language)
1303 t (if (c-lang-const c-block-comment-starter)
1304 (regexp-quote (c-lang-const c-block-comment-starter))
1305 "\\<\\>"))
1306 (c-lang-defvar c-block-comment-start-regexp
1307 (c-lang-const c-block-comment-start-regexp))
1309 (c-lang-defconst c-line-comment-start-regexp
1310 ;; Regexp which matches the start of a line comment (if such exists in the
1311 ;; language; it does in all 7 CC Mode languages).
1312 t (if (c-lang-const c-line-comment-starter)
1313 (regexp-quote (c-lang-const c-line-comment-starter))
1314 "\\<\\>"))
1315 (c-lang-defvar c-line-comment-start-regexp
1316 (c-lang-const c-line-comment-start-regexp))
1318 (c-lang-defconst c-literal-start-regexp
1319 ;; Regexp to match the start of comments and string literals.
1320 t (concat (c-lang-const c-comment-start-regexp)
1321 "\\|"
1322 (if (memq 'gen-string-delim c-emacs-features)
1323 "\"|"
1324 "\"")))
1325 (c-lang-defvar c-literal-start-regexp (c-lang-const c-literal-start-regexp))
1327 (c-lang-defconst c-doc-comment-start-regexp
1328 "Regexp to match the start of documentation comments."
1329 t "\\<\\>"
1330 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1331 (c c++ objc) "/\\*[*!]"
1332 java "/\\*\\*"
1333 pike "/[/*]!")
1334 (c-lang-defvar c-doc-comment-start-regexp
1335 (c-lang-const c-doc-comment-start-regexp))
1337 (c-lang-defconst comment-start
1338 "String that starts comments inserted with M-; etc.
1339 `comment-start' is initialized from this."
1340 ;; Default: Prefer line comments to block comments, and pad with a space.
1341 t (concat (or (c-lang-const c-line-comment-starter)
1342 (c-lang-const c-block-comment-starter))
1343 " ")
1344 ;; In C we still default to the block comment style since line
1345 ;; comments aren't entirely portable.
1346 c "/* ")
1347 (c-lang-setvar comment-start (c-lang-const comment-start))
1349 (c-lang-defconst comment-end
1350 "String that ends comments inserted with M-; etc.
1351 `comment-end' is initialized from this."
1352 ;; Default: Use block comment style if comment-start uses block
1353 ;; comments, and pad with a space in that case.
1354 t (if (string-match (concat "\\`\\("
1355 (c-lang-const c-block-comment-start-regexp)
1356 "\\)")
1357 (c-lang-const comment-start))
1358 (concat " " (c-lang-const c-block-comment-ender))
1359 ""))
1360 (c-lang-setvar comment-end (c-lang-const comment-end))
1362 (c-lang-defconst comment-start-skip
1363 "Regexp to match the start of a comment plus everything up to its body.
1364 `comment-start-skip' is initialized from this."
1365 ;; Default: Allow the last char of the comment starter(s) to be
1366 ;; repeated, then allow any amount of horizontal whitespace.
1367 t (concat "\\("
1368 (c-concat-separated
1369 (mapcar (lambda (cs)
1370 (when cs
1371 (concat (regexp-quote cs) "+")))
1372 (list (c-lang-const c-line-comment-starter)
1373 (c-lang-const c-block-comment-starter)))
1374 "\\|")
1375 "\\)\\s *"))
1376 (c-lang-setvar comment-start-skip (c-lang-const comment-start-skip))
1378 (c-lang-defconst c-syntactic-ws-start
1379 ;; Regexp matching any sequence that can start syntactic whitespace.
1380 ;; The only uncertain case is '#' when there are cpp directives.
1381 t (concat "\\s \\|"
1382 (c-make-keywords-re nil
1383 (append (list (c-lang-const c-line-comment-starter)
1384 (c-lang-const c-block-comment-starter)
1385 (when (c-lang-const c-opt-cpp-prefix)
1386 "#"))
1387 '("\n" "\r")))
1388 "\\|\\\\[\n\r]"
1389 (when (memq 'gen-comment-delim c-emacs-features)
1390 "\\|\\s!")))
1391 (c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start))
1393 (c-lang-defconst c-syntactic-ws-end
1394 ;; Regexp matching any single character that might end syntactic whitespace.
1395 t (concat "\\s \\|"
1396 (c-make-keywords-re nil
1397 (append (when (c-lang-const c-block-comment-ender)
1398 (list
1399 (string
1400 (elt (c-lang-const c-block-comment-ender)
1401 (1- (length
1402 (c-lang-const c-block-comment-ender)))))))
1403 '("\n" "\r")))
1404 (when (memq 'gen-comment-delim c-emacs-features)
1405 "\\|\\s!")))
1406 (c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end))
1408 (c-lang-defconst c-unterminated-block-comment-regexp
1409 ;; Regexp matching an unterminated block comment that doesn't
1410 ;; contain line breaks, or nil in languages without block comments.
1411 ;; Does not contain a \| operator at the top level.
1412 t (when (c-lang-const c-block-comment-starter)
1413 (concat
1414 (regexp-quote (c-lang-const c-block-comment-starter))
1415 ;; It's messy to cook together a regexp that matches anything
1416 ;; but c-block-comment-ender.
1417 (let ((end (c-lang-const c-block-comment-ender)))
1418 (cond ((= (length end) 1)
1419 (concat "[^" end "\n\r]*"))
1420 ((= (length end) 2)
1421 (concat "[^" (substring end 0 1) "\n\r]*"
1422 "\\("
1423 (regexp-quote (substring end 0 1)) "+"
1424 "[^"
1425 ;; The quoting rules inside char classes are silly. :P
1426 (cond ((= (elt end 0) (elt end 1))
1427 (concat (substring end 0 1) "\n\r"))
1428 ((= (elt end 1) ?\])
1429 (concat (substring end 1 2) "\n\r"
1430 (substring end 0 1)))
1432 (concat (substring end 0 1) "\n\r"
1433 (substring end 1 2))))
1435 "[^" (substring end 0 1) "\n\r]*"
1436 "\\)*"))
1438 (error "Can't handle a block comment ender of length %s"
1439 (length end))))))))
1441 (c-lang-defconst c-block-comment-regexp
1442 ;; Regexp matching a block comment that doesn't contain line breaks,
1443 ;; or nil in languages without block comments. The reason we don't
1444 ;; allow line breaks is to avoid going very far and risk running out
1445 ;; of regexp stack; this regexp is intended to handle only short
1446 ;; comments that might be put in the middle of limited constructs
1447 ;; like declarations. Does not contain a \| operator at the top
1448 ;; level.
1449 t (when (c-lang-const c-unterminated-block-comment-regexp)
1450 (concat
1451 (c-lang-const c-unterminated-block-comment-regexp)
1452 (let ((end (c-lang-const c-block-comment-ender)))
1453 (cond ((= (length end) 1)
1454 (regexp-quote end))
1455 ((= (length end) 2)
1456 (concat (regexp-quote (substring end 0 1)) "+"
1457 (regexp-quote (substring end 1 2))))
1459 (error "Can't handle a block comment ender of length %s"
1460 (length end))))))))
1462 (c-lang-defconst c-nonwhite-syntactic-ws
1463 ;; Regexp matching a piece of syntactic whitespace that isn't a
1464 ;; sequence of simple whitespace characters. As opposed to
1465 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1466 ;; directives as syntactic whitespace.
1467 t (c-concat-separated
1468 (list (when (c-lang-const c-line-comment-starter)
1469 (concat (regexp-quote (c-lang-const c-line-comment-starter))
1470 "[^\n\r]*[\n\r]"))
1471 (c-lang-const c-block-comment-regexp)
1472 "\\\\[\n\r]"
1473 (when (memq 'gen-comment-delim c-emacs-features)
1474 "\\s!\\S!*\\s!"))
1475 "\\|"))
1477 (c-lang-defconst c-syntactic-ws
1478 ;; Regexp matching syntactic whitespace, including possibly the
1479 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1480 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1481 ;; not contain a \| operator at the top level.
1482 t (concat (c-lang-const c-simple-ws) "*"
1483 "\\("
1484 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws) "\\)"
1485 (c-lang-const c-simple-ws) "*")
1486 "\\)*"))
1488 (c-lang-defconst c-syntactic-ws-depth
1489 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1490 t (regexp-opt-depth (c-lang-const c-syntactic-ws)))
1492 (c-lang-defconst c-nonempty-syntactic-ws
1493 ;; Regexp matching syntactic whitespace, which is at least one
1494 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1495 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1496 ;; not contain a \| operator at the top level.
1497 t (concat "\\("
1498 (c-lang-const c-simple-ws)
1499 "\\|"
1500 (c-lang-const c-nonwhite-syntactic-ws)
1501 "\\)+"))
1503 (c-lang-defconst c-nonempty-syntactic-ws-depth
1504 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1505 t (regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws)))
1507 (c-lang-defconst c-single-line-syntactic-ws
1508 ;; Regexp matching syntactic whitespace without any line breaks. As
1509 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1510 ;; regard cpp directives as syntactic whitespace. Does not contain
1511 ;; a \| operator at the top level.
1512 t (if (c-lang-const c-block-comment-regexp)
1513 (concat "\\s *\\("
1514 (c-lang-const c-block-comment-regexp)
1515 "\\s *\\)*")
1516 "\\s *"))
1518 (c-lang-defconst c-single-line-syntactic-ws-depth
1519 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1520 t (regexp-opt-depth (c-lang-const c-single-line-syntactic-ws)))
1522 (c-lang-defconst c-syntactic-eol
1523 ;; Regexp that matches when there is no syntactically significant
1524 ;; text before eol. Macros are regarded as syntactically
1525 ;; significant text here.
1526 t (concat (c-lang-const c-single-line-syntactic-ws)
1527 ;; Match eol (possibly inside a block comment or preceded
1528 ;; by a line continuation backslash), or the beginning of a
1529 ;; line comment. Note: This has to be modified for awk
1530 ;; where line comments start with '#'.
1531 "\\("
1532 (c-concat-separated
1533 (list (when (c-lang-const c-line-comment-starter)
1534 (regexp-quote (c-lang-const c-line-comment-starter)))
1535 (when (c-lang-const c-unterminated-block-comment-regexp)
1536 (concat (c-lang-const c-unterminated-block-comment-regexp)
1537 "$"))
1538 "\\\\$"
1539 "$")
1540 "\\|")
1541 "\\)"))
1542 (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol))
1545 ;;; Defun functions
1547 ;; The Emacs variables beginning-of-defun-function and
1548 ;; end-of-defun-function will be set so that commands like
1549 ;; `mark-defun' and `narrow-to-defun' work right. The key sequences
1550 ;; C-M-a and C-M-e are, however, bound directly to the CC Mode
1551 ;; functions, allowing optimization for large n.
1552 (c-lang-defconst beginning-of-defun-function
1553 "Function to which beginning-of-defun-function will be set."
1554 t 'c-beginning-of-defun
1555 awk 'c-awk-beginning-of-defun)
1556 (c-lang-setvar beginning-of-defun-function
1557 (c-lang-const beginning-of-defun-function))
1559 (c-lang-defconst end-of-defun-function
1560 "Function to which end-of-defun-function will be set."
1561 t 'c-end-of-defun
1562 awk 'c-awk-end-of-defun)
1563 (c-lang-setvar end-of-defun-function (c-lang-const end-of-defun-function))
1565 ;;; In-comment text handling.
1567 (c-lang-defconst c-paragraph-start
1568 "Regexp to append to `paragraph-start'."
1569 t "$"
1570 java "\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1571 pike "\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1572 (c-lang-defvar c-paragraph-start (c-lang-const c-paragraph-start))
1574 (c-lang-defconst c-paragraph-separate
1575 "Regexp to append to `paragraph-separate'."
1576 t "$"
1577 pike (c-lang-const c-paragraph-start))
1578 (c-lang-defvar c-paragraph-separate (c-lang-const c-paragraph-separate))
1581 ;;; Keyword lists.
1583 ;; Note: All and only all language constants containing keyword lists
1584 ;; should end with "-kwds"; they're automatically collected into the
1585 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1587 (c-lang-defconst c-primitive-type-kwds
1588 "Primitive type keywords. As opposed to the other keyword lists, the
1589 keywords listed here are fontified with the type face instead of the
1590 keyword face.
1592 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1593 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1594 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1595 will be handled.
1597 Do not try to modify this list for end user customizations; the
1598 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1599 the appropriate place for that."
1600 t '("char" "double" "float" "int" "long" "short" "signed"
1601 "unsigned" "void")
1602 c (append
1603 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1604 (c-lang-const c-primitive-type-kwds))
1605 c++ (append
1606 '("bool" "wchar_t")
1607 (c-lang-const c-primitive-type-kwds))
1608 ;; Objective-C extends C, but probably not the new stuff in C99.
1609 objc (append
1610 '("id" "Class" "SEL" "IMP" "BOOL")
1611 (c-lang-const c-primitive-type-kwds))
1612 java '("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1613 idl '("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1614 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1615 ;; In CORBA PSDL:
1616 "ref"
1617 ;; The following can't really end a type, but we have to specify them
1618 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1619 ;; doesn't matter that much.
1620 "unsigned" "strong")
1621 pike '(;; this_program isn't really a keyword, but it's practically
1622 ;; used as a builtin type.
1623 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1624 "object" "program" "string" "this_program" "void"))
1626 (c-lang-defconst c-primitive-type-key
1627 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1628 t (c-make-keywords-re t (c-lang-const c-primitive-type-kwds)))
1629 (c-lang-defvar c-primitive-type-key (c-lang-const c-primitive-type-key))
1631 (c-lang-defconst c-primitive-type-prefix-kwds
1632 "Keywords that might act as prefixes for primitive types. Assumed to
1633 be a subset of `c-primitive-type-kwds'."
1634 t nil
1635 (c c++) '("long" "short" "signed" "unsigned")
1636 idl '("long" "unsigned"
1637 ;; In CORBA PSDL:
1638 "strong"))
1640 (c-lang-defconst c-typedef-kwds
1641 "Prefix keyword\(s\) like \"typedef\" which make a type declaration out
1642 of a variable declaration."
1643 t '("typedef")
1644 (awk idl java) nil)
1646 (c-lang-defconst c-typedef-key
1647 ;; Adorned regexp matching `c-typedef-kwds'.
1648 t (c-make-keywords-re t (c-lang-const c-typedef-kwds)))
1649 (c-lang-defvar c-typedef-key (c-lang-const c-typedef-key))
1651 (c-lang-defconst c-type-prefix-kwds
1652 "Keywords where the following name - if any - is a type name, and
1653 where the keyword together with the symbol works as a type in
1654 declarations.
1656 Note that an alternative if the second part doesn't hold is
1657 `c-type-list-kwds'. Keywords on this list are typically also present
1658 on one of the `*-decl-kwds' lists."
1659 t nil
1660 c '("struct" "union" "enum")
1661 c++ (append '("class" "typename")
1662 (c-lang-const c-type-prefix-kwds c)))
1664 (c-lang-defconst c-type-prefix-key
1665 ;; Adorned regexp matching `c-type-prefix-kwds'.
1666 t (c-make-keywords-re t (c-lang-const c-type-prefix-kwds)))
1667 (c-lang-defvar c-type-prefix-key (c-lang-const c-type-prefix-key))
1669 (c-lang-defconst c-type-modifier-kwds
1670 "Type modifier keywords. These can occur almost anywhere in types
1671 but they don't build a type of themselves. Unlike the keywords on
1672 `c-primitive-type-kwds', they are fontified with the keyword face and
1673 not the type face."
1674 t nil
1675 c '("const" "restrict" "volatile")
1676 c++ '("const" "volatile" "throw")
1677 objc '("const" "volatile"))
1679 (c-lang-defconst c-opt-type-modifier-key
1680 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1681 ;; languages without such keywords.
1682 t (and (c-lang-const c-type-modifier-kwds)
1683 (c-make-keywords-re t (c-lang-const c-type-modifier-kwds))))
1684 (c-lang-defvar c-opt-type-modifier-key (c-lang-const c-opt-type-modifier-key))
1686 (c-lang-defconst c-opt-type-component-key
1687 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1688 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1689 t (and (or (c-lang-const c-primitive-type-prefix-kwds)
1690 (c-lang-const c-type-modifier-kwds))
1691 (c-make-keywords-re t
1692 (append (c-lang-const c-primitive-type-prefix-kwds)
1693 (c-lang-const c-type-modifier-kwds)))))
1694 (c-lang-defvar c-opt-type-component-key
1695 (c-lang-const c-opt-type-component-key))
1697 (c-lang-defconst c-type-start-kwds
1698 ;; All keywords that can start a type (i.e. are either a type prefix
1699 ;; or a complete type).
1700 t (delete-duplicates (append (c-lang-const c-primitive-type-kwds)
1701 (c-lang-const c-type-prefix-kwds)
1702 (c-lang-const c-type-modifier-kwds))
1703 :test 'string-equal))
1705 (c-lang-defconst c-class-decl-kwds
1706 "Keywords introducing declarations where the following block (if any)
1707 contains another declaration level that should be considered a class.
1709 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1710 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1711 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1712 will be handled.
1714 Note that presence on this list does not automatically treat the
1715 following identifier as a type; the keyword must also be present on
1716 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1717 t nil
1718 c '("struct" "union")
1719 c++ '("class" "struct" "union")
1720 objc '("struct" "union"
1721 "@interface" "@implementation" "@protocol")
1722 java '("class" "@interface" "interface")
1723 idl '("component" "eventtype" "exception" "home" "interface" "struct"
1724 "union" "valuetype"
1725 ;; In CORBA PSDL:
1726 "storagehome" "storagetype"
1727 ;; In CORBA CIDL:
1728 "catalog" "executor" "manages" "segment")
1729 pike '("class"))
1731 (c-lang-defconst c-class-key
1732 ;; Regexp matching the start of a class.
1733 t (c-make-keywords-re t (c-lang-const c-class-decl-kwds)))
1734 (c-lang-defvar c-class-key (c-lang-const c-class-key))
1736 (c-lang-defconst c-brace-list-decl-kwds
1737 "Keywords introducing declarations where the following block (if
1738 any) is a brace list.
1740 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1741 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1742 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1743 will be handled."
1744 t '("enum")
1745 (awk) nil)
1747 (c-lang-defconst c-brace-list-key
1748 ;; Regexp matching the start of declarations where the following
1749 ;; block is a brace list.
1750 t (c-make-keywords-re t (c-lang-const c-brace-list-decl-kwds)))
1751 (c-lang-defvar c-brace-list-key (c-lang-const c-brace-list-key))
1753 (c-lang-defconst c-other-block-decl-kwds
1754 "Keywords where the following block (if any) contains another
1755 declaration level that should not be considered a class. For every
1756 keyword here, CC Mode will add a set of special syntactic symbols for
1757 those blocks. E.g. if the keyword is \"foo\" then there will be
1758 `foo-open', `foo-close', and `infoo' symbols.
1760 The intention is that this category should be used for block
1761 constructs that aren't related to object orientation concepts like
1762 classes (which thus also include e.g. interfaces, templates,
1763 contracts, structs, etc). The more pragmatic distinction is that
1764 while most want some indentation inside classes, it's fairly common
1765 that they don't want it in some of these constructs, so it should be
1766 simple to configure that differently from classes. See also
1767 `c-class-decl-kwds'.
1769 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1770 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1771 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1772 will be handled."
1773 t nil
1774 (c objc) '("extern")
1775 c++ '("namespace" "extern")
1776 idl '("module"
1777 ;; In CORBA CIDL:
1778 "composition"))
1780 (c-lang-defconst c-other-decl-block-key
1781 ;; Regexp matching the start of blocks besides classes that contain
1782 ;; another declaration level.
1783 t (c-make-keywords-re t (c-lang-const c-other-block-decl-kwds)))
1784 (c-lang-defvar c-other-decl-block-key (c-lang-const c-other-decl-block-key))
1786 (c-lang-defvar c-other-decl-block-key-in-symbols-alist
1787 (mapcar
1788 (lambda (elt)
1789 (cons elt
1790 (if (string= elt "extern")
1791 'inextern-lang
1792 (intern (concat "in" elt)))))
1793 (c-lang-const c-other-block-decl-kwds))
1794 "Alist associating keywords in c-other-decl-block-decl-kwds with
1795 their matching \"in\" syntactic symbols.")
1797 (c-lang-defconst c-typedef-decl-kwds
1798 "Keywords introducing declarations where the identifier(s) being
1799 declared are types.
1801 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1802 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1803 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1804 will be handled."
1805 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1806 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1807 ;; {...}").
1808 t (append (c-lang-const c-class-decl-kwds)
1809 (c-lang-const c-brace-list-decl-kwds))
1810 ;; Languages that have a "typedef" construct.
1811 (c c++ objc idl pike) (append (c-lang-const c-typedef-decl-kwds)
1812 '("typedef"))
1813 ;; Unlike most other languages, exception names are not handled as
1814 ;; types in IDL since they only can occur in "raises" specs.
1815 idl (delete "exception" (append (c-lang-const c-typedef-decl-kwds) nil)))
1817 (c-lang-defconst c-typedef-decl-key
1818 t (c-make-keywords-re t (c-lang-const c-typedef-decl-kwds)))
1819 (c-lang-defvar c-typedef-decl-key (c-lang-const c-typedef-decl-key))
1821 (c-lang-defconst c-typeless-decl-kwds
1822 "Keywords introducing declarations where the \(first) identifier
1823 \(declarator) follows directly after the keyword, without any type.
1825 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1826 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1827 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1828 will be handled."
1829 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1830 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1831 ;; {...}").
1832 t (append (c-lang-const c-class-decl-kwds)
1833 (c-lang-const c-brace-list-decl-kwds))
1834 ;; Note: "manages" for CORBA CIDL clashes with its presence on
1835 ;; `c-type-list-kwds' for IDL.
1836 idl (append (c-lang-const c-typeless-decl-kwds)
1837 '("factory" "finder" "native"
1838 ;; In CORBA PSDL:
1839 "key" "stores"
1840 ;; In CORBA CIDL:
1841 "facet"))
1842 pike (append (c-lang-const c-class-decl-kwds)
1843 '("constant")))
1845 (c-lang-defconst c-modifier-kwds
1846 "Keywords that can prefix normal declarations of identifiers
1847 \(and typically act as flags). Things like argument declarations
1848 inside function headers are also considered declarations in this
1849 sense.
1851 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1852 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1853 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1854 will be handled."
1855 t nil
1856 (c c++) '("auto" "extern" "inline" "register" "static")
1857 c++ (append '("explicit" "friend" "mutable" "template" "using" "virtual")
1858 (c-lang-const c-modifier-kwds))
1859 objc '("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
1860 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
1861 idl '("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
1862 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
1863 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
1864 ;; In CORBA PSDL:
1865 "primary" "state"
1866 ;; In CORBA CIDL:
1867 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
1868 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
1869 java '("abstract" "const" "final" "native" "private" "protected" "public"
1870 "static" "strictfp" "synchronized" "transient" "volatile")
1871 pike '("final" "inline" "local" "nomask" "optional" "private" "protected"
1872 "public" "static" "variant"))
1874 (c-lang-defconst c-other-decl-kwds
1875 "Keywords that can start or prefix any declaration level construct,
1876 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1877 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1878 `c-typeless-decl-kwds' and `c-modifier-kwds'.
1880 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1881 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1882 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1883 will be handled."
1884 t nil
1885 objc '("@class" "@end" "@defs")
1886 java '("import" "package")
1887 pike '("import" "inherit"))
1889 (c-lang-defconst c-decl-start-kwds
1890 "Keywords that always start declarations, wherever they occur.
1891 This can be used for declarations that aren't recognized by the normal
1892 combination of `c-decl-prefix-re' and `c-decl-start-re'."
1893 t nil
1894 ;; Classes can be declared anywhere in a Pike expression.
1895 pike '("class"))
1897 (c-lang-defconst c-decl-hangon-kwds
1898 "Keywords that can occur anywhere in a declaration level construct.
1899 This is used for self-contained things that can be tacked on anywhere
1900 on a declaration and that should be ignored to be able to recognize it
1901 correctly. Typical cases are compiler extensions like
1902 \"__attribute__\" or \"__declspec\":
1904 __declspec(noreturn) void foo();
1905 class __declspec(dllexport) classname {...};
1906 void foo() __attribute__((noreturn));
1908 Note that unrecognized plain symbols are skipped anyway if they occur
1909 before the type, so such things are not necessary to mention here.
1910 Mentioning them here is necessary only if they can occur in other
1911 places, or if they are followed by a construct that must be skipped
1912 over \(like the parens in the \"__attribute__\" and \"__declspec\"
1913 examples above). In the last case, they alse need to be present on
1914 one of `c-type-list-kwds', `c-ref-list-kwds',
1915 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1916 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1917 ;; NB: These are currently not recognized in all parts of a
1918 ;; declaration. Specifically, they aren't recognized in the middle
1919 ;; of multi-token types, inside declarators, and between the
1920 ;; identifier and the arglist paren of a function declaration.
1922 ;; FIXME: This ought to be user customizable since compiler stuff
1923 ;; like this usually is wrapped in project specific macros. (It'd
1924 ;; of course be even better if we could cope without knowing this.)
1925 t nil
1926 (c c++) '(;; GCC extension.
1927 "__attribute__"
1928 ;; MSVC extension.
1929 "__declspec"))
1931 (c-lang-defconst c-decl-hangon-key
1932 ;; Adorned regexp matching `c-decl-hangon-kwds'.
1933 t (c-make-keywords-re t (c-lang-const c-decl-hangon-kwds)))
1934 (c-lang-defvar c-decl-hangon-key (c-lang-const c-decl-hangon-key))
1936 (c-lang-defconst c-prefix-spec-kwds
1937 ;; All keywords that can occur in the preamble of a declaration.
1938 ;; They typically occur before the type, but they are also matched
1939 ;; after presumptive types since we often can't be sure that
1940 ;; something is a type or just some sort of macro in front of the
1941 ;; declaration. They might be ambiguous with types or type
1942 ;; prefixes.
1943 t (delete-duplicates (append (c-lang-const c-class-decl-kwds)
1944 (c-lang-const c-brace-list-decl-kwds)
1945 (c-lang-const c-other-block-decl-kwds)
1946 (c-lang-const c-typedef-decl-kwds)
1947 (c-lang-const c-typeless-decl-kwds)
1948 (c-lang-const c-modifier-kwds)
1949 (c-lang-const c-other-decl-kwds)
1950 (c-lang-const c-decl-start-kwds)
1951 (c-lang-const c-decl-hangon-kwds))
1952 :test 'string-equal))
1954 (c-lang-defconst c-prefix-spec-kwds-re
1955 ;; Adorned regexp of `c-prefix-spec-kwds'.
1956 t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))
1958 (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
1960 (c-lang-defconst c-specifier-key
1961 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
1962 ;; ambiguous with types or type prefixes. These are the keywords (like
1963 ;; extern, namespace, but NOT template) that can modify a declaration.
1964 t (c-make-keywords-re t
1965 (set-difference (c-lang-const c-prefix-spec-kwds)
1966 (append (c-lang-const c-type-start-kwds)
1967 (c-lang-const c-<>-arglist-kwds))
1968 :test 'string-equal)))
1969 (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key))
1971 (c-lang-defconst c-postfix-spec-kwds
1972 ;; Keywords that can occur after argument list of a function header
1973 ;; declaration, i.e. in the "K&R region".
1974 t (append (c-lang-const c-postfix-decl-spec-kwds)
1975 (c-lang-const c-decl-hangon-kwds)))
1977 (c-lang-defconst c-not-decl-init-keywords
1978 ;; Adorned regexp matching all keywords that can't appear at the
1979 ;; start of a declaration.
1980 t (c-make-keywords-re t
1981 (set-difference (c-lang-const c-keywords)
1982 (append (c-lang-const c-type-start-kwds)
1983 (c-lang-const c-prefix-spec-kwds))
1984 :test 'string-equal)))
1985 (c-lang-defvar c-not-decl-init-keywords
1986 (c-lang-const c-not-decl-init-keywords))
1988 (c-lang-defconst c-not-primitive-type-keywords
1989 "List of all keywords apart from primitive types (like \"int\")."
1990 t (set-difference (c-lang-const c-keywords)
1991 (c-lang-const c-primitive-type-kwds)
1992 :test 'string-equal)
1993 ;; The "more" for C++ is the QT keyword (as in "more slots:").
1994 ;; This variable is intended for use in c-beginning-of-statement-1.
1995 c++ (append (c-lang-const c-not-primitive-type-keywords) '("more")))
1997 (c-lang-defconst c-not-primitive-type-keywords-regexp
1998 t (c-make-keywords-re t
1999 (c-lang-const c-not-primitive-type-keywords)))
2000 (c-lang-defvar c-not-primitive-type-keywords-regexp
2001 (c-lang-const c-not-primitive-type-keywords-regexp))
2003 (c-lang-defconst c-protection-kwds
2004 "Access protection label keywords in classes."
2005 t nil
2006 c++ '("private" "protected" "public")
2007 objc '("@private" "@protected" "@public"))
2009 (c-lang-defconst c-block-decls-with-vars
2010 "Keywords introducing declarations that can contain a block which
2011 might be followed by variable declarations, e.g. like \"foo\" in
2012 \"class Foo { ... } foo;\". So if there is a block in a declaration
2013 like that, it ends with the following ';' and not right away.
2015 The keywords on list are assumed to also be present on one of the
2016 `*-decl-kwds' lists."
2017 t nil
2018 (c objc) '("struct" "union" "enum" "typedef")
2019 c++ '("class" "struct" "union" "enum" "typedef"))
2021 (c-lang-defconst c-opt-block-decls-with-vars-key
2022 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
2023 ;; languages without such constructs.
2024 t (and (c-lang-const c-block-decls-with-vars)
2025 (c-make-keywords-re t (c-lang-const c-block-decls-with-vars))))
2026 (c-lang-defvar c-opt-block-decls-with-vars-key
2027 (c-lang-const c-opt-block-decls-with-vars-key))
2029 (c-lang-defconst c-postfix-decl-spec-kwds
2030 "Keywords introducing extra declaration specifiers in the region
2031 between the header and the body \(i.e. the \"K&R-region\") in
2032 declarations."
2033 t nil
2034 java '("extends" "implements" "throws")
2035 idl '("context" "getraises" "manages" "primarykey" "raises" "setraises"
2036 "supports"
2037 ;; In CORBA PSDL:
2038 "as" "const" "implements" "of" "ref"))
2040 (c-lang-defconst c-nonsymbol-sexp-kwds
2041 "Keywords that may be followed by a nonsymbol sexp before whatever
2042 construct it's part of continues."
2043 t nil
2044 (c c++ objc) '("extern"))
2046 (c-lang-defconst c-type-list-kwds
2047 "Keywords that may be followed by a comma separated list of type
2048 identifiers, where each optionally can be prefixed by keywords. (Can
2049 also be used for the special case when the list can contain only one
2050 element.)
2052 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
2053 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
2054 There's also no reason to add keywords that prefixes a normal
2055 declaration consisting of a type followed by a declarator (list), so
2056 the keywords on `c-modifier-kwds' should normally not be listed here
2057 either.
2059 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2060 or variable identifier (that's being defined)."
2061 t nil
2062 c++ '("operator")
2063 objc '("@class")
2064 java '("import" "new" "extends" "super" "implements" "throws")
2065 idl '("manages" "native" "primarykey" "supports"
2066 ;; In CORBA PSDL:
2067 "as" "implements" "of" "scope")
2068 pike '("inherit"))
2070 (c-lang-defconst c-ref-list-kwds
2071 "Keywords that may be followed by a comma separated list of
2072 reference (i.e. namespace/scope/module) identifiers, where each
2073 optionally can be prefixed by keywords. (Can also be used for the
2074 special case when the list can contain only one element.) Assumed to
2075 be mutually exclusive with `c-type-list-kwds'.
2077 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2078 or variable identifier (that's being defined)."
2079 t nil
2080 c++ '("namespace")
2081 java '("package")
2082 idl '("import" "module"
2083 ;; In CORBA CIDL:
2084 "composition")
2085 pike '("import"))
2087 (c-lang-defconst c-colon-type-list-kwds
2088 "Keywords that may be followed (not necessarily directly) by a colon
2089 and then a comma separated list of type identifiers, where each
2090 optionally can be prefixed by keywords. (Can also be used for the
2091 special case when the list can contain only one element.)"
2092 t nil
2093 c++ '("class" "struct")
2094 idl '("component" "eventtype" "home" "interface" "valuetype"
2095 ;; In CORBA PSDL:
2096 "storagehome" "storagetype"))
2098 (c-lang-defconst c-colon-type-list-re
2099 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
2100 forward to the colon. The end of the match is assumed to be directly
2101 after the colon, so the regexp should end with \":\". Must be a
2102 regexp if `c-colon-type-list-kwds' isn't nil."
2103 t (if (c-lang-const c-colon-type-list-kwds)
2104 ;; Disallow various common punctuation chars that can't come
2105 ;; before the ":" that starts the inherit list after "class"
2106 ;; or "struct" in C++. (Also used as default for other
2107 ;; languages.)
2108 "[^\]\[{}();,/#=:]*:"))
2109 (c-lang-defvar c-colon-type-list-re (c-lang-const c-colon-type-list-re))
2111 (c-lang-defconst c-paren-nontype-kwds
2112 "Keywords that may be followed by a parenthesis expression that doesn't
2113 contain type identifiers."
2114 t nil
2115 (c c++) '(;; GCC extension.
2116 "__attribute__"
2117 ;; MSVC extension.
2118 "__declspec"))
2120 (c-lang-defconst c-paren-type-kwds
2121 "Keywords that may be followed by a parenthesis expression containing
2122 type identifiers separated by arbitrary tokens."
2123 t nil
2124 c++ '("throw")
2125 objc '("@defs")
2126 idl '("switch")
2127 pike '("array" "function" "int" "mapping" "multiset" "object" "program"))
2129 (c-lang-defconst c-paren-any-kwds
2130 t (delete-duplicates (append (c-lang-const c-paren-nontype-kwds)
2131 (c-lang-const c-paren-type-kwds))
2132 :test 'string-equal))
2134 (c-lang-defconst c-<>-type-kwds
2135 "Keywords that may be followed by an angle bracket expression
2136 containing type identifiers separated by \",\". The difference from
2137 `c-<>-arglist-kwds' is that unknown names are taken to be types and
2138 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
2139 if this isn't nil."
2140 t nil
2141 objc '("id")
2142 idl '("sequence"
2143 ;; In CORBA PSDL:
2144 "ref"))
2146 (c-lang-defconst c-<>-arglist-kwds
2147 "Keywords that can be followed by a C++ style template arglist; see
2148 `c-recognize-<>-arglists' for details. That language constant is
2149 assumed to be set if this isn't nil."
2150 t nil
2151 c++ '("template")
2152 idl '("fixed" "string" "wstring"))
2154 (c-lang-defconst c-<>-sexp-kwds
2155 ;; All keywords that can be followed by an angle bracket sexp.
2156 t (delete-duplicates (append (c-lang-const c-<>-type-kwds)
2157 (c-lang-const c-<>-arglist-kwds))
2158 :test 'string-equal))
2160 (c-lang-defconst c-opt-<>-sexp-key
2161 ;; Adorned regexp matching keywords that can be followed by an angle
2162 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
2163 t (if (c-lang-const c-recognize-<>-arglists)
2164 (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds))))
2165 (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
2167 (c-lang-defconst c-brace-id-list-kwds
2168 "Keywords that may be followed by a brace block containing a comma
2169 separated list of identifier definitions, i.e. like the list of
2170 identifiers that follows the type in a normal declaration."
2171 t (c-lang-const c-brace-list-decl-kwds))
2173 (c-lang-defconst c-block-stmt-1-kwds
2174 "Statement keywords followed directly by a substatement."
2175 t '("do" "else")
2176 c++ '("do" "else" "try")
2177 objc '("do" "else" "@finally" "@try")
2178 java '("do" "else" "finally" "try")
2179 idl nil)
2181 (c-lang-defconst c-block-stmt-1-key
2182 ;; Regexp matching the start of any statement followed directly by a
2183 ;; substatement (doesn't match a bare block, however).
2184 t (c-make-keywords-re t (c-lang-const c-block-stmt-1-kwds)))
2185 (c-lang-defvar c-block-stmt-1-key (c-lang-const c-block-stmt-1-key))
2187 (c-lang-defconst c-block-stmt-2-kwds
2188 "Statement keywords followed by a paren sexp and then by a substatement."
2189 t '("for" "if" "switch" "while")
2190 c++ '("for" "if" "switch" "while" "catch")
2191 objc '("for" "if" "switch" "while" "@catch" "@synchronized")
2192 java '("for" "if" "switch" "while" "catch" "synchronized")
2193 idl nil
2194 pike '("for" "if" "switch" "while" "foreach")
2195 awk '("for" "if" "while"))
2197 (c-lang-defconst c-block-stmt-2-key
2198 ;; Regexp matching the start of any statement followed by a paren sexp
2199 ;; and then by a substatement.
2200 t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds)))
2201 (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key))
2203 (c-lang-defconst c-block-stmt-kwds
2204 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
2205 t (delete-duplicates (append (c-lang-const c-block-stmt-1-kwds)
2206 (c-lang-const c-block-stmt-2-kwds))
2207 :test 'string-equal))
2209 (c-lang-defconst c-opt-block-stmt-key
2210 ;; Regexp matching the start of any statement that has a
2211 ;; substatement (except a bare block). Nil in languages that
2212 ;; don't have such constructs.
2213 t (if (or (c-lang-const c-block-stmt-1-kwds)
2214 (c-lang-const c-block-stmt-2-kwds))
2215 (c-make-keywords-re t
2216 (append (c-lang-const c-block-stmt-1-kwds)
2217 (c-lang-const c-block-stmt-2-kwds)))))
2218 (c-lang-defvar c-opt-block-stmt-key (c-lang-const c-opt-block-stmt-key))
2220 (c-lang-defconst c-simple-stmt-kwds
2221 "Statement keywords followed by an expression or nothing."
2222 t '("break" "continue" "goto" "return")
2223 objc '("break" "continue" "goto" "return" "@throw")
2224 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
2225 java '("break" "continue" "goto" "return" "throw")
2226 idl nil
2227 pike '("break" "continue" "return")
2228 awk '(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
2229 "break" "continue" "return" "delete" "exit" "getline" "next"
2230 "nextfile" "print" "printf"))
2232 (c-lang-defconst c-simple-stmt-key
2233 ;; Adorned regexp matching `c-simple-stmt-kwds'.
2234 t (c-make-keywords-re t (c-lang-const c-simple-stmt-kwds)))
2235 (c-lang-defvar c-simple-stmt-key (c-lang-const c-simple-stmt-key))
2237 (c-lang-defconst c-paren-stmt-kwds
2238 "Statement keywords followed by a parenthesis expression that
2239 nevertheless contains a list separated with ';' and not ','."
2240 t '("for")
2241 idl nil)
2243 (c-lang-defconst c-paren-stmt-key
2244 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2245 t (c-make-keywords-re t (c-lang-const c-paren-stmt-kwds)))
2246 (c-lang-defvar c-paren-stmt-key (c-lang-const c-paren-stmt-key))
2248 (c-lang-defconst c-asm-stmt-kwds
2249 "Statement keywords followed by an assembler expression."
2250 t nil
2251 (c c++) '("asm" "__asm__")) ;; Not standard, but common.
2253 (c-lang-defconst c-opt-asm-stmt-key
2254 ;; Regexp matching the start of an assembler statement. Nil in
2255 ;; languages that don't support that.
2256 t (if (c-lang-const c-asm-stmt-kwds)
2257 (c-make-keywords-re t (c-lang-const c-asm-stmt-kwds))))
2258 (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key))
2260 (c-lang-defconst c-case-kwds
2261 "The keyword\(s) which introduce a \"case\" like construct.
2262 This construct is \"<keyword> <expression> :\"."
2263 t '("case")
2264 awk nil)
2266 (c-lang-defconst c-case-kwds-regexp
2267 ;; Adorned regexp matching any "case"-like keyword.
2268 t (c-make-keywords-re t (c-lang-const c-case-kwds)))
2269 (c-lang-defvar c-case-kwds-regexp (c-lang-const c-case-kwds-regexp))
2271 (c-lang-defconst c-label-kwds
2272 "Keywords introducing colon terminated labels in blocks."
2273 t '("case" "default"))
2275 (c-lang-defconst c-label-kwds-regexp
2276 ;; Adorned regexp matching any keyword that introduces a label.
2277 t (c-make-keywords-re t (c-lang-const c-label-kwds)))
2278 (c-lang-defvar c-label-kwds-regexp (c-lang-const c-label-kwds-regexp))
2280 (c-lang-defconst c-before-label-kwds
2281 "Keywords that might be followed by a label identifier."
2282 t '("goto")
2283 (java pike) (append '("break" "continue")
2284 (c-lang-const c-before-label-kwds))
2285 idl nil
2286 awk nil)
2288 (c-lang-defconst c-constant-kwds
2289 "Keywords for constants."
2290 t nil
2291 (c c++) '("NULL" ;; Not a keyword, but practically works as one.
2292 "false" "true") ; Defined in C99.
2293 objc '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER")
2294 idl '("TRUE" "FALSE")
2295 java '("true" "false" "null") ; technically "literals", not keywords
2296 pike '("UNDEFINED")) ;; Not a keyword, but practically works as one.
2298 (c-lang-defconst c-primary-expr-kwds
2299 "Keywords besides constants and operators that start primary expressions."
2300 t nil
2301 c++ '("operator" "this")
2302 objc '("super" "self")
2303 java '("this")
2304 pike '("this")) ;; Not really a keyword, but practically works as one.
2306 (c-lang-defconst c-expr-kwds
2307 ;; Keywords that can occur anywhere in expressions. Built from
2308 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2309 t (delete-duplicates
2310 (append (c-lang-const c-primary-expr-kwds)
2311 (c-filter-ops (c-lang-const c-operator-list)
2313 "\\`\\(\\w\\|\\s_\\)+\\'"))
2314 :test 'string-equal))
2316 (c-lang-defconst c-lambda-kwds
2317 "Keywords that start lambda constructs, i.e. function definitions in
2318 expressions."
2319 t nil
2320 pike '("lambda"))
2322 (c-lang-defconst c-inexpr-block-kwds
2323 "Keywords that start constructs followed by statement blocks which can
2324 be used in expressions \(the gcc extension for this in C and C++ is
2325 handled separately by `c-recognize-paren-inexpr-blocks')."
2326 t nil
2327 pike '("catch" "gauge"))
2329 (c-lang-defconst c-inexpr-class-kwds
2330 "Keywords that can start classes inside expressions."
2331 t nil
2332 java '("new")
2333 pike '("class"))
2335 (c-lang-defconst c-inexpr-brace-list-kwds
2336 "Keywords that can start brace list blocks inside expressions.
2337 Note that Java specific rules are currently applied to tell this from
2338 `c-inexpr-class-kwds'."
2339 t nil
2340 java '("new"))
2342 (c-lang-defconst c-opt-inexpr-brace-list-key
2343 ;; Regexp matching the start of a brace list in an expression, or
2344 ;; nil in languages that don't have such things. This should not
2345 ;; match brace lists recognized through `c-special-brace-lists'.
2346 t (and (c-lang-const c-inexpr-brace-list-kwds)
2347 (c-make-keywords-re t (c-lang-const c-inexpr-brace-list-kwds))))
2348 (c-lang-defvar c-opt-inexpr-brace-list-key
2349 (c-lang-const c-opt-inexpr-brace-list-key))
2351 (c-lang-defconst c-decl-block-key
2352 ;; Regexp matching keywords in any construct that contain another
2353 ;; declaration level, i.e. that isn't followed by a function block
2354 ;; or brace list. When the first submatch matches, it's an
2355 ;; unambiguous construct, otherwise it's an ambiguous match that
2356 ;; might also be the return type of a function declaration.
2357 t (let* ((decl-kwds (append (c-lang-const c-class-decl-kwds)
2358 (c-lang-const c-other-block-decl-kwds)
2359 (c-lang-const c-inexpr-class-kwds)))
2360 (unambiguous (set-difference decl-kwds
2361 (c-lang-const c-type-start-kwds)
2362 :test 'string-equal))
2363 (ambiguous (intersection decl-kwds
2364 (c-lang-const c-type-start-kwds)
2365 :test 'string-equal)))
2366 (if ambiguous
2367 (concat (c-make-keywords-re t unambiguous)
2368 "\\|"
2369 (c-make-keywords-re t ambiguous))
2370 (c-make-keywords-re t unambiguous))))
2371 (c-lang-defvar c-decl-block-key (c-lang-const c-decl-block-key))
2373 (c-lang-defconst c-bitfield-kwds
2374 "Keywords that can introduce bitfields."
2375 t nil
2376 (c c++ objc) '("char" "int" "long" "signed" "unsigned"))
2378 (c-lang-defconst c-opt-bitfield-key
2379 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2380 ;; languages without bitfield support.
2381 t nil
2382 (c c++) (c-make-keywords-re t (c-lang-const c-bitfield-kwds)))
2383 (c-lang-defvar c-opt-bitfield-key (c-lang-const c-opt-bitfield-key))
2385 (c-lang-defconst c-other-kwds
2386 "Keywords not accounted for by any other `*-kwds' language constant."
2387 t nil
2388 idl '("truncatable"
2389 ;; In CORBA CIDL: (These are declaration keywords that never
2390 ;; can start a declaration.)
2391 "entity" "process" "service" "session" "storage"))
2394 ;;; Constants built from keywords.
2396 ;; Note: No `*-kwds' language constants may be defined below this point.
2398 (eval-and-compile
2399 (defconst c-kwds-lang-consts
2400 ;; List of all the language constants that contain keyword lists.
2401 (let (list)
2402 (mapatoms (lambda (sym)
2403 (when (and (boundp sym)
2404 (string-match "-kwds\\'" (symbol-name sym)))
2405 ;; Make the list of globally interned symbols
2406 ;; instead of ones interned in `c-lang-constants'.
2407 (setq list (cons (intern (symbol-name sym)) list))))
2408 c-lang-constants)
2409 list)))
2411 (c-lang-defconst c-keywords
2412 ;; All keywords as a list.
2413 t (delete-duplicates
2414 (c-lang-defconst-eval-immediately
2415 `(append ,@(mapcar (lambda (kwds-lang-const)
2416 `(c-lang-const ,kwds-lang-const))
2417 c-kwds-lang-consts)
2418 nil))
2419 :test 'string-equal))
2421 (c-lang-defconst c-keywords-regexp
2422 ;; All keywords as an adorned regexp.
2423 t (c-make-keywords-re t (c-lang-const c-keywords)))
2424 (c-lang-defvar c-keywords-regexp (c-lang-const c-keywords-regexp))
2426 (c-lang-defconst c-keyword-member-alist
2427 ;; An alist with all the keywords in the cars. The cdr for each
2428 ;; keyword is a list of the symbols for the `*-kwds' lists that
2429 ;; contains it.
2430 t (let ((kwd-list-alist
2431 (c-lang-defconst-eval-immediately
2432 `(list ,@(mapcar (lambda (kwds-lang-const)
2433 `(cons ',kwds-lang-const
2434 (c-lang-const ,kwds-lang-const)))
2435 c-kwds-lang-consts))))
2436 lang-const kwd-list kwd
2437 result-alist elem)
2438 (while kwd-list-alist
2439 (setq lang-const (caar kwd-list-alist)
2440 kwd-list (cdar kwd-list-alist)
2441 kwd-list-alist (cdr kwd-list-alist))
2442 (while kwd-list
2443 (setq kwd (car kwd-list)
2444 kwd-list (cdr kwd-list))
2445 (unless (setq elem (assoc kwd result-alist))
2446 (setq result-alist (cons (setq elem (list kwd)) result-alist)))
2447 (unless (memq lang-const (cdr elem))
2448 (setcdr elem (cons lang-const (cdr elem))))))
2449 result-alist))
2451 (c-lang-defvar c-keywords-obarray
2452 ;; An obarray containing all keywords as symbols. The property list
2453 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2454 ;; lists it's a member of.
2456 ;; E.g. to see whether the string str contains a keyword on
2457 ;; `c-class-decl-kwds', one can do like this:
2458 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2459 ;; Which preferably is written using the associated functions in
2460 ;; cc-engine:
2461 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2463 ;; The obarray is not stored directly as a language constant since
2464 ;; the printed representation for obarrays used in .elc files isn't
2465 ;; complete.
2467 (let* ((alist (c-lang-const c-keyword-member-alist))
2468 kwd lang-const-list
2469 (obarray (make-vector (* (length alist) 2) 0)))
2470 (while alist
2471 (setq kwd (caar alist)
2472 lang-const-list (cdar alist)
2473 alist (cdr alist))
2474 (setplist (intern kwd obarray)
2475 ;; Emacs has an odd bug that causes `mapcan' to fail
2476 ;; with unintelligible errors. (XEmacs works.)
2477 ;;(mapcan (lambda (lang-const)
2478 ;; (list lang-const t))
2479 ;; lang-const-list)
2480 (apply 'nconc (mapcar (lambda (lang-const)
2481 (list lang-const t))
2482 lang-const-list))))
2483 obarray))
2485 (c-lang-defconst c-regular-keywords-regexp
2486 ;; Adorned regexp matching all keywords that should be fontified
2487 ;; with the keywords face. I.e. that aren't types or constants.
2488 t (c-make-keywords-re t
2489 (set-difference (c-lang-const c-keywords)
2490 (append (c-lang-const c-primitive-type-kwds)
2491 (c-lang-const c-constant-kwds))
2492 :test 'string-equal)))
2493 (c-lang-defvar c-regular-keywords-regexp
2494 (c-lang-const c-regular-keywords-regexp))
2496 (c-lang-defconst c-primary-expr-regexp
2497 ;; Regexp matching the start of any primary expression, i.e. any
2498 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2499 ;; exclude keywords; they are excluded afterwards unless the second
2500 ;; submatch matches. If the first but not the second submatch
2501 ;; matches then it is an ambiguous primary expression; it could also
2502 ;; be a match of e.g. an infix operator. (The case with ambiguous
2503 ;; keyword operators isn't handled.)
2505 t (let* ((prefix-ops
2506 (c-filter-ops (c-lang-const c-operators)
2507 '(prefix)
2508 (lambda (op)
2509 ;; Filter out the special case prefix
2510 ;; operators that are close parens.
2511 (not (string-match "\\s)" op)))))
2513 (nonkeyword-prefix-ops
2514 (c-filter-ops prefix-ops
2516 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2518 (in-or-postfix-ops
2519 (c-filter-ops (c-lang-const c-operators)
2520 '(postfix
2521 postfix-if-paren
2522 left-assoc
2523 right-assoc
2524 right-assoc-sequence)
2527 (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2528 in-or-postfix-ops
2529 :test 'string-equal))
2530 (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2531 in-or-postfix-ops
2532 :test 'string-equal)))
2534 (concat
2535 "\\("
2536 ;; Take out all symbol class operators from `prefix-ops' and make the
2537 ;; first submatch from them together with `c-primary-expr-kwds'.
2538 (c-make-keywords-re t
2539 (append (c-lang-const c-primary-expr-kwds)
2540 (set-difference prefix-ops nonkeyword-prefix-ops
2541 :test 'string-equal)))
2543 "\\|"
2544 ;; Match all ambiguous operators.
2545 (c-make-keywords-re nil
2546 (intersection nonkeyword-prefix-ops in-or-postfix-ops
2547 :test 'string-equal))
2548 "\\)"
2550 "\\|"
2551 ;; Now match all other symbols.
2552 (c-lang-const c-symbol-start)
2554 "\\|"
2555 ;; The chars that can start integer and floating point
2556 ;; constants.
2557 "\\.?[0-9]"
2559 "\\|"
2560 ;; The unambiguous operators from `prefix-ops'.
2561 (c-make-keywords-re nil
2562 (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2563 :test 'string-equal))
2565 "\\|"
2566 ;; Match string and character literals.
2567 "\\s\""
2568 (if (memq 'gen-string-delim c-emacs-features)
2569 "\\|\\s|"
2570 ""))))
2571 (c-lang-defvar c-primary-expr-regexp (c-lang-const c-primary-expr-regexp))
2574 ;;; Additional constants for parser-level constructs.
2576 (c-lang-defconst c-decl-prefix-re
2577 "Regexp matching something that might precede a declaration, cast or
2578 label, such as the last token of a preceding statement or declaration.
2579 This is used in the common situation where a declaration or cast
2580 doesn't start with any specific token that can be searched for.
2582 The regexp should not match bob; that is done implicitly. It can't
2583 require a match longer than one token. The end of the token is taken
2584 to be at the end of the first submatch, which is assumed to always
2585 match. It's undefined whether identifier syntax (see
2586 `c-identifier-syntax-table') is in effect or not. This regexp is
2587 assumed to be a superset of `c-label-prefix-re' if
2588 `c-recognize-colon-labels' is set.
2590 Besides this, `c-decl-start-kwds' is used to find declarations.
2592 Note: This variable together with `c-decl-start-re' and
2593 `c-decl-start-kwds' is only used to detect \"likely\"
2594 declaration/cast/label starts. I.e. they might produce more matches
2595 but should not miss anything (or else it's necessary to use text
2596 properties - see the next note). Wherever they match, the following
2597 construct is analyzed to see if it indeed is a declaration, cast or
2598 label. That analysis is not cheap, so it's important that not too
2599 many false matches are triggered.
2601 Note: If a declaration/cast/label start can't be detected with this
2602 variable, it's necessary to use the `c-type' text property with the
2603 value `c-decl-end' on the last char of the last token preceding the
2604 declaration. See the comment blurb at the start of cc-engine.el for
2605 more info."
2607 ;; We match a sequence of characters to skip over things like \"};\"
2608 ;; more quickly. We match ")" in C for K&R region declarations, and
2609 ;; in all languages except Java for when a cpp macro definition
2610 ;; begins with a declaration.
2611 t "\\([\{\}\(\);,]+\\)"
2612 java "\\([\{\}\(;,<]+\\)"
2613 ;; Match "<" in C++ to get the first argument in a template arglist.
2614 ;; In that case there's an additional check in `c-find-decl-spots'
2615 ;; that it got open paren syntax.
2616 c++ "\\([\{\}\(\);,<]+\\)"
2617 ;; Additionally match the protection directives in Objective-C.
2618 ;; Note that this doesn't cope with the longer directives, which we
2619 ;; would have to match from start to end since they don't end with
2620 ;; any easily recognized characters.
2621 objc (concat "\\([\{\}\(\);,]+\\|"
2622 (c-make-keywords-re nil (c-lang-const c-protection-kwds))
2623 "\\)")
2624 ;; Pike is like C but we also match "[" for multiple value
2625 ;; assignments and type casts.
2626 pike "\\([\{\}\(\)\[;,]+\\)")
2627 (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re)
2628 'dont-doc)
2630 (c-lang-defconst c-decl-start-re
2631 "Regexp matching the start of any declaration, cast or label.
2632 It's used on the token after the one `c-decl-prefix-re' matched. This
2633 regexp should not try to match those constructs accurately as it's
2634 only used as a sieve to avoid spending more time checking other
2635 constructs."
2636 t (c-lang-const c-identifier-start))
2637 (c-lang-defvar c-decl-start-re (c-lang-const c-decl-start-re))
2639 (c-lang-defconst c-decl-prefix-or-start-re
2640 ;; Regexp matching something that might precede or start a
2641 ;; declaration, cast or label.
2643 ;; If the first submatch matches, it's taken to match the end of a
2644 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2645 ;; It's built from `c-decl-prefix-re'.
2647 ;; If the first submatch did not match, the match of the whole
2648 ;; regexp is taken to be at the first token in the declaration.
2649 ;; `c-decl-start-re' is not checked in this case.
2651 ;; Design note: The reason the same regexp is used to match both
2652 ;; tokens that precede declarations and start them is to avoid an
2653 ;; extra regexp search from the previous declaration spot in
2654 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2655 ;; that it finds all declaration/cast/label starts in approximately
2656 ;; linear order, so we can't do the searches in two separate passes.
2657 t (if (c-lang-const c-decl-start-kwds)
2658 (concat (c-lang-const c-decl-prefix-re)
2659 "\\|"
2660 (c-make-keywords-re t (c-lang-const c-decl-start-kwds)))
2661 (c-lang-const c-decl-prefix-re)))
2662 (c-lang-defvar c-decl-prefix-or-start-re
2663 (c-lang-const c-decl-prefix-or-start-re)
2664 'dont-doc)
2666 (c-lang-defconst c-cast-parens
2667 ;; List containing the paren characters that can open a cast, or nil in
2668 ;; languages without casts.
2669 t (c-filter-ops (c-lang-const c-operators)
2670 '(prefix)
2671 "\\`\\s\(\\'"
2672 (lambda (op) (elt op 0))))
2673 (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens))
2675 (c-lang-defconst c-block-prefix-disallowed-chars
2676 "List of syntactically relevant characters that never can occur before
2677 the open brace in any construct that contains a brace block, e.g. in
2678 the \"class Foo: public Bar\" part of:
2680 class Foo: public Bar {int x();} a, *b;
2682 If parens can occur, the chars inside those aren't filtered with this
2683 list.
2685 '<' and '>' should be disallowed even if angle bracket arglists can
2686 occur. That since the search function needs to stop at them anyway to
2687 ensure they are given paren syntax.
2689 This is used to skip backward from the open brace to find the region
2690 in which to look for a construct like \"class\", \"enum\",
2691 \"namespace\" or whatever. That skipping should be as tight as
2692 possible for good performance."
2694 ;; Default to all chars that only occurs in nonsymbol tokens outside
2695 ;; identifiers.
2696 t (set-difference
2697 (c-lang-const c-nonsymbol-token-char-list)
2698 (c-filter-ops (append (c-lang-const c-identifier-ops)
2699 (list (cons nil
2700 (c-lang-const c-after-id-concat-ops))))
2703 (lambda (op)
2704 (let ((pos 0) res)
2705 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2706 op pos)
2707 (setq res (cons (aref op (match-beginning 1)) res)
2708 pos (match-end 0)))
2709 res))))
2711 ;; Allow cpp operations (where applicable).
2712 t (if (c-lang-const c-opt-cpp-prefix)
2713 (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2714 '(?#))
2715 (c-lang-const c-block-prefix-disallowed-chars))
2717 ;; Allow ':' for inherit list starters.
2718 (c++ objc idl) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2719 '(?:))
2721 ;; Allow ',' for multiple inherits.
2722 (c++ java) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2723 '(?,))
2725 ;; Allow parentheses for anonymous inner classes in Java and class
2726 ;; initializer lists in Pike.
2727 (java pike) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2728 '(?\( ?\)))
2730 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2731 (c c++ objc) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2732 '(?\" ?')))
2734 (c-lang-defconst c-block-prefix-charset
2735 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2736 ;; for `c-syntactic-skip-backward'.
2737 t (c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars) t))
2738 (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset))
2740 (c-lang-defconst c-type-decl-prefix-key
2741 "Regexp matching the declarator operators that might precede the
2742 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
2743 regexp should match \"(\" if parentheses are valid in declarators.
2744 The end of the first submatch is taken as the end of the operator.
2745 Identifier syntax is in effect when this is matched \(see
2746 `c-identifier-syntax-table')."
2747 t (if (c-lang-const c-type-modifier-kwds)
2748 (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>")
2749 ;; Default to a regexp that never matches.
2750 "\\<\\>")
2751 ;; Check that there's no "=" afterwards to avoid matching tokens
2752 ;; like "*=".
2753 (c objc) (concat "\\("
2754 "[*\(]"
2755 "\\|"
2756 (c-lang-const c-type-decl-prefix-key)
2757 "\\)"
2758 "\\([^=]\\|$\\)")
2759 c++ (concat "\\("
2760 "[*\(&]"
2761 "\\|"
2762 (c-lang-const c-type-decl-prefix-key)
2763 "\\|"
2764 (concat "\\(" ; 3
2765 ;; If this matches there's special treatment in
2766 ;; `c-font-lock-declarators' and
2767 ;; `c-font-lock-declarations' that check for a
2768 ;; complete name followed by ":: *".
2769 (c-lang-const c-identifier-start)
2770 "\\)")
2771 "\\)"
2772 "\\([^=]\\|$\\)")
2773 pike "\\(\\*\\)\\([^=]\\|$\\)")
2774 (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key)
2775 'dont-doc)
2777 (c-lang-defconst c-type-decl-suffix-key
2778 "Regexp matching the declarator operators that might follow after the
2779 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
2780 regexp should match \")\" if parentheses are valid in declarators. If
2781 it matches an open paren of some kind, the type declaration check
2782 continues at the corresponding close paren, otherwise the end of the
2783 first submatch is taken as the end of the operator. Identifier syntax
2784 is in effect when this is matched (see `c-identifier-syntax-table')."
2785 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
2786 ;; function argument list parenthesis.
2787 t (if (c-lang-const c-type-modifier-kwds)
2788 (concat "\\(\(\\|"
2789 (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"
2790 "\\)")
2791 "\\(\(\\)")
2792 (c c++ objc) (concat
2793 "\\("
2794 "[\)\[\(]"
2795 (if (c-lang-const c-type-modifier-kwds)
2796 (concat
2797 "\\|"
2798 ;; "throw" in `c-type-modifier-kwds' is followed
2799 ;; by a parenthesis list, but no extra measures
2800 ;; are necessary to handle that.
2801 (regexp-opt (c-lang-const c-type-modifier-kwds) t)
2802 "\\>")
2804 "\\)")
2805 (java idl) "\\([\[\(]\\)")
2806 (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
2807 'dont-doc)
2809 (c-lang-defconst c-after-suffixed-type-decl-key
2810 "This regexp is matched after a declarator expression where
2811 `c-type-decl-suffix-key' has matched. If it matches then the
2812 construct is taken as a declaration. It's typically used to match the
2813 beginning of a function body or whatever might occur after the
2814 function header in a function declaration or definition. It's
2815 undefined whether identifier syntax (see `c-identifier-syntax-table')
2816 is in effect or not.
2818 Note that it's used in cases like after \"foo (bar)\" so it should
2819 only match when it's certain that it's a declaration, e.g \"{\" but
2820 not \",\" or \";\"."
2821 t "{"
2822 ;; If K&R style declarations should be recognized then one could
2823 ;; consider to match the start of any symbol since we want to match
2824 ;; the start of the first declaration in the "K&R region". That
2825 ;; could however produce false matches on code like "FOO(bar) x"
2826 ;; where FOO is a cpp macro, so it's better to leave it out and rely
2827 ;; on the other heuristics in that case.
2828 t (if (c-lang-const c-postfix-spec-kwds)
2829 ;; Add on the keywords in `c-postfix-spec-kwds'.
2830 (concat (c-lang-const c-after-suffixed-type-decl-key)
2831 "\\|"
2832 (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
2833 (c-lang-const c-after-suffixed-type-decl-key))
2834 ;; Also match the colon that starts a base class initializer list in
2835 ;; C++. That can be confused with a function call before the colon
2836 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
2837 ;; match before such a thing (as a declaration-level construct;
2838 ;; matches inside arglist contexts are already excluded).
2839 c++ "[{:]")
2840 (c-lang-defvar c-after-suffixed-type-decl-key
2841 (c-lang-const c-after-suffixed-type-decl-key)
2842 'dont-doc)
2844 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
2845 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
2846 ;; matches ";" and ",".
2847 t (concat "\\(" (c-lang-const c-after-suffixed-type-decl-key) "\\)"
2848 "\\|[;,]"))
2849 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
2850 (c-lang-const c-after-suffixed-type-maybe-decl-key))
2852 (c-lang-defconst c-opt-type-concat-key
2853 "Regexp matching operators that concatenate types, e.g. the \"|\" in
2854 \"int|string\" in Pike. The end of the first submatch is taken as the
2855 end of the operator. nil in languages without such operators. It's
2856 undefined whether identifier syntax (see `c-identifier-syntax-table')
2857 is in effect or not."
2858 t nil
2859 pike "\\([|.&]\\)\\($\\|[^|.&]\\)")
2860 (c-lang-defvar c-opt-type-concat-key (c-lang-const c-opt-type-concat-key)
2861 'dont-doc)
2863 (c-lang-defconst c-opt-type-suffix-key
2864 "Regexp matching operators that might follow after a type, or nil in
2865 languages that don't have such operators. The end of the first
2866 submatch is taken as the end of the operator. This should not match
2867 things like C++ template arglists if `c-recognize-<>-arglists' is set.
2868 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
2869 is in effect or not."
2870 t nil
2871 (c c++ objc pike) "\\(\\.\\.\\.\\)"
2872 java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)"))
2873 (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))
2875 (c-lang-defvar c-known-type-key
2876 ;; Regexp matching the known type identifiers. This is initialized
2877 ;; from the type keywords and `*-font-lock-extra-types'. The first
2878 ;; submatch is the one that matches the type. Note that this regexp
2879 ;; assumes that symbol constituents like '_' and '$' have word
2880 ;; syntax.
2881 (let* ((extra-types
2882 (when (boundp (c-mode-symbol "font-lock-extra-types"))
2883 (c-mode-var "font-lock-extra-types")))
2884 (regexp-strings
2885 (apply 'nconc
2886 (mapcar (lambda (re)
2887 (when (string-match "[][.*+?^$\\]" re)
2888 (list re)))
2889 extra-types)))
2890 (plain-strings
2891 (apply 'nconc
2892 (mapcar (lambda (re)
2893 (unless (string-match "[][.*+?^$\\]" re)
2894 (list re)))
2895 extra-types))))
2896 (concat "\\<\\("
2897 (c-concat-separated
2898 (append (list (c-make-keywords-re nil
2899 (append (c-lang-const c-primitive-type-kwds)
2900 plain-strings)))
2901 regexp-strings)
2902 "\\|")
2903 "\\)\\>")))
2905 (c-lang-defconst c-special-brace-lists
2906 "List of open- and close-chars that makes up a pike-style brace list,
2907 i.e. for a ([ ]) list there should be a cons (?\\[ . ?\\]) in this
2908 list."
2909 t nil
2910 pike '((?{ . ?}) (?\[ . ?\]) (?< . ?>)))
2911 (c-lang-defvar c-special-brace-lists (c-lang-const c-special-brace-lists))
2913 (c-lang-defconst c-recognize-knr-p
2914 "Non-nil means K&R style argument declarations are valid."
2915 t nil
2916 c t)
2917 (c-lang-defvar c-recognize-knr-p (c-lang-const c-recognize-knr-p))
2919 (c-lang-defconst c-recognize-typeless-decls
2920 "Non-nil means function declarations without return type should be
2921 recognized. That can introduce an ambiguity with parenthesized macro
2922 calls before a brace block. This setting does not affect declarations
2923 that are preceded by a declaration starting keyword, so
2924 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2925 t nil
2926 (c c++ objc) t)
2927 (c-lang-defvar c-recognize-typeless-decls
2928 (c-lang-const c-recognize-typeless-decls))
2930 (c-lang-defconst c-recognize-<>-arglists
2931 "Non-nil means C++ style template arglists should be handled. More
2932 specifically, this means a comma separated list of types or
2933 expressions surrounded by \"<\" and \">\". It's always preceded by an
2934 identifier or one of the keywords on `c-<>-type-kwds' or
2935 `c-<>-arglist-kwds'. If there's an identifier before then the whole
2936 expression is considered to be a type."
2937 t (or (consp (c-lang-const c-<>-type-kwds))
2938 (consp (c-lang-const c-<>-arglist-kwds))))
2939 (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
2941 (c-lang-defconst c-enums-contain-decls
2942 "Non-nil means that an enum structure can contain declarations."
2943 t nil
2944 java t)
2945 (c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls))
2947 (c-lang-defconst c-recognize-paren-inits
2948 "Non-nil means that parenthesis style initializers exist,
2949 i.e. constructs like
2951 Foo bar (gnu);
2953 in addition to the more classic
2955 Foo bar = gnu;"
2956 t nil
2957 c++ t)
2958 (c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))
2960 (c-lang-defconst c-recognize-paren-inexpr-blocks
2961 "Non-nil to recognize gcc style in-expression blocks,
2962 i.e. compound statements surrounded by parentheses inside expressions."
2963 t nil
2964 (c c++) t)
2965 (c-lang-defvar c-recognize-paren-inexpr-blocks
2966 (c-lang-const c-recognize-paren-inexpr-blocks))
2968 (c-lang-defconst c-opt-<>-arglist-start
2969 ;; Regexp matching the start of angle bracket arglists in languages
2970 ;; where `c-recognize-<>-arglists' is set. Does not exclude
2971 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
2972 ;; assumed to surround the preceding symbol. The whole match is
2973 ;; assumed to end directly after the opening "<".
2974 t (if (c-lang-const c-recognize-<>-arglists)
2975 (concat "\\("
2976 (c-lang-const c-symbol-key)
2977 "\\)"
2978 (c-lang-const c-syntactic-ws)
2979 "<")))
2980 (c-lang-defvar c-opt-<>-arglist-start (c-lang-const c-opt-<>-arglist-start))
2982 (c-lang-defconst c-opt-<>-arglist-start-in-paren
2983 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
2984 ;; parens. The first submatch is assumed to surround
2985 ;; `c-opt-<>-arglist-start'.
2986 t (if (c-lang-const c-opt-<>-arglist-start)
2987 (concat "\\("
2988 (c-lang-const c-opt-<>-arglist-start)
2989 "\\)\\|\\s\)")))
2990 (c-lang-defvar c-opt-<>-arglist-start-in-paren
2991 (c-lang-const c-opt-<>-arglist-start-in-paren))
2993 (c-lang-defconst c-opt-postfix-decl-spec-key
2994 ;; Regexp matching the beginning of a declaration specifier in the
2995 ;; region between the header and the body of a declaration.
2997 ;; TODO: This is currently not used uniformly; c++-mode and
2998 ;; java-mode each have their own ways of using it.
2999 t nil
3000 c++ (concat ":?"
3001 (c-lang-const c-simple-ws) "*"
3002 "\\(virtual" (c-lang-const c-simple-ws) "+\\)?\\("
3003 (c-make-keywords-re nil (c-lang-const c-protection-kwds))
3004 "\\)" (c-lang-const c-simple-ws) "+"
3005 "\\(" (c-lang-const c-symbol-key) "\\)")
3006 java (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
3007 (c-lang-defvar c-opt-postfix-decl-spec-key
3008 (c-lang-const c-opt-postfix-decl-spec-key))
3010 (c-lang-defconst c-recognize-colon-labels
3011 "Non-nil if generic labels ending with \":\" should be recognized.
3012 That includes labels in code and access keys in classes. This does
3013 not apply to labels recognized by `c-label-kwds' and
3014 `c-opt-extra-label-key'."
3015 t nil
3016 (c c++ objc java pike) t)
3017 (c-lang-defvar c-recognize-colon-labels
3018 (c-lang-const c-recognize-colon-labels))
3020 (c-lang-defconst c-label-prefix-re
3021 "Regexp like `c-decl-prefix-re' that matches any token that can precede
3022 a generic colon label. Not used if `c-recognize-colon-labels' is
3023 nil."
3024 t "\\([{};]+\\)")
3025 (c-lang-defvar c-label-prefix-re
3026 (c-lang-const c-label-prefix-re))
3028 (c-lang-defconst c-nonlabel-token-key
3029 "Regexp matching things that can't occur in generic colon labels,
3030 neither in a statement nor in a declaration context. The regexp is
3031 tested at the beginning of every sexp in a suspected label,
3032 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
3033 t (concat
3034 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
3035 (c-make-keywords-re t
3036 (set-difference (c-lang-const c-keywords)
3037 (append (c-lang-const c-label-kwds)
3038 (c-lang-const c-protection-kwds))
3039 :test 'string-equal)))
3040 ;; Don't allow string literals, except in AWK. Character constants are OK.
3041 (c objc java pike idl) (concat "\"\\|"
3042 (c-lang-const c-nonlabel-token-key))
3043 ;; Also check for open parens in C++, to catch member init lists in
3044 ;; constructors. We normally allow it so that macros with arguments
3045 ;; work in labels.
3046 c++ (concat "\\s\(\\|\"\\|" (c-lang-const c-nonlabel-token-key)))
3047 (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
3049 (c-lang-defconst c-nonlabel-token-2-key
3050 "Regexp matching things that can't occur two symbols before a colon in
3051 a label construct. This catches C++'s inheritance construct \"class foo
3052 : bar\". Only used if `c-recognize-colon-labels' is set."
3053 t "\\<\\>" ; matches nothing
3054 c++ (c-make-keywords-re t '("class")))
3055 (c-lang-defvar c-nonlabel-token-2-key (c-lang-const c-nonlabel-token-2-key))
3057 (c-lang-defconst c-opt-extra-label-key
3058 "Optional regexp matching labels.
3059 Normally, labels are detected according to `c-nonlabel-token-key',
3060 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
3061 be used if there are additional labels that aren't recognized that
3062 way."
3063 t nil
3064 objc (c-make-keywords-re t (c-lang-const c-protection-kwds)))
3065 (c-lang-defvar c-opt-extra-label-key (c-lang-const c-opt-extra-label-key))
3067 (c-lang-defconst c-opt-friend-key
3068 ;; Regexp describing friend declarations classes, or nil in
3069 ;; languages that don't have such things.
3071 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
3072 ;; template skipping isn't done properly. This will disappear soon.
3073 t nil
3074 c++ (concat "friend" (c-lang-const c-simple-ws) "+"
3075 "\\|"
3076 (concat "template"
3077 (c-lang-const c-simple-ws) "*"
3078 "<.+>"
3079 (c-lang-const c-simple-ws) "*"
3080 "friend"
3081 (c-lang-const c-simple-ws) "+")))
3082 (c-lang-defvar c-opt-friend-key (c-lang-const c-opt-friend-key))
3084 (c-lang-defconst c-opt-method-key
3085 ;; Special regexp to match the start of Objective-C methods. The
3086 ;; first submatch is assumed to end after the + or - key.
3087 t nil
3088 objc (concat
3089 ;; TODO: Ought to use a better method than anchoring on bol.
3090 "^\\s *"
3091 "\\([+-]\\)"
3092 (c-lang-const c-simple-ws) "*"
3093 (concat "\\(" ; Return type.
3094 "([^\)]*)"
3095 (c-lang-const c-simple-ws) "*"
3096 "\\)?")
3097 "\\(" (c-lang-const c-symbol-key) "\\)"))
3098 (c-lang-defvar c-opt-method-key (c-lang-const c-opt-method-key))
3100 (c-lang-defconst c-type-decl-end-used
3101 ;; Must be set in buffers where the `c-type' text property might be
3102 ;; used with the value `c-decl-end'.
3104 ;; `c-decl-end' is used to mark the ends of labels and access keys
3105 ;; to make interactive refontification work better.
3106 t (or (c-lang-const c-recognize-colon-labels)
3107 (and (c-lang-const c-label-kwds) t))
3108 ;; `c-decl-end' is used to mark the end of the @-style directives in
3109 ;; Objective-C.
3110 objc t)
3111 (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used))
3114 ;;; Wrap up the `c-lang-defvar' system.
3116 ;; Compile in the list of language variables that has been collected
3117 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
3118 ;; first element of each is nil.
3119 (defconst c-lang-variable-inits (cc-eval-when-compile c-lang-variable-inits))
3120 (defconst c-emacs-variable-inits (cc-eval-when-compile c-emacs-variable-inits))
3122 ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
3123 ;; These are typically standard emacs variables such as `comment-start'.
3124 (defmacro c-make-emacs-variables-local ()
3125 `(progn
3126 ,@(mapcar (lambda (init)
3127 `(make-local-variable ',(car init)))
3128 (cdr c-emacs-variable-inits))))
3130 (defun c-make-init-lang-vars-fun (mode)
3131 "Create a function that initializes all the language dependent variables
3132 for the given mode.
3134 This function should be evaluated at compile time, so that the
3135 function it returns is byte compiled with all the evaluated results
3136 from the language constants. Use the `c-init-language-vars' macro to
3137 accomplish that conveniently."
3139 (if (and (not load-in-progress)
3140 (boundp 'byte-compile-dest-file)
3141 (stringp byte-compile-dest-file))
3143 ;; No need to byte compile this lambda since the byte compiler is
3144 ;; smart enough to detect the `funcall' construct in the
3145 ;; `c-init-language-vars' macro below and compile it all straight
3146 ;; into the function that contains `c-init-language-vars'.
3147 `(lambda ()
3149 ;; This let sets up the context for `c-mode-var' and similar
3150 ;; that could be in the result from `cl-macroexpand-all'.
3151 (let ((c-buffer-is-cc-mode ',mode)
3152 current-var source-eval)
3153 (c-make-emacs-variables-local)
3154 (condition-case err
3156 (if (eq c-version-sym ',c-version-sym)
3157 (setq ,@(let ((c-buffer-is-cc-mode mode)
3158 (c-lang-const-expansion 'immediate))
3159 ;; `c-lang-const' will expand to the evaluated
3160 ;; constant immediately in `cl-macroexpand-all'
3161 ;; below.
3162 (mapcan
3163 (lambda (init)
3164 `(current-var ',(car init)
3165 ,(car init) ,(cl-macroexpand-all
3166 (elt init 1))))
3167 ;; Note: The following `append' copies the
3168 ;; first argument. That list is small, so
3169 ;; this doesn't matter too much.
3170 (append (cdr c-emacs-variable-inits)
3171 (cdr c-lang-variable-inits)))))
3173 ;; This diagnostic message isn't useful for end
3174 ;; users, so it's disabled.
3175 ;;(unless (get ',mode 'c-has-warned-lang-consts)
3176 ;; (message ,(concat "%s compiled with CC Mode %s "
3177 ;; "but loaded with %s - evaluating "
3178 ;; "language constants from source")
3179 ;; ',mode ,c-version c-version)
3180 ;; (put ',mode 'c-has-warned-lang-consts t))
3182 (setq source-eval t)
3183 (let ((init ',(append (cdr c-emacs-variable-inits)
3184 (cdr c-lang-variable-inits))))
3185 (while init
3186 (setq current-var (caar init))
3187 (set (caar init) (eval (cadar init)))
3188 (setq init (cdr init)))))
3190 (error
3191 (if current-var
3192 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
3193 current-var
3194 (if source-eval
3195 (format "\
3196 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
3197 ',mode ,c-version c-version)
3199 err)
3200 (signal (car err) (cdr err)))))))
3202 ;; Being evaluated from source. Always use the dynamic method to
3203 ;; work well when `c-lang-defvar's in this file are reevaluated
3204 ;; interactively.
3205 `(lambda ()
3206 (require 'cc-langs)
3207 (let ((c-buffer-is-cc-mode ',mode)
3208 (init (append (cdr c-emacs-variable-inits)
3209 (cdr c-lang-variable-inits)))
3210 current-var)
3211 (c-make-emacs-variables-local)
3212 (condition-case err
3214 (while init
3215 (setq current-var (caar init))
3216 (set (caar init) (eval (cadar init)))
3217 (setq init (cdr init)))
3219 (error
3220 (if current-var
3221 (message
3222 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
3223 current-var err)
3224 (signal (car err) (cdr err)))))))
3227 (defmacro c-init-language-vars (mode)
3228 "Initialize all the language dependent variables for the given mode.
3229 This macro is expanded at compile time to a form tailored for the mode
3230 in question, so MODE must be a constant. Therefore MODE is not
3231 evaluated and should not be quoted."
3232 `(funcall ,(c-make-init-lang-vars-fun mode)))
3235 (cc-provide 'cc-langs)
3237 ;;; cc-langs.el ends here