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, 2007
5 ;; Free Software Foundation, Inc.
7 ;; Authors: 2002- Alan Mackenzie
8 ;; 1998- Martin Stjernholm
9 ;; 1992-1999 Barry A. Warsaw
10 ;; 1987 Dave Detlefs and Stewart Clamen
11 ;; 1985 Richard M. Stallman
12 ;; Maintainer: bug-cc-mode@gnu.org
13 ;; Created: 22-Apr-1997 (split from cc-mode.el)
14 ;; Version: See cc-mode.el
15 ;; Keywords: c languages oop
17 ;; This file is part of GNU Emacs.
19 ;; GNU Emacs is free software; you can redistribute it and/or modify
20 ;; it under the terms of the GNU General Public License as published by
21 ;; the Free Software Foundation; either version 2, or (at your option)
24 ;; GNU Emacs is distributed in the hope that it will be useful,
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;; GNU General Public License for more details.
29 ;; You should have received a copy of the GNU General Public License
30 ;; along with this program; see the file COPYING. If not, write to
31 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
32 ;; Boston, MA 02110-1301, USA.
36 ;; HACKERS NOTE: There's heavy macro magic here. If you need to make
37 ;; changes in this or other files containing `c-lang-defconst' but
38 ;; don't want to read through the longer discussion below then read
41 ;; o A change in a `c-lang-defconst' or `c-lang-defvar' will not take
42 ;; effect if the file containing the mode init function (typically
43 ;; cc-mode.el) is byte compiled.
44 ;; o To make changes show in font locking you need to reevaluate the
45 ;; `*-font-lock-keywords-*' constants, which normally is easiest to
46 ;; do with M-x eval-buffer in cc-fonts.el.
47 ;; o In either case it's necessary to reinitialize the mode to make
48 ;; the changes show in an existing buffer.
50 ;;; Introduction to the language dependent variable system:
52 ;; This file contains all the language dependent variables, except
53 ;; those specific for font locking which reside in cc-fonts.el. As
54 ;; far as possible, all the differences between the languages that CC
55 ;; Mode supports are described with these variables only, so that the
56 ;; code can be shared.
58 ;; The language constant system (see cc-defs.el) is used to specify
59 ;; various language dependent info at a high level, such as lists of
60 ;; keywords, and then from them generate - at compile time - the
61 ;; various regexps and other low-level structures actually employed in
62 ;; the code at runtime.
64 ;; This system is also designed to make it easy for developers of
65 ;; derived modes to customize the source constants for new language
66 ;; variants, without having to keep up with the exact regexps etc that
67 ;; are used in each CC Mode version. It's possible from an external
68 ;; package to add a new language by inheriting an existing one, and
69 ;; then change specific constants as necessary for the new language.
70 ;; The old values for those constants (and the values of all the other
71 ;; high-level constants) may be used to build the new ones, and those
72 ;; new values will in turn be used by the low-level definitions here
73 ;; to build the runtime constants appropriately for the new language
74 ;; in the current version of CC Mode.
76 ;; Like elsewhere in CC Mode, the existence of a doc string signifies
77 ;; that a language constant is part of the external API, and that it
78 ;; therefore can be used with a high confidence that it will continue
79 ;; to work with future versions of CC Mode. Even so, it's not
80 ;; unlikely that such constants will change meaning slightly as this
81 ;; system is refined further; a certain degree of dependence on the CC
82 ;; Mode version is unavoidable when hooking in at this level. Also
83 ;; note that there's still work to be done to actually use these
84 ;; constants everywhere inside CC Mode; there are still hardcoded
85 ;; values in many places in the code.
87 ;; Separate packages will also benefit from the compile time
88 ;; evaluation; the byte compiled file(s) for them will contain the
89 ;; compiled runtime constants ready for use by (the byte compiled) CC
90 ;; Mode, and the source definitions in this file don't have to be
91 ;; loaded then. However, if a byte compiled package is loaded that
92 ;; has been compiled with a different version of CC Mode than the one
93 ;; currently loaded, then the compiled-in values will be discarded and
94 ;; new ones will be built when the mode is initialized. That will
95 ;; automatically trig a load of the file(s) containing the source
96 ;; definitions (i.e. this file and/or cc-fonts.el) if necessary.
98 ;; A small example of a derived mode is available at
99 ;; <http://cc-mode.sourceforge.net/derived-mode-ex.el>. It also
100 ;; contains some useful hints for derived mode developers.
102 ;;; Using language variables:
104 ;; The `c-lang-defvar' forms in this file comprise the language
105 ;; variables that CC Mode uses. It does not work to use
106 ;; `c-lang-defvar' anywhere else (which isn't much of a limitation
107 ;; since these variables sole purpose is to interface with the CC Mode
108 ;; core functions). The values in these `c-lang-defvar's are not
109 ;; evaluated right away but instead collected to a single large `setq'
110 ;; that can be inserted for a particular language with the
111 ;; `c-init-language-vars' macro.
113 ;; This file is only required at compile time, or when not running
114 ;; from byte compiled files, or when the source definitions for the
115 ;; language constants are requested.
121 (if (and (boundp 'byte-compile-dest-file
)
122 (stringp byte-compile-dest-file
))
123 (cons (file-name-directory byte-compile-dest-file
) load-path
)
125 (load "cc-bytecomp" nil t
)))
127 (cc-require 'cc-defs
)
128 (cc-require 'cc-vars
)
131 ;; This file is not always loaded. See note above.
132 (cc-external-require 'cl
)
135 ;;; Setup for the `c-lang-defvar' system.
138 ;; These are used to collect the init forms from the subsequent
139 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
140 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
141 ;; and `make-variable-buffer-local's in cc-engine and
142 ;; `make-local-variable's in `c-init-language-vars-for'.
143 (defvar c-lang-variable-inits nil
)
144 (defvar c-lang-variable-inits-tail nil
)
145 (setq c-lang-variable-inits
(list nil
)
146 c-lang-variable-inits-tail c-lang-variable-inits
)
147 (defvar c-emacs-variable-inits nil
)
148 (defvar c-emacs-variable-inits-tail nil
)
149 (setq c-emacs-variable-inits
(list nil
)
150 c-emacs-variable-inits-tail c-emacs-variable-inits
))
152 (defmacro c-lang-defvar
(var val
&optional doc
)
153 "Declares the buffer local variable VAR to get the value VAL. VAL is
154 evaluated and assigned at mode initialization. More precisely, VAL is
155 evaluated and bound to VAR when the result from the macro
156 `c-init-language-vars' is evaluated.
158 `c-lang-const' is typically used in VAL to get the right value for the
159 language being initialized, and such calls will be macro expanded to
160 the evaluated constant value at compile time."
163 (eq (car-safe val
) 'c-lang-const
)
166 ;; Special case: If there's no docstring and the value is a
167 ;; simple (c-lang-const foo) where foo is the same name as VAR
168 ;; then take the docstring from the language constant foo.
169 (setq doc
(get (intern (symbol-name (nth 1 val
)) c-lang-constants
)
170 'variable-documentation
)))
174 (let ((elem (assq var
(cdr c-lang-variable-inits
))))
176 (setcdr elem
(list val doc
))
177 (setcdr c-lang-variable-inits-tail
(list (list var val doc
)))
178 (setq c-lang-variable-inits-tail
(cdr c-lang-variable-inits-tail
))))
180 ;; Return the symbol, like the other def* forms.
183 (defmacro c-lang-setvar
(var val
)
184 "Causes the variable VAR to be made buffer local and to get set to the
185 value VAL. VAL is evaluated and assigned at mode initialization. More
186 precisely, VAL is evaluated and bound to VAR when the result from the
187 macro `c-init-language-vars' is evaluated. VAR is typically a standard
188 Emacs variable like `comment-start'.
190 `c-lang-const' is typically used in VAL to get the right value for the
191 language being initialized, and such calls will be macro expanded to
192 the evaluated constant value at compile time."
193 (let ((elem (assq var
(cdr c-emacs-variable-inits
))))
195 (setcdr elem
(list val
)) ; Maybe remove "list", sometime. 2006-07-19
196 (setcdr c-emacs-variable-inits-tail
(list (list var val
)))
197 (setq c-emacs-variable-inits-tail
(cdr c-emacs-variable-inits-tail
))))
199 ;; Return the symbol, like the other def* forms.
202 (put 'c-lang-defvar
'lisp-indent-function
'defun
)
203 ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
205 (def-edebug-spec c-lang-defvar
206 (&define name def-form
&optional stringp
)) ;)
209 ;; Some helper functions used when building the language constants.
211 (defun c-filter-ops (ops opgroup-filter op-filter
&optional xlate
)
212 ;; Extract a subset of the operators in the list OPS in a DWIM:ey
213 ;; way. The return value is a plain list of operators:
215 ;; OPS either has the structure of `c-operators', is a single
216 ;; group in `c-operators', or is a plain list of operators.
218 ;; OPGROUP-FILTER specifies how to select the operator groups. It
219 ;; can be t to choose all groups, a list of group type symbols
220 ;; (such as 'prefix) to accept, or a function which will be called
221 ;; with the group symbol for each group and should return non-nil
222 ;; if that group is to be included.
224 ;; If XLATE is given, it's a function which is called for each
225 ;; matching operator and its return value is collected instead.
226 ;; If it returns a list, the elements are spliced directly into
227 ;; the final result, which is returned as a list with duplicates
228 ;; removed using `equal'.
230 ;; `c-mode-syntax-table' for the current mode is in effect during
231 ;; the whole procedure.
232 (unless (listp (car-safe ops
))
233 (setq ops
(list ops
)))
234 (cond ((eq opgroup-filter t
)
235 (setq opgroup-filter
(lambda (opgroup) t
)))
236 ((not (functionp opgroup-filter
))
237 (setq opgroup-filter
`(lambda (opgroup)
238 (memq opgroup
',opgroup-filter
)))))
239 (cond ((eq op-filter t
)
240 (setq op-filter
(lambda (op) t
)))
242 (setq op-filter
`(lambda (op)
243 (string-match ,op-filter op
)))))
245 (setq xlate
'identity
))
246 (c-with-syntax-table (c-lang-const c-mode-syntax-table
)
248 (mapcan (lambda (opgroup)
249 (when (if (symbolp (car opgroup
))
250 (when (funcall opgroup-filter
(car opgroup
))
251 (setq opgroup
(cdr opgroup
))
255 (when (funcall op-filter op
)
256 (let ((res (funcall xlate op
)))
257 (if (listp res
) res
(list res
)))))
263 ;;; Various mode specific values that aren't language related.
265 (c-lang-defconst c-mode-menu
266 ;; The definition for the mode menu. The menu title is prepended to
267 ;; this before it's fed to `easy-menu-define'.
268 t
`(["Comment Out Region" comment-region
269 (c-fn-region-is-active-p)]
270 ["Uncomment Region" (comment-region (region-beginning)
272 (c-fn-region-is-active-p)]
273 ["Indent Expression" c-indent-exp
274 (memq (char-after) '(?\
( ?\
[ ?\
{))]
275 ["Indent Line or Region" c-indent-line-or-region t
]
276 ["Fill Comment Paragraph" c-fill-paragraph t
]
278 ["Backward Statement" c-beginning-of-statement t
]
279 ["Forward Statement" c-end-of-statement t
]
280 ,@(when (c-lang-const c-opt-cpp-prefix
)
281 ;; Only applicable if there's a cpp preprocessor.
282 `(["Up Conditional" c-up-conditional t
]
283 ["Backward Conditional" c-backward-conditional t
]
284 ["Forward Conditional" c-forward-conditional t
]
286 ["Macro Expand Region" c-macro-expand
287 (c-fn-region-is-active-p)]
288 ["Backslashify" c-backslash-region
289 (c-fn-region-is-active-p)]))
292 ["Syntactic indentation" c-toggle-syntactic-indentation
293 :style toggle
:selected c-syntactic-indentation
]
294 ["Electric mode" c-toggle-electric-state
295 :style toggle
:selected c-electric-flag
]
296 ["Auto newline" c-toggle-auto-newline
297 :style toggle
:selected c-auto-newline
]
298 ["Hungry delete" c-toggle-hungry-state
299 :style toggle
:selected c-hungry-delete-key
]
300 ["Subword mode" c-subword-mode
301 :style toggle
:selected
(and (boundp 'c-subword-mode
)
307 (defun c-populate-syntax-table (table)
308 "Populate the given syntax table as necessary for a C-like language.
309 This includes setting ' and \" as string delimiters, and setting up
310 the comment syntax to handle both line style \"//\" and block style
311 \"/*\" \"*/\" comments."
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 ?
> "." table
)
321 (modify-syntax-entry ?
& "." table
)
322 (modify-syntax-entry ?|
"." table
)
323 (modify-syntax-entry ?
\' "\"" table
)
324 (modify-syntax-entry ?
\240 "." table
)
326 ;; Set up block and line oriented comments. The new C
327 ;; standard mandates both comment styles even in C, so since
328 ;; all languages now require dual comments, we make this the
332 ((memq '8-bit c-emacs-features
)
333 (modify-syntax-entry ?
/ ". 1456" table
)
334 (modify-syntax-entry ?
* ". 23" table
))
336 ((memq '1-bit c-emacs-features
)
337 (modify-syntax-entry ?
/ ". 124b" table
)
338 (modify-syntax-entry ?
* ". 23" table
))
340 (t (error "CC Mode is incompatible with this version of Emacs")))
342 (modify-syntax-entry ?
\n "> b" table
)
343 ;; Give CR the same syntax as newline, for selective-display
344 (modify-syntax-entry ?\^m
"> b" table
))
346 (c-lang-defconst c-make-mode-syntax-table
347 "Functions that generates the mode specific syntax tables.
348 The syntax tables aren't stored directly since they're quite large."
350 (let ((table (make-syntax-table)))
351 (c-populate-syntax-table table
)
352 ;; Mode specific syntaxes.
353 ,(cond ((c-major-mode-is 'objc-mode
)
354 ;; Let '@' be part of symbols in ObjC to cope with
355 ;; its compiler directives as single keyword tokens.
356 ;; This is then necessary since it's assumed that
357 ;; every keyword is a single symbol.
358 `(modify-syntax-entry ?
@ "_" table
))
359 ((c-major-mode-is 'pike-mode
)
360 `(modify-syntax-entry ?
@ "." table
)))
363 (c-lang-defconst c-mode-syntax-table
364 ;; The syntax tables in evaluated form. Only used temporarily when
365 ;; the constants in this file are evaluated.
366 t
(funcall (c-lang-const c-make-mode-syntax-table
)))
368 (c-lang-defconst c
++-make-template-syntax-table
369 ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
370 ;; parenthesis characters. Used temporarily when template argument
371 ;; lists are parsed. Note that this encourages incorrect parsing of
372 ;; templates since they might contain normal operators that uses the
373 ;; '<' and '>' characters. Therefore this syntax table might go
374 ;; away when CC Mode handles templates correctly everywhere.
377 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
378 (modify-syntax-entry ?
< "(>" table
)
379 (modify-syntax-entry ?
> ")<" table
)
381 (c-lang-defvar c
++-template-syntax-table
382 (and (c-lang-const c
++-make-template-syntax-table
)
383 (funcall (c-lang-const c
++-make-template-syntax-table
))))
385 (c-lang-defconst c-identifier-syntax-modifications
386 "A list that describes the modifications that should be done to the
387 mode syntax table to get a syntax table that matches all identifiers
388 and keywords as words.
390 The list is just like the one used in `font-lock-defaults': Each
391 element is a cons where the car is the character to modify and the cdr
392 the new syntax, as accepted by `modify-syntax-entry'."
393 ;; The $ character is not allowed in most languages (one exception
394 ;; is Java which allows it for legacy reasons) but we still classify
395 ;; it as an indentifier character since it's often used in various
396 ;; machine generated identifiers.
397 t
'((?_ .
"w") (?$ .
"w"))
398 objc
(append '((?
@ .
"w"))
399 (c-lang-const c-identifier-syntax-modifications
))
401 (c-lang-defvar c-identifier-syntax-modifications
402 (c-lang-const c-identifier-syntax-modifications
))
404 (c-lang-defvar c-identifier-syntax-table
405 (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
406 (mods c-identifier-syntax-modifications
)
411 (modify-syntax-entry (car mod
) (cdr mod
) table
))
413 "Syntax table built on the mode syntax table but additionally
414 classifies symbol constituents like '_' and '$' as word constituents,
415 so that all identifiers are recognized as words.")
418 ;;; Lexer-level syntax (identifiers, tokens etc).
420 (c-lang-defconst c-symbol-start
421 "Regexp that matches the start of a symbol, i.e. any identifier or
422 keyword. It's unspecified how far it matches. Does not contain a \\|
423 operator at the top level."
424 t
(concat "[" c-alpha
"_]")
425 objc
(concat "[" c-alpha
"@]")
426 pike
(concat "[" c-alpha
"_`]"))
427 (c-lang-defvar c-symbol-start
(c-lang-const c-symbol-start
))
429 (c-lang-defconst c-symbol-chars
430 "Set of characters that can be part of a symbol.
431 This is on the form that fits inside [ ] in a regexp."
432 ;; Pike note: With the backquote identifiers this would include most
433 ;; operator chars too, but they are handled with other means instead.
434 t
(concat c-alnum
"_$")
435 objc
(concat c-alnum
"_$@"))
437 (c-lang-defconst c-symbol-key
438 "Regexp matching identifiers and keywords (with submatch 0). Assumed
439 to match if `c-symbol-start' matches on the same position."
440 t
(concat (c-lang-const c-symbol-start
)
441 "[" (c-lang-const c-symbol-chars
) "]*")
443 ;; Use the value from C here since the operator backquote is
444 ;; covered by the other alternative.
445 (c-lang-const c-symbol-key c
)
447 (c-make-keywords-re nil
448 (c-lang-const c-overloadable-operators
))))
449 (c-lang-defvar c-symbol-key
(c-lang-const c-symbol-key
))
451 (c-lang-defconst c-symbol-key-depth
452 ;; Number of regexp grouping parens in `c-symbol-key'.
453 t
(regexp-opt-depth (c-lang-const c-symbol-key
)))
455 (c-lang-defconst c-nonsymbol-chars
456 "This is the set of chars that can't be part of a symbol, i.e. the
457 negation of `c-symbol-chars'."
458 t
(concat "^" (c-lang-const c-symbol-chars
)))
459 (c-lang-defvar c-nonsymbol-chars
(c-lang-const c-nonsymbol-chars
))
461 (c-lang-defconst c-nonsymbol-key
462 "Regexp that matches any character that can't be part of a symbol.
463 It's usually appended to other regexps to avoid matching a prefix.
464 It's assumed to not contain any submatchers."
465 ;; The same thing regarding Unicode identifiers applies here as to
467 t
(concat "[" (c-lang-const c-nonsymbol-chars
) "]"))
469 (c-lang-defconst c-identifier-ops
470 "The operators that make up fully qualified identifiers. nil in
471 languages that don't have such things. See `c-operators' for a
472 description of the format. Binary operators can concatenate symbols,
473 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
474 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
476 This value is by default merged into `c-operators'."
478 c
++ '((prefix "~" "??-" "compl")
481 ;; Java has "." to concatenate identifiers but it's also used for
482 ;; normal indexing. There's special code in the Java font lock
483 ;; rules to fontify qualified identifiers based on the standard
484 ;; naming conventions. We still define "." here to make
485 ;; `c-forward-name' move over as long names as possible which is
486 ;; necessary to e.g. handle throws clauses correctly.
487 java
'((left-assoc "."))
488 idl
'((left-assoc "::")
490 pike
'((left-assoc "::")
494 (c-lang-defconst c-opt-identifier-concat-key
495 ;; Appendable adorned regexp matching the operators that join
496 ;; symbols to fully qualified identifiers, or nil in languages that
497 ;; don't have such things.
499 ;; This was a docstring constant in 5.30. It still works but is now
500 ;; considered internal - change `c-identifier-ops' instead.
501 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
502 '(left-assoc right-assoc
)
505 (c-make-keywords-re 'appendable ops
))))
506 (c-lang-defvar c-opt-identifier-concat-key
507 (c-lang-const c-opt-identifier-concat-key
)
510 (c-lang-defconst c-opt-identifier-concat-key-depth
511 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
512 t
(regexp-opt-depth (c-lang-const c-opt-identifier-concat-key
)))
514 (c-lang-defconst c-opt-identifier-prefix-key
515 ;; Appendable adorned regexp matching operators that might precede
516 ;; an identifier and that are part of the identifier in that case.
517 ;; nil in languages without such things.
518 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
522 (c-make-keywords-re 'appendable ops
))))
524 (c-lang-defconst c-after-id-concat-ops
525 "Operators that can occur after a binary operator on `c-identifier-ops'
526 in identifiers. nil in languages that don't have such things.
528 Operators here should also have appropriate entries in `c-operators' -
529 it's not taken care of by default."
531 ;; '~' for destructors in C++, '*' for member pointers.
533 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
534 ;; in import declarations. (This will also match bogus things like
535 ;; "foo.*bar" but we don't bother.)
538 (c-lang-defconst c-opt-after-id-concat-key
539 ;; Regexp that must match the token after
540 ;; `c-opt-identifier-concat-key' for it to be considered an
541 ;; identifier concatenation operator (which e.g. causes the
542 ;; preceding identifier to be fontified as a reference). Assumed to
543 ;; be a string if `c-opt-identifier-concat-key' is.
545 ;; This was a docstring constant in 5.30. It still works but is now
546 ;; considered internal - change `c-after-id-concat-ops' instead.
547 t
(concat (c-lang-const c-symbol-start
)
548 (if (c-lang-const c-after-id-concat-ops
)
549 (concat "\\|" (c-make-keywords-re 'appendable
550 (c-lang-const c-after-id-concat-ops
)))
553 (c-lang-defconst c-identifier-start
554 "Regexp that matches the start of an (optionally qualified) identifier.
555 It should also match all keywords. It's unspecified how far it
557 t
(concat (c-lang-const c-symbol-start
)
558 (if (c-lang-const c-opt-identifier-prefix-key
)
560 (c-lang-const c-opt-identifier-prefix-key
))
562 (c-lang-defvar c-identifier-start
(c-lang-const c-identifier-start
))
564 (c-lang-defconst c-identifier-key
565 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
566 C++. It does not recognize the full range of syntactic whitespace
567 between the tokens; `c-forward-name' has to be used for that. It
568 should also not match identifiers containing parenthesis groupings,
569 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
570 ;; This regexp is more complex than strictly necessary to ensure
571 ;; that it can be matched with a minimum of backtracking.
572 t
(concat (if (c-lang-const c-opt-identifier-prefix-key
)
575 (c-lang-const c-opt-identifier-prefix-key
)
576 (c-lang-const c-simple-ws
) "*"
579 "\\(" (c-lang-const c-symbol-key
) "\\)"
580 (if (c-lang-const c-opt-identifier-concat-key
)
583 (c-lang-const c-simple-ws
) "*"
584 (c-lang-const c-opt-identifier-concat-key
)
585 (c-lang-const c-simple-ws
) "*"
586 (if (c-lang-const c-after-id-concat-ops
)
589 (c-make-keywords-re 'appendable
590 (c-lang-const c-after-id-concat-ops
))
592 ;; For flexibility, consider the symbol match
593 ;; optional if we've hit a
594 ;; `c-after-id-concat-ops' operator. This is
595 ;; also necessary to handle the "*" that can
596 ;; end import declaration identifiers in Java.
598 (c-lang-const c-simple-ws
) "*"
599 "\\(" (c-lang-const c-symbol-key
) "\\)"
602 "\\(" (c-lang-const c-symbol-key
) "\\)"
604 (concat "\\(" (c-lang-const c-symbol-key
) "\\)"))
607 (c-lang-defvar c-identifier-key
(c-lang-const c-identifier-key
))
609 (c-lang-defconst c-identifier-last-sym-match
610 ;; This was a docstring constant in 5.30 but it's no longer used.
611 ;; It's only kept to avoid breaking third party code.
613 ;; Used to identify the submatch in `c-identifier-key' that
614 ;; surrounds the last symbol in the qualified identifier. It's a
615 ;; list of submatch numbers, of which the first that has a match is
616 ;; taken. It's assumed that at least one does when the regexp has
620 (c-lang-defconst c-string-escaped-newlines
621 "Set if the language support backslash escaped newlines inside string
625 (c-lang-defvar c-string-escaped-newlines
626 (c-lang-const c-string-escaped-newlines
))
628 (c-lang-defconst c-multiline-string-start-char
629 "Set if the language supports multiline string literals without escaped
630 newlines. If t, all string literals are multiline. If a character,
631 only literals where the open quote is immediately preceded by that
632 literal are multiline."
635 (c-lang-defvar c-multiline-string-start-char
636 (c-lang-const c-multiline-string-start-char
))
638 (c-lang-defconst c-opt-cpp-prefix
639 "Regexp matching the prefix of a cpp directive in the languages that
640 normally use that macro preprocessor. Tested at bol or at boi.
641 Assumed to not contain any submatches or \\| operators."
642 ;; TODO (ACM, 2005-04-01). Amend the following to recognise escaped NLs;
643 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
646 (c-lang-defvar c-opt-cpp-prefix
(c-lang-const c-opt-cpp-prefix
))
648 (c-lang-defconst c-opt-cpp-start
649 "Regexp matching the prefix of a cpp directive including the directive
650 name, or nil in languages without preprocessor support. The first
651 submatch surrounds the directive name."
652 t
(if (c-lang-const c-opt-cpp-prefix
)
653 (concat (c-lang-const c-opt-cpp-prefix
)
654 "\\([" c-alnum
"]+\\)"))
655 ;; Pike, being a scripting language, recognizes hash-bangs too.
656 pike
(concat (c-lang-const c-opt-cpp-prefix
)
657 "\\([" c-alnum
"]+\\|!\\)"))
658 (c-lang-defvar c-opt-cpp-start
(c-lang-const c-opt-cpp-start
))
660 (c-lang-defconst c-cpp-message-directives
661 "List of cpp directives (without the prefix) that are followed by a
663 t
(if (c-lang-const c-opt-cpp-prefix
)
665 pike
'("error" "warning"))
667 (c-lang-defconst c-cpp-include-directives
668 "List of cpp directives (without the prefix) that are followed by a
669 file name in angle brackets or quotes."
670 t
(if (c-lang-const c-opt-cpp-prefix
)
672 objc
'("include" "import"))
674 (c-lang-defconst c-opt-cpp-macro-define
675 "Cpp directive (without the prefix) that is followed by a macro
676 definition, or nil if the language doesn't have any."
677 t
(if (c-lang-const c-opt-cpp-prefix
)
680 (c-lang-defconst c-opt-cpp-macro-define-start
681 ;; Regexp matching everything up to the macro body of a cpp define,
682 ;; or the end of the logical line if there is none. Set if
683 ;; c-opt-cpp-macro-define is.
684 t
(if (c-lang-const c-opt-cpp-macro-define
)
685 (concat (c-lang-const c-opt-cpp-prefix
)
686 (c-lang-const c-opt-cpp-macro-define
)
687 "[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?"
688 "\\([ \t]\\|\\\\\n\\)*")))
689 (c-lang-defvar c-opt-cpp-macro-define-start
690 (c-lang-const c-opt-cpp-macro-define-start
))
692 (c-lang-defconst c-opt-cpp-macro-define-id
693 ;; Regexp matching everything up to the end of the identifier defined
695 t
(if (c-lang-const c-opt-cpp-macro-define
)
696 (concat (c-lang-const c-opt-cpp-prefix
) ; #
697 (c-lang-const c-opt-cpp-macro-define
) ; define
698 "[ \t]+\\(\\sw\\|_\\)+")))
699 (c-lang-defvar c-opt-cpp-macro-define-id
700 (c-lang-const c-opt-cpp-macro-define-id
))
702 (c-lang-defconst c-cpp-expr-directives
703 "List if cpp directives (without the prefix) that are followed by an
705 t
(if (c-lang-const c-opt-cpp-prefix
)
708 (c-lang-defconst c-cpp-expr-functions
709 "List of functions in cpp expressions."
710 t
(if (c-lang-const c-opt-cpp-prefix
)
712 pike
'("defined" "efun" "constant"))
714 (c-lang-defconst c-assignment-operators
715 "List of all assignment operators."
716 t
'("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
717 java
(append (c-lang-const c-assignment-operators
)
719 c
++ (append (c-lang-const c-assignment-operators
)
720 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
723 (c-lang-defconst c-operators
724 "List describing all operators, along with their precedence and
725 associativity. The order in the list corresponds to the precedence of
726 the operators: The operators in each element are a group with the same
727 precedence, and the group has higher precedence than the groups in all
728 following elements. The car of each element describes the type of the
729 operator group, and the cdr is a list of the operator tokens in it.
730 The operator group types are:
732 'prefix Unary prefix operators.
733 'postfix Unary postfix operators.
735 Unary postfix operators if and only if the chars have
737 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
738 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
739 'right-assoc-sequence
740 Right associative operator that constitutes of a
741 sequence of tokens that separate expressions. All the
742 tokens in the group are in this case taken as
743 describing the sequence in one such operator, and the
744 order between them is therefore significant.
746 Operators containing a character with paren syntax are taken to match
747 with a corresponding open/close paren somewhere else. A postfix
748 operator with close paren syntax is taken to end a postfix expression
749 started somewhere earlier, rather than start a new one at point. Vice
750 versa for prefix operators with open paren syntax.
752 Note that operators like \".\" and \"->\" which in language references
753 often are described as postfix operators are considered binary here,
754 since CC Mode treats every identifier as an expression."
756 ;; There's currently no code in CC Mode that exploit all the info
757 ;; in this variable; precedence, associativity etc are present as a
758 ;; preparation for future work.
761 ,@(when (c-lang-const c-opt-cpp-prefix
)
763 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
766 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
767 '("%:%:" "??=??=")))))
770 ,@(c-lang-const c-identifier-ops
)
771 ,@(cond ((c-major-mode-is 'c
++-mode
)
772 `((postfix-if-paren "<" ">"))) ; Templates.
773 ((c-major-mode-is 'pike-mode
)
774 `((prefix "global" "predef")))
775 ((c-major-mode-is 'java-mode
)
776 `((prefix "super"))))
779 ,@(when (c-major-mode-is 'c
++-mode
)
780 ;; The following need special treatment.
781 `((prefix "dynamic_cast" "static_cast"
782 "reinterpret_cast" "const_cast" "typeid")))
784 ,@(unless (c-major-mode-is 'java-mode
)
786 (postfix "++" "--" "[" "]" "(" ")"
787 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
788 '("<:" ":>" "??(" "??)")))
791 (prefix "++" "--" "+" "-" "!" "~"
792 ,@(when (c-major-mode-is 'c
++-mode
) '("not" "compl"))
793 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
794 '("*" "&" "sizeof" "??-"))
795 ,@(when (c-major-mode-is 'objc-mode
)
796 '("@selector" "@protocol" "@encode"))
797 ;; The following need special treatment.
798 ,@(cond ((c-major-mode-is 'c
++-mode
)
800 ((c-major-mode-is 'java-mode
)
802 ((c-major-mode-is 'pike-mode
)
803 '("class" "lambda" "catch" "throw" "gauge")))
805 ,@(when (c-major-mode-is 'pike-mode
)
806 '("[" "]"))) ; Type cast.
809 ,@(when (c-major-mode-is 'c
++-mode
)
810 `((left-assoc ".*" "->*")))
813 (left-assoc "*" "/" "%")
819 (left-assoc "<<" ">>"
820 ,@(when (c-major-mode-is 'java-mode
)
824 (left-assoc "<" ">" "<=" ">="
825 ,@(when (c-major-mode-is 'java-mode
)
829 (left-assoc "==" "!="
830 ,@(when (c-major-mode-is 'c
++-mode
) '("not_eq")))
834 ,@(when (c-major-mode-is 'c
++-mode
) '("bitand")))
836 ;; Bitwise exclusive or.
838 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
840 ,@(when (c-major-mode-is 'c
++-mode
) '("xor")))
844 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
846 ,@(when (c-major-mode-is 'c
++-mode
) '("bitor")))
850 ,@(when (c-major-mode-is 'c
++-mode
) '("and")))
854 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
856 ,@(when (c-major-mode-is 'c
++-mode
) '("or")))
859 (right-assoc-sequence "?" ":")
862 (right-assoc ,@(c-lang-const c-assignment-operators
))
865 ,@(when (c-major-mode-is 'c
++-mode
)
871 ;; IDL got its own definition since it has a much smaller operator
872 ;; set than the other languages.
873 idl
`(;; Preprocessor.
877 ,@(c-lang-const c-identifier-ops
)
881 (left-assoc "*" "/" "%")
885 (left-assoc "<<" ">>")
893 (c-lang-defconst c-operator-list
894 ;; The operators as a flat list (without duplicates).
895 t
(c-filter-ops (c-lang-const c-operators
) t t
))
897 (c-lang-defconst c-overloadable-operators
898 "List of the operators that are overloadable, in their \"identifier
899 form\". See also `c-op-identifier-prefix'."
901 c
++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
903 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
904 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
905 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
906 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
907 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
908 "()" "[]" "<::>" "??(??)")
909 ;; These work like identifiers in Pike.
910 pike
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
911 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
912 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
915 (c-lang-defconst c-overloadable-operators-regexp
916 ;; Regexp tested after an "operator" token in C++.
918 c
++ (c-make-keywords-re nil
(c-lang-const c-overloadable-operators
)))
919 (c-lang-defvar c-overloadable-operators-regexp
920 (c-lang-const c-overloadable-operators-regexp
))
922 (c-lang-defconst c-opt-op-identifier-prefix
923 "Regexp matching the token before the ones in
924 `c-overloadable-operators' when operators are specified in their
925 \"identifier form\". This typically matches \"operator\" in C++ where
926 operator functions are specified as e.g. \"operator +\". It's nil in
927 languages without operator functions or where the complete operator
928 identifier is listed in `c-overloadable-operators'.
930 This regexp is assumed to not match any non-operator identifier."
932 c
++ (c-make-keywords-re t
'("operator")))
933 (c-lang-defvar c-opt-op-identifier-prefix
934 (c-lang-const c-opt-op-identifier-prefix
))
936 ;; Note: the following alias is an old name which was a mis-spelling. It has
937 ;; been corrected above and throughout cc-engine.el. It will be removed at
938 ;; some release very shortly in the future. ACM, 2006-04-14.
939 (defalias 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
)
940 (make-obsolete-variable 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
941 "CC Mode 5.31.4, 2006-04-14")
943 (c-lang-defconst c-other-op-syntax-tokens
944 "List of the tokens made up of characters in the punctuation or
945 parenthesis syntax classes that have uses other than as expression
947 t
'("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
948 (c c
++ pike
) (append '("#" "##" ; Used by cpp.
950 (c-lang-const c-other-op-syntax-tokens
))
951 (c c
++) (append '("*") (c-lang-const c-other-op-syntax-tokens
))
952 c
++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
953 (c-lang-const c-other-op-syntax-tokens
))
954 objc
(append '("#" "##" ; Used by cpp.
955 "+" "-") (c-lang-const c-other-op-syntax-tokens
))
956 idl
(append '("#" "##") ; Used by cpp.
957 (c-lang-const c-other-op-syntax-tokens
))
959 (c-lang-const c-other-op-syntax-tokens
)
960 (c-lang-const c-overloadable-operators
))
961 awk
'("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
963 (c-lang-defconst c-all-op-syntax-tokens
964 ;; List of all tokens in the punctuation and parenthesis syntax
966 t
(delete-duplicates (append (c-lang-const c-other-op-syntax-tokens
)
967 (c-lang-const c-operator-list
))
968 :test
'string-equal
))
970 (c-lang-defconst c-nonsymbol-token-char-list
971 ;; List containing all chars not in the word, symbol or
972 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
973 ;; parenthesis and string delimiter chars.
974 t
(c-with-syntax-table (c-lang-const c-mode-syntax-table
)
975 ;; Only go through the chars in the printable ASCII range. No
976 ;; language so far has 8-bit or widestring operators.
977 (let (list (char 32))
979 (or (memq (char-syntax char
) '(?w ?_ ?
< ?
> ?\
))
980 (setq list
(cons (c-int-to-char char
) list
)))
981 (setq char
(1+ char
)))
984 (c-lang-defconst c-nonsymbol-token-regexp
985 ;; Regexp matching all tokens in the punctuation and parenthesis
986 ;; syntax classes. Note that this also matches ".", which can start
988 t
(c-make-keywords-re nil
989 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
991 "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
992 (c-lang-defvar c-nonsymbol-token-regexp
993 (c-lang-const c-nonsymbol-token-regexp
))
995 (c-lang-defconst c-assignment-op-regexp
996 ;; Regexp matching all assignment operators and only them. The
997 ;; beginning of the first submatch is used to detect the end of the
998 ;; token, along with the end of the whole match.
999 t
(if (c-lang-const c-assignment-operators
)
1001 ;; Need special case for "=" since it's a prefix of "==".
1004 (c-make-keywords-re nil
1005 (set-difference (c-lang-const c-assignment-operators
)
1007 :test
'string-equal
)))
1009 (c-lang-defvar c-assignment-op-regexp
1010 (c-lang-const c-assignment-op-regexp
))
1012 (c-lang-defconst c-
<>-multichar-token-regexp
1013 ;; Regexp matching all tokens containing "<" or ">" which are longer
1015 t
(c-make-keywords-re nil
1016 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1019 (c-lang-defvar c-
<>-multichar-token-regexp
1020 (c-lang-const c-
<>-multichar-token-regexp
))
1022 (c-lang-defconst c-
<-op-cont-regexp
1023 ;; Regexp matching the second and subsequent characters of all
1024 ;; multicharacter tokens that begin with "<".
1025 t
(c-make-keywords-re nil
1026 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1029 (lambda (op) (substring op
1)))))
1030 (c-lang-defvar c-
<-op-cont-regexp
(c-lang-const c-
<-op-cont-regexp
))
1032 (c-lang-defconst c-
>-op-cont-regexp
1033 ;; Regexp matching the second and subsequent characters of all
1034 ;; multicharacter tokens that begin with ">".
1035 t
(c-make-keywords-re nil
1036 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1039 (lambda (op) (substring op
1)))))
1040 (c-lang-defvar c-
>-op-cont-regexp
(c-lang-const c-
>-op-cont-regexp
))
1042 (c-lang-defconst c-stmt-delim-chars
1043 ;; The characters that should be considered to bound statements. To
1044 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1045 ;; begin with "^" to negate the set. If ? : operators should be
1046 ;; detected then the string must end with "?:".
1048 awk
"^;{}#\n\r?:") ; The newline chars gets special treatment.
1049 (c-lang-defvar c-stmt-delim-chars
(c-lang-const c-stmt-delim-chars
))
1051 (c-lang-defconst c-stmt-delim-chars-with-comma
1052 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1054 awk
"^;,{}\n\r?:") ; The newline chars gets special treatment.
1055 (c-lang-defvar c-stmt-delim-chars-with-comma
1056 (c-lang-const c-stmt-delim-chars-with-comma
))
1059 ;;; Syntactic whitespace.
1061 (c-lang-defconst c-simple-ws
1062 "Regexp matching an ordinary whitespace character.
1063 Does not contain a \\| operator at the top level."
1064 ;; "\\s " is not enough since it doesn't match line breaks.
1065 t
"\\(\\s \\|[\n\r]\\)")
1067 (c-lang-defconst c-simple-ws-depth
1068 ;; Number of regexp grouping parens in `c-simple-ws'.
1069 t
(regexp-opt-depth (c-lang-const c-simple-ws
)))
1071 (c-lang-defconst c-line-comment-starter
1072 "String that starts line comments, or nil if such don't exist.
1073 Line comments are always terminated by newlines. At least one of
1074 `c-block-comment-starter' and this one is assumed to be set.
1076 Note that it's currently not enough to set this to support a new
1077 comment style. Other stuff like the syntax table must also be set up
1081 (c-lang-defvar c-line-comment-starter
(c-lang-const c-line-comment-starter
))
1083 (c-lang-defconst c-block-comment-starter
1084 "String that starts block comments, or nil if such don't exist.
1085 Block comments are ended by `c-block-comment-ender', which is assumed
1086 to be set if this is. At least one of `c-line-comment-starter' and
1087 this one is assumed to be set.
1089 Note that it's currently not enough to set this to support a new
1090 comment style. Other stuff like the syntax table must also be set up
1095 (c-lang-defconst c-block-comment-ender
1096 "String that ends block comments, or nil if such don't exist.
1098 Note that it's currently not enough to set this to support a new
1099 comment style. Other stuff like the syntax table must also be set up
1104 (c-lang-defconst c-comment-start-regexp
1105 ;; Regexp to match the start of any type of comment.
1106 t
(let ((re (c-make-keywords-re nil
1107 (list (c-lang-const c-line-comment-starter
)
1108 (c-lang-const c-block-comment-starter
)))))
1109 (if (memq 'gen-comment-delim c-emacs-features
)
1110 (concat re
"\\|\\s!")
1112 (c-lang-defvar c-comment-start-regexp
(c-lang-const c-comment-start-regexp
))
1114 ;;;; Added by ACM, 2003/9/18.
1115 (c-lang-defconst c-block-comment-start-regexp
1116 ;; Regexp which matches the start of a block comment (if such exists in the
1118 t
(if (c-lang-const c-block-comment-starter
)
1119 (regexp-quote (c-lang-const c-block-comment-starter
))
1121 (c-lang-defvar c-block-comment-start-regexp
1122 (c-lang-const c-block-comment-start-regexp
))
1124 (c-lang-defconst c-literal-start-regexp
1125 ;; Regexp to match the start of comments and string literals.
1126 t
(concat (c-lang-const c-comment-start-regexp
)
1128 (if (memq 'gen-string-delim c-emacs-features
)
1131 (c-lang-defvar c-literal-start-regexp
(c-lang-const c-literal-start-regexp
))
1133 (c-lang-defconst c-doc-comment-start-regexp
1134 "Regexp to match the start of documentation comments."
1136 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1137 (c c
++ objc
) "/\\*[*!]"
1140 (c-lang-defvar c-doc-comment-start-regexp
1141 (c-lang-const c-doc-comment-start-regexp
))
1143 (c-lang-defconst comment-start
1144 "String that starts comments inserted with M-; etc.
1145 `comment-start' is initialized from this."
1146 ;; Default: Prefer line comments to block comments, and pad with a space.
1147 t
(concat (or (c-lang-const c-line-comment-starter
)
1148 (c-lang-const c-block-comment-starter
))
1150 ;; In C we still default to the block comment style since line
1151 ;; comments aren't entirely portable.
1153 (c-lang-setvar comment-start
(c-lang-const comment-start
))
1155 (c-lang-defconst comment-end
1156 "String that ends comments inserted with M-; etc.
1157 `comment-end' is initialized from this."
1158 ;; Default: Use block comment style if comment-start uses block
1159 ;; comments, and pad with a space in that case.
1160 t
(if (string-match (concat "\\`\\("
1161 (c-lang-const c-block-comment-start-regexp
)
1163 (c-lang-const comment-start
))
1164 (concat " " (c-lang-const c-block-comment-ender
))
1166 (c-lang-setvar comment-end
(c-lang-const comment-end
))
1168 (c-lang-defconst comment-start-skip
1169 "Regexp to match the start of a comment plus everything up to its body.
1170 `comment-start-skip' is initialized from this."
1171 ;; Default: Allow the last char of the comment starter(s) to be
1172 ;; repeated, then allow any amount of horizontal whitespace.
1175 (mapcar (lambda (cs)
1177 (concat (regexp-quote cs
) "+")))
1178 (list (c-lang-const c-line-comment-starter
)
1179 (c-lang-const c-block-comment-starter
)))
1182 (c-lang-setvar comment-start-skip
(c-lang-const comment-start-skip
))
1184 (c-lang-defconst c-syntactic-ws-start
1185 ;; Regexp matching any sequence that can start syntactic whitespace.
1186 ;; The only uncertain case is '#' when there are cpp directives.
1188 (c-make-keywords-re nil
1189 (append (list (c-lang-const c-line-comment-starter
)
1190 (c-lang-const c-block-comment-starter
)
1191 (when (c-lang-const c-opt-cpp-prefix
)
1195 (when (memq 'gen-comment-delim c-emacs-features
)
1197 (c-lang-defvar c-syntactic-ws-start
(c-lang-const c-syntactic-ws-start
))
1199 (c-lang-defconst c-syntactic-ws-end
1200 ;; Regexp matching any single character that might end syntactic whitespace.
1202 (c-make-keywords-re nil
1203 (append (when (c-lang-const c-block-comment-ender
)
1206 (elt (c-lang-const c-block-comment-ender
)
1208 (c-lang-const c-block-comment-ender
)))))))
1210 (when (memq 'gen-comment-delim c-emacs-features
)
1212 (c-lang-defvar c-syntactic-ws-end
(c-lang-const c-syntactic-ws-end
))
1214 (c-lang-defconst c-unterminated-block-comment-regexp
1215 ;; Regexp matching an unterminated block comment that doesn't
1216 ;; contain line breaks, or nil in languages without block comments.
1217 ;; Does not contain a \| operator at the top level.
1218 t
(when (c-lang-const c-block-comment-starter
)
1220 (regexp-quote (c-lang-const c-block-comment-starter
))
1221 ;; It's messy to cook together a regexp that matches anything
1222 ;; but c-block-comment-ender.
1223 (let ((end (c-lang-const c-block-comment-ender
)))
1224 (cond ((= (length end
) 1)
1225 (concat "[^" end
"\n\r]*"))
1227 (concat "[^" (substring end
0 1) "\n\r]*"
1229 (regexp-quote (substring end
0 1)) "+"
1231 ;; The quoting rules inside char classes are silly. :P
1232 (cond ((= (elt end
0) (elt end
1))
1233 (concat (substring end
0 1) "\n\r"))
1234 ((= (elt end
1) ?\
])
1235 (concat (substring end
1 2) "\n\r"
1236 (substring end
0 1)))
1238 (concat (substring end
0 1) "\n\r"
1239 (substring end
1 2))))
1241 "[^" (substring end
0 1) "\n\r]*"
1244 (error "Can't handle a block comment ender of length %s"
1247 (c-lang-defconst c-block-comment-regexp
1248 ;; Regexp matching a block comment that doesn't contain line breaks,
1249 ;; or nil in languages without block comments. The reason we don't
1250 ;; allow line breaks is to avoid going very far and risk running out
1251 ;; of regexp stack; this regexp is intended to handle only short
1252 ;; comments that might be put in the middle of limited constructs
1253 ;; like declarations. Does not contain a \| operator at the top
1255 t
(when (c-lang-const c-unterminated-block-comment-regexp
)
1257 (c-lang-const c-unterminated-block-comment-regexp
)
1258 (let ((end (c-lang-const c-block-comment-ender
)))
1259 (cond ((= (length end
) 1)
1262 (concat (regexp-quote (substring end
0 1)) "+"
1263 (regexp-quote (substring end
1 2))))
1265 (error "Can't handle a block comment ender of length %s"
1268 (c-lang-defconst c-nonwhite-syntactic-ws
1269 ;; Regexp matching a piece of syntactic whitespace that isn't a
1270 ;; sequence of simple whitespace characters. As opposed to
1271 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1272 ;; directives as syntactic whitespace.
1273 t
(c-concat-separated
1274 (list (when (c-lang-const c-line-comment-starter
)
1275 (concat (regexp-quote (c-lang-const c-line-comment-starter
))
1277 (c-lang-const c-block-comment-regexp
)
1279 (when (memq 'gen-comment-delim c-emacs-features
)
1283 (c-lang-defconst c-syntactic-ws
1284 ;; Regexp matching syntactic whitespace, including possibly the
1285 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1286 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1287 ;; not contain a \| operator at the top level.
1288 t
(concat (c-lang-const c-simple-ws
) "*"
1290 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws
) "\\)"
1291 (c-lang-const c-simple-ws
) "*")
1294 (c-lang-defconst c-syntactic-ws-depth
1295 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1296 t
(regexp-opt-depth (c-lang-const c-syntactic-ws
)))
1298 (c-lang-defconst c-nonempty-syntactic-ws
1299 ;; Regexp matching syntactic whitespace, which is at least one
1300 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1301 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1302 ;; not contain a \| operator at the top level.
1304 (c-lang-const c-simple-ws
)
1306 (c-lang-const c-nonwhite-syntactic-ws
)
1309 (c-lang-defconst c-nonempty-syntactic-ws-depth
1310 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1311 t
(regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws
)))
1313 (c-lang-defconst c-single-line-syntactic-ws
1314 ;; Regexp matching syntactic whitespace without any line breaks. As
1315 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1316 ;; regard cpp directives as syntactic whitespace. Does not contain
1317 ;; a \| operator at the top level.
1318 t
(if (c-lang-const c-block-comment-regexp
)
1320 (c-lang-const c-block-comment-regexp
)
1324 (c-lang-defconst c-single-line-syntactic-ws-depth
1325 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1326 t
(regexp-opt-depth (c-lang-const c-single-line-syntactic-ws
)))
1328 (c-lang-defconst c-syntactic-eol
1329 ;; Regexp that matches when there is no syntactically significant
1330 ;; text before eol. Macros are regarded as syntactically
1331 ;; significant text here.
1332 t
(concat (c-lang-const c-single-line-syntactic-ws
)
1333 ;; Match eol (possibly inside a block comment or preceded
1334 ;; by a line continuation backslash), or the beginning of a
1335 ;; line comment. Note: This has to be modified for awk
1336 ;; where line comments start with '#'.
1339 (list (when (c-lang-const c-line-comment-starter
)
1340 (regexp-quote (c-lang-const c-line-comment-starter
)))
1341 (when (c-lang-const c-unterminated-block-comment-regexp
)
1342 (concat (c-lang-const c-unterminated-block-comment-regexp
)
1348 (c-lang-defvar c-syntactic-eol
(c-lang-const c-syntactic-eol
))
1351 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
1352 (c-lang-defconst c-at-vsemi-p-fn
1353 "Contains a function \"Is there a virtual semicolon at POS or point?\".
1354 Such a function takes one optional parameter, a buffer position (defaults to
1355 point), and returns nil or t. This variable contains nil for languages which
1356 don't have EOL terminated statements. "
1358 awk
'c-awk-at-vsemi-p
)
1359 (c-lang-defvar c-at-vsemi-p-fn
(c-lang-const c-at-vsemi-p-fn
))
1361 (c-lang-defconst c-vsemi-status-unknown-p-fn
1362 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
1363 The (admittedly kludgey) purpose of such a function is to prevent an infinite
1364 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
1365 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
1366 even indirectly. This variable contains nil for languages which don't have
1367 EOL terminated statements."
1369 awk
'c-awk-vsemi-status-unknown-p
)
1370 (c-lang-defvar c-vsemi-status-unknown-p-fn
1371 (c-lang-const c-vsemi-status-unknown-p-fn
))
1376 ;; The Emacs variables beginning-of-defun-function and
1377 ;; end-of-defun-function will be set so that commands like
1378 ;; `mark-defun' and `narrow-to-defun' work right. The key sequences
1379 ;; C-M-a and C-M-e are, however, bound directly to the CC Mode
1380 ;; functions, allowing optimisation for large n.
1381 (c-lang-defconst beginning-of-defun-function
1382 "Function to which beginning-of-defun-function will be set."
1383 t
'c-beginning-of-defun
1384 awk
'c-awk-beginning-of-defun
)
1385 (c-lang-setvar beginning-of-defun-function
1386 (c-lang-const beginning-of-defun-function
))
1388 (c-lang-defconst end-of-defun-function
1389 "Function to which end-of-defun-function will be set."
1391 awk
'c-awk-end-of-defun
)
1392 (c-lang-setvar end-of-defun-function
(c-lang-const end-of-defun-function
))
1394 ;;; In-comment text handling.
1396 (c-lang-defconst c-paragraph-start
1397 "Regexp to append to `paragraph-start'."
1399 java
"\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1400 pike
"\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1401 (c-lang-defvar c-paragraph-start
(c-lang-const c-paragraph-start
))
1403 (c-lang-defconst c-paragraph-separate
1404 "Regexp to append to `paragraph-separate'."
1406 pike
(c-lang-const c-paragraph-start
))
1407 (c-lang-defvar c-paragraph-separate
(c-lang-const c-paragraph-separate
))
1412 ;; Note: All and only all language constants containing keyword lists
1413 ;; should end with "-kwds"; they're automatically collected into the
1414 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1416 (c-lang-defconst c-primitive-type-kwds
1417 "Primitive type keywords. As opposed to the other keyword lists, the
1418 keywords listed here are fontified with the type face instead of the
1421 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1422 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1423 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1426 Do not try to modify this list for end user customizations; the
1427 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1428 the appropriate place for that."
1429 t
'("char" "double" "float" "int" "long" "short" "signed"
1432 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1433 (c-lang-const c-primitive-type-kwds
))
1436 (c-lang-const c-primitive-type-kwds
))
1437 ;; Objective-C extends C, but probably not the new stuff in C99.
1439 '("id" "Class" "SEL" "IMP" "BOOL")
1440 (c-lang-const c-primitive-type-kwds
))
1441 java
'("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1442 idl
'("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1443 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1446 ;; The following can't really end a type, but we have to specify them
1447 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1448 ;; doesn't matter that much.
1449 "unsigned" "strong")
1450 pike
'(;; this_program isn't really a keyword, but it's practically
1451 ;; used as a builtin type.
1452 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1453 "object" "program" "string" "this_program" "void"))
1455 (c-lang-defconst c-primitive-type-key
1456 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1457 t
(c-make-keywords-re t
(c-lang-const c-primitive-type-kwds
)))
1458 (c-lang-defvar c-primitive-type-key
(c-lang-const c-primitive-type-key
))
1460 (c-lang-defconst c-primitive-type-prefix-kwds
1461 "Keywords that might act as prefixes for primitive types. Assumed to
1462 be a subset of `c-primitive-type-kwds'."
1464 (c c
++) '("long" "short" "signed" "unsigned")
1465 idl
'("long" "unsigned"
1469 (c-lang-defconst c-type-prefix-kwds
1470 "Keywords where the following name - if any - is a type name, and
1471 where the keyword together with the symbol works as a type in
1474 Note that an alternative if the second part doesn't hold is
1475 `c-type-list-kwds'. Keywords on this list are typically also present
1476 on one of the `*-decl-kwds' lists."
1478 c
'("struct" "union" "enum")
1479 c
++ (append '("class" "typename")
1480 (c-lang-const c-type-prefix-kwds c
)))
1482 (c-lang-defconst c-type-prefix-key
1483 ;; Adorned regexp matching `c-type-prefix-kwds'.
1484 t
(c-make-keywords-re t
(c-lang-const c-type-prefix-kwds
)))
1485 (c-lang-defvar c-type-prefix-key
(c-lang-const c-type-prefix-key
))
1487 (c-lang-defconst c-type-modifier-kwds
1488 "Type modifier keywords. These can occur almost anywhere in types
1489 but they don't build a type of themselves. Unlike the keywords on
1490 `c-primitive-type-kwds', they are fontified with the keyword face and
1493 c
'("const" "restrict" "volatile")
1494 c
++ '("const" "volatile" "throw")
1495 objc
'("const" "volatile"))
1497 (c-lang-defconst c-opt-type-modifier-key
1498 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1499 ;; languages without such keywords.
1500 t
(and (c-lang-const c-type-modifier-kwds
)
1501 (c-make-keywords-re t
(c-lang-const c-type-modifier-kwds
))))
1502 (c-lang-defvar c-opt-type-modifier-key
(c-lang-const c-opt-type-modifier-key
))
1504 (c-lang-defconst c-opt-type-component-key
1505 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1506 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1507 t
(and (or (c-lang-const c-primitive-type-prefix-kwds
)
1508 (c-lang-const c-type-modifier-kwds
))
1509 (c-make-keywords-re t
1510 (append (c-lang-const c-primitive-type-prefix-kwds
)
1511 (c-lang-const c-type-modifier-kwds
)))))
1512 (c-lang-defvar c-opt-type-component-key
1513 (c-lang-const c-opt-type-component-key
))
1515 (c-lang-defconst c-type-start-kwds
1516 ;; All keywords that can start a type (i.e. are either a type prefix
1517 ;; or a complete type).
1518 t
(delete-duplicates (append (c-lang-const c-primitive-type-kwds
)
1519 (c-lang-const c-type-prefix-kwds
)
1520 (c-lang-const c-type-modifier-kwds
))
1521 :test
'string-equal
))
1523 (c-lang-defconst c-class-decl-kwds
1524 "Keywords introducing declarations where the following block (if any)
1525 contains another declaration level that should be considered a class.
1527 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1528 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1529 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1532 Note that presence on this list does not automatically treat the
1533 following identifier as a type; the keyword must also be present on
1534 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1536 c
'("struct" "union")
1537 c
++ '("class" "struct" "union")
1538 objc
'("struct" "union"
1539 "@interface" "@implementation" "@protocol")
1540 java
'("class" "interface")
1541 idl
'("component" "eventtype" "exception" "home" "interface" "struct"
1544 "storagehome" "storagetype"
1546 "catalog" "executor" "manages" "segment")
1549 (c-lang-defconst c-class-key
1550 ;; Regexp matching the start of a class.
1551 t
(c-make-keywords-re t
(c-lang-const c-class-decl-kwds
)))
1552 (c-lang-defvar c-class-key
(c-lang-const c-class-key
))
1554 (c-lang-defconst c-brace-list-decl-kwds
1555 "Keywords introducing declarations where the following block (if
1556 any) is a brace list.
1558 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1559 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1560 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1565 (c-lang-defconst c-brace-list-key
1566 ;; Regexp matching the start of declarations where the following
1567 ;; block is a brace list.
1568 t
(c-make-keywords-re t
(c-lang-const c-brace-list-decl-kwds
)))
1569 (c-lang-defvar c-brace-list-key
(c-lang-const c-brace-list-key
))
1571 (c-lang-defconst c-other-block-decl-kwds
1572 "Keywords where the following block (if any) contains another
1573 declaration level that should not be considered a class. For every
1574 keyword here, CC Mode will add a set of special syntactic symbols for
1575 those blocks. E.g. if the keyword is \"foo\" then there will be
1576 `foo-open', `foo-close', and `infoo' symbols.
1578 The intention is that this category should be used for block
1579 constructs that aren't related to object orientation concepts like
1580 classes (which thus also include e.g. interfaces, templates,
1581 contracts, structs, etc). The more pragmatic distinction is that
1582 while most want some indentation inside classes, it's fairly common
1583 that they don't want it in some of these constructs, so it should be
1584 simple to configure that differently from classes. See also
1585 `c-class-decl-kwds'.
1587 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1588 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1589 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1592 (c objc
) '("extern")
1593 c
++ '("namespace" "extern")
1598 (c-lang-defconst c-other-decl-block-key
1599 ;; Regexp matching the start of blocks besides classes that contain
1600 ;; another declaration level.
1601 t
(c-make-keywords-re t
(c-lang-const c-other-block-decl-kwds
)))
1602 (c-lang-defvar c-other-decl-block-key
(c-lang-const c-other-decl-block-key
))
1604 (c-lang-defconst c-typedef-decl-kwds
1605 "Keywords introducing declarations where the identifier(s) being
1608 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1609 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1610 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1612 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1613 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1615 t
(append (c-lang-const c-class-decl-kwds
)
1616 (c-lang-const c-brace-list-decl-kwds
))
1617 ;; Languages that have a "typedef" construct.
1618 (c c
++ objc idl pike
) (append (c-lang-const c-typedef-decl-kwds
)
1620 ;; Unlike most other languages, exception names are not handled as
1621 ;; types in IDL since they only can occur in "raises" specs.
1622 idl
(delete "exception" (append (c-lang-const c-typedef-decl-kwds
) nil
)))
1624 (c-lang-defconst c-typeless-decl-kwds
1625 "Keywords introducing declarations where the \(first) identifier
1626 \(declarator) follows directly after the keyword, without any type.
1628 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1629 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1630 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1632 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1633 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1635 t
(append (c-lang-const c-class-decl-kwds
)
1636 (c-lang-const c-brace-list-decl-kwds
))
1637 ;; Note: "manages" for CORBA CIDL clashes with its presence on
1638 ;; `c-type-list-kwds' for IDL.
1639 idl
(append (c-lang-const c-typeless-decl-kwds
)
1640 '("factory" "finder" "native"
1645 pike
(append (c-lang-const c-class-decl-kwds
)
1648 (c-lang-defconst c-modifier-kwds
1649 "Keywords that can prefix normal declarations of identifiers
1650 \(and typically act as flags). Things like argument declarations
1651 inside function headers are also considered declarations in this
1654 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1655 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1656 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1659 (c c
++) '("auto" "extern" "inline" "register" "static")
1660 c
++ (append '("explicit" "friend" "mutable" "template" "using" "virtual")
1661 (c-lang-const c-modifier-kwds
))
1662 objc
'("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
1663 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
1664 idl
'("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
1665 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
1666 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
1670 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
1671 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
1672 java
'("abstract" "const" "final" "native" "private" "protected" "public"
1673 "static" "strictfp" "synchronized" "transient" "volatile")
1674 pike
'("final" "inline" "local" "nomask" "optional" "private" "protected"
1675 "public" "static" "variant"))
1677 (c-lang-defconst c-other-decl-kwds
1678 "Keywords that can start or prefix any declaration level construct,
1679 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1680 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1681 `c-typeless-decl-kwds' and `c-modifier-kwds'.
1683 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1684 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1685 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1688 objc
'("@class" "@end" "@defs")
1689 java
'("import" "package")
1690 pike
'("import" "inherit"))
1692 (c-lang-defconst c-decl-start-kwds
1693 "Keywords that always start declarations, wherever they occur.
1694 This can be used for declarations that aren't recognized by the normal
1695 combination of `c-decl-prefix-re' and `c-decl-start-re'."
1697 ;; Classes can be declared anywhere in a Pike expression.
1700 (c-lang-defconst c-decl-hangon-kwds
1701 "Keywords that can occur anywhere in a declaration level construct.
1702 This is used for self-contained things that can be tacked on anywhere
1703 on a declaration and that should be ignored to be able to recognize it
1704 correctly. Typical cases are compiler extensions like
1705 \"__attribute__\" or \"__declspec\":
1707 __declspec(noreturn) void foo();
1708 class __declspec(dllexport) classname {...};
1709 void foo() __attribute__((noreturn));
1711 Note that unrecognized plain symbols are skipped anyway if they occur
1712 before the type, so such things are not necessary to mention here.
1713 Mentioning them here is necessary only if they can occur in other
1714 places, or if they are followed by a construct that must be skipped
1715 over \(like the parens in the \"__attribute__\" and \"__declspec\"
1716 examples above). In the last case, they alse need to be present on
1717 one of `c-type-list-kwds', `c-ref-list-kwds',
1718 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1719 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1720 ;; NB: These are currently not recognized in all parts of a
1721 ;; declaration. Specifically, they aren't recognized in the middle
1722 ;; of multi-token types, inside declarators, and between the
1723 ;; identifier and the arglist paren of a function declaration.
1725 ;; FIXME: This ought to be user customizable since compiler stuff
1726 ;; like this usually is wrapped in project specific macros. (It'd
1727 ;; of course be even better if we could cope without knowing this.)
1729 (c c
++) '(;; GCC extension.
1734 (c-lang-defconst c-decl-hangon-key
1735 ;; Adorned regexp matching `c-decl-hangon-kwds'.
1736 t
(c-make-keywords-re t
(c-lang-const c-decl-hangon-kwds
)))
1737 (c-lang-defvar c-decl-hangon-key
(c-lang-const c-decl-hangon-key
))
1739 (c-lang-defconst c-prefix-spec-kwds
1740 ;; All keywords that can occur in the preamble of a declaration.
1741 ;; They typically occur before the type, but they are also matched
1742 ;; after presumptive types since we often can't be sure that
1743 ;; something is a type or just some sort of macro in front of the
1744 ;; declaration. They might be ambiguous with types or type
1746 t
(delete-duplicates (append (c-lang-const c-class-decl-kwds
)
1747 (c-lang-const c-brace-list-decl-kwds
)
1748 (c-lang-const c-other-block-decl-kwds
)
1749 (c-lang-const c-typedef-decl-kwds
)
1750 (c-lang-const c-typeless-decl-kwds
)
1751 (c-lang-const c-modifier-kwds
)
1752 (c-lang-const c-other-decl-kwds
)
1753 (c-lang-const c-decl-start-kwds
)
1754 (c-lang-const c-decl-hangon-kwds
))
1755 :test
'string-equal
))
1757 (c-lang-defconst c-prefix-spec-kwds-re
1758 ;; Adorned regexp of `c-prefix-spec-kwds'.
1759 t
(c-make-keywords-re t
(c-lang-const c-prefix-spec-kwds
)))
1760 (c-lang-defvar c-prefix-spec-kwds-re
(c-lang-const c-prefix-spec-kwds-re
))
1762 (c-lang-defconst c-specifier-key
1763 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that
1764 ;; aren't ambiguous with types or type prefixes.
1765 t
(c-make-keywords-re t
1766 (set-difference (c-lang-const c-prefix-spec-kwds
)
1767 (c-lang-const c-type-start-kwds
)
1768 :test
'string-equal
)))
1769 (c-lang-defvar c-specifier-key
(c-lang-const c-specifier-key
))
1771 (c-lang-defconst c-postfix-spec-kwds
1772 ;; Keywords that can occur after argument list of a function header
1773 ;; declaration, i.e. in the "K&R region".
1774 t
(append (c-lang-const c-postfix-decl-spec-kwds
)
1775 (c-lang-const c-decl-hangon-kwds
)))
1777 (c-lang-defconst c-not-decl-init-keywords
1778 ;; Adorned regexp matching all keywords that can't appear at the
1779 ;; start of a declaration.
1780 t
(c-make-keywords-re t
1781 (set-difference (c-lang-const c-keywords
)
1782 (append (c-lang-const c-type-start-kwds
)
1783 (c-lang-const c-prefix-spec-kwds
))
1784 :test
'string-equal
)))
1785 (c-lang-defvar c-not-decl-init-keywords
1786 (c-lang-const c-not-decl-init-keywords
))
1788 (c-lang-defconst c-protection-kwds
1789 "Access protection label keywords in classes."
1791 c
++ '("private" "protected" "public")
1792 objc
'("@private" "@protected" "@public"))
1794 (c-lang-defconst c-block-decls-with-vars
1795 "Keywords introducing declarations that can contain a block which
1796 might be followed by variable declarations, e.g. like \"foo\" in
1797 \"class Foo { ... } foo;\". So if there is a block in a declaration
1798 like that, it ends with the following ';' and not right away.
1800 The keywords on list are assumed to also be present on one of the
1801 `*-decl-kwds' lists."
1803 (c objc
) '("struct" "union" "enum" "typedef")
1804 c
++ '("class" "struct" "union" "enum" "typedef"))
1806 (c-lang-defconst c-opt-block-decls-with-vars-key
1807 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
1808 ;; languages without such constructs.
1809 t
(and (c-lang-const c-block-decls-with-vars
)
1810 (c-make-keywords-re t
(c-lang-const c-block-decls-with-vars
))))
1811 (c-lang-defvar c-opt-block-decls-with-vars-key
1812 (c-lang-const c-opt-block-decls-with-vars-key
))
1814 (c-lang-defconst c-postfix-decl-spec-kwds
1815 "Keywords introducing extra declaration specifiers in the region
1816 between the header and the body \(i.e. the \"K&R-region\") in
1819 java
'("extends" "implements" "throws")
1820 idl
'("context" "getraises" "manages" "primarykey" "raises" "setraises"
1823 "as" "const" "implements" "of" "ref"))
1825 (c-lang-defconst c-nonsymbol-sexp-kwds
1826 "Keywords that may be followed by a nonsymbol sexp before whatever
1827 construct it's part of continues."
1829 (c c
++ objc
) '("extern"))
1831 (c-lang-defconst c-type-list-kwds
1832 "Keywords that may be followed by a comma separated list of type
1833 identifiers, where each optionally can be prefixed by keywords. (Can
1834 also be used for the special case when the list can contain only one
1837 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
1838 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
1839 There's also no reason to add keywords that prefixes a normal
1840 declaration consisting of a type followed by a declarator (list), so
1841 the keywords on `c-modifier-kwds' should normally not be listed here
1844 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1845 or variable identifier (that's being defined)."
1849 java
'("import" "new" "extends" "implements" "throws")
1850 idl
'("manages" "native" "primarykey" "supports"
1852 "as" "implements" "of" "scope")
1855 (c-lang-defconst c-ref-list-kwds
1856 "Keywords that may be followed by a comma separated list of
1857 reference (i.e. namespace/scope/module) identifiers, where each
1858 optionally can be prefixed by keywords. (Can also be used for the
1859 special case when the list can contain only one element.) Assumed to
1860 be mutually exclusive with `c-type-list-kwds'.
1862 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1863 or variable identifier (that's being defined)."
1867 idl
'("import" "module"
1872 (c-lang-defconst c-colon-type-list-kwds
1873 "Keywords that may be followed (not necessarily directly) by a colon
1874 and then a comma separated list of type identifiers, where each
1875 optionally can be prefixed by keywords. (Can also be used for the
1876 special case when the list can contain only one element.)"
1878 c
++ '("class" "struct")
1879 idl
'("component" "eventtype" "home" "interface" "valuetype"
1881 "storagehome" "storagetype"))
1883 (c-lang-defconst c-colon-type-list-re
1884 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
1885 forward to the colon. The end of the match is assumed to be directly
1886 after the colon, so the regexp should end with \":\". Must be a
1887 regexp if `c-colon-type-list-kwds' isn't nil."
1888 t
(if (c-lang-const c-colon-type-list-kwds
)
1889 ;; Disallow various common punctuation chars that can't come
1890 ;; before the ":" that starts the inherit list after "class"
1891 ;; or "struct" in C++. (Also used as default for other
1893 "[^\]\[{}();,/#=:]*:"))
1894 (c-lang-defvar c-colon-type-list-re
(c-lang-const c-colon-type-list-re
))
1896 (c-lang-defconst c-paren-nontype-kwds
1897 "Keywords that may be followed by a parenthesis expression that doesn't
1898 contain type identifiers."
1900 (c c
++) '(;; GCC extension.
1905 (c-lang-defconst c-paren-type-kwds
1906 "Keywords that may be followed by a parenthesis expression containing
1907 type identifiers separated by arbitrary tokens."
1912 pike
'("array" "function" "int" "mapping" "multiset" "object" "program"))
1914 (c-lang-defconst c-paren-any-kwds
1915 t
(delete-duplicates (append (c-lang-const c-paren-nontype-kwds
)
1916 (c-lang-const c-paren-type-kwds
))
1917 :test
'string-equal
))
1919 (c-lang-defconst c-
<>-type-kwds
1920 "Keywords that may be followed by an angle bracket expression
1921 containing type identifiers separated by \",\". The difference from
1922 `c-<>-arglist-kwds' is that unknown names are taken to be types and
1923 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
1931 (c-lang-defconst c-
<>-arglist-kwds
1932 "Keywords that can be followed by a C++ style template arglist; see
1933 `c-recognize-<>-arglists' for details. That language constant is
1934 assumed to be set if this isn't nil."
1937 idl
'("fixed" "string" "wstring"))
1939 (c-lang-defconst c-
<>-sexp-kwds
1940 ;; All keywords that can be followed by an angle bracket sexp.
1941 t
(delete-duplicates (append (c-lang-const c-
<>-type-kwds
)
1942 (c-lang-const c-
<>-arglist-kwds
))
1943 :test
'string-equal
))
1945 (c-lang-defconst c-opt-
<>-sexp-key
1946 ;; Adorned regexp matching keywords that can be followed by an angle
1947 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
1948 t
(if (c-lang-const c-recognize-
<>-arglists
)
1949 (c-make-keywords-re t
(c-lang-const c-
<>-sexp-kwds
))))
1950 (c-lang-defvar c-opt-
<>-sexp-key
(c-lang-const c-opt-
<>-sexp-key
))
1952 (c-lang-defconst c-brace-id-list-kwds
1953 "Keywords that may be followed by a brace block containing a comma
1954 separated list of identifier definitions, i.e. like the list of
1955 identifiers that follows the type in a normal declaration."
1956 t
(c-lang-const c-brace-list-decl-kwds
))
1958 (c-lang-defconst c-block-stmt-1-kwds
1959 "Statement keywords followed directly by a substatement."
1961 c
++ '("do" "else" "try")
1962 java
'("do" "else" "finally" "try")
1965 (c-lang-defconst c-block-stmt-1-key
1966 ;; Regexp matching the start of any statement followed directly by a
1967 ;; substatement (doesn't match a bare block, however).
1968 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-kwds
)))
1969 (c-lang-defvar c-block-stmt-1-key
(c-lang-const c-block-stmt-1-key
))
1971 (c-lang-defconst c-block-stmt-2-kwds
1972 "Statement keywords followed by a paren sexp and then by a substatement."
1973 t
'("for" "if" "switch" "while")
1974 c
++ '("for" "if" "switch" "while" "catch")
1975 java
'("for" "if" "switch" "while" "catch" "synchronized")
1977 pike
'("for" "if" "switch" "while" "foreach")
1978 awk
'("for" "if" "while"))
1980 (c-lang-defconst c-block-stmt-2-key
1981 ;; Regexp matching the start of any statement followed by a paren sexp
1982 ;; and then by a substatement.
1983 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-2-kwds
)))
1984 (c-lang-defvar c-block-stmt-2-key
(c-lang-const c-block-stmt-2-key
))
1986 (c-lang-defconst c-block-stmt-kwds
1987 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
1988 t
(delete-duplicates (append (c-lang-const c-block-stmt-1-kwds
)
1989 (c-lang-const c-block-stmt-2-kwds
))
1990 :test
'string-equal
))
1992 (c-lang-defconst c-opt-block-stmt-key
1993 ;; Regexp matching the start of any statement that has a
1994 ;; substatement (except a bare block). Nil in languages that
1995 ;; don't have such constructs.
1996 t
(if (or (c-lang-const c-block-stmt-1-kwds
)
1997 (c-lang-const c-block-stmt-2-kwds
))
1998 (c-make-keywords-re t
1999 (append (c-lang-const c-block-stmt-1-kwds
)
2000 (c-lang-const c-block-stmt-2-kwds
)))))
2001 (c-lang-defvar c-opt-block-stmt-key
(c-lang-const c-opt-block-stmt-key
))
2003 (c-lang-defconst c-simple-stmt-kwds
2004 "Statement keywords followed by an expression or nothing."
2005 t
'("break" "continue" "goto" "return")
2006 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
2007 java
'("break" "continue" "goto" "return" "throw")
2009 pike
'("break" "continue" "return")
2010 awk
'(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
2011 "break" "continue" "return" "delete" "exit" "getline" "next"
2012 "nextfile" "print" "printf"))
2014 (c-lang-defconst c-simple-stmt-key
2015 ;; Adorned regexp matching `c-simple-stmt-kwds'.
2016 t
(c-make-keywords-re t
(c-lang-const c-simple-stmt-kwds
)))
2017 (c-lang-defvar c-simple-stmt-key
(c-lang-const c-simple-stmt-key
))
2019 (c-lang-defconst c-paren-stmt-kwds
2020 "Statement keywords followed by a parenthesis expression that
2021 nevertheless contains a list separated with ';' and not ','."
2025 (c-lang-defconst c-paren-stmt-key
2026 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2027 t
(c-make-keywords-re t
(c-lang-const c-paren-stmt-kwds
)))
2028 (c-lang-defvar c-paren-stmt-key
(c-lang-const c-paren-stmt-key
))
2030 (c-lang-defconst c-asm-stmt-kwds
2031 "Statement keywords followed by an assembler expression."
2033 (c c
++) '("asm" "__asm__")) ;; Not standard, but common.
2035 (c-lang-defconst c-opt-asm-stmt-key
2036 ;; Regexp matching the start of an assembler statement. Nil in
2037 ;; languages that don't support that.
2038 t
(if (c-lang-const c-asm-stmt-kwds
)
2039 (c-make-keywords-re t
(c-lang-const c-asm-stmt-kwds
))))
2040 (c-lang-defvar c-opt-asm-stmt-key
(c-lang-const c-opt-asm-stmt-key
))
2042 (c-lang-defconst c-label-kwds
2043 "Keywords introducing colon terminated labels in blocks."
2044 t
'("case" "default")
2047 (c-lang-defconst c-label-kwds-regexp
2048 ;; Adorned regexp matching any keyword that introduces a label.
2049 t
(c-make-keywords-re t
(c-lang-const c-label-kwds
)))
2050 (c-lang-defvar c-label-kwds-regexp
(c-lang-const c-label-kwds-regexp
))
2052 (c-lang-defconst c-before-label-kwds
2053 "Keywords that might be followed by a label identifier."
2055 (java pike
) (append '("break" "continue")
2056 (c-lang-const c-before-label-kwds
))
2060 (c-lang-defconst c-constant-kwds
2061 "Keywords for constants."
2063 (c c
++) '("NULL" ;; Not a keyword, but practically works as one.
2064 "false" "true") ; Defined in C99.
2066 idl
'("TRUE" "FALSE")
2067 pike
'("UNDEFINED")) ;; Not a keyword, but practically works as one.
2069 (c-lang-defconst c-primary-expr-kwds
2070 "Keywords besides constants and operators that start primary expressions."
2072 c
++ '("operator" "this")
2073 objc
'("super" "self")
2075 pike
'("this")) ;; Not really a keyword, but practically works as one.
2077 (c-lang-defconst c-expr-kwds
2078 ;; Keywords that can occur anywhere in expressions. Built from
2079 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2080 t
(delete-duplicates
2081 (append (c-lang-const c-primary-expr-kwds
)
2082 (c-filter-ops (c-lang-const c-operator-list
)
2084 "\\`\\(\\w\\|\\s_\\)+\\'"))
2085 :test
'string-equal
))
2087 (c-lang-defconst c-lambda-kwds
2088 "Keywords that start lambda constructs, i.e. function definitions in
2093 (c-lang-defconst c-inexpr-block-kwds
2094 "Keywords that start constructs followed by statement blocks which can
2095 be used in expressions \(the gcc extension for this in C and C++ is
2096 handled separately by `c-recognize-paren-inexpr-blocks')."
2098 pike
'("catch" "gauge"))
2100 (c-lang-defconst c-inexpr-class-kwds
2101 "Keywords that can start classes inside expressions."
2106 (c-lang-defconst c-inexpr-brace-list-kwds
2107 "Keywords that can start brace list blocks inside expressions.
2108 Note that Java specific rules are currently applied to tell this from
2109 `c-inexpr-class-kwds'."
2113 (c-lang-defconst c-opt-inexpr-brace-list-key
2114 ;; Regexp matching the start of a brace list in an expression, or
2115 ;; nil in languages that don't have such things. This should not
2116 ;; match brace lists recognized through `c-special-brace-lists'.
2117 t
(and (c-lang-const c-inexpr-brace-list-kwds
)
2118 (c-make-keywords-re t
(c-lang-const c-inexpr-brace-list-kwds
))))
2119 (c-lang-defvar c-opt-inexpr-brace-list-key
2120 (c-lang-const c-opt-inexpr-brace-list-key
))
2122 (c-lang-defconst c-decl-block-key
2123 ;; Regexp matching keywords in any construct that contain another
2124 ;; declaration level, i.e. that isn't followed by a function block
2125 ;; or brace list. When the first submatch matches, it's an
2126 ;; unambiguous construct, otherwise it's an ambiguous match that
2127 ;; might also be the return type of a function declaration.
2128 t
(let* ((decl-kwds (append (c-lang-const c-class-decl-kwds
)
2129 (c-lang-const c-other-block-decl-kwds
)
2130 (c-lang-const c-inexpr-class-kwds
)))
2131 (unambiguous (set-difference decl-kwds
2132 (c-lang-const c-type-start-kwds
)
2133 :test
'string-equal
))
2134 (ambiguous (intersection decl-kwds
2135 (c-lang-const c-type-start-kwds
)
2136 :test
'string-equal
)))
2138 (concat (c-make-keywords-re t unambiguous
)
2140 (c-make-keywords-re t ambiguous
))
2141 (c-make-keywords-re t unambiguous
))))
2142 (c-lang-defvar c-decl-block-key
(c-lang-const c-decl-block-key
))
2144 (c-lang-defconst c-bitfield-kwds
2145 "Keywords that can introduce bitfields."
2147 (c c
++ objc
) '("char" "int" "long" "signed" "unsigned"))
2149 (c-lang-defconst c-opt-bitfield-key
2150 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2151 ;; languages without bitfield support.
2153 (c c
++) (c-make-keywords-re t
(c-lang-const c-bitfield-kwds
)))
2154 (c-lang-defvar c-opt-bitfield-key
(c-lang-const c-opt-bitfield-key
))
2156 (c-lang-defconst c-other-kwds
2157 "Keywords not accounted for by any other `*-kwds' language constant."
2160 ;; In CORBA CIDL: (These are declaration keywords that never
2161 ;; can start a declaration.)
2162 "entity" "process" "service" "session" "storage"))
2165 ;;; Constants built from keywords.
2167 ;; Note: No `*-kwds' language constants may be defined below this point.
2170 (defconst c-kwds-lang-consts
2171 ;; List of all the language constants that contain keyword lists.
2173 (mapatoms (lambda (sym)
2174 (when (and (boundp sym
)
2175 (string-match "-kwds\\'" (symbol-name sym
)))
2176 ;; Make the list of globally interned symbols
2177 ;; instead of ones interned in `c-lang-constants'.
2178 (setq list
(cons (intern (symbol-name sym
)) list
))))
2182 (c-lang-defconst c-keywords
2183 ;; All keywords as a list.
2184 t
(delete-duplicates
2185 (c-lang-defconst-eval-immediately
2186 `(append ,@(mapcar (lambda (kwds-lang-const)
2187 `(c-lang-const ,kwds-lang-const
))
2190 :test
'string-equal
))
2192 (c-lang-defconst c-keywords-regexp
2193 ;; All keywords as an adorned regexp.
2194 t
(c-make-keywords-re t
(c-lang-const c-keywords
)))
2195 (c-lang-defvar c-keywords-regexp
(c-lang-const c-keywords-regexp
))
2197 (c-lang-defconst c-keyword-member-alist
2198 ;; An alist with all the keywords in the cars. The cdr for each
2199 ;; keyword is a list of the symbols for the `*-kwds' lists that
2201 t
(let ((kwd-list-alist
2202 (c-lang-defconst-eval-immediately
2203 `(list ,@(mapcar (lambda (kwds-lang-const)
2204 `(cons ',kwds-lang-const
2205 (c-lang-const ,kwds-lang-const
)))
2206 c-kwds-lang-consts
))))
2207 lang-const kwd-list kwd
2209 (while kwd-list-alist
2210 (setq lang-const
(caar kwd-list-alist
)
2211 kwd-list
(cdar kwd-list-alist
)
2212 kwd-list-alist
(cdr kwd-list-alist
))
2214 (setq kwd
(car kwd-list
)
2215 kwd-list
(cdr kwd-list
))
2216 (unless (setq elem
(assoc kwd result-alist
))
2217 (setq result-alist
(cons (setq elem
(list kwd
)) result-alist
)))
2218 (unless (memq lang-const
(cdr elem
))
2219 (setcdr elem
(cons lang-const
(cdr elem
))))))
2222 (c-lang-defvar c-keywords-obarray
2223 ;; An obarray containing all keywords as symbols. The property list
2224 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2225 ;; lists it's a member of.
2227 ;; E.g. to see whether the string str contains a keyword on
2228 ;; `c-class-decl-kwds', one can do like this:
2229 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2230 ;; Which preferably is written using the associated functions in
2232 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2234 ;; The obarray is not stored directly as a language constant since
2235 ;; the printed representation for obarrays used in .elc files isn't
2238 (let* ((alist (c-lang-const c-keyword-member-alist
))
2240 (obarray (make-vector (* (length alist
) 2) 0)))
2242 (setq kwd
(caar alist
)
2243 lang-const-list
(cdar alist
)
2245 (setplist (intern kwd obarray
)
2246 ;; Emacs has an odd bug that causes `mapcan' to fail
2247 ;; with unintelligible errors. (XEmacs works.)
2248 ;;(mapcan (lambda (lang-const)
2249 ;; (list lang-const t))
2251 (apply 'nconc
(mapcar (lambda (lang-const)
2252 (list lang-const t
))
2256 (c-lang-defconst c-regular-keywords-regexp
2257 ;; Adorned regexp matching all keywords that should be fontified
2258 ;; with the keywords face. I.e. that aren't types or constants.
2259 t
(c-make-keywords-re t
2260 (set-difference (c-lang-const c-keywords
)
2261 (append (c-lang-const c-primitive-type-kwds
)
2262 (c-lang-const c-constant-kwds
))
2263 :test
'string-equal
)))
2264 (c-lang-defvar c-regular-keywords-regexp
2265 (c-lang-const c-regular-keywords-regexp
))
2267 (c-lang-defconst c-primary-expr-regexp
2268 ;; Regexp matching the start of any primary expression, i.e. any
2269 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2270 ;; exclude keywords; they are excluded afterwards unless the second
2271 ;; submatch matches. If the first but not the second submatch
2272 ;; matches then it is an ambiguous primary expression; it could also
2273 ;; be a match of e.g. an infix operator. (The case with ambiguous
2274 ;; keyword operators isn't handled.)
2276 t
(let* ((prefix-ops
2277 (c-filter-ops (c-lang-const c-operators
)
2280 ;; Filter out the special case prefix
2281 ;; operators that are close parens.
2282 (not (string-match "\\s)" op
)))))
2284 (nonkeyword-prefix-ops
2285 (c-filter-ops prefix-ops
2287 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2290 (c-filter-ops (c-lang-const c-operators
)
2295 right-assoc-sequence
)
2298 (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2300 :test
'string-equal
))
2301 (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2303 :test
'string-equal
)))
2307 ;; Take out all symbol class operators from `prefix-ops' and make the
2308 ;; first submatch from them together with `c-primary-expr-kwds'.
2309 (c-make-keywords-re t
2310 (append (c-lang-const c-primary-expr-kwds
)
2311 (set-difference prefix-ops nonkeyword-prefix-ops
2312 :test
'string-equal
)))
2315 ;; Match all ambiguous operators.
2316 (c-make-keywords-re nil
2317 (intersection nonkeyword-prefix-ops in-or-postfix-ops
2318 :test
'string-equal
))
2322 ;; Now match all other symbols.
2323 (c-lang-const c-symbol-start
)
2326 ;; The chars that can start integer and floating point
2331 ;; The nonambiguous operators from `prefix-ops'.
2332 (c-make-keywords-re nil
2333 (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2334 :test
'string-equal
))
2337 ;; Match string and character literals.
2339 (if (memq 'gen-string-delim c-emacs-features
)
2342 (c-lang-defvar c-primary-expr-regexp
(c-lang-const c-primary-expr-regexp
))
2345 ;;; Additional constants for parser-level constructs.
2347 (c-lang-defconst c-decl-prefix-re
2348 "Regexp matching something that might precede a declaration, cast or
2349 label, such as the last token of a preceding statement or declaration.
2350 This is used in the common situation where a declaration or cast
2351 doesn't start with any specific token that can be searched for.
2353 The regexp should not match bob; that is done implicitly. It can't
2354 require a match longer than one token. The end of the token is taken
2355 to be at the end of the first submatch, which is assumed to always
2356 match. It's undefined whether identifier syntax (see
2357 `c-identifier-syntax-table') is in effect or not. This regexp is
2358 assumed to be a superset of `c-label-prefix-re' if
2359 `c-recognize-colon-labels' is set.
2361 Besides this, `c-decl-start-kwds' is used to find declarations.
2363 Note: This variable together with `c-decl-start-re' and
2364 `c-decl-start-kwds' is only used to detect \"likely\"
2365 declaration/cast/label starts. I.e. they might produce more matches
2366 but should not miss anything (or else it's necessary to use text
2367 properties - see the next note). Wherever they match, the following
2368 construct is analyzed to see if it indeed is a declaration, cast or
2369 label. That analysis is not cheap, so it's important that not too
2370 many false matches are triggered.
2372 Note: If a declaration/cast/label start can't be detected with this
2373 variable, it's necessary to use the `c-type' text property with the
2374 value `c-decl-end' on the last char of the last token preceding the
2375 declaration. See the comment blurb at the start of cc-engine.el for
2378 ;; We match a sequence of characters to skip over things like \"};\"
2379 ;; more quickly. We match ")" in C for K&R region declarations, and
2380 ;; in all languages except Java for when a cpp macro definition
2381 ;; begins with a declaration.
2382 t
"\\([\{\}\(\);,]+\\)"
2383 java
"\\([\{\}\(;,]+\\)"
2384 ;; Match "<" in C++ to get the first argument in a template arglist.
2385 ;; In that case there's an additional check in `c-find-decl-spots'
2386 ;; that it got open paren syntax.
2387 c
++ "\\([\{\}\(\);,<]+\\)"
2388 ;; Additionally match the protection directives in Objective-C.
2389 ;; Note that this doesn't cope with the longer directives, which we
2390 ;; would have to match from start to end since they don't end with
2391 ;; any easily recognized characters.
2392 objc
(concat "\\([\{\}\(\);,]+\\|"
2393 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2395 ;; Pike is like C but we also match "[" for multiple value
2396 ;; assignments and type casts.
2397 pike
"\\([\{\}\(\)\[;,]+\\)")
2398 (c-lang-defvar c-decl-prefix-re
(c-lang-const c-decl-prefix-re
)
2401 (c-lang-defconst c-decl-start-re
2402 "Regexp matching the start of any declaration, cast or label.
2403 It's used on the token after the one `c-decl-prefix-re' matched. This
2404 regexp should not try to match those constructs accurately as it's
2405 only used as a sieve to avoid spending more time checking other
2407 t
(c-lang-const c-identifier-start
))
2408 (c-lang-defvar c-decl-start-re
(c-lang-const c-decl-start-re
))
2410 (c-lang-defconst c-decl-prefix-or-start-re
2411 ;; Regexp matching something that might precede or start a
2412 ;; declaration, cast or label.
2414 ;; If the first submatch matches, it's taken to match the end of a
2415 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2416 ;; It's built from `c-decl-prefix-re'.
2418 ;; If the first submatch did not match, the match of the whole
2419 ;; regexp is taken to be at the first token in the declaration.
2420 ;; `c-decl-start-re' is not checked in this case.
2422 ;; Design note: The reason the same regexp is used to match both
2423 ;; tokens that precede declarations and start them is to avoid an
2424 ;; extra regexp search from the previous declaration spot in
2425 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2426 ;; that it finds all declaration/cast/label starts in approximately
2427 ;; linear order, so we can't do the searches in two separate passes.
2428 t
(if (c-lang-const c-decl-start-kwds
)
2429 (concat (c-lang-const c-decl-prefix-re
)
2431 (c-make-keywords-re t
(c-lang-const c-decl-start-kwds
)))
2432 (c-lang-const c-decl-prefix-re
)))
2433 (c-lang-defvar c-decl-prefix-or-start-re
2434 (c-lang-const c-decl-prefix-or-start-re
)
2437 (c-lang-defconst c-cast-parens
2438 ;; List containing the paren characters that can open a cast, or nil in
2439 ;; languages without casts.
2440 t
(c-filter-ops (c-lang-const c-operators
)
2443 (lambda (op) (elt op
0))))
2444 (c-lang-defvar c-cast-parens
(c-lang-const c-cast-parens
))
2446 (c-lang-defconst c-block-prefix-disallowed-chars
2447 "List of syntactically relevant characters that never can occur before
2448 the open brace in any construct that contains a brace block, e.g. in
2449 the \"class Foo: public Bar\" part of:
2451 class Foo: public Bar {int x();} a, *b;
2453 If parens can occur, the chars inside those aren't filtered with this
2456 '<' and '>' should be disallowed even if angle bracket arglists can
2457 occur. That since the search function needs to stop at them anyway to
2458 ensure they are given paren syntax.
2460 This is used to skip backward from the open brace to find the region
2461 in which to look for a construct like \"class\", \"enum\",
2462 \"namespace\" or whatever. That skipping should be as tight as
2463 possible for good performance."
2465 ;; Default to all chars that only occurs in nonsymbol tokens outside
2468 (c-lang-const c-nonsymbol-token-char-list
)
2469 (c-filter-ops (append (c-lang-const c-identifier-ops
)
2471 (c-lang-const c-after-id-concat-ops
))))
2476 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2478 (setq res
(cons (aref op
(match-beginning 1)) res
)
2482 ;; Allow cpp operatios (where applicable).
2483 t
(if (c-lang-const c-opt-cpp-prefix
)
2484 (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2486 (c-lang-const c-block-prefix-disallowed-chars
))
2488 ;; Allow ':' for inherit list starters.
2489 (c++ objc idl
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2492 ;; Allow ',' for multiple inherits.
2493 (c++ java
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2496 ;; Allow parentheses for anonymous inner classes in Java and class
2497 ;; initializer lists in Pike.
2498 (java pike
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2501 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2502 (c c
++ objc
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2505 (c-lang-defconst c-block-prefix-charset
2506 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2507 ;; for `c-syntactic-skip-backward'.
2508 t
(c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars
) t
))
2509 (c-lang-defvar c-block-prefix-charset
(c-lang-const c-block-prefix-charset
))
2511 (c-lang-defconst c-type-decl-prefix-key
2512 "Regexp matching the declarator operators that might precede the
2513 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
2514 regexp should match \"(\" if parentheses are valid in declarators.
2515 The end of the first submatch is taken as the end of the operator.
2516 Identifier syntax is in effect when this is matched \(see
2517 `c-identifier-syntax-table')."
2518 t
(if (c-lang-const c-type-modifier-kwds
)
2519 (concat (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>")
2520 ;; Default to a regexp that never matches.
2522 ;; Check that there's no "=" afterwards to avoid matching tokens
2524 (c objc
) (concat "\\("
2527 (c-lang-const c-type-decl-prefix-key
)
2534 ;; If this matches there's special treatment in
2535 ;; `c-font-lock-declarators' and
2536 ;; `c-font-lock-declarations' that check for a
2537 ;; complete name followed by ":: *".
2538 (c-lang-const c-identifier-start
)
2541 (c-lang-const c-type-decl-prefix-key
)
2544 pike
"\\(\\*\\)\\([^=]\\|$\\)")
2545 (c-lang-defvar c-type-decl-prefix-key
(c-lang-const c-type-decl-prefix-key
)
2548 (c-lang-defconst c-type-decl-suffix-key
2549 "Regexp matching the declarator operators that might follow after the
2550 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
2551 regexp should match \")\" if parentheses are valid in declarators. If
2552 it matches an open paren of some kind, the type declaration check
2553 continues at the corresponding close paren, otherwise the end of the
2554 first submatch is taken as the end of the operator. Identifier syntax
2555 is in effect when this is matched (see `c-identifier-syntax-table')."
2556 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
2557 ;; function argument list parenthesis.
2558 t
(if (c-lang-const c-type-modifier-kwds
)
2560 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>"
2563 (c c
++ objc
) (concat
2566 (if (c-lang-const c-type-modifier-kwds
)
2569 ;; "throw" in `c-type-modifier-kwds' is followed
2570 ;; by a parenthesis list, but no extra measures
2571 ;; are necessary to handle that.
2572 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
)
2576 (java idl
) "\\([\[\(]\\)")
2577 (c-lang-defvar c-type-decl-suffix-key
(c-lang-const c-type-decl-suffix-key
)
2580 (c-lang-defconst c-after-suffixed-type-decl-key
2581 "This regexp is matched after a declarator expression where
2582 `c-type-decl-suffix-key' has matched. If it matches then the
2583 construct is taken as a declaration. It's typically used to match the
2584 beginning of a function body or whatever might occur after the
2585 function header in a function declaration or definition. It's
2586 undefined whether identifier syntax (see `c-identifier-syntax-table')
2587 is in effect or not.
2589 Note that it's used in cases like after \"foo (bar)\" so it should
2590 only match when it's certain that it's a declaration, e.g \"{\" but
2591 not \",\" or \";\"."
2593 ;; If K&R style declarations should be recognized then one could
2594 ;; consider to match the start of any symbol since we want to match
2595 ;; the start of the first declaration in the "K&R region". That
2596 ;; could however produce false matches on code like "FOO(bar) x"
2597 ;; where FOO is a cpp macro, so it's better to leave it out and rely
2598 ;; on the other heuristics in that case.
2599 t
(if (c-lang-const c-postfix-spec-kwds
)
2600 ;; Add on the keywords in `c-postfix-spec-kwds'.
2601 (concat (c-lang-const c-after-suffixed-type-decl-key
)
2603 (c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2604 (c-lang-const c-after-suffixed-type-decl-key
))
2605 ;; Also match the colon that starts a base class initializer list in
2606 ;; C++. That can be confused with a function call before the colon
2607 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
2608 ;; match before such a thing (as a declaration-level construct;
2609 ;; matches inside arglist contexts are already excluded).
2611 (c-lang-defvar c-after-suffixed-type-decl-key
2612 (c-lang-const c-after-suffixed-type-decl-key
)
2615 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
2616 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
2617 ;; matches ";" and ",".
2618 t
(concat "\\(" (c-lang-const c-after-suffixed-type-decl-key
) "\\)"
2620 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
2621 (c-lang-const c-after-suffixed-type-maybe-decl-key
))
2623 (c-lang-defconst c-opt-type-concat-key
2624 "Regexp matching operators that concatenate types, e.g. the \"|\" in
2625 \"int|string\" in Pike. The end of the first submatch is taken as the
2626 end of the operator. nil in languages without such operators. It's
2627 undefined whether identifier syntax (see `c-identifier-syntax-table')
2628 is in effect or not."
2630 pike
"\\([|.&]\\)\\($\\|[^|.&]\\)")
2631 (c-lang-defvar c-opt-type-concat-key
(c-lang-const c-opt-type-concat-key
)
2634 (c-lang-defconst c-opt-type-suffix-key
2635 "Regexp matching operators that might follow after a type, or nil in
2636 languages that don't have such operators. The end of the first
2637 submatch is taken as the end of the operator. This should not match
2638 things like C++ template arglists if `c-recognize-<>-arglists' is set.
2639 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
2640 is in effect or not."
2642 (c c
++ objc pike
) "\\(\\.\\.\\.\\)"
2643 java
(concat "\\(\\[" (c-lang-const c-simple-ws
) "*\\]\\)"))
2644 (c-lang-defvar c-opt-type-suffix-key
(c-lang-const c-opt-type-suffix-key
))
2646 (c-lang-defvar c-known-type-key
2647 ;; Regexp matching the known type identifiers. This is initialized
2648 ;; from the type keywords and `*-font-lock-extra-types'. The first
2649 ;; submatch is the one that matches the type. Note that this regexp
2650 ;; assumes that symbol constituents like '_' and '$' have word
2653 (when (boundp (c-mode-symbol "font-lock-extra-types"))
2654 (c-mode-var "font-lock-extra-types")))
2657 (mapcar (lambda (re)
2658 (when (string-match "[][.*+?^$\\]" re
)
2663 (mapcar (lambda (re)
2664 (unless (string-match "[][.*+?^$\\]" re
)
2669 (append (list (c-make-keywords-re nil
2670 (append (c-lang-const c-primitive-type-kwds
)
2676 (c-lang-defconst c-special-brace-lists
2677 "List of open- and close-chars that makes up a pike-style brace list,
2678 i.e. for a ([Â ]) list there should be a cons (?\\[ . ?\\]) in this
2681 pike
'((?
{ . ?
}) (?\
[ . ?\
]) (?
< . ?
>)))
2682 (c-lang-defvar c-special-brace-lists
(c-lang-const c-special-brace-lists
))
2684 (c-lang-defconst c-recognize-knr-p
2685 "Non-nil means K&R style argument declarations are valid."
2688 (c-lang-defvar c-recognize-knr-p
(c-lang-const c-recognize-knr-p
))
2690 (c-lang-defconst c-recognize-typeless-decls
2691 "Non-nil means function declarations without return type should be
2692 recognized. That can introduce an ambiguity with parenthesized macro
2693 calls before a brace block. This setting does not affect declarations
2694 that are preceded by a declaration starting keyword, so
2695 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2698 (c-lang-defvar c-recognize-typeless-decls
2699 (c-lang-const c-recognize-typeless-decls
))
2701 (c-lang-defconst c-recognize-
<>-arglists
2702 "Non-nil means C++ style template arglists should be handled. More
2703 specifically, this means a comma separated list of types or
2704 expressions surrounded by \"<\" and \">\". It's always preceded by an
2705 identifier or one of the keywords on `c-<>-type-kwds' or
2706 `c-<>-arglist-kwds'. If there's an identifier before then the whole
2707 expression is considered to be a type."
2708 t
(or (consp (c-lang-const c-
<>-type-kwds
))
2709 (consp (c-lang-const c-
<>-arglist-kwds
))))
2710 (c-lang-defvar c-recognize-
<>-arglists
(c-lang-const c-recognize-
<>-arglists
))
2712 (c-lang-defconst c-recognize-paren-inits
2713 "Non-nil means that parenthesis style initializers exist,
2714 i.e. constructs like
2718 in addition to the more classic
2723 (c-lang-defvar c-recognize-paren-inits
(c-lang-const c-recognize-paren-inits
))
2725 (c-lang-defconst c-recognize-paren-inexpr-blocks
2726 "Non-nil to recognize gcc style in-expression blocks,
2727 i.e. compound statements surrounded by parentheses inside expressions."
2730 (c-lang-defvar c-recognize-paren-inexpr-blocks
2731 (c-lang-const c-recognize-paren-inexpr-blocks
))
2733 (c-lang-defconst c-opt-
<>-arglist-start
2734 ;; Regexp matching the start of angle bracket arglists in languages
2735 ;; where `c-recognize-<>-arglists' is set. Does not exclude
2736 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
2737 ;; assumed to surround the preceding symbol. The whole match is
2738 ;; assumed to end directly after the opening "<".
2739 t
(if (c-lang-const c-recognize-
<>-arglists
)
2741 (c-lang-const c-symbol-key
)
2743 (c-lang-const c-syntactic-ws
)
2745 (c-lang-defvar c-opt-
<>-arglist-start
(c-lang-const c-opt-
<>-arglist-start
))
2747 (c-lang-defconst c-opt-
<>-arglist-start-in-paren
2748 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
2749 ;; parens. The first submatch is assumed to surround
2750 ;; `c-opt-<>-arglist-start'.
2751 t
(if (c-lang-const c-opt-
<>-arglist-start
)
2753 (c-lang-const c-opt-
<>-arglist-start
)
2755 (c-lang-defvar c-opt-
<>-arglist-start-in-paren
2756 (c-lang-const c-opt-
<>-arglist-start-in-paren
))
2758 (c-lang-defconst c-opt-postfix-decl-spec-key
2759 ;; Regexp matching the beginning of a declaration specifier in the
2760 ;; region between the header and the body of a declaration.
2762 ;; TODO: This is currently not used uniformly; c++-mode and
2763 ;; java-mode each have their own ways of using it.
2766 (c-lang-const c-simple-ws
) "*"
2767 "\\(virtual" (c-lang-const c-simple-ws
) "+\\)?\\("
2768 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2769 "\\)" (c-lang-const c-simple-ws
) "+"
2770 "\\(" (c-lang-const c-symbol-key
) "\\)")
2771 java
(c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2772 (c-lang-defvar c-opt-postfix-decl-spec-key
2773 (c-lang-const c-opt-postfix-decl-spec-key
))
2775 (c-lang-defconst c-recognize-colon-labels
2776 "Non-nil if generic labels ending with \":\" should be recognized.
2777 That includes labels in code and access keys in classes. This does
2778 not apply to labels recognized by `c-label-kwds' and
2779 `c-opt-extra-label-key'."
2781 (c c
++ objc java pike
) t
)
2782 (c-lang-defvar c-recognize-colon-labels
2783 (c-lang-const c-recognize-colon-labels
))
2785 (c-lang-defconst c-label-prefix-re
2786 "Regexp like `c-decl-prefix-re' that matches any token that can precede
2787 a generic colon label. Not used if `c-recognize-colon-labels' is
2790 (c-lang-defvar c-label-prefix-re
2791 (c-lang-const c-label-prefix-re
))
2793 (c-lang-defconst c-nonlabel-token-key
2794 "Regexp matching things that can't occur in generic colon labels,
2795 neither in a statement nor in a declaration context. The regexp is
2796 tested at the beginning of every sexp in a suspected label,
2797 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
2799 ;; Don't allow string literals.
2801 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
2802 (c-make-keywords-re t
2803 (set-difference (c-lang-const c-keywords
)
2804 (append (c-lang-const c-label-kwds
)
2805 (c-lang-const c-protection-kwds
))
2806 :test
'string-equal
)))
2807 ;; Also check for open parens in C++, to catch member init lists in
2808 ;; constructors. We normally allow it so that macros with arguments
2810 c
++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key
)))
2811 (c-lang-defvar c-nonlabel-token-key
(c-lang-const c-nonlabel-token-key
))
2813 (c-lang-defconst c-opt-extra-label-key
2814 "Optional regexp matching labels.
2815 Normally, labels are detected according to `c-nonlabel-token-key',
2816 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
2817 be used if there are additional labels that aren't recognized that
2820 objc
(c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
2821 (c-lang-defvar c-opt-extra-label-key
(c-lang-const c-opt-extra-label-key
))
2823 (c-lang-defconst c-opt-friend-key
2824 ;; Regexp describing friend declarations classes, or nil in
2825 ;; languages that don't have such things.
2827 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
2828 ;; template skipping isn't done properly. This will disappear soon.
2830 c
++ (concat "friend" (c-lang-const c-simple-ws
) "+"
2833 (c-lang-const c-simple-ws
) "*"
2835 (c-lang-const c-simple-ws
) "*"
2837 (c-lang-const c-simple-ws
) "+")))
2838 (c-lang-defvar c-opt-friend-key
(c-lang-const c-opt-friend-key
))
2840 (c-lang-defconst c-opt-method-key
2841 ;; Special regexp to match the start of Objective-C methods. The
2842 ;; first submatch is assumed to end after the + or - key.
2845 ;; TODO: Ought to use a better method than anchoring on bol.
2848 (c-lang-const c-simple-ws
) "*"
2849 (concat "\\(" ; Return type.
2851 (c-lang-const c-simple-ws
) "*"
2853 "\\(" (c-lang-const c-symbol-key
) "\\)"))
2854 (c-lang-defvar c-opt-method-key
(c-lang-const c-opt-method-key
))
2856 (c-lang-defconst c-type-decl-end-used
2857 ;; Must be set in buffers where the `c-type' text property might be
2858 ;; used with the value `c-decl-end'.
2860 ;; `c-decl-end' is used to mark the ends of labels and access keys
2861 ;; to make interactive refontification work better.
2862 t
(or (c-lang-const c-recognize-colon-labels
)
2863 (and (c-lang-const c-label-kwds
) t
))
2864 ;; `c-decl-end' is used to mark the end of the @-style directives in
2867 (c-lang-defvar c-type-decl-end-used
(c-lang-const c-type-decl-end-used
))
2870 ;;; Wrap up the `c-lang-defvar' system.
2872 ;; Compile in the list of language variables that has been collected
2873 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
2874 ;; first element of each is nil.
2875 (defconst c-lang-variable-inits
(cc-eval-when-compile c-lang-variable-inits
))
2876 (defconst c-emacs-variable-inits
(cc-eval-when-compile c-emacs-variable-inits
))
2878 (defun c-make-init-lang-vars-fun (mode)
2879 "Create a function that initializes all the language dependent variables
2882 This function should be evaluated at compile time, so that the
2883 function it returns is byte compiled with all the evaluated results
2884 from the language constants. Use the `c-init-language-vars' macro to
2885 accomplish that conveniently."
2887 (if (and (not load-in-progress
)
2888 (boundp 'byte-compile-dest-file
)
2889 (stringp byte-compile-dest-file
))
2891 ;; No need to byte compile this lambda since the byte compiler is
2892 ;; smart enough to detect the `funcall' construct in the
2893 ;; `c-init-language-vars' macro below and compile it all straight
2894 ;; into the function that contains `c-init-language-vars'.
2897 ;; This let sets up the context for `c-mode-var' and similar
2898 ;; that could be in the result from `cl-macroexpand-all'.
2899 (let ((c-buffer-is-cc-mode ',mode
)
2900 current-var source-eval
)
2903 (if (eq c-version-sym
',c-version-sym
)
2904 (setq ,@(let ((c-buffer-is-cc-mode mode
)
2905 (c-lang-const-expansion 'immediate
))
2906 ;; `c-lang-const' will expand to the evaluated
2907 ;; constant immediately in `cl-macroexpand-all'
2911 `(current-var ',(car init
)
2912 ,(car init
) ,(cl-macroexpand-all
2914 ;; Note: The following `append' copies the
2915 ;; first argument. That list is small, so
2916 ;; this doesn't matter too much.
2917 (append (cdr c-emacs-variable-inits
)
2918 (cdr c-lang-variable-inits
)))))
2920 ;; This diagnostic message isn't useful for end
2921 ;; users, so it's disabled.
2922 ;;(unless (get ',mode 'c-has-warned-lang-consts)
2923 ;; (message ,(concat "%s compiled with CC Mode %s "
2924 ;; "but loaded with %s - evaluating "
2925 ;; "language constants from source")
2926 ;; ',mode ,c-version c-version)
2927 ;; (put ',mode 'c-has-warned-lang-consts t))
2930 (setq source-eval t
)
2931 (let ((init (append (cdr c-emacs-variable-inits
)
2932 (cdr c-lang-variable-inits
))))
2934 (setq current-var
(caar init
))
2935 (set (caar init
) (eval (cadar init
)))
2936 (setq init
(cdr init
)))))
2940 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
2944 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
2945 ',mode
,c-version c-version
)
2948 (signal (car err
) (cdr err
)))))))
2950 ;; Being evaluated from source. Always use the dynamic method to
2951 ;; work well when `c-lang-defvar's in this file are reevaluated
2955 (let ((c-buffer-is-cc-mode ',mode
)
2956 (init (append (cdr c-emacs-variable-inits
)
2957 (cdr c-lang-variable-inits
)))
2962 (setq current-var
(caar init
))
2963 (set (caar init
) (eval (cadar init
)))
2964 (setq init
(cdr init
)))
2969 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
2971 (signal (car err
) (cdr err
)))))))
2974 (defmacro c-init-language-vars
(mode)
2975 "Initialize all the language dependent variables for the given mode.
2976 This macro is expanded at compile time to a form tailored for the mode
2977 in question, so MODE must be a constant. Therefore MODE is not
2978 evaluated and should not be quoted."
2979 `(funcall ,(c-make-init-lang-vars-fun mode
)))
2982 (cc-provide 'cc-langs
)
2984 ;;; arch-tag: 1ab57482-cfc2-4c5b-b628-3539c3098822
2985 ;;; cc-langs.el ends here