1 ;;; cc-langs.el --- language specific settings for CC Mode
3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
7 ;; Authors: 1998- Martin Stjernholm
8 ;; 1992-1999 Barry A. Warsaw
9 ;; 1987 Dave Detlefs and 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 ;; Version: See cc-mode.el
14 ;; Keywords: c languages oop
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 2, or (at your option)
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 this program; see the file COPYING. If not, write to
30 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
31 ;; Boston, MA 02110-1301, USA.
35 ;; HACKERS NOTE: There's heavy macro magic here. If you need to make
36 ;; changes in this or other files containing `c-lang-defconst' but
37 ;; don't want to read through the longer discussion below then read
40 ;; o A change in a `c-lang-defconst' or `c-lang-defvar' will not take
41 ;; effect if the file containing the mode init function (typically
42 ;; cc-mode.el) is byte compiled.
43 ;; o To make changes show in font locking you need to reevaluate the
44 ;; `*-font-lock-keywords-*' constants, which normally is easiest to
45 ;; do with M-x eval-buffer in cc-fonts.el.
46 ;; o In either case it's necessary to reinitialize the mode to make
47 ;; the changes show in an existing buffer.
49 ;;; Introduction to the language dependent variable system:
51 ;; This file contains all the language dependent variables, except
52 ;; those specific for font locking which reside in cc-fonts.el. As
53 ;; far as possible, all the differences between the languages that CC
54 ;; Mode supports are described with these variables only, so that the
55 ;; code can be shared.
57 ;; The language constant system (see cc-defs.el) is used to specify
58 ;; various language dependent info at a high level, such as lists of
59 ;; keywords, and then from them generate - at compile time - the
60 ;; various regexps and other low-level structures actually employed in
61 ;; the code at runtime.
63 ;; This system is also designed to make it easy for developers of
64 ;; derived modes to customize the source constants for new language
65 ;; variants, without having to keep up with the exact regexps etc that
66 ;; are used in each CC Mode version. It's possible from an external
67 ;; package to add a new language by inheriting an existing one, and
68 ;; then change specific constants as necessary for the new language.
69 ;; The old values for those constants (and the values of all the other
70 ;; high-level constants) may be used to build the new ones, and those
71 ;; new values will in turn be used by the low-level definitions here
72 ;; to build the runtime constants appropriately for the new language
73 ;; in the current version of CC Mode.
75 ;; Like elsewhere in CC Mode, the existence of a doc string signifies
76 ;; that a language constant is part of the external API, and that it
77 ;; therefore can be used with a high confidence that it will continue
78 ;; to work with future versions of CC Mode. Even so, it's not
79 ;; unlikely that such constants will change meaning slightly as this
80 ;; system is refined further; a certain degree of dependence on the CC
81 ;; Mode version is unavoidable when hooking in at this level. Also
82 ;; note that there's still work to be done to actually use these
83 ;; constants everywhere inside CC Mode; there are still hardcoded
84 ;; values in many places in the code.
86 ;; Separate packages will also benefit from the compile time
87 ;; evaluation; the byte compiled file(s) for them will contain the
88 ;; compiled runtime constants ready for use by (the byte compiled) CC
89 ;; Mode, and the source definitions in this file don't have to be
90 ;; loaded then. However, if a byte compiled package is loaded that
91 ;; has been compiled with a different version of CC Mode than the one
92 ;; currently loaded, then the compiled-in values will be discarded and
93 ;; new ones will be built when the mode is initialized. That will
94 ;; automatically trig a load of the file(s) containing the source
95 ;; definitions (i.e. this file and/or cc-fonts.el) if necessary.
97 ;; A small example of a derived mode is available at
98 ;; <http://cc-mode.sourceforge.net/derived-mode-ex.el>. It also
99 ;; contains some useful hints for derived mode developers.
101 ;;; Using language variables:
103 ;; The `c-lang-defvar' forms in this file comprise the language
104 ;; variables that CC Mode uses. It does not work to use
105 ;; `c-lang-defvar' anywhere else (which isn't much of a limitation
106 ;; since these variables sole purpose is to interface with the CC Mode
107 ;; core functions). The values in these `c-lang-defvar's are not
108 ;; evaluated right away but instead collected to a single large `setq'
109 ;; that can be inserted for a particular language with the
110 ;; `c-init-language-vars' macro.
112 ;; This file is only required at compile time, or when not running
113 ;; from byte compiled files, or when the source definitions for the
114 ;; language constants are requested.
120 (if (and (boundp 'byte-compile-dest-file
)
121 (stringp byte-compile-dest-file
))
122 (cons (file-name-directory byte-compile-dest-file
) load-path
)
124 (load "cc-bytecomp" nil t
)))
126 (cc-require 'cc-defs
)
127 (cc-require 'cc-vars
)
130 ;; This file is not always loaded. See note above.
131 (cc-external-require 'cl
)
134 ;;; Setup for the `c-lang-defvar' system.
137 ;; These are used to collect the init forms from the subsequent
138 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
139 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
140 ;; and `make-variable-buffer-local's in cc-engine and
141 ;; `make-local-variable's in `c-init-language-vars-for'.
142 (defvar c-lang-variable-inits nil
)
143 (defvar c-lang-variable-inits-tail nil
)
144 (setq c-lang-variable-inits
(list nil
)
145 c-lang-variable-inits-tail c-lang-variable-inits
)
146 (defvar c-emacs-variable-inits nil
)
147 (defvar c-emacs-variable-inits-tail nil
)
148 (setq c-emacs-variable-inits
(list nil
)
149 c-emacs-variable-inits-tail c-emacs-variable-inits
))
151 (defmacro c-lang-defvar
(var val
&optional doc
)
152 "Declares the buffer local variable VAR to get the value VAL. VAL is
153 evaluated and assigned at mode initialization. More precisely, VAL is
154 evaluated and bound to VAR when the result from the macro
155 `c-init-language-vars' is evaluated.
157 `c-lang-const' is typically used in VAL to get the right value for the
158 language being initialized, and such calls will be macro expanded to
159 the evaluated constant value at compile time."
162 (eq (car-safe val
) 'c-lang-const
)
165 ;; Special case: If there's no docstring and the value is a
166 ;; simple (c-lang-const foo) where foo is the same name as VAR
167 ;; then take the docstring from the language constant foo.
168 (setq doc
(get (intern (symbol-name (nth 1 val
)) c-lang-constants
)
169 'variable-documentation
)))
173 (let ((elem (assq var
(cdr c-lang-variable-inits
))))
175 (setcdr elem
(list val doc
))
176 (setcdr c-lang-variable-inits-tail
(list (list var val doc
)))
177 (setq c-lang-variable-inits-tail
(cdr c-lang-variable-inits-tail
))))
179 ;; Return the symbol, like the other def* forms.
182 (defmacro c-lang-setvar
(var val
)
183 "Causes the variable VAR to be made buffer local and to get set to the
184 value VAL. VAL is evaluated and assigned at mode initialization. More
185 precisely, VAL is evaluated and bound to VAR when the result from the
186 macro `c-init-language-vars' is evaluated. VAR is typically a standard
187 Emacs variable like `comment-start'.
189 `c-lang-const' is typically used in VAL to get the right value for the
190 language being initialized, and such calls will be macro expanded to
191 the evaluated constant value at compile time."
192 (let ((elem (assq var
(cdr c-emacs-variable-inits
))))
194 (setcdr elem
(list val
)) ; Maybe remove "list", sometime. 2006-07-19
195 (setcdr c-emacs-variable-inits-tail
(list (list var val
)))
196 (setq c-emacs-variable-inits-tail
(cdr c-emacs-variable-inits-tail
))))
198 ;; Return the symbol, like the other def* forms.
201 (put 'c-lang-defvar
'lisp-indent-function
'defun
)
202 ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
204 (def-edebug-spec c-lang-defvar
205 (&define name def-form
&optional stringp
)) ;)
208 ;; Some helper functions used when building the language constants.
210 (defun c-filter-ops (ops opgroup-filter op-filter
&optional xlate
)
211 ;; Used to filter operators from the list OPS in a DWIM:ey way:
212 ;; OPS either has the structure of `c-operators', as a single
213 ;; group in `c-operators', or is a plain list of operators.
214 ;; OPGROUP-FILTER is used filter out the operator groups. It can
215 ;; be t to choose all groups, a list of the group type symbols to
216 ;; accept, or a function which will be called with the group
217 ;; symbol for each group and should return non-nil for those to
218 ;; include. OP-FILTER filters the individual operators in each
219 ;; group. It can be t to choose all operators, a regexp to test
220 ;; against each operator, or a function which will be called for
221 ;; each operator and should return non-nil for those to include.
222 ;; If XLATE is given, it's a function which is called for each
223 ;; matching operator and its return value is collected instead.
224 ;; If it returns a list, the elements are spliced directly into
225 ;; the final result, which is returned as a list with duplicates
226 ;; removed using `equal'. `c-mode-syntax-table' for the current
227 ;; mode is in effect during the whole procedure.
228 (unless (listp (car-safe ops
))
229 (setq ops
(list ops
)))
230 (cond ((eq opgroup-filter t
)
231 (setq opgroup-filter
(lambda (opgroup) t
)))
232 ((not (functionp opgroup-filter
))
233 (setq opgroup-filter
`(lambda (opgroup)
234 (memq opgroup
',opgroup-filter
)))))
235 (cond ((eq op-filter t
)
236 (setq op-filter
(lambda (op) t
)))
238 (setq op-filter
`(lambda (op)
239 (string-match ,op-filter op
)))))
241 (setq xlate
'identity
))
242 (c-with-syntax-table (c-lang-const c-mode-syntax-table
)
244 (mapcan (lambda (opgroup)
245 (when (if (symbolp (car opgroup
))
246 (when (funcall opgroup-filter
(car opgroup
))
247 (setq opgroup
(cdr opgroup
))
251 (when (funcall op-filter op
)
252 (let ((res (funcall xlate op
)))
253 (if (listp res
) res
(list res
)))))
259 ;;; Various mode specific values that aren't language related.
261 (c-lang-defconst c-mode-menu
262 ;; The definition for the mode menu. The menu title is prepended to
263 ;; this before it's fed to `easy-menu-define'.
264 t
`(["Comment Out Region" comment-region
265 (c-fn-region-is-active-p)]
266 ["Uncomment Region" (comment-region (region-beginning)
268 (c-fn-region-is-active-p)]
269 ["Indent Expression" c-indent-exp
270 (memq (char-after) '(?\
( ?\
[ ?\
{))]
271 ["Indent Line or Region" c-indent-line-or-region t
]
272 ["Fill Comment Paragraph" c-fill-paragraph t
]
274 ["Backward Statement" c-beginning-of-statement t
]
275 ["Forward Statement" c-end-of-statement t
]
276 ,@(when (c-lang-const c-opt-cpp-prefix
)
277 ;; Only applicable if there's a cpp preprocessor.
278 `(["Up Conditional" c-up-conditional t
]
279 ["Backward Conditional" c-backward-conditional t
]
280 ["Forward Conditional" c-forward-conditional t
]
282 ["Macro Expand Region" c-macro-expand
283 (c-fn-region-is-active-p)]
284 ["Backslashify" c-backslash-region
285 (c-fn-region-is-active-p)]))
288 ["Syntactic indentation" c-toggle-syntactic-indentation
289 :style toggle
:selected c-syntactic-indentation
]
290 ["Electric mode" c-toggle-electric-state
291 :style toggle
:selected c-electric-flag
]
292 ["Auto newline" c-toggle-auto-newline
293 :style toggle
:selected c-auto-newline
]
294 ["Hungry delete" c-toggle-hungry-state
295 :style toggle
:selected c-hungry-delete-key
]
296 ["Subword mode" c-subword-mode
297 :style toggle
:selected
(and (boundp 'c-subword-mode
)
303 (defun c-populate-syntax-table (table)
304 "Populate the given syntax table as necessary for a C-like language.
305 This includes setting ' and \" as string delimiters, and setting up
306 the comment syntax to handle both line style \"//\" and block style
307 \"/*\" \"*/\" comments."
309 (modify-syntax-entry ?_
"_" table
)
310 (modify-syntax-entry ?
\\ "\\" table
)
311 (modify-syntax-entry ?
+ "." table
)
312 (modify-syntax-entry ?-
"." table
)
313 (modify-syntax-entry ?
= "." table
)
314 (modify-syntax-entry ?%
"." table
)
315 (modify-syntax-entry ?
< "." table
)
316 (modify-syntax-entry ?
> "." table
)
317 (modify-syntax-entry ?
& "." table
)
318 (modify-syntax-entry ?|
"." table
)
319 (modify-syntax-entry ?
\' "\"" table
)
320 (modify-syntax-entry ?
\240 "." table
)
322 ;; Set up block and line oriented comments. The new C
323 ;; standard mandates both comment styles even in C, so since
324 ;; all languages now require dual comments, we make this the
328 ((memq '8-bit c-emacs-features
)
329 (modify-syntax-entry ?
/ ". 1456" table
)
330 (modify-syntax-entry ?
* ". 23" table
))
332 ((memq '1-bit c-emacs-features
)
333 (modify-syntax-entry ?
/ ". 124b" table
)
334 (modify-syntax-entry ?
* ". 23" table
))
336 (t (error "CC Mode is incompatible with this version of Emacs")))
338 (modify-syntax-entry ?
\n "> b" table
)
339 ;; Give CR the same syntax as newline, for selective-display
340 (modify-syntax-entry ?\^m
"> b" table
))
342 (c-lang-defconst c-make-mode-syntax-table
343 "Functions that generates the mode specific syntax tables.
344 The syntax tables aren't stored directly since they're quite large."
346 (let ((table (make-syntax-table)))
347 (c-populate-syntax-table table
)
348 ;; Mode specific syntaxes.
349 ,(cond ((c-major-mode-is 'objc-mode
)
350 ;; Let '@' be part of symbols in ObjC to cope with
351 ;; its compiler directives as single keyword tokens.
352 ;; This is then necessary since it's assumed that
353 ;; every keyword is a single symbol.
354 `(modify-syntax-entry ?
@ "_" table
))
355 ((c-major-mode-is 'pike-mode
)
356 `(modify-syntax-entry ?
@ "." table
)))
359 (c-lang-defconst c-mode-syntax-table
360 ;; The syntax tables in evaluated form. Only used temporarily when
361 ;; the constants in this file are evaluated.
362 t
(funcall (c-lang-const c-make-mode-syntax-table
)))
364 (c-lang-defconst c
++-make-template-syntax-table
365 ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
366 ;; parenthesis characters. Used temporarily when template argument
367 ;; lists are parsed. Note that this encourages incorrect parsing of
368 ;; templates since they might contain normal operators that uses the
369 ;; '<' and '>' characters. Therefore this syntax table might go
370 ;; away when CC Mode handles templates correctly everywhere.
373 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
374 (modify-syntax-entry ?
< "(>" table
)
375 (modify-syntax-entry ?
> ")<" table
)
377 (c-lang-defvar c
++-template-syntax-table
378 (and (c-lang-const c
++-make-template-syntax-table
)
379 (funcall (c-lang-const c
++-make-template-syntax-table
))))
381 (c-lang-defconst c-identifier-syntax-modifications
382 "A list that describes the modifications that should be done to the
383 mode syntax table to get a syntax table that matches all identifiers
384 and keywords as words.
386 The list is just like the one used in `font-lock-defaults': Each
387 element is a cons where the car is the character to modify and the cdr
388 the new syntax, as accepted by `modify-syntax-entry'."
389 ;; The $ character is not allowed in most languages (one exception
390 ;; is Java which allows it for legacy reasons) but we still classify
391 ;; it as an indentifier character since it's often used in various
392 ;; machine generated identifiers.
393 t
'((?_ .
"w") (?$ .
"w"))
394 objc
(append '((?
@ .
"w"))
395 (c-lang-const c-identifier-syntax-modifications
))
397 (c-lang-defvar c-identifier-syntax-modifications
398 (c-lang-const c-identifier-syntax-modifications
))
400 (c-lang-defvar c-identifier-syntax-table
401 (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
402 (mods c-identifier-syntax-modifications
)
407 (modify-syntax-entry (car mod
) (cdr mod
) table
))
409 "Syntax table built on the mode syntax table but additionally
410 classifies symbol constituents like '_' and '$' as word constituents,
411 so that all identifiers are recognized as words.")
414 ;;; Lexer-level syntax (identifiers, tokens etc).
416 (c-lang-defconst c-symbol-start
417 "Regexp that matches the start of a symbol, i.e. any identifier or
418 keyword. It's unspecified how far it matches. Does not contain a \\|
419 operator at the top level."
420 t
(concat "[" c-alpha
"_]")
421 objc
(concat "[" c-alpha
"@]")
422 pike
(concat "[" c-alpha
"_`]"))
423 (c-lang-defvar c-symbol-start
(c-lang-const c-symbol-start
))
425 (c-lang-defconst c-symbol-chars
426 "Set of characters that can be part of a symbol.
427 This is on the form that fits inside [ ] in a regexp."
428 ;; Pike note: With the backquote identifiers this would include most
429 ;; operator chars too, but they are handled with other means instead.
430 t
(concat c-alnum
"_$")
431 objc
(concat c-alnum
"_$@"))
433 (c-lang-defconst c-symbol-key
434 "Regexp matching identifiers and keywords (with submatch 0). Assumed
435 to match if `c-symbol-start' matches on the same position."
436 t
(concat (c-lang-const c-symbol-start
)
437 "[" (c-lang-const c-symbol-chars
) "]*")
439 ;; Use the value from C here since the operator backquote is
440 ;; covered by the other alternative.
441 (c-lang-const c-symbol-key c
)
443 (c-make-keywords-re nil
444 (c-lang-const c-overloadable-operators
))))
445 (c-lang-defvar c-symbol-key
(c-lang-const c-symbol-key
))
447 (c-lang-defconst c-symbol-key-depth
448 ;; Number of regexp grouping parens in `c-symbol-key'.
449 t
(regexp-opt-depth (c-lang-const c-symbol-key
)))
451 (c-lang-defconst c-nonsymbol-chars
452 "This is the set of chars that can't be part of a symbol, i.e. the
453 negation of `c-symbol-chars'."
454 t
(concat "^" (c-lang-const c-symbol-chars
)))
455 (c-lang-defvar c-nonsymbol-chars
(c-lang-const c-nonsymbol-chars
))
457 (c-lang-defconst c-nonsymbol-key
458 "Regexp that matches any character that can't be part of a symbol.
459 It's usually appended to other regexps to avoid matching a prefix.
460 It's assumed to not contain any submatchers."
461 ;; The same thing regarding Unicode identifiers applies here as to
463 t
(concat "[" (c-lang-const c-nonsymbol-chars
) "]"))
465 (c-lang-defconst c-identifier-ops
466 "The operators that make up fully qualified identifiers. nil in
467 languages that don't have such things. See `c-operators' for a
468 description of the format. Binary operators can concatenate symbols,
469 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
470 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
472 This value is by default merged into `c-operators'."
474 c
++ '((prefix "~" "??-" "compl")
477 ;; Java has "." to concatenate identifiers but it's also used for
478 ;; normal indexing. There's special code in the Java font lock
479 ;; rules to fontify qualified identifiers based on the standard
480 ;; naming conventions. We still define "." here to make
481 ;; `c-forward-name' move over as long names as possible which is
482 ;; necessary to e.g. handle throws clauses correctly.
483 java
'((left-assoc "."))
484 idl
'((left-assoc "::")
486 pike
'((left-assoc "::")
490 (c-lang-defconst c-opt-identifier-concat-key
491 ;; Appendable adorned regexp matching the operators that join
492 ;; symbols to fully qualified identifiers, or nil in languages that
493 ;; don't have such things.
495 ;; This was a docstring constant in 5.30. It still works but is now
496 ;; considered internal - change `c-identifier-ops' instead.
497 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
498 '(left-assoc right-assoc
)
501 (c-make-keywords-re 'appendable ops
))))
502 (c-lang-defvar c-opt-identifier-concat-key
503 (c-lang-const c-opt-identifier-concat-key
)
506 (c-lang-defconst c-opt-identifier-concat-key-depth
507 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
508 t
(regexp-opt-depth (c-lang-const c-opt-identifier-concat-key
)))
510 (c-lang-defconst c-opt-identifier-prefix-key
511 ;; Appendable adorned regexp matching operators that might precede
512 ;; an identifier and that are part of the identifier in that case.
513 ;; nil in languages without such things.
514 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
518 (c-make-keywords-re 'appendable ops
))))
520 (c-lang-defconst c-after-id-concat-ops
521 "Operators that can occur after a binary operator on `c-identifier-ops'
522 in identifiers. nil in languages that don't have such things.
524 Operators here should also have appropriate entries in `c-operators' -
525 it's not taken care of by default."
527 ;; '~' for destructors in C++, '*' for member pointers.
529 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
530 ;; in import declarations. (This will also match bogus things like
531 ;; "foo.*bar" but we don't bother.)
534 (c-lang-defconst c-opt-after-id-concat-key
535 ;; Regexp that must match the token after
536 ;; `c-opt-identifier-concat-key' for it to be considered an
537 ;; identifier concatenation operator (which e.g. causes the
538 ;; preceding identifier to be fontified as a reference). Assumed to
539 ;; be a string if `c-opt-identifier-concat-key' is.
541 ;; This was a docstring constant in 5.30. It still works but is now
542 ;; considered internal - change `c-after-id-concat-ops' instead.
543 t
(concat (c-lang-const c-symbol-start
)
544 (if (c-lang-const c-after-id-concat-ops
)
545 (concat "\\|" (c-make-keywords-re 'appendable
546 (c-lang-const c-after-id-concat-ops
)))
549 (c-lang-defconst c-identifier-start
550 "Regexp that matches the start of an (optionally qualified) identifier.
551 It should also match all keywords. It's unspecified how far it
553 t
(concat (c-lang-const c-symbol-start
)
554 (if (c-lang-const c-opt-identifier-prefix-key
)
556 (c-lang-const c-opt-identifier-prefix-key
))
558 (c-lang-defvar c-identifier-start
(c-lang-const c-identifier-start
))
560 (c-lang-defconst c-identifier-key
561 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
562 C++. It does not recognize the full range of syntactic whitespace
563 between the tokens; `c-forward-name' has to be used for that. It
564 should also not match identifiers containing parenthesis groupings,
565 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
566 ;; This regexp is more complex than strictly necessary to ensure
567 ;; that it can be matched with a minimum of backtracking.
568 t
(concat (if (c-lang-const c-opt-identifier-prefix-key
)
571 (c-lang-const c-opt-identifier-prefix-key
)
572 (c-lang-const c-simple-ws
) "*"
575 "\\(" (c-lang-const c-symbol-key
) "\\)"
576 (if (c-lang-const c-opt-identifier-concat-key
)
579 (c-lang-const c-simple-ws
) "*"
580 (c-lang-const c-opt-identifier-concat-key
)
581 (c-lang-const c-simple-ws
) "*"
582 (if (c-lang-const c-after-id-concat-ops
)
585 (c-make-keywords-re 'appendable
586 (c-lang-const c-after-id-concat-ops
))
588 ;; For flexibility, consider the symbol match
589 ;; optional if we've hit a
590 ;; `c-after-id-concat-ops' operator. This is
591 ;; also necessary to handle the "*" that can
592 ;; end import declaration identifiers in Java.
594 (c-lang-const c-simple-ws
) "*"
595 "\\(" (c-lang-const c-symbol-key
) "\\)"
598 "\\(" (c-lang-const c-symbol-key
) "\\)"
600 (concat "\\(" (c-lang-const c-symbol-key
) "\\)"))
603 (c-lang-defvar c-identifier-key
(c-lang-const c-identifier-key
))
605 (c-lang-defconst c-identifier-last-sym-match
606 ;; This was a docstring constant in 5.30 but it's no longer used.
607 ;; It's only kept to avoid breaking third party code.
609 ;; Used to identify the submatch in `c-identifier-key' that
610 ;; surrounds the last symbol in the qualified identifier. It's a
611 ;; list of submatch numbers, of which the first that has a match is
612 ;; taken. It's assumed that at least one does when the regexp has
616 (c-lang-defconst c-string-escaped-newlines
617 "Set if the language support backslash escaped newlines inside string
621 (c-lang-defvar c-string-escaped-newlines
622 (c-lang-const c-string-escaped-newlines
))
624 (c-lang-defconst c-multiline-string-start-char
625 "Set if the language supports multiline string literals without escaped
626 newlines. If t, all string literals are multiline. If a character,
627 only literals where the open quote is immediately preceded by that
628 literal are multiline."
631 (c-lang-defvar c-multiline-string-start-char
632 (c-lang-const c-multiline-string-start-char
))
634 (c-lang-defconst c-opt-cpp-prefix
635 "Regexp matching the prefix of a cpp directive in the languages that
636 normally use that macro preprocessor. Tested at bol or at boi.
637 Assumed to not contain any submatches or \\| operators."
638 ;; TODO (ACM, 2005-04-01). Amend the following to recognise escaped NLs;
639 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
642 (c-lang-defvar c-opt-cpp-prefix
(c-lang-const c-opt-cpp-prefix
))
644 (c-lang-defconst c-opt-cpp-start
645 "Regexp matching the prefix of a cpp directive including the directive
646 name, or nil in languages without preprocessor support. The first
647 submatch surrounds the directive name."
648 t
(if (c-lang-const c-opt-cpp-prefix
)
649 (concat (c-lang-const c-opt-cpp-prefix
)
650 "\\([" c-alnum
"]+\\)"))
651 ;; Pike, being a scripting language, recognizes hash-bangs too.
652 pike
(concat (c-lang-const c-opt-cpp-prefix
)
653 "\\([" c-alnum
"]+\\|!\\)"))
654 (c-lang-defvar c-opt-cpp-start
(c-lang-const c-opt-cpp-start
))
656 (c-lang-defconst c-cpp-message-directives
657 "List of cpp directives (without the prefix) that are followed by a
659 t
(if (c-lang-const c-opt-cpp-prefix
)
661 pike
'("error" "warning"))
663 (c-lang-defconst c-cpp-include-directives
664 "List of cpp directives (without the prefix) that are followed by a
665 file name in angle brackets or quotes."
666 t
(if (c-lang-const c-opt-cpp-prefix
)
668 objc
'("include" "import"))
670 (c-lang-defconst c-opt-cpp-macro-define
671 "Cpp directive (without the prefix) that is followed by a macro
672 definition, or nil if the language doesn't have any."
673 t
(if (c-lang-const c-opt-cpp-prefix
)
676 (c-lang-defconst c-opt-cpp-macro-define-start
677 ;; Regexp matching everything up to the macro body of a cpp define,
678 ;; or the end of the logical line if there is none. Set if
679 ;; c-opt-cpp-macro-define is.
680 t
(if (c-lang-const c-opt-cpp-macro-define
)
681 (concat (c-lang-const c-opt-cpp-prefix
)
682 (c-lang-const c-opt-cpp-macro-define
)
683 "[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?"
684 "\\([ \t]\\|\\\\\n\\)*")))
685 (c-lang-defvar c-opt-cpp-macro-define-start
686 (c-lang-const c-opt-cpp-macro-define-start
))
688 (c-lang-defconst c-opt-cpp-macro-define-id
689 ;; Regexp matching everything up to the end of the identifier defined
691 t
(if (c-lang-const c-opt-cpp-macro-define
)
692 (concat (c-lang-const c-opt-cpp-prefix
) ; #
693 (c-lang-const c-opt-cpp-macro-define
) ; define
694 "[ \t]+\\(\\sw\\|_\\)+")))
695 (c-lang-defvar c-opt-cpp-macro-define-id
696 (c-lang-const c-opt-cpp-macro-define-id
))
698 (c-lang-defconst c-cpp-expr-directives
699 "List if cpp directives (without the prefix) that are followed by an
701 t
(if (c-lang-const c-opt-cpp-prefix
)
704 (c-lang-defconst c-cpp-expr-functions
705 "List of functions in cpp expressions."
706 t
(if (c-lang-const c-opt-cpp-prefix
)
708 pike
'("defined" "efun" "constant"))
710 (c-lang-defconst c-assignment-operators
711 "List of all assignment operators."
712 t
'("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
713 java
(append (c-lang-const c-assignment-operators
)
715 c
++ (append (c-lang-const c-assignment-operators
)
716 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
719 (c-lang-defconst c-operators
720 "List describing all operators, along with their precedence and
721 associativity. The order in the list corresponds to the precedence of
722 the operators: The operators in each element is a group with the same
723 precedence, and the group has higher precedence than the groups in all
724 following elements. The car of each element describes the type of of
725 the operator group, and the cdr is a list of the operator tokens in
726 it. The operator group types are:
728 'prefix Unary prefix operators.
729 'postfix Unary postfix operators.
731 Unary postfix operators if and only if the chars have
733 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
734 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
735 'right-assoc-sequence
736 Right associative operator that constitutes of a
737 sequence of tokens that separate expressions. All the
738 tokens in the group are in this case taken as
739 describing the sequence in one such operator, and the
740 order between them is therefore significant.
742 Operators containing a character with paren syntax are taken to match
743 with a corresponding open/close paren somewhere else. A postfix
744 operator with close paren syntax is taken to end a postfix expression
745 started somewhere earlier, rather than start a new one at point. Vice
746 versa for prefix operators with open paren syntax.
748 Note that operators like \".\" and \"->\" which in language references
749 often are described as postfix operators are considered binary here,
750 since CC Mode treats every identifier as an expression."
752 ;; There's currently no code in CC Mode that exploit all the info
753 ;; in this variable; precedence, associativity etc are present as a
754 ;; preparation for future work.
757 ,@(when (c-lang-const c-opt-cpp-prefix
)
759 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
762 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
763 '("%:%:" "??=??=")))))
766 ,@(c-lang-const c-identifier-ops
)
767 ,@(cond ((c-major-mode-is 'c
++-mode
)
768 `((postfix-if-paren "<" ">"))) ; Templates.
769 ((c-major-mode-is 'pike-mode
)
770 `((prefix "global" "predef")))
771 ((c-major-mode-is 'java-mode
)
772 `((prefix "super"))))
775 ,@(when (c-major-mode-is 'c
++-mode
)
776 ;; The following need special treatment.
777 `((prefix "dynamic_cast" "static_cast"
778 "reinterpret_cast" "const_cast" "typeid")))
780 ,@(unless (c-major-mode-is 'java-mode
)
782 (postfix "++" "--" "[" "]" "(" ")"
783 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
784 '("<:" ":>" "??(" "??)")))
787 (prefix "++" "--" "+" "-" "!" "~"
788 ,@(when (c-major-mode-is 'c
++-mode
) '("not" "compl"))
789 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
790 '("*" "&" "sizeof" "??-"))
791 ,@(when (c-major-mode-is 'objc-mode
)
792 '("@selector" "@protocol" "@encode"))
793 ;; The following need special treatment.
794 ,@(cond ((c-major-mode-is 'c
++-mode
)
796 ((c-major-mode-is 'java-mode
)
798 ((c-major-mode-is 'pike-mode
)
799 '("class" "lambda" "catch" "throw" "gauge")))
801 ,@(when (c-major-mode-is 'pike-mode
)
802 '("[" "]"))) ; Type cast.
805 ,@(when (c-major-mode-is 'c
++-mode
)
806 `((left-assoc ".*" "->*")))
809 (left-assoc "*" "/" "%")
815 (left-assoc "<<" ">>"
816 ,@(when (c-major-mode-is 'java-mode
)
820 (left-assoc "<" ">" "<=" ">="
821 ,@(when (c-major-mode-is 'java-mode
)
825 (left-assoc "==" "!="
826 ,@(when (c-major-mode-is 'c
++-mode
) '("not_eq")))
830 ,@(when (c-major-mode-is 'c
++-mode
) '("bitand")))
832 ;; Bitwise exclusive or.
834 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
836 ,@(when (c-major-mode-is 'c
++-mode
) '("xor")))
840 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
842 ,@(when (c-major-mode-is 'c
++-mode
) '("bitor")))
846 ,@(when (c-major-mode-is 'c
++-mode
) '("and")))
850 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
852 ,@(when (c-major-mode-is 'c
++-mode
) '("or")))
855 (right-assoc-sequence "?" ":")
858 (right-assoc ,@(c-lang-const c-assignment-operators
))
861 ,@(when (c-major-mode-is 'c
++-mode
)
867 ;; IDL got its own definition since it has a much smaller operator
868 ;; set than the other languages.
869 idl
`(;; Preprocessor.
873 ,@(c-lang-const c-identifier-ops
)
877 (left-assoc "*" "/" "%")
881 (left-assoc "<<" ">>")
889 (c-lang-defconst c-operator-list
890 ;; The operators as a flat list (without duplicates).
891 t
(c-filter-ops (c-lang-const c-operators
) t t
))
893 (c-lang-defconst c-overloadable-operators
894 "List of the operators that are overloadable, in their \"identifier
895 form\". See also `c-op-identifier-prefix'."
897 c
++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
899 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
900 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
901 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
902 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
903 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
904 "()" "[]" "<::>" "??(??)")
905 ;; These work like identifiers in Pike.
906 pike
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
907 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
908 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
911 (c-lang-defconst c-overloadable-operators-regexp
912 ;; Regexp tested after an "operator" token in C++.
914 c
++ (c-make-keywords-re nil
(c-lang-const c-overloadable-operators
)))
915 (c-lang-defvar c-overloadable-operators-regexp
916 (c-lang-const c-overloadable-operators-regexp
))
918 (c-lang-defconst c-opt-op-identifier-prefix
919 "Regexp matching the token before the ones in
920 `c-overloadable-operators' when operators are specified in their
921 \"identifier form\". This typically matches \"operator\" in C++ where
922 operator functions are specified as e.g. \"operator +\". It's nil in
923 languages without operator functions or where the complete operator
924 identifier is listed in `c-overloadable-operators'.
926 This regexp is assumed to not match any non-operator identifier."
928 c
++ (c-make-keywords-re t
'("operator")))
929 (c-lang-defvar c-opt-op-identifier-prefix
930 (c-lang-const c-opt-op-identifier-prefix
))
932 ;; Note: the following alias is an old name which was a mis-spelling. It has
933 ;; been corrected above and throughout cc-engine.el. It will be removed at
934 ;; some release very shortly in the future. ACM, 2006-04-14.
935 (defalias 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
)
936 (make-obsolete-variable 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
937 "CC Mode 5.31.4, 2006-04-14")
939 (c-lang-defconst c-other-op-syntax-tokens
940 "List of the tokens made up of characters in the punctuation or
941 parenthesis syntax classes that have uses other than as expression
943 t
'("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
944 (c c
++ pike
) (append '("#" "##" ; Used by cpp.
946 (c-lang-const c-other-op-syntax-tokens
))
947 (c c
++) (append '("*") (c-lang-const c-other-op-syntax-tokens
))
948 c
++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
949 (c-lang-const c-other-op-syntax-tokens
))
950 objc
(append '("#" "##" ; Used by cpp.
951 "+" "-") (c-lang-const c-other-op-syntax-tokens
))
952 idl
(append '("#" "##") ; Used by cpp.
953 (c-lang-const c-other-op-syntax-tokens
))
955 (c-lang-const c-other-op-syntax-tokens
)
956 (c-lang-const c-overloadable-operators
))
957 awk
'("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
959 (c-lang-defconst c-all-op-syntax-tokens
960 ;; List of all tokens in the punctuation and parenthesis syntax
962 t
(delete-duplicates (append (c-lang-const c-other-op-syntax-tokens
)
963 (c-lang-const c-operator-list
))
964 :test
'string-equal
))
966 (c-lang-defconst c-nonsymbol-token-char-list
967 ;; List containing all chars not in the word, symbol or
968 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
969 ;; parenthesis and string delimiter chars.
970 t
(c-with-syntax-table (c-lang-const c-mode-syntax-table
)
971 ;; Only go through the chars in the printable ASCII range. No
972 ;; language so far has 8-bit or widestring operators.
973 (let (list (char 32))
975 (or (memq (char-syntax char
) '(?w ?_ ?
< ?
> ?\
))
976 (setq list
(cons (c-int-to-char char
) list
)))
977 (setq char
(1+ char
)))
980 (c-lang-defconst c-nonsymbol-token-regexp
981 ;; Regexp matching all tokens in the punctuation and parenthesis
982 ;; syntax classes. Note that this also matches ".", which can start
984 t
(c-make-keywords-re nil
985 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
987 "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
988 (c-lang-defvar c-nonsymbol-token-regexp
989 (c-lang-const c-nonsymbol-token-regexp
))
991 (c-lang-defconst c-assignment-op-regexp
992 ;; Regexp matching all assignment operators and only them. The
993 ;; beginning of the first submatch is used to detect the end of the
994 ;; token, along with the end of the whole match.
995 t
(if (c-lang-const c-assignment-operators
)
997 ;; Need special case for "=" since it's a prefix of "==".
1000 (c-make-keywords-re nil
1001 (set-difference (c-lang-const c-assignment-operators
)
1003 :test
'string-equal
)))
1005 (c-lang-defvar c-assignment-op-regexp
1006 (c-lang-const c-assignment-op-regexp
))
1008 (c-lang-defconst c-
<>-multichar-token-regexp
1009 ;; Regexp matching all tokens containing "<" or ">" which are longer
1011 t
(c-make-keywords-re nil
1012 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1015 (c-lang-defvar c-
<>-multichar-token-regexp
1016 (c-lang-const c-
<>-multichar-token-regexp
))
1018 (c-lang-defconst c-
<-op-cont-regexp
1019 ;; Regexp matching the second and subsequent characters of all
1020 ;; multicharacter tokens that begin with "<".
1021 t
(c-make-keywords-re nil
1022 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1025 (lambda (op) (substring op
1)))))
1026 (c-lang-defvar c-
<-op-cont-regexp
(c-lang-const c-
<-op-cont-regexp
))
1028 (c-lang-defconst c-
>-op-cont-regexp
1029 ;; Regexp matching the second and subsequent characters of all
1030 ;; multicharacter tokens that begin with ">".
1031 t
(c-make-keywords-re nil
1032 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1035 (lambda (op) (substring op
1)))))
1036 (c-lang-defvar c-
>-op-cont-regexp
(c-lang-const c-
>-op-cont-regexp
))
1038 (c-lang-defconst c-stmt-delim-chars
1039 ;; The characters that should be considered to bound statements. To
1040 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1041 ;; begin with "^" to negate the set. If ? : operators should be
1042 ;; detected then the string must end with "?:".
1044 awk
"^;{}#\n\r?:") ; The newline chars gets special treatment.
1045 (c-lang-defvar c-stmt-delim-chars
(c-lang-const c-stmt-delim-chars
))
1047 (c-lang-defconst c-stmt-delim-chars-with-comma
1048 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1050 awk
"^;,{}\n\r?:") ; The newline chars gets special treatment.
1051 (c-lang-defvar c-stmt-delim-chars-with-comma
1052 (c-lang-const c-stmt-delim-chars-with-comma
))
1055 ;;; Syntactic whitespace.
1057 (c-lang-defconst c-simple-ws
1058 "Regexp matching an ordinary whitespace character.
1059 Does not contain a \\| operator at the top level."
1060 ;; "\\s " is not enough since it doesn't match line breaks.
1061 t
"\\(\\s \\|[\n\r]\\)")
1063 (c-lang-defconst c-simple-ws-depth
1064 ;; Number of regexp grouping parens in `c-simple-ws'.
1065 t
(regexp-opt-depth (c-lang-const c-simple-ws
)))
1067 (c-lang-defconst c-line-comment-starter
1068 "String that starts line comments, or nil if such don't exist.
1069 Line comments are always terminated by newlines. At least one of
1070 `c-block-comment-starter' and this one is assumed to be set.
1072 Note that it's currently not enough to set this to support a new
1073 comment style. Other stuff like the syntax table must also be set up
1077 (c-lang-defvar c-line-comment-starter
(c-lang-const c-line-comment-starter
))
1079 (c-lang-defconst c-block-comment-starter
1080 "String that starts block comments, or nil if such don't exist.
1081 Block comments are ended by `c-block-comment-ender', which is assumed
1082 to be set if this is. At least one of `c-line-comment-starter' and
1083 this one is assumed to be set.
1085 Note that it's currently not enough to set this to support a new
1086 comment style. Other stuff like the syntax table must also be set up
1091 (c-lang-defconst c-block-comment-ender
1092 "String that ends block comments, or nil if such don't exist.
1094 Note that it's currently not enough to set this to support a new
1095 comment style. Other stuff like the syntax table must also be set up
1100 (c-lang-defconst c-comment-start-regexp
1101 ;; Regexp to match the start of any type of comment.
1102 t
(let ((re (c-make-keywords-re nil
1103 (list (c-lang-const c-line-comment-starter
)
1104 (c-lang-const c-block-comment-starter
)))))
1105 (if (memq 'gen-comment-delim c-emacs-features
)
1106 (concat re
"\\|\\s!")
1108 (c-lang-defvar c-comment-start-regexp
(c-lang-const c-comment-start-regexp
))
1110 ;;;; Added by ACM, 2003/9/18.
1111 (c-lang-defconst c-block-comment-start-regexp
1112 ;; Regexp which matches the start of a block comment (if such exists in the
1114 t
(if (c-lang-const c-block-comment-starter
)
1115 (regexp-quote (c-lang-const c-block-comment-starter
))
1117 (c-lang-defvar c-block-comment-start-regexp
1118 (c-lang-const c-block-comment-start-regexp
))
1120 (c-lang-defconst c-literal-start-regexp
1121 ;; Regexp to match the start of comments and string literals.
1122 t
(concat (c-lang-const c-comment-start-regexp
)
1124 (if (memq 'gen-string-delim c-emacs-features
)
1127 (c-lang-defvar c-literal-start-regexp
(c-lang-const c-literal-start-regexp
))
1129 (c-lang-defconst c-doc-comment-start-regexp
1130 "Regexp to match the start of documentation comments."
1132 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1133 (c c
++ objc
) "/\\*[*!]"
1136 (c-lang-defvar c-doc-comment-start-regexp
1137 (c-lang-const c-doc-comment-start-regexp
))
1139 (c-lang-defconst comment-start
1140 "String that starts comments inserted with M-; etc.
1141 `comment-start' is initialized from this."
1142 ;; Default: Prefer line comments to block comments, and pad with a space.
1143 t
(concat (or (c-lang-const c-line-comment-starter
)
1144 (c-lang-const c-block-comment-starter
))
1146 ;; In C we still default to the block comment style since line
1147 ;; comments aren't entirely portable.
1149 (c-lang-setvar comment-start
(c-lang-const comment-start
))
1151 (c-lang-defconst comment-end
1152 "String that ends comments inserted with M-; etc.
1153 `comment-end' is initialized from this."
1154 ;; Default: Use block comment style if comment-start uses block
1155 ;; comments, and pad with a space in that case.
1156 t
(if (string-match (concat "\\`\\("
1157 (c-lang-const c-block-comment-start-regexp
)
1159 (c-lang-const comment-start
))
1160 (concat " " (c-lang-const c-block-comment-ender
))
1162 (c-lang-setvar comment-end
(c-lang-const comment-end
))
1164 (c-lang-defconst comment-start-skip
1165 "Regexp to match the start of a comment plus everything up to its body.
1166 `comment-start-skip' is initialized from this."
1167 ;; Default: Allow the last char of the comment starter(s) to be
1168 ;; repeated, then allow any amount of horizontal whitespace.
1171 (mapcar (lambda (cs)
1173 (concat (regexp-quote cs
) "+")))
1174 (list (c-lang-const c-line-comment-starter
)
1175 (c-lang-const c-block-comment-starter
)))
1178 (c-lang-setvar comment-start-skip
(c-lang-const comment-start-skip
))
1180 (c-lang-defconst c-syntactic-ws-start
1181 ;; Regexp matching any sequence that can start syntactic whitespace.
1182 ;; The only uncertain case is '#' when there are cpp directives.
1184 (c-make-keywords-re nil
1185 (append (list (c-lang-const c-line-comment-starter
)
1186 (c-lang-const c-block-comment-starter
)
1187 (when (c-lang-const c-opt-cpp-prefix
)
1191 (when (memq 'gen-comment-delim c-emacs-features
)
1193 (c-lang-defvar c-syntactic-ws-start
(c-lang-const c-syntactic-ws-start
))
1195 (c-lang-defconst c-syntactic-ws-end
1196 ;; Regexp matching any single character that might end syntactic whitespace.
1198 (c-make-keywords-re nil
1199 (append (when (c-lang-const c-block-comment-ender
)
1202 (elt (c-lang-const c-block-comment-ender
)
1204 (c-lang-const c-block-comment-ender
)))))))
1206 (when (memq 'gen-comment-delim c-emacs-features
)
1208 (c-lang-defvar c-syntactic-ws-end
(c-lang-const c-syntactic-ws-end
))
1210 (c-lang-defconst c-unterminated-block-comment-regexp
1211 ;; Regexp matching an unterminated block comment that doesn't
1212 ;; contain line breaks, or nil in languages without block comments.
1213 ;; Does not contain a \| operator at the top level.
1214 t
(when (c-lang-const c-block-comment-starter
)
1216 (regexp-quote (c-lang-const c-block-comment-starter
))
1217 ;; It's messy to cook together a regexp that matches anything
1218 ;; but c-block-comment-ender.
1219 (let ((end (c-lang-const c-block-comment-ender
)))
1220 (cond ((= (length end
) 1)
1221 (concat "[^" end
"\n\r]*"))
1223 (concat "[^" (substring end
0 1) "\n\r]*"
1225 (regexp-quote (substring end
0 1)) "+"
1227 ;; The quoting rules inside char classes are silly. :P
1228 (cond ((= (elt end
0) (elt end
1))
1229 (concat (substring end
0 1) "\n\r"))
1230 ((= (elt end
1) ?\
])
1231 (concat (substring end
1 2) "\n\r"
1232 (substring end
0 1)))
1234 (concat (substring end
0 1) "\n\r"
1235 (substring end
1 2))))
1237 "[^" (substring end
0 1) "\n\r]*"
1240 (error "Can't handle a block comment ender of length %s"
1243 (c-lang-defconst c-block-comment-regexp
1244 ;; Regexp matching a block comment that doesn't contain line breaks,
1245 ;; or nil in languages without block comments. The reason we don't
1246 ;; allow line breaks is to avoid going very far and risk running out
1247 ;; of regexp stack; this regexp is intended to handle only short
1248 ;; comments that might be put in the middle of limited constructs
1249 ;; like declarations. Does not contain a \| operator at the top
1251 t
(when (c-lang-const c-unterminated-block-comment-regexp
)
1253 (c-lang-const c-unterminated-block-comment-regexp
)
1254 (let ((end (c-lang-const c-block-comment-ender
)))
1255 (cond ((= (length end
) 1)
1258 (concat (regexp-quote (substring end
0 1)) "+"
1259 (regexp-quote (substring end
1 2))))
1261 (error "Can't handle a block comment ender of length %s"
1264 (c-lang-defconst c-nonwhite-syntactic-ws
1265 ;; Regexp matching a piece of syntactic whitespace that isn't a
1266 ;; sequence of simple whitespace characters. As opposed to
1267 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1268 ;; directives as syntactic whitespace.
1269 t
(c-concat-separated
1270 (list (when (c-lang-const c-line-comment-starter
)
1271 (concat (regexp-quote (c-lang-const c-line-comment-starter
))
1273 (c-lang-const c-block-comment-regexp
)
1275 (when (memq 'gen-comment-delim c-emacs-features
)
1279 (c-lang-defconst c-syntactic-ws
1280 ;; Regexp matching syntactic whitespace, including possibly the
1281 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1282 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1283 ;; not contain a \| operator at the top level.
1284 t
(concat (c-lang-const c-simple-ws
) "*"
1286 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws
) "\\)"
1287 (c-lang-const c-simple-ws
) "*")
1290 (c-lang-defconst c-syntactic-ws-depth
1291 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1292 t
(regexp-opt-depth (c-lang-const c-syntactic-ws
)))
1294 (c-lang-defconst c-nonempty-syntactic-ws
1295 ;; Regexp matching syntactic whitespace, which is at least one
1296 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1297 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1298 ;; not contain a \| operator at the top level.
1300 (c-lang-const c-simple-ws
)
1302 (c-lang-const c-nonwhite-syntactic-ws
)
1305 (c-lang-defconst c-nonempty-syntactic-ws-depth
1306 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1307 t
(regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws
)))
1309 (c-lang-defconst c-single-line-syntactic-ws
1310 ;; Regexp matching syntactic whitespace without any line breaks. As
1311 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1312 ;; regard cpp directives as syntactic whitespace. Does not contain
1313 ;; a \| operator at the top level.
1314 t
(if (c-lang-const c-block-comment-regexp
)
1316 (c-lang-const c-block-comment-regexp
)
1320 (c-lang-defconst c-single-line-syntactic-ws-depth
1321 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1322 t
(regexp-opt-depth (c-lang-const c-single-line-syntactic-ws
)))
1324 (c-lang-defconst c-syntactic-eol
1325 ;; Regexp that matches when there is no syntactically significant
1326 ;; text before eol. Macros are regarded as syntactically
1327 ;; significant text here.
1328 t
(concat (c-lang-const c-single-line-syntactic-ws
)
1329 ;; Match eol (possibly inside a block comment or preceded
1330 ;; by a line continuation backslash), or the beginning of a
1331 ;; line comment. Note: This has to be modified for awk
1332 ;; where line comments start with '#'.
1335 (list (when (c-lang-const c-line-comment-starter
)
1336 (regexp-quote (c-lang-const c-line-comment-starter
)))
1337 (when (c-lang-const c-unterminated-block-comment-regexp
)
1338 (concat (c-lang-const c-unterminated-block-comment-regexp
)
1344 (c-lang-defvar c-syntactic-eol
(c-lang-const c-syntactic-eol
))
1347 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
1348 (c-lang-defconst c-at-vsemi-p-fn
1349 "Contains a function \"Is there a virtual semicolon at POS or point?\".
1350 Such a function takes one optional parameter, a buffer position (defaults to
1351 point), and returns nil or t. This variable contains nil for languages which
1352 don't have EOL terminated statements. "
1354 awk
'c-awk-at-vsemi-p
)
1355 (c-lang-defvar c-at-vsemi-p-fn
(c-lang-const c-at-vsemi-p-fn
))
1357 (c-lang-defconst c-vsemi-status-unknown-p-fn
1358 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
1359 The (admittedly kludgey) purpose of such a function is to prevent an infinite
1360 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
1361 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
1362 even indirectly. This variable contains nil for languages which don't have
1363 EOL terminated statements."
1365 awk
'c-awk-vsemi-status-unknown-p
)
1366 (c-lang-defvar c-vsemi-status-unknown-p-fn
1367 (c-lang-const c-vsemi-status-unknown-p-fn
))
1370 ;;; In-comment text handling.
1372 (c-lang-defconst c-paragraph-start
1373 "Regexp to append to `paragraph-start'."
1375 java
"\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1376 pike
"\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1377 (c-lang-defvar c-paragraph-start
(c-lang-const c-paragraph-start
))
1379 (c-lang-defconst c-paragraph-separate
1380 "Regexp to append to `paragraph-separate'."
1382 pike
(c-lang-const c-paragraph-start
))
1383 (c-lang-defvar c-paragraph-separate
(c-lang-const c-paragraph-separate
))
1388 ;; Note: All and only all language constants containing keyword lists
1389 ;; should end with "-kwds"; they're automatically collected into the
1390 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1392 (c-lang-defconst c-primitive-type-kwds
1393 "Primitive type keywords. As opposed to the other keyword lists, the
1394 keywords listed here are fontified with the type face instead of the
1397 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1398 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1399 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1402 Do not try to modify this list for end user customizations; the
1403 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1404 the appropriate place for that."
1405 t
'("char" "double" "float" "int" "long" "short" "signed"
1408 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1409 (c-lang-const c-primitive-type-kwds
))
1412 (c-lang-const c-primitive-type-kwds
))
1413 ;; Objective-C extends C, but probably not the new stuff in C99.
1415 '("id" "Class" "SEL" "IMP" "BOOL")
1416 (c-lang-const c-primitive-type-kwds
))
1417 java
'("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1418 idl
'("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1419 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1422 ;; The following can't really end a type, but we have to specify them
1423 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1424 ;; doesn't matter that much.
1425 "unsigned" "strong")
1426 pike
'(;; this_program isn't really a keyword, but it's practically
1427 ;; used as a builtin type.
1428 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1429 "object" "program" "string" "this_program" "void"))
1431 (c-lang-defconst c-primitive-type-key
1432 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1433 t
(c-make-keywords-re t
(c-lang-const c-primitive-type-kwds
)))
1434 (c-lang-defvar c-primitive-type-key
(c-lang-const c-primitive-type-key
))
1436 (c-lang-defconst c-primitive-type-prefix-kwds
1437 "Keywords that might act as prefixes for primitive types. Assumed to
1438 be a subset of `c-primitive-type-kwds'."
1440 (c c
++) '("long" "short" "signed" "unsigned")
1441 idl
'("long" "unsigned"
1445 (c-lang-defconst c-type-prefix-kwds
1446 "Keywords where the following name - if any - is a type name, and
1447 where the keyword together with the symbol works as a type in
1450 Note that an alternative if the second part doesn't hold is
1451 `c-type-list-kwds'. Keywords on this list are typically also present
1452 on one of the `*-decl-kwds' lists."
1454 c
'("struct" "union" "enum")
1455 c
++ (append '("class" "typename")
1456 (c-lang-const c-type-prefix-kwds c
)))
1458 (c-lang-defconst c-type-prefix-key
1459 ;; Adorned regexp matching `c-type-prefix-kwds'.
1460 t
(c-make-keywords-re t
(c-lang-const c-type-prefix-kwds
)))
1461 (c-lang-defvar c-type-prefix-key
(c-lang-const c-type-prefix-key
))
1463 (c-lang-defconst c-type-modifier-kwds
1464 "Type modifier keywords. These can occur almost anywhere in types
1465 but they don't build a type of themselves. Unlike the keywords on
1466 `c-primitive-type-kwds', they are fontified with the keyword face and
1469 c
'("const" "restrict" "volatile")
1470 c
++ '("const" "volatile" "throw")
1471 objc
'("const" "volatile"))
1473 (c-lang-defconst c-opt-type-modifier-key
1474 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1475 ;; languages without such keywords.
1476 t
(and (c-lang-const c-type-modifier-kwds
)
1477 (c-make-keywords-re t
(c-lang-const c-type-modifier-kwds
))))
1478 (c-lang-defvar c-opt-type-modifier-key
(c-lang-const c-opt-type-modifier-key
))
1480 (c-lang-defconst c-opt-type-component-key
1481 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1482 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1483 t
(and (or (c-lang-const c-primitive-type-prefix-kwds
)
1484 (c-lang-const c-type-modifier-kwds
))
1485 (c-make-keywords-re t
1486 (append (c-lang-const c-primitive-type-prefix-kwds
)
1487 (c-lang-const c-type-modifier-kwds
)))))
1488 (c-lang-defvar c-opt-type-component-key
1489 (c-lang-const c-opt-type-component-key
))
1491 (c-lang-defconst c-type-start-kwds
1492 ;; All keywords that can start a type (i.e. are either a type prefix
1493 ;; or a complete type).
1494 t
(delete-duplicates (append (c-lang-const c-primitive-type-kwds
)
1495 (c-lang-const c-type-prefix-kwds
)
1496 (c-lang-const c-type-modifier-kwds
))
1497 :test
'string-equal
))
1499 (c-lang-defconst c-class-decl-kwds
1500 "Keywords introducing declarations where the following block (if any)
1501 contains another declaration level that should be considered a class.
1503 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1504 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1505 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1508 Note that presence on this list does not automatically treat the
1509 following identifier as a type; the keyword must also be present on
1510 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1512 c
'("struct" "union")
1513 c
++ '("class" "struct" "union")
1514 objc
'("struct" "union"
1515 "@interface" "@implementation" "@protocol")
1516 java
'("class" "interface")
1517 idl
'("component" "eventtype" "exception" "home" "interface" "struct"
1520 "storagehome" "storagetype"
1522 "catalog" "executor" "manages" "segment")
1525 (c-lang-defconst c-class-key
1526 ;; Regexp matching the start of a class.
1527 t
(c-make-keywords-re t
(c-lang-const c-class-decl-kwds
)))
1528 (c-lang-defvar c-class-key
(c-lang-const c-class-key
))
1530 (c-lang-defconst c-brace-list-decl-kwds
1531 "Keywords introducing declarations where the following block (if
1532 any) is a brace list.
1534 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1535 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1536 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1541 (c-lang-defconst c-brace-list-key
1542 ;; Regexp matching the start of declarations where the following
1543 ;; block is a brace list.
1544 t
(c-make-keywords-re t
(c-lang-const c-brace-list-decl-kwds
)))
1545 (c-lang-defvar c-brace-list-key
(c-lang-const c-brace-list-key
))
1547 (c-lang-defconst c-other-block-decl-kwds
1548 "Keywords where the following block (if any) contains another
1549 declaration level that should not be considered a class. For every
1550 keyword here, CC Mode will add a set of special syntactic symbols for
1551 those blocks. E.g. if the keyword is \"foo\" then there will be
1552 `foo-open', `foo-close', and `infoo' symbols.
1554 The intention is that this category should be used for block
1555 constructs that aren't related to object orientation concepts like
1556 classes (which thus also include e.g. interfaces, templates,
1557 contracts, structs, etc). The more pragmatic distinction is that
1558 while most want some indentation inside classes, it's fairly common
1559 that they don't want it in some of these constructs, so it should be
1560 simple to configure that differently from classes. See also
1561 `c-class-decl-kwds'.
1563 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1564 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1565 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1568 (c objc
) '("extern")
1569 c
++ '("namespace" "extern")
1574 (c-lang-defconst c-other-decl-block-key
1575 ;; Regexp matching the start of blocks besides classes that contain
1576 ;; another declaration level.
1577 t
(c-make-keywords-re t
(c-lang-const c-other-block-decl-kwds
)))
1578 (c-lang-defvar c-other-decl-block-key
(c-lang-const c-other-decl-block-key
))
1580 (c-lang-defconst c-typedef-decl-kwds
1581 "Keywords introducing declarations where the identifier(s) being
1584 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1585 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1586 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1588 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1589 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1591 t
(append (c-lang-const c-class-decl-kwds
)
1592 (c-lang-const c-brace-list-decl-kwds
))
1593 ;; Languages that have a "typedef" construct.
1594 (c c
++ objc idl pike
) (append (c-lang-const c-typedef-decl-kwds
)
1596 ;; Unlike most other languages, exception names are not handled as
1597 ;; types in IDL since they only can occur in "raises" specs.
1598 idl
(delete "exception" (append (c-lang-const c-typedef-decl-kwds
) nil
)))
1600 (c-lang-defconst c-typeless-decl-kwds
1601 "Keywords introducing declarations where the \(first) identifier
1602 \(declarator) follows directly after the keyword, without any type.
1604 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1605 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1606 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1608 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1609 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1611 t
(append (c-lang-const c-class-decl-kwds
)
1612 (c-lang-const c-brace-list-decl-kwds
))
1613 ;; Note: "manages" for CORBA CIDL clashes with its presence on
1614 ;; `c-type-list-kwds' for IDL.
1615 idl
(append (c-lang-const c-typeless-decl-kwds
)
1616 '("factory" "finder" "native"
1621 pike
(append (c-lang-const c-class-decl-kwds
)
1624 (c-lang-defconst c-modifier-kwds
1625 "Keywords that can prefix normal declarations of identifiers
1626 \(and typically act as flags). Things like argument declarations
1627 inside function headers are also considered declarations in this
1630 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1631 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1632 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1635 (c c
++) '("auto" "extern" "inline" "register" "static")
1636 c
++ (append '("explicit" "friend" "mutable" "template" "using" "virtual")
1637 (c-lang-const c-modifier-kwds
))
1638 objc
'("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
1639 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
1640 idl
'("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
1641 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
1642 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
1646 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
1647 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
1648 java
'("abstract" "const" "final" "native" "private" "protected" "public"
1649 "static" "strictfp" "synchronized" "transient" "volatile")
1650 pike
'("final" "inline" "local" "nomask" "optional" "private" "protected"
1651 "public" "static" "variant"))
1653 (c-lang-defconst c-other-decl-kwds
1654 "Keywords that can start or prefix any declaration level construct,
1655 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1656 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1657 `c-typeless-decl-kwds' and `c-modifier-kwds'.
1659 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1660 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1661 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1664 objc
'("@class" "@end" "@defs")
1665 java
'("import" "package")
1666 pike
'("import" "inherit"))
1668 (c-lang-defconst c-decl-start-kwds
1669 "Keywords that always start declarations, wherever they occur.
1670 This can be used for declarations that aren't recognized by the normal
1671 combination of `c-decl-prefix-re' and `c-decl-start-re'."
1673 ;; Classes can be declared anywhere in a Pike expression.
1676 (c-lang-defconst c-decl-hangon-kwds
1677 "Keywords that can occur anywhere in a declaration level construct.
1678 This is used for self-contained things that can be tacked on anywhere
1679 on a declaration and that should be ignored to be able to recognize it
1680 correctly. Typical cases are compiler extensions like
1681 \"__attribute__\" or \"__declspec\":
1683 __declspec(noreturn) void foo();
1684 class __declspec(dllexport) classname {...};
1685 void foo() __attribute__((noreturn));
1687 Note that unrecognized plain symbols are skipped anyway if they occur
1688 before the type, so such things are not necessary to mention here.
1689 Mentioning them here is necessary only if they can occur in other
1690 places, or if they are followed by a construct that must be skipped
1691 over \(like the parens in the \"__attribute__\" and \"__declspec\"
1692 examples above). In the last case, they alse need to be present on
1693 one of `c-type-list-kwds', `c-ref-list-kwds',
1694 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1695 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1696 ;; NB: These are currently not recognized in all parts of a
1697 ;; declaration. Specifically, they aren't recognized in the middle
1698 ;; of multi-token types, inside declarators, and between the
1699 ;; identifier and the arglist paren of a function declaration.
1701 ;; FIXME: This ought to be user customizable since compiler stuff
1702 ;; like this usually is wrapped in project specific macros. (It'd
1703 ;; of course be even better if we could cope without knowing this.)
1705 (c c
++) '(;; GCC extension.
1710 (c-lang-defconst c-decl-hangon-key
1711 ;; Adorned regexp matching `c-decl-hangon-kwds'.
1712 t
(c-make-keywords-re t
(c-lang-const c-decl-hangon-kwds
)))
1713 (c-lang-defvar c-decl-hangon-key
(c-lang-const c-decl-hangon-key
))
1715 (c-lang-defconst c-prefix-spec-kwds
1716 ;; All keywords that can occur in the preamble of a declaration.
1717 ;; They typically occur before the type, but they are also matched
1718 ;; after presumptive types since we often can't be sure that
1719 ;; something is a type or just some sort of macro in front of the
1720 ;; declaration. They might be ambiguous with types or type
1722 t
(delete-duplicates (append (c-lang-const c-class-decl-kwds
)
1723 (c-lang-const c-brace-list-decl-kwds
)
1724 (c-lang-const c-other-block-decl-kwds
)
1725 (c-lang-const c-typedef-decl-kwds
)
1726 (c-lang-const c-typeless-decl-kwds
)
1727 (c-lang-const c-modifier-kwds
)
1728 (c-lang-const c-other-decl-kwds
)
1729 (c-lang-const c-decl-start-kwds
)
1730 (c-lang-const c-decl-hangon-kwds
))
1731 :test
'string-equal
))
1733 (c-lang-defconst c-prefix-spec-kwds-re
1734 ;; Adorned regexp of `c-prefix-spec-kwds'.
1735 t
(c-make-keywords-re t
(c-lang-const c-prefix-spec-kwds
)))
1736 (c-lang-defvar c-prefix-spec-kwds-re
(c-lang-const c-prefix-spec-kwds-re
))
1738 (c-lang-defconst c-specifier-key
1739 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that
1740 ;; aren't ambiguous with types or type prefixes.
1741 t
(c-make-keywords-re t
1742 (set-difference (c-lang-const c-prefix-spec-kwds
)
1743 (c-lang-const c-type-start-kwds
)
1744 :test
'string-equal
)))
1745 (c-lang-defvar c-specifier-key
(c-lang-const c-specifier-key
))
1747 (c-lang-defconst c-postfix-spec-kwds
1748 ;; Keywords that can occur after argument list of a function header
1749 ;; declaration, i.e. in the "K&R region".
1750 t
(append (c-lang-const c-postfix-decl-spec-kwds
)
1751 (c-lang-const c-decl-hangon-kwds
)))
1753 (c-lang-defconst c-not-decl-init-keywords
1754 ;; Adorned regexp matching all keywords that can't appear at the
1755 ;; start of a declaration.
1756 t
(c-make-keywords-re t
1757 (set-difference (c-lang-const c-keywords
)
1758 (append (c-lang-const c-type-start-kwds
)
1759 (c-lang-const c-prefix-spec-kwds
))
1760 :test
'string-equal
)))
1761 (c-lang-defvar c-not-decl-init-keywords
1762 (c-lang-const c-not-decl-init-keywords
))
1764 (c-lang-defconst c-protection-kwds
1765 "Access protection label keywords in classes."
1767 c
++ '("private" "protected" "public")
1768 objc
'("@private" "@protected" "@public"))
1770 (c-lang-defconst c-block-decls-with-vars
1771 "Keywords introducing declarations that can contain a block which
1772 might be followed by variable declarations, e.g. like \"foo\" in
1773 \"class Foo { ... } foo;\". So if there is a block in a declaration
1774 like that, it ends with the following ';' and not right away.
1776 The keywords on list are assumed to also be present on one of the
1777 `*-decl-kwds' lists."
1779 (c objc
) '("struct" "union" "enum" "typedef")
1780 c
++ '("class" "struct" "union" "enum" "typedef"))
1782 (c-lang-defconst c-opt-block-decls-with-vars-key
1783 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
1784 ;; languages without such constructs.
1785 t
(and (c-lang-const c-block-decls-with-vars
)
1786 (c-make-keywords-re t
(c-lang-const c-block-decls-with-vars
))))
1787 (c-lang-defvar c-opt-block-decls-with-vars-key
1788 (c-lang-const c-opt-block-decls-with-vars-key
))
1790 (c-lang-defconst c-postfix-decl-spec-kwds
1791 "Keywords introducing extra declaration specifiers in the region
1792 between the header and the body \(i.e. the \"K&R-region\") in
1795 java
'("extends" "implements" "throws")
1796 idl
'("context" "getraises" "manages" "primarykey" "raises" "setraises"
1799 "as" "const" "implements" "of" "ref"))
1801 (c-lang-defconst c-nonsymbol-sexp-kwds
1802 "Keywords that may be followed by a nonsymbol sexp before whatever
1803 construct it's part of continues."
1805 (c c
++ objc
) '("extern"))
1807 (c-lang-defconst c-type-list-kwds
1808 "Keywords that may be followed by a comma separated list of type
1809 identifiers, where each optionally can be prefixed by keywords. (Can
1810 also be used for the special case when the list can contain only one
1813 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
1814 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
1815 There's also no reason to add keywords that prefixes a normal
1816 declaration consisting of a type followed by a declarator (list), so
1817 the keywords on `c-modifier-kwds' should normally not be listed here
1820 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1821 or variable identifier (that's being defined)."
1825 java
'("import" "new" "extends" "implements" "throws")
1826 idl
'("manages" "native" "primarykey" "supports"
1828 "as" "implements" "of" "scope")
1831 (c-lang-defconst c-ref-list-kwds
1832 "Keywords that may be followed by a comma separated list of
1833 reference (i.e. namespace/scope/module) identifiers, where each
1834 optionally can be prefixed by keywords. (Can also be used for the
1835 special case when the list can contain only one element.) Assumed to
1836 be mutually exclusive with `c-type-list-kwds'.
1838 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1839 or variable identifier (that's being defined)."
1843 idl
'("import" "module"
1848 (c-lang-defconst c-colon-type-list-kwds
1849 "Keywords that may be followed (not necessarily directly) by a colon
1850 and then a comma separated list of type identifiers, where each
1851 optionally can be prefixed by keywords. (Can also be used for the
1852 special case when the list can contain only one element.)"
1854 c
++ '("class" "struct")
1855 idl
'("component" "eventtype" "home" "interface" "valuetype"
1857 "storagehome" "storagetype"))
1859 (c-lang-defconst c-colon-type-list-re
1860 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
1861 forward to the colon. The end of the match is assumed to be directly
1862 after the colon, so the regexp should end with \":\". Must be a
1863 regexp if `c-colon-type-list-kwds' isn't nil."
1864 t
(if (c-lang-const c-colon-type-list-kwds
)
1865 ;; Disallow various common punctuation chars that can't come
1866 ;; before the ":" that starts the inherit list after "class"
1867 ;; or "struct" in C++. (Also used as default for other
1869 "[^\]\[{}();,/#=:]*:"))
1870 (c-lang-defvar c-colon-type-list-re
(c-lang-const c-colon-type-list-re
))
1872 (c-lang-defconst c-paren-nontype-kwds
1873 "Keywords that may be followed by a parenthesis expression that doesn't
1874 contain type identifiers."
1876 (c c
++) '(;; GCC extension.
1881 (c-lang-defconst c-paren-type-kwds
1882 "Keywords that may be followed by a parenthesis expression containing
1883 type identifiers separated by arbitrary tokens."
1888 pike
'("array" "function" "int" "mapping" "multiset" "object" "program"))
1890 (c-lang-defconst c-paren-any-kwds
1891 t
(delete-duplicates (append (c-lang-const c-paren-nontype-kwds
)
1892 (c-lang-const c-paren-type-kwds
))
1893 :test
'string-equal
))
1895 (c-lang-defconst c-
<>-type-kwds
1896 "Keywords that may be followed by an angle bracket expression
1897 containing type identifiers separated by \",\". The difference from
1898 `c-<>-arglist-kwds' is that unknown names are taken to be types and
1899 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
1907 (c-lang-defconst c-
<>-arglist-kwds
1908 "Keywords that can be followed by a C++ style template arglist; see
1909 `c-recognize-<>-arglists' for details. That language constant is
1910 assumed to be set if this isn't nil."
1913 idl
'("fixed" "string" "wstring"))
1915 (c-lang-defconst c-
<>-sexp-kwds
1916 ;; All keywords that can be followed by an angle bracket sexp.
1917 t
(delete-duplicates (append (c-lang-const c-
<>-type-kwds
)
1918 (c-lang-const c-
<>-arglist-kwds
))
1919 :test
'string-equal
))
1921 (c-lang-defconst c-opt-
<>-sexp-key
1922 ;; Adorned regexp matching keywords that can be followed by an angle
1923 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
1924 t
(if (c-lang-const c-recognize-
<>-arglists
)
1925 (c-make-keywords-re t
(c-lang-const c-
<>-sexp-kwds
))))
1926 (c-lang-defvar c-opt-
<>-sexp-key
(c-lang-const c-opt-
<>-sexp-key
))
1928 (c-lang-defconst c-brace-id-list-kwds
1929 "Keywords that may be followed by a brace block containing a comma
1930 separated list of identifier definitions, i.e. like the list of
1931 identifiers that follows the type in a normal declaration."
1932 t
(c-lang-const c-brace-list-decl-kwds
))
1934 (c-lang-defconst c-block-stmt-1-kwds
1935 "Statement keywords followed directly by a substatement."
1937 c
++ '("do" "else" "try")
1938 java
'("do" "else" "finally" "try")
1941 (c-lang-defconst c-block-stmt-1-key
1942 ;; Regexp matching the start of any statement followed directly by a
1943 ;; substatement (doesn't match a bare block, however).
1944 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-kwds
)))
1945 (c-lang-defvar c-block-stmt-1-key
(c-lang-const c-block-stmt-1-key
))
1947 (c-lang-defconst c-block-stmt-2-kwds
1948 "Statement keywords followed by a paren sexp and then by a substatement."
1949 t
'("for" "if" "switch" "while")
1950 c
++ '("for" "if" "switch" "while" "catch")
1951 java
'("for" "if" "switch" "while" "catch" "synchronized")
1953 pike
'("for" "if" "switch" "while" "foreach")
1954 awk
'("for" "if" "while"))
1956 (c-lang-defconst c-block-stmt-2-key
1957 ;; Regexp matching the start of any statement followed by a paren sexp
1958 ;; and then by a substatement.
1959 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-2-kwds
)))
1960 (c-lang-defvar c-block-stmt-2-key
(c-lang-const c-block-stmt-2-key
))
1962 (c-lang-defconst c-block-stmt-kwds
1963 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
1964 t
(delete-duplicates (append (c-lang-const c-block-stmt-1-kwds
)
1965 (c-lang-const c-block-stmt-2-kwds
))
1966 :test
'string-equal
))
1968 (c-lang-defconst c-opt-block-stmt-key
1969 ;; Regexp matching the start of any statement that has a
1970 ;; substatement (except a bare block). Nil in languages that
1971 ;; don't have such constructs.
1972 t
(if (or (c-lang-const c-block-stmt-1-kwds
)
1973 (c-lang-const c-block-stmt-2-kwds
))
1974 (c-make-keywords-re t
1975 (append (c-lang-const c-block-stmt-1-kwds
)
1976 (c-lang-const c-block-stmt-2-kwds
)))))
1977 (c-lang-defvar c-opt-block-stmt-key
(c-lang-const c-opt-block-stmt-key
))
1979 (c-lang-defconst c-simple-stmt-kwds
1980 "Statement keywords followed by an expression or nothing."
1981 t
'("break" "continue" "goto" "return")
1982 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
1983 java
'("break" "continue" "goto" "return" "throw")
1985 pike
'("break" "continue" "return")
1986 awk
'(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
1987 "break" "continue" "return" "delete" "exit" "getline" "next"
1988 "nextfile" "print" "printf"))
1990 (c-lang-defconst c-simple-stmt-key
1991 ;; Adorned regexp matching `c-simple-stmt-kwds'.
1992 t
(c-make-keywords-re t
(c-lang-const c-simple-stmt-kwds
)))
1993 (c-lang-defvar c-simple-stmt-key
(c-lang-const c-simple-stmt-key
))
1995 (c-lang-defconst c-paren-stmt-kwds
1996 "Statement keywords followed by a parenthesis expression that
1997 nevertheless contains a list separated with ';' and not ','."
2001 (c-lang-defconst c-paren-stmt-key
2002 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2003 t
(c-make-keywords-re t
(c-lang-const c-paren-stmt-kwds
)))
2004 (c-lang-defvar c-paren-stmt-key
(c-lang-const c-paren-stmt-key
))
2006 (c-lang-defconst c-asm-stmt-kwds
2007 "Statement keywords followed by an assembler expression."
2009 (c c
++) '("asm" "__asm__")) ;; Not standard, but common.
2011 (c-lang-defconst c-opt-asm-stmt-key
2012 ;; Regexp matching the start of an assembler statement. Nil in
2013 ;; languages that don't support that.
2014 t
(if (c-lang-const c-asm-stmt-kwds
)
2015 (c-make-keywords-re t
(c-lang-const c-asm-stmt-kwds
))))
2016 (c-lang-defvar c-opt-asm-stmt-key
(c-lang-const c-opt-asm-stmt-key
))
2018 (c-lang-defconst c-label-kwds
2019 "Keywords introducing colon terminated labels in blocks."
2020 t
'("case" "default")
2023 (c-lang-defconst c-label-kwds-regexp
2024 ;; Adorned regexp matching any keyword that introduces a label.
2025 t
(c-make-keywords-re t
(c-lang-const c-label-kwds
)))
2026 (c-lang-defvar c-label-kwds-regexp
(c-lang-const c-label-kwds-regexp
))
2028 (c-lang-defconst c-before-label-kwds
2029 "Keywords that might be followed by a label identifier."
2031 (java pike
) (append '("break" "continue")
2032 (c-lang-const c-before-label-kwds
))
2036 (c-lang-defconst c-constant-kwds
2037 "Keywords for constants."
2039 (c c
++) '("NULL" ;; Not a keyword, but practically works as one.
2040 "false" "true") ; Defined in C99.
2042 idl
'("TRUE" "FALSE")
2043 pike
'("UNDEFINED")) ;; Not a keyword, but practically works as one.
2045 (c-lang-defconst c-primary-expr-kwds
2046 "Keywords besides constants and operators that start primary expressions."
2048 c
++ '("operator" "this")
2049 objc
'("super" "self")
2051 pike
'("this")) ;; Not really a keyword, but practically works as one.
2053 (c-lang-defconst c-expr-kwds
2054 ;; Keywords that can occur anywhere in expressions. Built from
2055 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2056 t
(delete-duplicates
2057 (append (c-lang-const c-primary-expr-kwds
)
2058 (c-filter-ops (c-lang-const c-operator-list
)
2060 "\\`\\(\\w\\|\\s_\\)+\\'"))
2061 :test
'string-equal
))
2063 (c-lang-defconst c-lambda-kwds
2064 "Keywords that start lambda constructs, i.e. function definitions in
2069 (c-lang-defconst c-inexpr-block-kwds
2070 "Keywords that start constructs followed by statement blocks which can
2071 be used in expressions \(the gcc extension for this in C and C++ is
2072 handled separately by `c-recognize-paren-inexpr-blocks')."
2074 pike
'("catch" "gauge"))
2076 (c-lang-defconst c-inexpr-class-kwds
2077 "Keywords that can start classes inside expressions."
2082 (c-lang-defconst c-inexpr-brace-list-kwds
2083 "Keywords that can start brace list blocks inside expressions.
2084 Note that Java specific rules are currently applied to tell this from
2085 `c-inexpr-class-kwds'."
2089 (c-lang-defconst c-opt-inexpr-brace-list-key
2090 ;; Regexp matching the start of a brace list in an expression, or
2091 ;; nil in languages that don't have such things. This should not
2092 ;; match brace lists recognized through `c-special-brace-lists'.
2093 t
(and (c-lang-const c-inexpr-brace-list-kwds
)
2094 (c-make-keywords-re t
(c-lang-const c-inexpr-brace-list-kwds
))))
2095 (c-lang-defvar c-opt-inexpr-brace-list-key
2096 (c-lang-const c-opt-inexpr-brace-list-key
))
2098 (c-lang-defconst c-decl-block-key
2099 ;; Regexp matching keywords in any construct that contain another
2100 ;; declaration level, i.e. that isn't followed by a function block
2101 ;; or brace list. When the first submatch matches, it's an
2102 ;; unambiguous construct, otherwise it's an ambiguous match that
2103 ;; might also be the return type of a function declaration.
2104 t
(let* ((decl-kwds (append (c-lang-const c-class-decl-kwds
)
2105 (c-lang-const c-other-block-decl-kwds
)
2106 (c-lang-const c-inexpr-class-kwds
)))
2107 (unambiguous (set-difference decl-kwds
2108 (c-lang-const c-type-start-kwds
)
2109 :test
'string-equal
))
2110 (ambiguous (intersection decl-kwds
2111 (c-lang-const c-type-start-kwds
)
2112 :test
'string-equal
)))
2114 (concat (c-make-keywords-re t unambiguous
)
2116 (c-make-keywords-re t ambiguous
))
2117 (c-make-keywords-re t unambiguous
))))
2118 (c-lang-defvar c-decl-block-key
(c-lang-const c-decl-block-key
))
2120 (c-lang-defconst c-bitfield-kwds
2121 "Keywords that can introduce bitfields."
2123 (c c
++ objc
) '("char" "int" "long" "signed" "unsigned"))
2125 (c-lang-defconst c-opt-bitfield-key
2126 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2127 ;; languages without bitfield support.
2129 (c c
++) (c-make-keywords-re t
(c-lang-const c-bitfield-kwds
)))
2130 (c-lang-defvar c-opt-bitfield-key
(c-lang-const c-opt-bitfield-key
))
2132 (c-lang-defconst c-other-kwds
2133 "Keywords not accounted for by any other `*-kwds' language constant."
2136 ;; In CORBA CIDL: (These are declaration keywords that never
2137 ;; can start a declaration.)
2138 "entity" "process" "service" "session" "storage"))
2141 ;;; Constants built from keywords.
2143 ;; Note: No `*-kwds' language constants may be defined below this point.
2146 (defconst c-kwds-lang-consts
2147 ;; List of all the language constants that contain keyword lists.
2149 (mapatoms (lambda (sym)
2150 (when (and (boundp sym
)
2151 (string-match "-kwds\\'" (symbol-name sym
)))
2152 ;; Make the list of globally interned symbols
2153 ;; instead of ones interned in `c-lang-constants'.
2154 (setq list
(cons (intern (symbol-name sym
)) list
))))
2158 (c-lang-defconst c-keywords
2159 ;; All keywords as a list.
2160 t
(delete-duplicates
2161 (c-lang-defconst-eval-immediately
2162 `(append ,@(mapcar (lambda (kwds-lang-const)
2163 `(c-lang-const ,kwds-lang-const
))
2166 :test
'string-equal
))
2168 (c-lang-defconst c-keywords-regexp
2169 ;; All keywords as an adorned regexp.
2170 t
(c-make-keywords-re t
(c-lang-const c-keywords
)))
2171 (c-lang-defvar c-keywords-regexp
(c-lang-const c-keywords-regexp
))
2173 (c-lang-defconst c-keyword-member-alist
2174 ;; An alist with all the keywords in the cars. The cdr for each
2175 ;; keyword is a list of the symbols for the `*-kwds' lists that
2177 t
(let ((kwd-list-alist
2178 (c-lang-defconst-eval-immediately
2179 `(list ,@(mapcar (lambda (kwds-lang-const)
2180 `(cons ',kwds-lang-const
2181 (c-lang-const ,kwds-lang-const
)))
2182 c-kwds-lang-consts
))))
2183 lang-const kwd-list kwd
2185 (while kwd-list-alist
2186 (setq lang-const
(caar kwd-list-alist
)
2187 kwd-list
(cdar kwd-list-alist
)
2188 kwd-list-alist
(cdr kwd-list-alist
))
2190 (setq kwd
(car kwd-list
)
2191 kwd-list
(cdr kwd-list
))
2192 (unless (setq elem
(assoc kwd result-alist
))
2193 (setq result-alist
(cons (setq elem
(list kwd
)) result-alist
)))
2194 (unless (memq lang-const
(cdr elem
))
2195 (setcdr elem
(cons lang-const
(cdr elem
))))))
2198 (c-lang-defvar c-keywords-obarray
2199 ;; An obarray containing all keywords as symbols. The property list
2200 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2201 ;; lists it's a member of.
2203 ;; E.g. to see whether the string str contains a keyword on
2204 ;; `c-class-decl-kwds', one can do like this:
2205 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2206 ;; Which preferably is written using the associated functions in
2208 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2210 ;; The obarray is not stored directly as a language constant since
2211 ;; the printed representation for obarrays used in .elc files isn't
2214 (let* ((alist (c-lang-const c-keyword-member-alist
))
2216 (obarray (make-vector (* (length alist
) 2) 0)))
2218 (setq kwd
(caar alist
)
2219 lang-const-list
(cdar alist
)
2221 (setplist (intern kwd obarray
)
2222 ;; Emacs has an odd bug that causes `mapcan' to fail
2223 ;; with unintelligible errors. (XEmacs works.)
2224 ;;(mapcan (lambda (lang-const)
2225 ;; (list lang-const t))
2227 (apply 'nconc
(mapcar (lambda (lang-const)
2228 (list lang-const t
))
2232 (c-lang-defconst c-regular-keywords-regexp
2233 ;; Adorned regexp matching all keywords that should be fontified
2234 ;; with the keywords face. I.e. that aren't types or constants.
2235 t
(c-make-keywords-re t
2236 (set-difference (c-lang-const c-keywords
)
2237 (append (c-lang-const c-primitive-type-kwds
)
2238 (c-lang-const c-constant-kwds
))
2239 :test
'string-equal
)))
2240 (c-lang-defvar c-regular-keywords-regexp
2241 (c-lang-const c-regular-keywords-regexp
))
2243 (c-lang-defconst c-primary-expr-regexp
2244 ;; Regexp matching the start of any primary expression, i.e. any
2245 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2246 ;; exclude keywords; they are excluded afterwards unless the second
2247 ;; submatch matches. If the first but not the second submatch
2248 ;; matches then it is an ambiguous primary expression; it could also
2249 ;; be a match of e.g. an infix operator. (The case with ambiguous
2250 ;; keyword operators isn't handled.)
2252 t
(let* ((prefix-ops
2253 (c-filter-ops (c-lang-const c-operators
)
2256 ;; Filter out the special case prefix
2257 ;; operators that are close parens.
2258 (not (string-match "\\s)" op
)))))
2260 (nonkeyword-prefix-ops
2261 (c-filter-ops prefix-ops
2263 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2266 (c-filter-ops (c-lang-const c-operators
)
2271 right-assoc-sequence
)
2274 (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2276 :test
'string-equal
))
2277 (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2279 :test
'string-equal
)))
2283 ;; Take out all symbol class operators from `prefix-ops' and make the
2284 ;; first submatch from them together with `c-primary-expr-kwds'.
2285 (c-make-keywords-re t
2286 (append (c-lang-const c-primary-expr-kwds
)
2287 (set-difference prefix-ops nonkeyword-prefix-ops
2288 :test
'string-equal
)))
2291 ;; Match all ambiguous operators.
2292 (c-make-keywords-re nil
2293 (intersection nonkeyword-prefix-ops in-or-postfix-ops
2294 :test
'string-equal
))
2298 ;; Now match all other symbols.
2299 (c-lang-const c-symbol-start
)
2302 ;; The chars that can start integer and floating point
2307 ;; The nonambiguous operators from `prefix-ops'.
2308 (c-make-keywords-re nil
2309 (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2310 :test
'string-equal
))
2313 ;; Match string and character literals.
2315 (if (memq 'gen-string-delim c-emacs-features
)
2318 (c-lang-defvar c-primary-expr-regexp
(c-lang-const c-primary-expr-regexp
))
2321 ;;; Additional constants for parser-level constructs.
2323 (c-lang-defconst c-decl-prefix-re
2324 "Regexp matching something that might precede a declaration, cast or
2325 label, such as the last token of a preceding statement or declaration.
2326 This is used in the common situation where a declaration or cast
2327 doesn't start with any specific token that can be searched for.
2329 The regexp should not match bob; that is done implicitly. It can't
2330 require a match longer than one token. The end of the token is taken
2331 to be at the end of the first submatch, which is assumed to always
2332 match. It's undefined whether identifier syntax (see
2333 `c-identifier-syntax-table') is in effect or not. This regexp is
2334 assumed to be a superset of `c-label-prefix-re' if
2335 `c-recognize-colon-labels' is set.
2337 Besides this, `c-decl-start-kwds' is used to find declarations.
2339 Note: This variable together with `c-decl-start-re' and
2340 `c-decl-start-kwds' is only used to detect \"likely\"
2341 declaration/cast/label starts. I.e. they might produce more matches
2342 but should not miss anything (or else it's necessary to use text
2343 properties - see the next note). Wherever they match, the following
2344 construct is analyzed to see if it indeed is a declaration, cast or
2345 label. That analysis is not cheap, so it's important that not too
2346 many false matches are triggered.
2348 Note: If a declaration/cast/label start can't be detected with this
2349 variable, it's necessary to use the `c-type' text property with the
2350 value `c-decl-end' on the last char of the last token preceding the
2351 declaration. See the comment blurb at the start of cc-engine.el for
2354 ;; We match a sequence of characters to skip over things like \"};\"
2355 ;; more quickly. We match ")" in C for K&R region declarations, and
2356 ;; in all languages except Java for when a cpp macro definition
2357 ;; begins with a declaration.
2358 t
"\\([\{\}\(\);,]+\\)"
2359 java
"\\([\{\}\(;,]+\\)"
2360 ;; Match "<" in C++ to get the first argument in a template arglist.
2361 ;; In that case there's an additional check in `c-find-decl-spots'
2362 ;; that it got open paren syntax.
2363 c
++ "\\([\{\}\(\);,<]+\\)"
2364 ;; Additionally match the protection directives in Objective-C.
2365 ;; Note that this doesn't cope with the longer directives, which we
2366 ;; would have to match from start to end since they don't end with
2367 ;; any easily recognized characters.
2368 objc
(concat "\\([\{\}\(\);,]+\\|"
2369 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2371 ;; Pike is like C but we also match "[" for multiple value
2372 ;; assignments and type casts.
2373 pike
"\\([\{\}\(\)\[;,]+\\)")
2374 (c-lang-defvar c-decl-prefix-re
(c-lang-const c-decl-prefix-re
)
2377 (c-lang-defconst c-decl-start-re
2378 "Regexp matching the start of any declaration, cast or label.
2379 It's used on the token after the one `c-decl-prefix-re' matched. This
2380 regexp should not try to match those constructs accurately as it's
2381 only used as a sieve to avoid spending more time checking other
2383 t
(c-lang-const c-identifier-start
))
2384 (c-lang-defvar c-decl-start-re
(c-lang-const c-decl-start-re
))
2386 (c-lang-defconst c-decl-prefix-or-start-re
2387 ;; Regexp matching something that might precede or start a
2388 ;; declaration, cast or label.
2390 ;; If the first submatch matches, it's taken to match the end of a
2391 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2392 ;; It's built from `c-decl-prefix-re'.
2394 ;; If the first submatch did not match, the match of the whole
2395 ;; regexp is taken to be at the first token in the declaration.
2396 ;; `c-decl-start-re' is not checked in this case.
2398 ;; Design note: The reason the same regexp is used to match both
2399 ;; tokens that precede declarations and start them is to avoid an
2400 ;; extra regexp search from the previous declaration spot in
2401 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2402 ;; that it finds all declaration/cast/label starts in approximately
2403 ;; linear order, so we can't do the searches in two separate passes.
2404 t
(if (c-lang-const c-decl-start-kwds
)
2405 (concat (c-lang-const c-decl-prefix-re
)
2407 (c-make-keywords-re t
(c-lang-const c-decl-start-kwds
)))
2408 (c-lang-const c-decl-prefix-re
)))
2409 (c-lang-defvar c-decl-prefix-or-start-re
2410 (c-lang-const c-decl-prefix-or-start-re
)
2413 (c-lang-defconst c-cast-parens
2414 ;; List containing the paren characters that can open a cast, or nil in
2415 ;; languages without casts.
2416 t
(c-filter-ops (c-lang-const c-operators
)
2419 (lambda (op) (elt op
0))))
2420 (c-lang-defvar c-cast-parens
(c-lang-const c-cast-parens
))
2422 (c-lang-defconst c-block-prefix-disallowed-chars
2423 "List of syntactically relevant characters that never can occur before
2424 the open brace in any construct that contains a brace block, e.g. in
2425 the \"class Foo: public Bar\" part of:
2427 class Foo: public Bar {int x();} a, *b;
2429 If parens can occur, the chars inside those aren't filtered with this
2432 '<' and '>' should be disallowed even if angle bracket arglists can
2433 occur. That since the search function needs to stop at them anyway to
2434 ensure they are given paren syntax.
2436 This is used to skip backward from the open brace to find the region
2437 in which to look for a construct like \"class\", \"enum\",
2438 \"namespace\" or whatever. That skipping should be as tight as
2439 possible for good performance."
2441 ;; Default to all chars that only occurs in nonsymbol tokens outside
2444 (c-lang-const c-nonsymbol-token-char-list
)
2445 (c-filter-ops (append (c-lang-const c-identifier-ops
)
2447 (c-lang-const c-after-id-concat-ops
))))
2452 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2454 (setq res
(cons (aref op
(match-beginning 1)) res
)
2458 ;; Allow cpp operatios (where applicable).
2459 t
(if (c-lang-const c-opt-cpp-prefix
)
2460 (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2462 (c-lang-const c-block-prefix-disallowed-chars
))
2464 ;; Allow ':' for inherit list starters.
2465 (c++ objc idl
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2468 ;; Allow ',' for multiple inherits.
2469 (c++ java
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2472 ;; Allow parentheses for anonymous inner classes in Java and class
2473 ;; initializer lists in Pike.
2474 (java pike
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2477 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2478 (c c
++ objc
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2481 (c-lang-defconst c-block-prefix-charset
2482 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2483 ;; for `c-syntactic-skip-backward'.
2484 t
(c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars
) t
))
2485 (c-lang-defvar c-block-prefix-charset
(c-lang-const c-block-prefix-charset
))
2487 (c-lang-defconst c-type-decl-prefix-key
2488 "Regexp matching the declarator operators that might precede the
2489 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
2490 regexp should match \"(\" if parentheses are valid in declarators.
2491 The end of the first submatch is taken as the end of the operator.
2492 Identifier syntax is in effect when this is matched \(see
2493 `c-identifier-syntax-table')."
2494 t
(if (c-lang-const c-type-modifier-kwds
)
2495 (concat (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>")
2496 ;; Default to a regexp that never matches.
2498 ;; Check that there's no "=" afterwards to avoid matching tokens
2500 (c objc
) (concat "\\("
2503 (c-lang-const c-type-decl-prefix-key
)
2510 ;; If this matches there's special treatment in
2511 ;; `c-font-lock-declarators' and
2512 ;; `c-font-lock-declarations' that check for a
2513 ;; complete name followed by ":: *".
2514 (c-lang-const c-identifier-start
)
2517 (c-lang-const c-type-decl-prefix-key
)
2520 pike
"\\(\\*\\)\\([^=]\\|$\\)")
2521 (c-lang-defvar c-type-decl-prefix-key
(c-lang-const c-type-decl-prefix-key
)
2524 (c-lang-defconst c-type-decl-suffix-key
2525 "Regexp matching the declarator operators that might follow after the
2526 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
2527 regexp should match \")\" if parentheses are valid in declarators. If
2528 it matches an open paren of some kind, the type declaration check
2529 continues at the corresponding close paren, otherwise the end of the
2530 first submatch is taken as the end of the operator. Identifier syntax
2531 is in effect when this is matched (see `c-identifier-syntax-table')."
2532 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
2533 ;; function argument list parenthesis.
2534 t
(if (c-lang-const c-type-modifier-kwds
)
2536 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>"
2539 (c c
++ objc
) (concat
2542 (if (c-lang-const c-type-modifier-kwds
)
2545 ;; "throw" in `c-type-modifier-kwds' is followed
2546 ;; by a parenthesis list, but no extra measures
2547 ;; are necessary to handle that.
2548 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
)
2552 (java idl
) "\\([\[\(]\\)")
2553 (c-lang-defvar c-type-decl-suffix-key
(c-lang-const c-type-decl-suffix-key
)
2556 (c-lang-defconst c-after-suffixed-type-decl-key
2557 "This regexp is matched after a declarator expression where
2558 `c-type-decl-suffix-key' has matched. If it matches then the
2559 construct is taken as a declaration. It's typically used to match the
2560 beginning of a function body or whatever might occur after the
2561 function header in a function declaration or definition. It's
2562 undefined whether identifier syntax (see `c-identifier-syntax-table')
2563 is in effect or not.
2565 Note that it's used in cases like after \"foo (bar)\" so it should
2566 only match when it's certain that it's a declaration, e.g \"{\" but
2567 not \",\" or \";\"."
2569 ;; If K&R style declarations should be recognized then one could
2570 ;; consider to match the start of any symbol since we want to match
2571 ;; the start of the first declaration in the "K&R region". That
2572 ;; could however produce false matches on code like "FOO(bar) x"
2573 ;; where FOO is a cpp macro, so it's better to leave it out and rely
2574 ;; on the other heuristics in that case.
2575 t
(if (c-lang-const c-postfix-spec-kwds
)
2576 ;; Add on the keywords in `c-postfix-spec-kwds'.
2577 (concat (c-lang-const c-after-suffixed-type-decl-key
)
2579 (c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2580 (c-lang-const c-after-suffixed-type-decl-key
))
2581 ;; Also match the colon that starts a base class initializer list in
2582 ;; C++. That can be confused with a function call before the colon
2583 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
2584 ;; match before such a thing (as a declaration-level construct;
2585 ;; matches inside arglist contexts are already excluded).
2587 (c-lang-defvar c-after-suffixed-type-decl-key
2588 (c-lang-const c-after-suffixed-type-decl-key
)
2591 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
2592 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
2593 ;; matches ";" and ",".
2594 t
(concat "\\(" (c-lang-const c-after-suffixed-type-decl-key
) "\\)"
2596 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
2597 (c-lang-const c-after-suffixed-type-maybe-decl-key
))
2599 (c-lang-defconst c-opt-type-concat-key
2600 "Regexp matching operators that concatenate types, e.g. the \"|\" in
2601 \"int|string\" in Pike. The end of the first submatch is taken as the
2602 end of the operator. nil in languages without such operators. It's
2603 undefined whether identifier syntax (see `c-identifier-syntax-table')
2604 is in effect or not."
2606 pike
"\\([|.&]\\)\\($\\|[^|.&]\\)")
2607 (c-lang-defvar c-opt-type-concat-key
(c-lang-const c-opt-type-concat-key
)
2610 (c-lang-defconst c-opt-type-suffix-key
2611 "Regexp matching operators that might follow after a type, or nil in
2612 languages that don't have such operators. The end of the first
2613 submatch is taken as the end of the operator. This should not match
2614 things like C++ template arglists if `c-recognize-<>-arglists' is set.
2615 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
2616 is in effect or not."
2618 (c c
++ objc pike
) "\\(\\.\\.\\.\\)"
2619 java
(concat "\\(\\[" (c-lang-const c-simple-ws
) "*\\]\\)"))
2620 (c-lang-defvar c-opt-type-suffix-key
(c-lang-const c-opt-type-suffix-key
))
2622 (c-lang-defvar c-known-type-key
2623 ;; Regexp matching the known type identifiers. This is initialized
2624 ;; from the type keywords and `*-font-lock-extra-types'. The first
2625 ;; submatch is the one that matches the type. Note that this regexp
2626 ;; assumes that symbol constituents like '_' and '$' have word
2629 (when (boundp (c-mode-symbol "font-lock-extra-types"))
2630 (c-mode-var "font-lock-extra-types")))
2633 (mapcar (lambda (re)
2634 (when (string-match "[][.*+?^$\\]" re
)
2639 (mapcar (lambda (re)
2640 (unless (string-match "[][.*+?^$\\]" re
)
2645 (append (list (c-make-keywords-re nil
2646 (append (c-lang-const c-primitive-type-kwds
)
2652 (c-lang-defconst c-special-brace-lists
2653 "List of open- and close-chars that makes up a pike-style brace list,
2654 i.e. for a ([Â ]) list there should be a cons (?\\[ . ?\\]) in this
2657 pike
'((?
{ . ?
}) (?\
[ . ?\
]) (?
< . ?
>)))
2658 (c-lang-defvar c-special-brace-lists
(c-lang-const c-special-brace-lists
))
2660 (c-lang-defconst c-recognize-knr-p
2661 "Non-nil means K&R style argument declarations are valid."
2664 (c-lang-defvar c-recognize-knr-p
(c-lang-const c-recognize-knr-p
))
2666 (c-lang-defconst c-recognize-typeless-decls
2667 "Non-nil means function declarations without return type should be
2668 recognized. That can introduce an ambiguity with parenthesized macro
2669 calls before a brace block. This setting does not affect declarations
2670 that are preceded by a declaration starting keyword, so
2671 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2674 (c-lang-defvar c-recognize-typeless-decls
2675 (c-lang-const c-recognize-typeless-decls
))
2677 (c-lang-defconst c-recognize-
<>-arglists
2678 "Non-nil means C++ style template arglists should be handled. More
2679 specifically, this means a comma separated list of types or
2680 expressions surrounded by \"<\" and \">\". It's always preceded by an
2681 identifier or one of the keywords on `c-<>-type-kwds' or
2682 `c-<>-arglist-kwds'. If there's an identifier before then the whole
2683 expression is considered to be a type."
2684 t
(or (consp (c-lang-const c-
<>-type-kwds
))
2685 (consp (c-lang-const c-
<>-arglist-kwds
))))
2686 (c-lang-defvar c-recognize-
<>-arglists
(c-lang-const c-recognize-
<>-arglists
))
2688 (c-lang-defconst c-recognize-paren-inits
2689 "Non-nil means that parenthesis style initializers exist,
2690 i.e. constructs like
2694 in addition to the more classic
2699 (c-lang-defvar c-recognize-paren-inits
(c-lang-const c-recognize-paren-inits
))
2701 (c-lang-defconst c-recognize-paren-inexpr-blocks
2702 "Non-nil to recognize gcc style in-expression blocks,
2703 i.e. compound statements surrounded by parentheses inside expressions."
2706 (c-lang-defvar c-recognize-paren-inexpr-blocks
2707 (c-lang-const c-recognize-paren-inexpr-blocks
))
2709 (c-lang-defconst c-opt-
<>-arglist-start
2710 ;; Regexp matching the start of angle bracket arglists in languages
2711 ;; where `c-recognize-<>-arglists' is set. Does not exclude
2712 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
2713 ;; assumed to surround the preceding symbol. The whole match is
2714 ;; assumed to end directly after the opening "<".
2715 t
(if (c-lang-const c-recognize-
<>-arglists
)
2717 (c-lang-const c-symbol-key
)
2719 (c-lang-const c-syntactic-ws
)
2721 (c-lang-defvar c-opt-
<>-arglist-start
(c-lang-const c-opt-
<>-arglist-start
))
2723 (c-lang-defconst c-opt-
<>-arglist-start-in-paren
2724 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
2725 ;; parens. The first submatch is assumed to surround
2726 ;; `c-opt-<>-arglist-start'.
2727 t
(if (c-lang-const c-opt-
<>-arglist-start
)
2729 (c-lang-const c-opt-
<>-arglist-start
)
2731 (c-lang-defvar c-opt-
<>-arglist-start-in-paren
2732 (c-lang-const c-opt-
<>-arglist-start-in-paren
))
2734 (c-lang-defconst c-opt-postfix-decl-spec-key
2735 ;; Regexp matching the beginning of a declaration specifier in the
2736 ;; region between the header and the body of a declaration.
2738 ;; TODO: This is currently not used uniformly; c++-mode and
2739 ;; java-mode each have their own ways of using it.
2742 (c-lang-const c-simple-ws
) "*"
2743 "\\(virtual" (c-lang-const c-simple-ws
) "+\\)?\\("
2744 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2745 "\\)" (c-lang-const c-simple-ws
) "+"
2746 "\\(" (c-lang-const c-symbol-key
) "\\)")
2747 java
(c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2748 (c-lang-defvar c-opt-postfix-decl-spec-key
2749 (c-lang-const c-opt-postfix-decl-spec-key
))
2751 (c-lang-defconst c-recognize-colon-labels
2752 "Non-nil if generic labels ending with \":\" should be recognized.
2753 That includes labels in code and access keys in classes. This does
2754 not apply to labels recognized by `c-label-kwds' and
2755 `c-opt-extra-label-key'."
2757 (c c
++ objc java pike
) t
)
2758 (c-lang-defvar c-recognize-colon-labels
2759 (c-lang-const c-recognize-colon-labels
))
2761 (c-lang-defconst c-label-prefix-re
2762 "Regexp like `c-decl-prefix-re' that matches any token that can precede
2763 a generic colon label. Not used if `c-recognize-colon-labels' is
2766 (c-lang-defvar c-label-prefix-re
2767 (c-lang-const c-label-prefix-re
))
2769 (c-lang-defconst c-nonlabel-token-key
2770 "Regexp matching things that can't occur in generic colon labels,
2771 neither in a statement nor in a declaration context. The regexp is
2772 tested at the beginning of every sexp in a suspected label,
2773 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
2775 ;; Don't allow string literals.
2777 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
2778 (c-make-keywords-re t
2779 (set-difference (c-lang-const c-keywords
)
2780 (append (c-lang-const c-label-kwds
)
2781 (c-lang-const c-protection-kwds
))
2782 :test
'string-equal
)))
2783 ;; Also check for open parens in C++, to catch member init lists in
2784 ;; constructors. We normally allow it so that macros with arguments
2786 c
++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key
)))
2787 (c-lang-defvar c-nonlabel-token-key
(c-lang-const c-nonlabel-token-key
))
2789 (c-lang-defconst c-opt-extra-label-key
2790 "Optional regexp matching labels.
2791 Normally, labels are detected according to `c-nonlabel-token-key',
2792 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
2793 be used if there are additional labels that aren't recognized that
2796 objc
(c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
2797 (c-lang-defvar c-opt-extra-label-key
(c-lang-const c-opt-extra-label-key
))
2799 (c-lang-defconst c-opt-friend-key
2800 ;; Regexp describing friend declarations classes, or nil in
2801 ;; languages that don't have such things.
2803 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
2804 ;; template skipping isn't done properly. This will disappear soon.
2806 c
++ (concat "friend" (c-lang-const c-simple-ws
) "+"
2809 (c-lang-const c-simple-ws
) "*"
2811 (c-lang-const c-simple-ws
) "*"
2813 (c-lang-const c-simple-ws
) "+")))
2814 (c-lang-defvar c-opt-friend-key
(c-lang-const c-opt-friend-key
))
2816 (c-lang-defconst c-opt-method-key
2817 ;; Special regexp to match the start of Objective-C methods. The
2818 ;; first submatch is assumed to end after the + or - key.
2821 ;; TODO: Ought to use a better method than anchoring on bol.
2824 (c-lang-const c-simple-ws
) "*"
2825 (concat "\\(" ; Return type.
2827 (c-lang-const c-simple-ws
) "*"
2829 "\\(" (c-lang-const c-symbol-key
) "\\)"))
2830 (c-lang-defvar c-opt-method-key
(c-lang-const c-opt-method-key
))
2832 (c-lang-defconst c-type-decl-end-used
2833 ;; Must be set in buffers where the `c-type' text property might be
2834 ;; used with the value `c-decl-end'.
2836 ;; `c-decl-end' is used to mark the ends of labels and access keys
2837 ;; to make interactive refontification work better.
2838 t
(or (c-lang-const c-recognize-colon-labels
)
2839 (and (c-lang-const c-label-kwds
) t
))
2840 ;; `c-decl-end' is used to mark the end of the @-style directives in
2843 (c-lang-defvar c-type-decl-end-used
(c-lang-const c-type-decl-end-used
))
2846 ;;; Wrap up the `c-lang-defvar' system.
2848 ;; Compile in the list of language variables that has been collected
2849 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
2850 ;; first element of each is nil.
2851 (defconst c-lang-variable-inits
(cc-eval-when-compile c-lang-variable-inits
))
2852 (defconst c-emacs-variable-inits
(cc-eval-when-compile c-emacs-variable-inits
))
2854 (defun c-make-init-lang-vars-fun (mode)
2855 "Create a function that initializes all the language dependent variables
2858 This function should be evaluated at compile time, so that the
2859 function it returns is byte compiled with all the evaluated results
2860 from the language constants. Use the `c-init-language-vars' macro to
2861 accomplish that conveniently."
2863 (if (and (not load-in-progress
)
2864 (boundp 'byte-compile-dest-file
)
2865 (stringp byte-compile-dest-file
))
2867 ;; No need to byte compile this lambda since the byte compiler is
2868 ;; smart enough to detect the `funcall' construct in the
2869 ;; `c-init-language-vars' macro below and compile it all straight
2870 ;; into the function that contains `c-init-language-vars'.
2873 ;; This let sets up the context for `c-mode-var' and similar
2874 ;; that could be in the result from `cl-macroexpand-all'.
2875 (let ((c-buffer-is-cc-mode ',mode
)
2876 current-var source-eval
)
2879 (if (eq c-version-sym
',c-version-sym
)
2880 (setq ,@(let ((c-buffer-is-cc-mode mode
)
2881 (c-lang-const-expansion 'immediate
))
2882 ;; `c-lang-const' will expand to the evaluated
2883 ;; constant immediately in `cl-macroexpand-all'
2887 `(current-var ',(car init
)
2888 ,(car init
) ,(cl-macroexpand-all
2890 ;; Note: The following `append' copies the
2891 ;; first argument. That list is small, so
2892 ;; this doesn't matter too much.
2893 (append (cdr c-emacs-variable-inits
)
2894 (cdr c-lang-variable-inits
)))))
2896 ;; This diagnostic message isn't useful for end
2897 ;; users, so it's disabled.
2898 ;;(unless (get ',mode 'c-has-warned-lang-consts)
2899 ;; (message ,(concat "%s compiled with CC Mode %s "
2900 ;; "but loaded with %s - evaluating "
2901 ;; "language constants from source")
2902 ;; ',mode ,c-version c-version)
2903 ;; (put ',mode 'c-has-warned-lang-consts t))
2906 (setq source-eval t
)
2907 (let ((init (append (cdr c-emacs-variable-inits
)
2908 (cdr c-lang-variable-inits
))))
2910 (setq current-var
(caar init
))
2911 (set (caar init
) (eval (cadar init
)))
2912 (setq init
(cdr init
)))))
2916 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
2920 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
2921 ',mode
,c-version c-version
)
2924 (signal (car err
) (cdr err
)))))))
2926 ;; Being evaluated from source. Always use the dynamic method to
2927 ;; work well when `c-lang-defvar's in this file are reevaluated
2931 (let ((c-buffer-is-cc-mode ',mode
)
2932 (init (append (cdr c-emacs-variable-inits
)
2933 (cdr c-lang-variable-inits
)))
2938 (setq current-var
(caar init
))
2939 (set (caar init
) (eval (cadar init
)))
2940 (setq init
(cdr init
)))
2945 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
2947 (signal (car err
) (cdr err
)))))))
2950 (defmacro c-init-language-vars
(mode)
2951 "Initialize all the language dependent variables for the given mode.
2952 This macro is expanded at compile time to a form tailored for the mode
2953 in question, so MODE must be a constant. Therefore MODE is not
2954 evaluated and should not be quoted."
2955 `(funcall ,(c-make-init-lang-vars-fun mode
)))
2958 (cc-provide 'cc-langs
)
2960 ;;; arch-tag: 1ab57482-cfc2-4c5b-b628-3539c3098822
2961 ;;; cc-langs.el ends here