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, 2008
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 3, 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.")
417 (c-lang-defconst c-get-state-before-change-function
418 "If non-nil, a function called from c-before-change-hook.
419 Typically it will record enough state to allow
420 `c-before-font-lock-function' to extend the region to fontify,
421 and may do such things as removing text-properties which must be
424 It takes 2 parameters, the BEG and END supplied to every
425 before-change function; on entry, the buffer will have been
426 widened and match-data will have been saved; point is undefined
427 on both entry and exit; the return value is ignored.
429 When the mode is initialized, this function is called with
430 parameters \(point-min) and \(point-max)."
432 (c c
++ objc
) 'c-extend-region-for-CPP
433 awk
'c-awk-record-region-clear-NL
)
434 (c-lang-defvar c-get-state-before-change-function
435 (c-lang-const c-get-state-before-change-function
))
437 (c-lang-defconst c-before-font-lock-function
438 "If non-nil, a function called just before font locking.
439 Typically it will extend the region about to be fontified \(see
440 below) and will set `syntax-table' text properties on the region.
442 It takes 3 parameters, the BEG, END, and OLD-LEN supplied to
443 every after-change function; point is undefined on both entry and
444 exit; on entry, the buffer will have been widened and match-data
445 will have been saved; the return value is ignored.
447 The function may extend the region to be fontified by setting the
448 buffer local variables c-new-BEG and c-new-END.
450 The function is called even when font locking is disabled.
452 When the mode is initialized, this function is called with
453 parameters \(point-min), \(point-max) and <buffer size>."
455 (c c
++ objc
) 'c-neutralize-syntax-in-CPP
456 awk
'c-awk-extend-and-syntax-tablify-region
)
457 (c-lang-defvar c-before-font-lock-function
458 (c-lang-const c-before-font-lock-function
))
461 ;;; Lexer-level syntax (identifiers, tokens etc).
463 (c-lang-defconst c-symbol-start
464 "Regexp that matches the start of a symbol, i.e. any identifier or
465 keyword. It's unspecified how far it matches. Does not contain a \\|
466 operator at the top level."
467 t
(concat "[" c-alpha
"_]")
468 objc
(concat "[" c-alpha
"@]")
469 pike
(concat "[" c-alpha
"_`]"))
470 (c-lang-defvar c-symbol-start
(c-lang-const c-symbol-start
))
472 (c-lang-defconst c-symbol-chars
473 "Set of characters that can be part of a symbol.
474 This is on the form that fits inside [ ] in a regexp."
475 ;; Pike note: With the backquote identifiers this would include most
476 ;; operator chars too, but they are handled with other means instead.
477 t
(concat c-alnum
"_$")
478 objc
(concat c-alnum
"_$@"))
480 (c-lang-defconst c-symbol-key
481 "Regexp matching identifiers and keywords (with submatch 0). Assumed
482 to match if `c-symbol-start' matches on the same position."
483 t
(concat (c-lang-const c-symbol-start
)
484 "[" (c-lang-const c-symbol-chars
) "]*")
486 ;; Use the value from C here since the operator backquote is
487 ;; covered by the other alternative.
488 (c-lang-const c-symbol-key c
)
490 (c-make-keywords-re nil
491 (c-lang-const c-overloadable-operators
))))
492 (c-lang-defvar c-symbol-key
(c-lang-const c-symbol-key
))
494 (c-lang-defconst c-symbol-key-depth
495 ;; Number of regexp grouping parens in `c-symbol-key'.
496 t
(regexp-opt-depth (c-lang-const c-symbol-key
)))
498 (c-lang-defconst c-nonsymbol-chars
499 "This is the set of chars that can't be part of a symbol, i.e. the
500 negation of `c-symbol-chars'."
501 t
(concat "^" (c-lang-const c-symbol-chars
)))
502 (c-lang-defvar c-nonsymbol-chars
(c-lang-const c-nonsymbol-chars
))
504 (c-lang-defconst c-nonsymbol-key
505 "Regexp that matches any character that can't be part of a symbol.
506 It's usually appended to other regexps to avoid matching a prefix.
507 It's assumed to not contain any submatchers."
508 ;; The same thing regarding Unicode identifiers applies here as to
510 t
(concat "[" (c-lang-const c-nonsymbol-chars
) "]"))
512 (c-lang-defconst c-identifier-ops
513 "The operators that make up fully qualified identifiers. nil in
514 languages that don't have such things. See `c-operators' for a
515 description of the format. Binary operators can concatenate symbols,
516 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
517 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
519 This value is by default merged into `c-operators'."
521 c
++ '((prefix "~" "??-" "compl")
524 ;; Java has "." to concatenate identifiers but it's also used for
525 ;; normal indexing. There's special code in the Java font lock
526 ;; rules to fontify qualified identifiers based on the standard
527 ;; naming conventions. We still define "." here to make
528 ;; `c-forward-name' move over as long names as possible which is
529 ;; necessary to e.g. handle throws clauses correctly.
530 java
'((left-assoc "."))
531 idl
'((left-assoc "::")
533 pike
'((left-assoc "::")
537 (c-lang-defconst c-opt-identifier-concat-key
538 ;; Appendable adorned regexp matching the operators that join
539 ;; symbols to fully qualified identifiers, or nil in languages that
540 ;; don't have such things.
542 ;; This was a docstring constant in 5.30. It still works but is now
543 ;; considered internal - change `c-identifier-ops' instead.
544 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
545 '(left-assoc right-assoc
)
548 (c-make-keywords-re 'appendable ops
))))
549 (c-lang-defvar c-opt-identifier-concat-key
550 (c-lang-const c-opt-identifier-concat-key
)
553 (c-lang-defconst c-opt-identifier-concat-key-depth
554 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
555 t
(regexp-opt-depth (c-lang-const c-opt-identifier-concat-key
)))
557 (c-lang-defconst c-opt-identifier-prefix-key
558 ;; Appendable adorned regexp matching operators that might precede
559 ;; an identifier and that are part of the identifier in that case.
560 ;; nil in languages without such things.
561 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
565 (c-make-keywords-re 'appendable ops
))))
567 (c-lang-defconst c-after-id-concat-ops
568 "Operators that can occur after a binary operator on `c-identifier-ops'
569 in identifiers. nil in languages that don't have such things.
571 Operators here should also have appropriate entries in `c-operators' -
572 it's not taken care of by default."
574 ;; '~' for destructors in C++, '*' for member pointers.
576 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
577 ;; in import declarations. (This will also match bogus things like
578 ;; "foo.*bar" but we don't bother.)
581 (c-lang-defconst c-opt-after-id-concat-key
582 ;; Regexp that must match the token after
583 ;; `c-opt-identifier-concat-key' for it to be considered an
584 ;; identifier concatenation operator (which e.g. causes the
585 ;; preceding identifier to be fontified as a reference). Assumed to
586 ;; be a string if `c-opt-identifier-concat-key' is.
588 ;; This was a docstring constant in 5.30. It still works but is now
589 ;; considered internal - change `c-after-id-concat-ops' instead.
590 t
(concat (c-lang-const c-symbol-start
)
591 (if (c-lang-const c-after-id-concat-ops
)
592 (concat "\\|" (c-make-keywords-re 'appendable
593 (c-lang-const c-after-id-concat-ops
)))
596 (c-lang-defconst c-identifier-start
597 "Regexp that matches the start of an (optionally qualified) identifier.
598 It should also match all keywords. It's unspecified how far it
600 t
(concat (c-lang-const c-symbol-start
)
601 (if (c-lang-const c-opt-identifier-prefix-key
)
603 (c-lang-const c-opt-identifier-prefix-key
))
605 (c-lang-defvar c-identifier-start
(c-lang-const c-identifier-start
))
607 (c-lang-defconst c-identifier-key
608 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
609 C++. It does not recognize the full range of syntactic whitespace
610 between the tokens; `c-forward-name' has to be used for that. It
611 should also not match identifiers containing parenthesis groupings,
612 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
613 ;; This regexp is more complex than strictly necessary to ensure
614 ;; that it can be matched with a minimum of backtracking.
615 t
(concat (if (c-lang-const c-opt-identifier-prefix-key
)
618 (c-lang-const c-opt-identifier-prefix-key
)
619 (c-lang-const c-simple-ws
) "*"
622 "\\(" (c-lang-const c-symbol-key
) "\\)"
623 (if (c-lang-const c-opt-identifier-concat-key
)
626 (c-lang-const c-simple-ws
) "*"
627 (c-lang-const c-opt-identifier-concat-key
)
628 (c-lang-const c-simple-ws
) "*"
629 (if (c-lang-const c-after-id-concat-ops
)
632 (c-make-keywords-re 'appendable
633 (c-lang-const c-after-id-concat-ops
))
635 ;; For flexibility, consider the symbol match
636 ;; optional if we've hit a
637 ;; `c-after-id-concat-ops' operator. This is
638 ;; also necessary to handle the "*" that can
639 ;; end import declaration identifiers in Java.
641 (c-lang-const c-simple-ws
) "*"
642 "\\(" (c-lang-const c-symbol-key
) "\\)"
645 "\\(" (c-lang-const c-symbol-key
) "\\)"
647 (concat "\\(" (c-lang-const c-symbol-key
) "\\)"))
650 (c-lang-defvar c-identifier-key
(c-lang-const c-identifier-key
))
652 (c-lang-defconst c-identifier-last-sym-match
653 ;; This was a docstring constant in 5.30 but it's no longer used.
654 ;; It's only kept to avoid breaking third party code.
656 ;; Used to identify the submatch in `c-identifier-key' that
657 ;; surrounds the last symbol in the qualified identifier. It's a
658 ;; list of submatch numbers, of which the first that has a match is
659 ;; taken. It's assumed that at least one does when the regexp has
663 (c-lang-defconst c-string-escaped-newlines
664 "Set if the language support backslash escaped newlines inside string
668 (c-lang-defvar c-string-escaped-newlines
669 (c-lang-const c-string-escaped-newlines
))
671 (c-lang-defconst c-multiline-string-start-char
672 "Set if the language supports multiline string literals without escaped
673 newlines. If t, all string literals are multiline. If a character,
674 only literals where the open quote is immediately preceded by that
675 literal are multiline."
678 (c-lang-defvar c-multiline-string-start-char
679 (c-lang-const c-multiline-string-start-char
))
681 (c-lang-defconst c-opt-cpp-prefix
682 "Regexp matching the prefix of a cpp directive in the languages that
683 normally use that macro preprocessor. Tested at bol or at boi.
684 Assumed to not contain any submatches or \\| operators."
685 ;; TODO (ACM, 2005-04-01). Amend the following to recognise escaped NLs;
686 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
689 (c-lang-defvar c-opt-cpp-prefix
(c-lang-const c-opt-cpp-prefix
))
691 (c-lang-defconst c-anchored-cpp-prefix
692 "Regexp matching the prefix of a cpp directive anchored to BOL,
693 in the languages that have a macro preprocessor."
694 t
(if (c-lang-const c-opt-cpp-prefix
)
695 (concat "^" (c-lang-const c-opt-cpp-prefix
))))
696 (c-lang-defvar c-anchored-cpp-prefix
(c-lang-const c-anchored-cpp-prefix
))
698 (c-lang-defconst c-opt-cpp-start
699 "Regexp matching the prefix of a cpp directive including the directive
700 name, or nil in languages without preprocessor support. The first
701 submatch surrounds the directive name."
702 t
(if (c-lang-const c-opt-cpp-prefix
)
703 (concat (c-lang-const c-opt-cpp-prefix
)
704 "\\([" c-alnum
"]+\\)"))
705 ;; Pike, being a scripting language, recognizes hash-bangs too.
706 pike
(concat (c-lang-const c-opt-cpp-prefix
)
707 "\\([" c-alnum
"]+\\|!\\)"))
708 (c-lang-defvar c-opt-cpp-start
(c-lang-const c-opt-cpp-start
))
710 (c-lang-defconst c-cpp-message-directives
711 "List of cpp directives (without the prefix) that are followed by a
713 t
(if (c-lang-const c-opt-cpp-prefix
)
715 (c c
++ objc pike
) '("error" "warning"))
717 (c-lang-defconst c-cpp-include-directives
718 "List of cpp directives (without the prefix) that are followed by a
719 file name in angle brackets or quotes."
720 t
(if (c-lang-const c-opt-cpp-prefix
)
722 objc
'("include" "import"))
724 (c-lang-defconst c-opt-cpp-macro-define
725 "Cpp directive (without the prefix) that is followed by a macro
726 definition, or nil if the language doesn't have any."
727 t
(if (c-lang-const c-opt-cpp-prefix
)
730 (c-lang-defconst c-opt-cpp-macro-define-start
731 ;; Regexp matching everything up to the macro body of a cpp define, or the
732 ;; end of the logical line if there is none. Submatch 1 is the name of the
733 ;; macro. Set if c-opt-cpp-macro-define is.
734 t
(if (c-lang-const c-opt-cpp-macro-define
)
735 (concat (c-lang-const c-opt-cpp-prefix
)
736 (c-lang-const c-opt-cpp-macro-define
)
737 "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(\([^\)]*\)\\)?"
739 "\\([ \t]\\|\\\\\n\\)*")))
740 (c-lang-defvar c-opt-cpp-macro-define-start
741 (c-lang-const c-opt-cpp-macro-define-start
))
743 (c-lang-defconst c-opt-cpp-macro-define-id
744 ;; Regexp matching everything up to the end of the identifier defined
746 t
(if (c-lang-const c-opt-cpp-macro-define
)
747 (concat (c-lang-const c-opt-cpp-prefix
) ; #
748 (c-lang-const c-opt-cpp-macro-define
) ; define
749 "[ \t]+\\(\\sw\\|_\\)+")))
750 (c-lang-defvar c-opt-cpp-macro-define-id
751 (c-lang-const c-opt-cpp-macro-define-id
))
753 (c-lang-defconst c-cpp-expr-directives
754 "List of cpp directives (without the prefix) that are followed by an
756 t
(if (c-lang-const c-opt-cpp-prefix
)
759 (c-lang-defconst c-cpp-expr-functions
760 "List of functions in cpp expressions."
761 t
(if (c-lang-const c-opt-cpp-prefix
)
763 pike
'("defined" "efun" "constant"))
765 (c-lang-defconst c-assignment-operators
766 "List of all assignment operators."
767 t
'("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
768 java
(append (c-lang-const c-assignment-operators
)
770 c
++ (append (c-lang-const c-assignment-operators
)
771 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
774 (c-lang-defconst c-operators
775 "List describing all operators, along with their precedence and
776 associativity. The order in the list corresponds to the precedence of
777 the operators: The operators in each element are a group with the same
778 precedence, and the group has higher precedence than the groups in all
779 following elements. The car of each element describes the type of the
780 operator group, and the cdr is a list of the operator tokens in it.
781 The operator group types are:
783 'prefix Unary prefix operators.
784 'postfix Unary postfix operators.
786 Unary postfix operators if and only if the chars have
788 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
789 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
790 'right-assoc-sequence
791 Right associative operator that constitutes of a
792 sequence of tokens that separate expressions. All the
793 tokens in the group are in this case taken as
794 describing the sequence in one such operator, and the
795 order between them is therefore significant.
797 Operators containing a character with paren syntax are taken to match
798 with a corresponding open/close paren somewhere else. A postfix
799 operator with close paren syntax is taken to end a postfix expression
800 started somewhere earlier, rather than start a new one at point. Vice
801 versa for prefix operators with open paren syntax.
803 Note that operators like \".\" and \"->\" which in language references
804 often are described as postfix operators are considered binary here,
805 since CC Mode treats every identifier as an expression."
807 ;; There's currently no code in CC Mode that exploit all the info
808 ;; in this variable; precedence, associativity etc are present as a
809 ;; preparation for future work.
812 ,@(when (c-lang-const c-opt-cpp-prefix
)
814 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
817 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
818 '("%:%:" "??=??=")))))
821 ,@(c-lang-const c-identifier-ops
)
822 ,@(cond ((c-major-mode-is 'c
++-mode
)
823 `((postfix-if-paren "<" ">"))) ; Templates.
824 ((c-major-mode-is 'pike-mode
)
825 `((prefix "global" "predef")))
826 ((c-major-mode-is 'java-mode
)
827 `((prefix "super"))))
830 ,@(when (c-major-mode-is 'c
++-mode
)
831 ;; The following need special treatment.
832 `((prefix "dynamic_cast" "static_cast"
833 "reinterpret_cast" "const_cast" "typeid")))
835 ,@(unless (c-major-mode-is 'java-mode
)
837 (postfix "++" "--" "[" "]" "(" ")"
838 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
839 '("<:" ":>" "??(" "??)")))
842 (prefix "++" "--" "+" "-" "!" "~"
843 ,@(when (c-major-mode-is 'c
++-mode
) '("not" "compl"))
844 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
845 '("*" "&" "sizeof" "??-"))
846 ,@(when (c-major-mode-is 'objc-mode
)
847 '("@selector" "@protocol" "@encode"))
848 ;; The following need special treatment.
849 ,@(cond ((c-major-mode-is 'c
++-mode
)
851 ((c-major-mode-is 'java-mode
)
853 ((c-major-mode-is 'pike-mode
)
854 '("class" "lambda" "catch" "throw" "gauge")))
856 ,@(when (c-major-mode-is 'pike-mode
)
857 '("[" "]"))) ; Type cast.
860 ,@(when (c-major-mode-is 'c
++-mode
)
861 `((left-assoc ".*" "->*")))
864 (left-assoc "*" "/" "%")
870 (left-assoc "<<" ">>"
871 ,@(when (c-major-mode-is 'java-mode
)
875 (left-assoc "<" ">" "<=" ">="
876 ,@(when (c-major-mode-is 'java-mode
)
880 (left-assoc "==" "!="
881 ,@(when (c-major-mode-is 'c
++-mode
) '("not_eq")))
885 ,@(when (c-major-mode-is 'c
++-mode
) '("bitand")))
887 ;; Bitwise exclusive or.
889 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
891 ,@(when (c-major-mode-is 'c
++-mode
) '("xor")))
895 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
897 ,@(when (c-major-mode-is 'c
++-mode
) '("bitor")))
901 ,@(when (c-major-mode-is 'c
++-mode
) '("and")))
905 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
907 ,@(when (c-major-mode-is 'c
++-mode
) '("or")))
910 (right-assoc-sequence "?" ":")
913 (right-assoc ,@(c-lang-const c-assignment-operators
))
916 ,@(when (c-major-mode-is 'c
++-mode
)
922 ;; IDL got its own definition since it has a much smaller operator
923 ;; set than the other languages.
924 idl
`(;; Preprocessor.
928 ,@(c-lang-const c-identifier-ops
)
932 (left-assoc "*" "/" "%")
936 (left-assoc "<<" ">>")
944 (c-lang-defconst c-operator-list
945 ;; The operators as a flat list (without duplicates).
946 t
(c-filter-ops (c-lang-const c-operators
) t t
))
948 (c-lang-defconst c-overloadable-operators
949 "List of the operators that are overloadable, in their \"identifier
950 form\". See also `c-op-identifier-prefix'."
952 c
++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
954 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
955 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
956 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
957 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
958 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
959 "()" "[]" "<::>" "??(??)")
960 ;; These work like identifiers in Pike.
961 pike
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
962 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
963 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
966 (c-lang-defconst c-overloadable-operators-regexp
967 ;; Regexp tested after an "operator" token in C++.
969 c
++ (c-make-keywords-re nil
(c-lang-const c-overloadable-operators
)))
970 (c-lang-defvar c-overloadable-operators-regexp
971 (c-lang-const c-overloadable-operators-regexp
))
973 (c-lang-defconst c-opt-op-identifier-prefix
974 "Regexp matching the token before the ones in
975 `c-overloadable-operators' when operators are specified in their
976 \"identifier form\". This typically matches \"operator\" in C++ where
977 operator functions are specified as e.g. \"operator +\". It's nil in
978 languages without operator functions or where the complete operator
979 identifier is listed in `c-overloadable-operators'.
981 This regexp is assumed to not match any non-operator identifier."
983 c
++ (c-make-keywords-re t
'("operator")))
984 (c-lang-defvar c-opt-op-identifier-prefix
985 (c-lang-const c-opt-op-identifier-prefix
))
987 ;; Note: the following alias is an old name which was a mis-spelling. It has
988 ;; been corrected above and throughout cc-engine.el. It will be removed at
989 ;; some release very shortly in the future. ACM, 2006-04-14.
990 (defalias 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
)
991 (make-obsolete-variable 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
992 "CC Mode 5.31.4, 2006-04-14")
994 (c-lang-defconst c-other-op-syntax-tokens
995 "List of the tokens made up of characters in the punctuation or
996 parenthesis syntax classes that have uses other than as expression
998 t
'("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
999 (c c
++ pike
) (append '("#" "##" ; Used by cpp.
1001 (c-lang-const c-other-op-syntax-tokens
))
1002 (c c
++) (append '("*") (c-lang-const c-other-op-syntax-tokens
))
1003 c
++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
1004 (c-lang-const c-other-op-syntax-tokens
))
1005 objc
(append '("#" "##" ; Used by cpp.
1006 "+" "-") (c-lang-const c-other-op-syntax-tokens
))
1007 idl
(append '("#" "##") ; Used by cpp.
1008 (c-lang-const c-other-op-syntax-tokens
))
1009 pike
(append '("..")
1010 (c-lang-const c-other-op-syntax-tokens
)
1011 (c-lang-const c-overloadable-operators
))
1012 awk
'("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
1014 (c-lang-defconst c-all-op-syntax-tokens
1015 ;; List of all tokens in the punctuation and parenthesis syntax
1017 t
(delete-duplicates (append (c-lang-const c-other-op-syntax-tokens
)
1018 (c-lang-const c-operator-list
))
1019 :test
'string-equal
))
1021 (c-lang-defconst c-nonsymbol-token-char-list
1022 ;; List containing all chars not in the word, symbol or
1023 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
1024 ;; parenthesis and string delimiter chars.
1025 t
(c-with-syntax-table (c-lang-const c-mode-syntax-table
)
1026 ;; Only go through the chars in the printable ASCII range. No
1027 ;; language so far has 8-bit or widestring operators.
1028 (let (list (char 32))
1030 (or (memq (char-syntax char
) '(?w ?_ ?
< ?
> ?\
))
1031 (setq list
(cons (c-int-to-char char
) list
)))
1032 (setq char
(1+ char
)))
1035 (c-lang-defconst c-nonsymbol-token-regexp
1036 ;; Regexp matching all tokens in the punctuation and parenthesis
1037 ;; syntax classes. Note that this also matches ".", which can start
1039 t
(c-make-keywords-re nil
1040 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1042 "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
1043 (c-lang-defvar c-nonsymbol-token-regexp
1044 (c-lang-const c-nonsymbol-token-regexp
))
1046 (c-lang-defconst c-assignment-op-regexp
1047 ;; Regexp matching all assignment operators and only them. The
1048 ;; beginning of the first submatch is used to detect the end of the
1049 ;; token, along with the end of the whole match.
1050 t
(if (c-lang-const c-assignment-operators
)
1052 ;; Need special case for "=" since it's a prefix of "==".
1055 (c-make-keywords-re nil
1056 (set-difference (c-lang-const c-assignment-operators
)
1058 :test
'string-equal
)))
1060 (c-lang-defvar c-assignment-op-regexp
1061 (c-lang-const c-assignment-op-regexp
))
1063 (c-lang-defconst c-
<>-multichar-token-regexp
1064 ;; Regexp matching all tokens containing "<" or ">" which are longer
1066 t
(c-make-keywords-re nil
1067 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1070 (c-lang-defvar c-
<>-multichar-token-regexp
1071 (c-lang-const c-
<>-multichar-token-regexp
))
1073 (c-lang-defconst c-
<-op-cont-regexp
1074 ;; Regexp matching the second and subsequent characters of all
1075 ;; multicharacter tokens that begin with "<".
1076 t
(c-make-keywords-re nil
1077 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1080 (lambda (op) (substring op
1)))))
1081 (c-lang-defvar c-
<-op-cont-regexp
(c-lang-const c-
<-op-cont-regexp
))
1083 (c-lang-defconst c-
>-op-cont-regexp
1084 ;; Regexp matching the second and subsequent characters of all
1085 ;; multicharacter tokens that begin with ">".
1086 t
(c-make-keywords-re nil
1087 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1090 (lambda (op) (substring op
1)))))
1091 (c-lang-defvar c-
>-op-cont-regexp
(c-lang-const c-
>-op-cont-regexp
))
1093 (c-lang-defconst c-stmt-delim-chars
1094 ;; The characters that should be considered to bound statements. To
1095 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1096 ;; begin with "^" to negate the set. If ? : operators should be
1097 ;; detected then the string must end with "?:".
1099 awk
"^;{}#\n\r?:") ; The newline chars gets special treatment.
1100 (c-lang-defvar c-stmt-delim-chars
(c-lang-const c-stmt-delim-chars
))
1102 (c-lang-defconst c-stmt-delim-chars-with-comma
1103 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1105 awk
"^;,{}\n\r?:") ; The newline chars gets special treatment.
1106 (c-lang-defvar c-stmt-delim-chars-with-comma
1107 (c-lang-const c-stmt-delim-chars-with-comma
))
1110 ;;; Syntactic whitespace.
1112 (c-lang-defconst c-simple-ws
1113 "Regexp matching an ordinary whitespace character.
1114 Does not contain a \\| operator at the top level."
1115 ;; "\\s " is not enough since it doesn't match line breaks.
1116 t
"\\(\\s \\|[\n\r]\\)")
1118 (c-lang-defconst c-simple-ws-depth
1119 ;; Number of regexp grouping parens in `c-simple-ws'.
1120 t
(regexp-opt-depth (c-lang-const c-simple-ws
)))
1122 (c-lang-defconst c-line-comment-starter
1123 "String that starts line comments, or nil if such don't exist.
1124 Line comments are always terminated by newlines. At least one of
1125 `c-block-comment-starter' and this one is assumed to be set.
1127 Note that it's currently not enough to set this to support a new
1128 comment style. Other stuff like the syntax table must also be set up
1132 (c-lang-defvar c-line-comment-starter
(c-lang-const c-line-comment-starter
))
1134 (c-lang-defconst c-block-comment-starter
1135 "String that starts block comments, or nil if such don't exist.
1136 Block comments are ended by `c-block-comment-ender', which is assumed
1137 to be set if this is. At least one of `c-line-comment-starter' and
1138 this one is assumed to be set.
1140 Note that it's currently not enough to set this to support a new
1141 comment style. Other stuff like the syntax table must also be set up
1146 (c-lang-defconst c-block-comment-ender
1147 "String that ends block comments, or nil if such don't exist.
1149 Note that it's currently not enough to set this to support a new
1150 comment style. Other stuff like the syntax table must also be set up
1155 (c-lang-defconst c-comment-start-regexp
1156 ;; Regexp to match the start of any type of comment.
1157 t
(let ((re (c-make-keywords-re nil
1158 (list (c-lang-const c-line-comment-starter
)
1159 (c-lang-const c-block-comment-starter
)))))
1160 (if (memq 'gen-comment-delim c-emacs-features
)
1161 (concat re
"\\|\\s!")
1163 (c-lang-defvar c-comment-start-regexp
(c-lang-const c-comment-start-regexp
))
1165 ;;;; Added by ACM, 2003/9/18.
1166 (c-lang-defconst c-block-comment-start-regexp
1167 ;; Regexp which matches the start of a block comment (if such exists in the
1169 t
(if (c-lang-const c-block-comment-starter
)
1170 (regexp-quote (c-lang-const c-block-comment-starter
))
1172 (c-lang-defvar c-block-comment-start-regexp
1173 (c-lang-const c-block-comment-start-regexp
))
1175 (c-lang-defconst c-literal-start-regexp
1176 ;; Regexp to match the start of comments and string literals.
1177 t
(concat (c-lang-const c-comment-start-regexp
)
1179 (if (memq 'gen-string-delim c-emacs-features
)
1182 (c-lang-defvar c-literal-start-regexp
(c-lang-const c-literal-start-regexp
))
1184 (c-lang-defconst c-doc-comment-start-regexp
1185 "Regexp to match the start of documentation comments."
1187 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1188 (c c
++ objc
) "/\\*[*!]"
1191 (c-lang-defvar c-doc-comment-start-regexp
1192 (c-lang-const c-doc-comment-start-regexp
))
1194 (c-lang-defconst comment-start
1195 "String that starts comments inserted with M-; etc.
1196 `comment-start' is initialized from this."
1197 ;; Default: Prefer line comments to block comments, and pad with a space.
1198 t
(concat (or (c-lang-const c-line-comment-starter
)
1199 (c-lang-const c-block-comment-starter
))
1201 ;; In C we still default to the block comment style since line
1202 ;; comments aren't entirely portable.
1204 (c-lang-setvar comment-start
(c-lang-const comment-start
))
1206 (c-lang-defconst comment-end
1207 "String that ends comments inserted with M-; etc.
1208 `comment-end' is initialized from this."
1209 ;; Default: Use block comment style if comment-start uses block
1210 ;; comments, and pad with a space in that case.
1211 t
(if (string-match (concat "\\`\\("
1212 (c-lang-const c-block-comment-start-regexp
)
1214 (c-lang-const comment-start
))
1215 (concat " " (c-lang-const c-block-comment-ender
))
1217 (c-lang-setvar comment-end
(c-lang-const comment-end
))
1219 (c-lang-defconst comment-start-skip
1220 "Regexp to match the start of a comment plus everything up to its body.
1221 `comment-start-skip' is initialized from this."
1222 ;; Default: Allow the last char of the comment starter(s) to be
1223 ;; repeated, then allow any amount of horizontal whitespace.
1226 (mapcar (lambda (cs)
1228 (concat (regexp-quote cs
) "+")))
1229 (list (c-lang-const c-line-comment-starter
)
1230 (c-lang-const c-block-comment-starter
)))
1233 (c-lang-setvar comment-start-skip
(c-lang-const comment-start-skip
))
1235 (c-lang-defconst c-syntactic-ws-start
1236 ;; Regexp matching any sequence that can start syntactic whitespace.
1237 ;; The only uncertain case is '#' when there are cpp directives.
1239 (c-make-keywords-re nil
1240 (append (list (c-lang-const c-line-comment-starter
)
1241 (c-lang-const c-block-comment-starter
)
1242 (when (c-lang-const c-opt-cpp-prefix
)
1246 (when (memq 'gen-comment-delim c-emacs-features
)
1248 (c-lang-defvar c-syntactic-ws-start
(c-lang-const c-syntactic-ws-start
))
1250 (c-lang-defconst c-syntactic-ws-end
1251 ;; Regexp matching any single character that might end syntactic whitespace.
1253 (c-make-keywords-re nil
1254 (append (when (c-lang-const c-block-comment-ender
)
1257 (elt (c-lang-const c-block-comment-ender
)
1259 (c-lang-const c-block-comment-ender
)))))))
1261 (when (memq 'gen-comment-delim c-emacs-features
)
1263 (c-lang-defvar c-syntactic-ws-end
(c-lang-const c-syntactic-ws-end
))
1265 (c-lang-defconst c-unterminated-block-comment-regexp
1266 ;; Regexp matching an unterminated block comment that doesn't
1267 ;; contain line breaks, or nil in languages without block comments.
1268 ;; Does not contain a \| operator at the top level.
1269 t
(when (c-lang-const c-block-comment-starter
)
1271 (regexp-quote (c-lang-const c-block-comment-starter
))
1272 ;; It's messy to cook together a regexp that matches anything
1273 ;; but c-block-comment-ender.
1274 (let ((end (c-lang-const c-block-comment-ender
)))
1275 (cond ((= (length end
) 1)
1276 (concat "[^" end
"\n\r]*"))
1278 (concat "[^" (substring end
0 1) "\n\r]*"
1280 (regexp-quote (substring end
0 1)) "+"
1282 ;; The quoting rules inside char classes are silly. :P
1283 (cond ((= (elt end
0) (elt end
1))
1284 (concat (substring end
0 1) "\n\r"))
1285 ((= (elt end
1) ?\
])
1286 (concat (substring end
1 2) "\n\r"
1287 (substring end
0 1)))
1289 (concat (substring end
0 1) "\n\r"
1290 (substring end
1 2))))
1292 "[^" (substring end
0 1) "\n\r]*"
1295 (error "Can't handle a block comment ender of length %s"
1298 (c-lang-defconst c-block-comment-regexp
1299 ;; Regexp matching a block comment that doesn't contain line breaks,
1300 ;; or nil in languages without block comments. The reason we don't
1301 ;; allow line breaks is to avoid going very far and risk running out
1302 ;; of regexp stack; this regexp is intended to handle only short
1303 ;; comments that might be put in the middle of limited constructs
1304 ;; like declarations. Does not contain a \| operator at the top
1306 t
(when (c-lang-const c-unterminated-block-comment-regexp
)
1308 (c-lang-const c-unterminated-block-comment-regexp
)
1309 (let ((end (c-lang-const c-block-comment-ender
)))
1310 (cond ((= (length end
) 1)
1313 (concat (regexp-quote (substring end
0 1)) "+"
1314 (regexp-quote (substring end
1 2))))
1316 (error "Can't handle a block comment ender of length %s"
1319 (c-lang-defconst c-nonwhite-syntactic-ws
1320 ;; Regexp matching a piece of syntactic whitespace that isn't a
1321 ;; sequence of simple whitespace characters. As opposed to
1322 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1323 ;; directives as syntactic whitespace.
1324 t
(c-concat-separated
1325 (list (when (c-lang-const c-line-comment-starter
)
1326 (concat (regexp-quote (c-lang-const c-line-comment-starter
))
1328 (c-lang-const c-block-comment-regexp
)
1330 (when (memq 'gen-comment-delim c-emacs-features
)
1334 (c-lang-defconst c-syntactic-ws
1335 ;; Regexp matching syntactic whitespace, including possibly the
1336 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1337 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1338 ;; not contain a \| operator at the top level.
1339 t
(concat (c-lang-const c-simple-ws
) "*"
1341 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws
) "\\)"
1342 (c-lang-const c-simple-ws
) "*")
1345 (c-lang-defconst c-syntactic-ws-depth
1346 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1347 t
(regexp-opt-depth (c-lang-const c-syntactic-ws
)))
1349 (c-lang-defconst c-nonempty-syntactic-ws
1350 ;; Regexp matching syntactic whitespace, which is at least one
1351 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1352 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1353 ;; not contain a \| operator at the top level.
1355 (c-lang-const c-simple-ws
)
1357 (c-lang-const c-nonwhite-syntactic-ws
)
1360 (c-lang-defconst c-nonempty-syntactic-ws-depth
1361 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1362 t
(regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws
)))
1364 (c-lang-defconst c-single-line-syntactic-ws
1365 ;; Regexp matching syntactic whitespace without any line breaks. As
1366 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1367 ;; regard cpp directives as syntactic whitespace. Does not contain
1368 ;; a \| operator at the top level.
1369 t
(if (c-lang-const c-block-comment-regexp
)
1371 (c-lang-const c-block-comment-regexp
)
1375 (c-lang-defconst c-single-line-syntactic-ws-depth
1376 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1377 t
(regexp-opt-depth (c-lang-const c-single-line-syntactic-ws
)))
1379 (c-lang-defconst c-syntactic-eol
1380 ;; Regexp that matches when there is no syntactically significant
1381 ;; text before eol. Macros are regarded as syntactically
1382 ;; significant text here.
1383 t
(concat (c-lang-const c-single-line-syntactic-ws
)
1384 ;; Match eol (possibly inside a block comment or preceded
1385 ;; by a line continuation backslash), or the beginning of a
1386 ;; line comment. Note: This has to be modified for awk
1387 ;; where line comments start with '#'.
1390 (list (when (c-lang-const c-line-comment-starter
)
1391 (regexp-quote (c-lang-const c-line-comment-starter
)))
1392 (when (c-lang-const c-unterminated-block-comment-regexp
)
1393 (concat (c-lang-const c-unterminated-block-comment-regexp
)
1399 (c-lang-defvar c-syntactic-eol
(c-lang-const c-syntactic-eol
))
1402 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
1403 (c-lang-defconst c-at-vsemi-p-fn
1404 "Contains a function \"Is there a virtual semicolon at POS or point?\".
1405 Such a function takes one optional parameter, a buffer position (defaults to
1406 point), and returns nil or t. This variable contains nil for languages which
1407 don't have EOL terminated statements. "
1409 awk
'c-awk-at-vsemi-p
)
1410 (c-lang-defvar c-at-vsemi-p-fn
(c-lang-const c-at-vsemi-p-fn
))
1412 (c-lang-defconst c-vsemi-status-unknown-p-fn
1413 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
1414 The (admittedly kludgey) purpose of such a function is to prevent an infinite
1415 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
1416 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
1417 even indirectly. This variable contains nil for languages which don't have
1418 EOL terminated statements."
1420 awk
'c-awk-vsemi-status-unknown-p
)
1421 (c-lang-defvar c-vsemi-status-unknown-p-fn
1422 (c-lang-const c-vsemi-status-unknown-p-fn
))
1427 ;; The Emacs variables beginning-of-defun-function and
1428 ;; end-of-defun-function will be set so that commands like
1429 ;; `mark-defun' and `narrow-to-defun' work right. The key sequences
1430 ;; C-M-a and C-M-e are, however, bound directly to the CC Mode
1431 ;; functions, allowing optimisation for large n.
1432 (c-lang-defconst beginning-of-defun-function
1433 "Function to which beginning-of-defun-function will be set."
1434 t
'c-beginning-of-defun
1435 awk
'c-awk-beginning-of-defun
)
1436 (c-lang-setvar beginning-of-defun-function
1437 (c-lang-const beginning-of-defun-function
))
1439 (c-lang-defconst end-of-defun-function
1440 "Function to which end-of-defun-function will be set."
1442 awk
'c-awk-end-of-defun
)
1443 (c-lang-setvar end-of-defun-function
(c-lang-const end-of-defun-function
))
1445 ;;; In-comment text handling.
1447 (c-lang-defconst c-paragraph-start
1448 "Regexp to append to `paragraph-start'."
1450 java
"\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1451 pike
"\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1452 (c-lang-defvar c-paragraph-start
(c-lang-const c-paragraph-start
))
1454 (c-lang-defconst c-paragraph-separate
1455 "Regexp to append to `paragraph-separate'."
1457 pike
(c-lang-const c-paragraph-start
))
1458 (c-lang-defvar c-paragraph-separate
(c-lang-const c-paragraph-separate
))
1463 ;; Note: All and only all language constants containing keyword lists
1464 ;; should end with "-kwds"; they're automatically collected into the
1465 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1467 (c-lang-defconst c-primitive-type-kwds
1468 "Primitive type keywords. As opposed to the other keyword lists, the
1469 keywords listed here are fontified with the type face instead of the
1472 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1473 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1474 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1477 Do not try to modify this list for end user customizations; the
1478 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1479 the appropriate place for that."
1480 t
'("char" "double" "float" "int" "long" "short" "signed"
1483 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1484 (c-lang-const c-primitive-type-kwds
))
1487 (c-lang-const c-primitive-type-kwds
))
1488 ;; Objective-C extends C, but probably not the new stuff in C99.
1490 '("id" "Class" "SEL" "IMP" "BOOL")
1491 (c-lang-const c-primitive-type-kwds
))
1492 java
'("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1493 idl
'("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1494 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1497 ;; The following can't really end a type, but we have to specify them
1498 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1499 ;; doesn't matter that much.
1500 "unsigned" "strong")
1501 pike
'(;; this_program isn't really a keyword, but it's practically
1502 ;; used as a builtin type.
1503 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1504 "object" "program" "string" "this_program" "void"))
1506 (c-lang-defconst c-primitive-type-key
1507 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1508 t
(c-make-keywords-re t
(c-lang-const c-primitive-type-kwds
)))
1509 (c-lang-defvar c-primitive-type-key
(c-lang-const c-primitive-type-key
))
1511 (c-lang-defconst c-primitive-type-prefix-kwds
1512 "Keywords that might act as prefixes for primitive types. Assumed to
1513 be a subset of `c-primitive-type-kwds'."
1515 (c c
++) '("long" "short" "signed" "unsigned")
1516 idl
'("long" "unsigned"
1520 (c-lang-defconst c-type-prefix-kwds
1521 "Keywords where the following name - if any - is a type name, and
1522 where the keyword together with the symbol works as a type in
1525 Note that an alternative if the second part doesn't hold is
1526 `c-type-list-kwds'. Keywords on this list are typically also present
1527 on one of the `*-decl-kwds' lists."
1529 c
'("struct" "union" "enum")
1530 c
++ (append '("class" "typename")
1531 (c-lang-const c-type-prefix-kwds c
)))
1533 (c-lang-defconst c-type-prefix-key
1534 ;; Adorned regexp matching `c-type-prefix-kwds'.
1535 t
(c-make-keywords-re t
(c-lang-const c-type-prefix-kwds
)))
1536 (c-lang-defvar c-type-prefix-key
(c-lang-const c-type-prefix-key
))
1538 (c-lang-defconst c-type-modifier-kwds
1539 "Type modifier keywords. These can occur almost anywhere in types
1540 but they don't build a type of themselves. Unlike the keywords on
1541 `c-primitive-type-kwds', they are fontified with the keyword face and
1544 c
'("const" "restrict" "volatile")
1545 c
++ '("const" "volatile" "throw")
1546 objc
'("const" "volatile"))
1548 (c-lang-defconst c-opt-type-modifier-key
1549 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1550 ;; languages without such keywords.
1551 t
(and (c-lang-const c-type-modifier-kwds
)
1552 (c-make-keywords-re t
(c-lang-const c-type-modifier-kwds
))))
1553 (c-lang-defvar c-opt-type-modifier-key
(c-lang-const c-opt-type-modifier-key
))
1555 (c-lang-defconst c-opt-type-component-key
1556 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1557 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1558 t
(and (or (c-lang-const c-primitive-type-prefix-kwds
)
1559 (c-lang-const c-type-modifier-kwds
))
1560 (c-make-keywords-re t
1561 (append (c-lang-const c-primitive-type-prefix-kwds
)
1562 (c-lang-const c-type-modifier-kwds
)))))
1563 (c-lang-defvar c-opt-type-component-key
1564 (c-lang-const c-opt-type-component-key
))
1566 (c-lang-defconst c-type-start-kwds
1567 ;; All keywords that can start a type (i.e. are either a type prefix
1568 ;; or a complete type).
1569 t
(delete-duplicates (append (c-lang-const c-primitive-type-kwds
)
1570 (c-lang-const c-type-prefix-kwds
)
1571 (c-lang-const c-type-modifier-kwds
))
1572 :test
'string-equal
))
1574 (c-lang-defconst c-class-decl-kwds
1575 "Keywords introducing declarations where the following block (if any)
1576 contains another declaration level that should be considered a class.
1578 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1579 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1580 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1583 Note that presence on this list does not automatically treat the
1584 following identifier as a type; the keyword must also be present on
1585 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1587 c
'("struct" "union")
1588 c
++ '("class" "struct" "union")
1589 objc
'("struct" "union"
1590 "@interface" "@implementation" "@protocol")
1591 java
'("class" "interface")
1592 idl
'("component" "eventtype" "exception" "home" "interface" "struct"
1595 "storagehome" "storagetype"
1597 "catalog" "executor" "manages" "segment")
1600 (c-lang-defconst c-class-key
1601 ;; Regexp matching the start of a class.
1602 t
(c-make-keywords-re t
(c-lang-const c-class-decl-kwds
)))
1603 (c-lang-defvar c-class-key
(c-lang-const c-class-key
))
1605 (c-lang-defconst c-brace-list-decl-kwds
1606 "Keywords introducing declarations where the following block (if
1607 any) is a brace list.
1609 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1610 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1611 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1616 (c-lang-defconst c-brace-list-key
1617 ;; Regexp matching the start of declarations where the following
1618 ;; block is a brace list.
1619 t
(c-make-keywords-re t
(c-lang-const c-brace-list-decl-kwds
)))
1620 (c-lang-defvar c-brace-list-key
(c-lang-const c-brace-list-key
))
1622 (c-lang-defconst c-other-block-decl-kwds
1623 "Keywords where the following block (if any) contains another
1624 declaration level that should not be considered a class. For every
1625 keyword here, CC Mode will add a set of special syntactic symbols for
1626 those blocks. E.g. if the keyword is \"foo\" then there will be
1627 `foo-open', `foo-close', and `infoo' symbols.
1629 The intention is that this category should be used for block
1630 constructs that aren't related to object orientation concepts like
1631 classes (which thus also include e.g. interfaces, templates,
1632 contracts, structs, etc). The more pragmatic distinction is that
1633 while most want some indentation inside classes, it's fairly common
1634 that they don't want it in some of these constructs, so it should be
1635 simple to configure that differently from classes. See also
1636 `c-class-decl-kwds'.
1638 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1639 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1640 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1643 (c objc
) '("extern")
1644 c
++ '("namespace" "extern")
1649 (c-lang-defconst c-other-decl-block-key
1650 ;; Regexp matching the start of blocks besides classes that contain
1651 ;; another declaration level.
1652 t
(c-make-keywords-re t
(c-lang-const c-other-block-decl-kwds
)))
1653 (c-lang-defvar c-other-decl-block-key
(c-lang-const c-other-decl-block-key
))
1655 (c-lang-defvar c-other-decl-block-key-in-symbols-alist
1659 (if (string= elt
"extern")
1661 (intern (concat "in" elt
)))))
1662 (c-lang-const c-other-block-decl-kwds
))
1663 "Alist associating keywords in c-other-decl-block-decl-kwds with
1664 their matching \"in\" syntactic symbols.")
1666 (c-lang-defconst c-typedef-decl-kwds
1667 "Keywords introducing declarations where the identifier(s) being
1670 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1671 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1672 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1674 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1675 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1677 t
(append (c-lang-const c-class-decl-kwds
)
1678 (c-lang-const c-brace-list-decl-kwds
))
1679 ;; Languages that have a "typedef" construct.
1680 (c c
++ objc idl pike
) (append (c-lang-const c-typedef-decl-kwds
)
1682 ;; Unlike most other languages, exception names are not handled as
1683 ;; types in IDL since they only can occur in "raises" specs.
1684 idl
(delete "exception" (append (c-lang-const c-typedef-decl-kwds
) nil
)))
1686 (c-lang-defconst c-typeless-decl-kwds
1687 "Keywords introducing declarations where the \(first) identifier
1688 \(declarator) follows directly after the keyword, without any type.
1690 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1691 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1692 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1694 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1695 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1697 t
(append (c-lang-const c-class-decl-kwds
)
1698 (c-lang-const c-brace-list-decl-kwds
))
1699 ;; Note: "manages" for CORBA CIDL clashes with its presence on
1700 ;; `c-type-list-kwds' for IDL.
1701 idl
(append (c-lang-const c-typeless-decl-kwds
)
1702 '("factory" "finder" "native"
1707 pike
(append (c-lang-const c-class-decl-kwds
)
1710 (c-lang-defconst c-modifier-kwds
1711 "Keywords that can prefix normal declarations of identifiers
1712 \(and typically act as flags). Things like argument declarations
1713 inside function headers are also considered declarations in this
1716 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1717 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1718 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1721 (c c
++) '("auto" "extern" "inline" "register" "static")
1722 c
++ (append '("explicit" "friend" "mutable" "template" "using" "virtual")
1723 (c-lang-const c-modifier-kwds
))
1724 objc
'("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
1725 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
1726 idl
'("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
1727 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
1728 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
1732 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
1733 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
1734 java
'("abstract" "const" "final" "native" "private" "protected" "public"
1735 "static" "strictfp" "synchronized" "transient" "volatile")
1736 pike
'("final" "inline" "local" "nomask" "optional" "private" "protected"
1737 "public" "static" "variant"))
1739 (c-lang-defconst c-other-decl-kwds
1740 "Keywords that can start or prefix any declaration level construct,
1741 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1742 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1743 `c-typeless-decl-kwds' and `c-modifier-kwds'.
1745 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1746 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1747 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1750 objc
'("@class" "@end" "@defs")
1751 java
'("import" "package")
1752 pike
'("import" "inherit"))
1754 (c-lang-defconst c-decl-start-kwds
1755 "Keywords that always start declarations, wherever they occur.
1756 This can be used for declarations that aren't recognized by the normal
1757 combination of `c-decl-prefix-re' and `c-decl-start-re'."
1759 ;; Classes can be declared anywhere in a Pike expression.
1762 (c-lang-defconst c-decl-hangon-kwds
1763 "Keywords that can occur anywhere in a declaration level construct.
1764 This is used for self-contained things that can be tacked on anywhere
1765 on a declaration and that should be ignored to be able to recognize it
1766 correctly. Typical cases are compiler extensions like
1767 \"__attribute__\" or \"__declspec\":
1769 __declspec(noreturn) void foo();
1770 class __declspec(dllexport) classname {...};
1771 void foo() __attribute__((noreturn));
1773 Note that unrecognized plain symbols are skipped anyway if they occur
1774 before the type, so such things are not necessary to mention here.
1775 Mentioning them here is necessary only if they can occur in other
1776 places, or if they are followed by a construct that must be skipped
1777 over \(like the parens in the \"__attribute__\" and \"__declspec\"
1778 examples above). In the last case, they alse need to be present on
1779 one of `c-type-list-kwds', `c-ref-list-kwds',
1780 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1781 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1782 ;; NB: These are currently not recognized in all parts of a
1783 ;; declaration. Specifically, they aren't recognized in the middle
1784 ;; of multi-token types, inside declarators, and between the
1785 ;; identifier and the arglist paren of a function declaration.
1787 ;; FIXME: This ought to be user customizable since compiler stuff
1788 ;; like this usually is wrapped in project specific macros. (It'd
1789 ;; of course be even better if we could cope without knowing this.)
1791 (c c
++) '(;; GCC extension.
1796 (c-lang-defconst c-decl-hangon-key
1797 ;; Adorned regexp matching `c-decl-hangon-kwds'.
1798 t
(c-make-keywords-re t
(c-lang-const c-decl-hangon-kwds
)))
1799 (c-lang-defvar c-decl-hangon-key
(c-lang-const c-decl-hangon-key
))
1801 (c-lang-defconst c-prefix-spec-kwds
1802 ;; All keywords that can occur in the preamble of a declaration.
1803 ;; They typically occur before the type, but they are also matched
1804 ;; after presumptive types since we often can't be sure that
1805 ;; something is a type or just some sort of macro in front of the
1806 ;; declaration. They might be ambiguous with types or type
1808 t
(delete-duplicates (append (c-lang-const c-class-decl-kwds
)
1809 (c-lang-const c-brace-list-decl-kwds
)
1810 (c-lang-const c-other-block-decl-kwds
)
1811 (c-lang-const c-typedef-decl-kwds
)
1812 (c-lang-const c-typeless-decl-kwds
)
1813 (c-lang-const c-modifier-kwds
)
1814 (c-lang-const c-other-decl-kwds
)
1815 (c-lang-const c-decl-start-kwds
)
1816 (c-lang-const c-decl-hangon-kwds
))
1817 :test
'string-equal
))
1819 (c-lang-defconst c-prefix-spec-kwds-re
1820 ;; Adorned regexp of `c-prefix-spec-kwds'.
1821 t
(c-make-keywords-re t
(c-lang-const c-prefix-spec-kwds
)))
1822 (c-lang-defvar c-prefix-spec-kwds-re
(c-lang-const c-prefix-spec-kwds-re
))
1824 (c-lang-defconst c-specifier-key
1825 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
1826 ;; ambiguous with types or type prefixes. These are the keywords (like
1827 ;; extern, namespace, but NOT template) that can modify a declaration.
1828 t
(c-make-keywords-re t
1829 (set-difference (c-lang-const c-prefix-spec-kwds
)
1830 (append (c-lang-const c-type-start-kwds
)
1831 (c-lang-const c-
<>-arglist-kwds
))
1832 :test
'string-equal
)))
1833 (c-lang-defvar c-specifier-key
(c-lang-const c-specifier-key
))
1835 (c-lang-defconst c-postfix-spec-kwds
1836 ;; Keywords that can occur after argument list of a function header
1837 ;; declaration, i.e. in the "K&R region".
1838 t
(append (c-lang-const c-postfix-decl-spec-kwds
)
1839 (c-lang-const c-decl-hangon-kwds
)))
1841 (c-lang-defconst c-not-decl-init-keywords
1842 ;; Adorned regexp matching all keywords that can't appear at the
1843 ;; start of a declaration.
1844 t
(c-make-keywords-re t
1845 (set-difference (c-lang-const c-keywords
)
1846 (append (c-lang-const c-type-start-kwds
)
1847 (c-lang-const c-prefix-spec-kwds
))
1848 :test
'string-equal
)))
1849 (c-lang-defvar c-not-decl-init-keywords
1850 (c-lang-const c-not-decl-init-keywords
))
1852 (c-lang-defconst c-protection-kwds
1853 "Access protection label keywords in classes."
1855 c
++ '("private" "protected" "public")
1856 objc
'("@private" "@protected" "@public"))
1858 (c-lang-defconst c-block-decls-with-vars
1859 "Keywords introducing declarations that can contain a block which
1860 might be followed by variable declarations, e.g. like \"foo\" in
1861 \"class Foo { ... } foo;\". So if there is a block in a declaration
1862 like that, it ends with the following ';' and not right away.
1864 The keywords on list are assumed to also be present on one of the
1865 `*-decl-kwds' lists."
1867 (c objc
) '("struct" "union" "enum" "typedef")
1868 c
++ '("class" "struct" "union" "enum" "typedef"))
1870 (c-lang-defconst c-opt-block-decls-with-vars-key
1871 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
1872 ;; languages without such constructs.
1873 t
(and (c-lang-const c-block-decls-with-vars
)
1874 (c-make-keywords-re t
(c-lang-const c-block-decls-with-vars
))))
1875 (c-lang-defvar c-opt-block-decls-with-vars-key
1876 (c-lang-const c-opt-block-decls-with-vars-key
))
1878 (c-lang-defconst c-postfix-decl-spec-kwds
1879 "Keywords introducing extra declaration specifiers in the region
1880 between the header and the body \(i.e. the \"K&R-region\") in
1883 java
'("extends" "implements" "throws")
1884 idl
'("context" "getraises" "manages" "primarykey" "raises" "setraises"
1887 "as" "const" "implements" "of" "ref"))
1889 (c-lang-defconst c-nonsymbol-sexp-kwds
1890 "Keywords that may be followed by a nonsymbol sexp before whatever
1891 construct it's part of continues."
1893 (c c
++ objc
) '("extern"))
1895 (c-lang-defconst c-type-list-kwds
1896 "Keywords that may be followed by a comma separated list of type
1897 identifiers, where each optionally can be prefixed by keywords. (Can
1898 also be used for the special case when the list can contain only one
1901 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
1902 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
1903 There's also no reason to add keywords that prefixes a normal
1904 declaration consisting of a type followed by a declarator (list), so
1905 the keywords on `c-modifier-kwds' should normally not be listed here
1908 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1909 or variable identifier (that's being defined)."
1913 java
'("import" "new" "extends" "implements" "throws")
1914 idl
'("manages" "native" "primarykey" "supports"
1916 "as" "implements" "of" "scope")
1919 (c-lang-defconst c-ref-list-kwds
1920 "Keywords that may be followed by a comma separated list of
1921 reference (i.e. namespace/scope/module) identifiers, where each
1922 optionally can be prefixed by keywords. (Can also be used for the
1923 special case when the list can contain only one element.) Assumed to
1924 be mutually exclusive with `c-type-list-kwds'.
1926 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1927 or variable identifier (that's being defined)."
1931 idl
'("import" "module"
1936 (c-lang-defconst c-colon-type-list-kwds
1937 "Keywords that may be followed (not necessarily directly) by a colon
1938 and then a comma separated list of type identifiers, where each
1939 optionally can be prefixed by keywords. (Can also be used for the
1940 special case when the list can contain only one element.)"
1942 c
++ '("class" "struct")
1943 idl
'("component" "eventtype" "home" "interface" "valuetype"
1945 "storagehome" "storagetype"))
1947 (c-lang-defconst c-colon-type-list-re
1948 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
1949 forward to the colon. The end of the match is assumed to be directly
1950 after the colon, so the regexp should end with \":\". Must be a
1951 regexp if `c-colon-type-list-kwds' isn't nil."
1952 t
(if (c-lang-const c-colon-type-list-kwds
)
1953 ;; Disallow various common punctuation chars that can't come
1954 ;; before the ":" that starts the inherit list after "class"
1955 ;; or "struct" in C++. (Also used as default for other
1957 "[^\]\[{}();,/#=:]*:"))
1958 (c-lang-defvar c-colon-type-list-re
(c-lang-const c-colon-type-list-re
))
1960 (c-lang-defconst c-paren-nontype-kwds
1961 "Keywords that may be followed by a parenthesis expression that doesn't
1962 contain type identifiers."
1964 (c c
++) '(;; GCC extension.
1969 (c-lang-defconst c-paren-type-kwds
1970 "Keywords that may be followed by a parenthesis expression containing
1971 type identifiers separated by arbitrary tokens."
1976 pike
'("array" "function" "int" "mapping" "multiset" "object" "program"))
1978 (c-lang-defconst c-paren-any-kwds
1979 t
(delete-duplicates (append (c-lang-const c-paren-nontype-kwds
)
1980 (c-lang-const c-paren-type-kwds
))
1981 :test
'string-equal
))
1983 (c-lang-defconst c-
<>-type-kwds
1984 "Keywords that may be followed by an angle bracket expression
1985 containing type identifiers separated by \",\". The difference from
1986 `c-<>-arglist-kwds' is that unknown names are taken to be types and
1987 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
1995 (c-lang-defconst c-
<>-arglist-kwds
1996 "Keywords that can be followed by a C++ style template arglist; see
1997 `c-recognize-<>-arglists' for details. That language constant is
1998 assumed to be set if this isn't nil."
2001 idl
'("fixed" "string" "wstring"))
2003 (c-lang-defconst c-
<>-sexp-kwds
2004 ;; All keywords that can be followed by an angle bracket sexp.
2005 t
(delete-duplicates (append (c-lang-const c-
<>-type-kwds
)
2006 (c-lang-const c-
<>-arglist-kwds
))
2007 :test
'string-equal
))
2009 (c-lang-defconst c-opt-
<>-sexp-key
2010 ;; Adorned regexp matching keywords that can be followed by an angle
2011 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
2012 t
(if (c-lang-const c-recognize-
<>-arglists
)
2013 (c-make-keywords-re t
(c-lang-const c-
<>-sexp-kwds
))))
2014 (c-lang-defvar c-opt-
<>-sexp-key
(c-lang-const c-opt-
<>-sexp-key
))
2016 (c-lang-defconst c-brace-id-list-kwds
2017 "Keywords that may be followed by a brace block containing a comma
2018 separated list of identifier definitions, i.e. like the list of
2019 identifiers that follows the type in a normal declaration."
2020 t
(c-lang-const c-brace-list-decl-kwds
))
2022 (c-lang-defconst c-block-stmt-1-kwds
2023 "Statement keywords followed directly by a substatement."
2025 c
++ '("do" "else" "try")
2026 objc
'("do" "else" "@finally" "@try")
2027 java
'("do" "else" "finally" "try")
2030 (c-lang-defconst c-block-stmt-1-key
2031 ;; Regexp matching the start of any statement followed directly by a
2032 ;; substatement (doesn't match a bare block, however).
2033 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-kwds
)))
2034 (c-lang-defvar c-block-stmt-1-key
(c-lang-const c-block-stmt-1-key
))
2036 (c-lang-defconst c-block-stmt-2-kwds
2037 "Statement keywords followed by a paren sexp and then by a substatement."
2038 t
'("for" "if" "switch" "while")
2039 c
++ '("for" "if" "switch" "while" "catch")
2040 objc
'("for" "if" "switch" "while" "@catch" "@synchronized")
2041 java
'("for" "if" "switch" "while" "catch" "synchronized")
2043 pike
'("for" "if" "switch" "while" "foreach")
2044 awk
'("for" "if" "while"))
2046 (c-lang-defconst c-block-stmt-2-key
2047 ;; Regexp matching the start of any statement followed by a paren sexp
2048 ;; and then by a substatement.
2049 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-2-kwds
)))
2050 (c-lang-defvar c-block-stmt-2-key
(c-lang-const c-block-stmt-2-key
))
2052 (c-lang-defconst c-block-stmt-kwds
2053 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
2054 t
(delete-duplicates (append (c-lang-const c-block-stmt-1-kwds
)
2055 (c-lang-const c-block-stmt-2-kwds
))
2056 :test
'string-equal
))
2058 (c-lang-defconst c-opt-block-stmt-key
2059 ;; Regexp matching the start of any statement that has a
2060 ;; substatement (except a bare block). Nil in languages that
2061 ;; don't have such constructs.
2062 t
(if (or (c-lang-const c-block-stmt-1-kwds
)
2063 (c-lang-const c-block-stmt-2-kwds
))
2064 (c-make-keywords-re t
2065 (append (c-lang-const c-block-stmt-1-kwds
)
2066 (c-lang-const c-block-stmt-2-kwds
)))))
2067 (c-lang-defvar c-opt-block-stmt-key
(c-lang-const c-opt-block-stmt-key
))
2069 (c-lang-defconst c-simple-stmt-kwds
2070 "Statement keywords followed by an expression or nothing."
2071 t
'("break" "continue" "goto" "return")
2072 objc
'("break" "continue" "goto" "return" "@throw")
2073 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
2074 java
'("break" "continue" "goto" "return" "throw")
2076 pike
'("break" "continue" "return")
2077 awk
'(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
2078 "break" "continue" "return" "delete" "exit" "getline" "next"
2079 "nextfile" "print" "printf"))
2081 (c-lang-defconst c-simple-stmt-key
2082 ;; Adorned regexp matching `c-simple-stmt-kwds'.
2083 t
(c-make-keywords-re t
(c-lang-const c-simple-stmt-kwds
)))
2084 (c-lang-defvar c-simple-stmt-key
(c-lang-const c-simple-stmt-key
))
2086 (c-lang-defconst c-paren-stmt-kwds
2087 "Statement keywords followed by a parenthesis expression that
2088 nevertheless contains a list separated with ';' and not ','."
2092 (c-lang-defconst c-paren-stmt-key
2093 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2094 t
(c-make-keywords-re t
(c-lang-const c-paren-stmt-kwds
)))
2095 (c-lang-defvar c-paren-stmt-key
(c-lang-const c-paren-stmt-key
))
2097 (c-lang-defconst c-asm-stmt-kwds
2098 "Statement keywords followed by an assembler expression."
2100 (c c
++) '("asm" "__asm__")) ;; Not standard, but common.
2102 (c-lang-defconst c-opt-asm-stmt-key
2103 ;; Regexp matching the start of an assembler statement. Nil in
2104 ;; languages that don't support that.
2105 t
(if (c-lang-const c-asm-stmt-kwds
)
2106 (c-make-keywords-re t
(c-lang-const c-asm-stmt-kwds
))))
2107 (c-lang-defvar c-opt-asm-stmt-key
(c-lang-const c-opt-asm-stmt-key
))
2109 (c-lang-defconst c-label-kwds
2110 "Keywords introducing colon terminated labels in blocks."
2111 t
'("case" "default")
2114 (c-lang-defconst c-label-kwds-regexp
2115 ;; Adorned regexp matching any keyword that introduces a label.
2116 t
(c-make-keywords-re t
(c-lang-const c-label-kwds
)))
2117 (c-lang-defvar c-label-kwds-regexp
(c-lang-const c-label-kwds-regexp
))
2119 (c-lang-defconst c-before-label-kwds
2120 "Keywords that might be followed by a label identifier."
2122 (java pike
) (append '("break" "continue")
2123 (c-lang-const c-before-label-kwds
))
2127 (c-lang-defconst c-constant-kwds
2128 "Keywords for constants."
2130 (c c
++) '("NULL" ;; Not a keyword, but practically works as one.
2131 "false" "true") ; Defined in C99.
2133 idl
'("TRUE" "FALSE")
2134 java
'("true" "false" "null") ; technically "literals", not keywords
2135 pike
'("UNDEFINED")) ;; Not a keyword, but practically works as one.
2137 (c-lang-defconst c-primary-expr-kwds
2138 "Keywords besides constants and operators that start primary expressions."
2140 c
++ '("operator" "this")
2141 objc
'("super" "self")
2143 pike
'("this")) ;; Not really a keyword, but practically works as one.
2145 (c-lang-defconst c-expr-kwds
2146 ;; Keywords that can occur anywhere in expressions. Built from
2147 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2148 t
(delete-duplicates
2149 (append (c-lang-const c-primary-expr-kwds
)
2150 (c-filter-ops (c-lang-const c-operator-list
)
2152 "\\`\\(\\w\\|\\s_\\)+\\'"))
2153 :test
'string-equal
))
2155 (c-lang-defconst c-lambda-kwds
2156 "Keywords that start lambda constructs, i.e. function definitions in
2161 (c-lang-defconst c-inexpr-block-kwds
2162 "Keywords that start constructs followed by statement blocks which can
2163 be used in expressions \(the gcc extension for this in C and C++ is
2164 handled separately by `c-recognize-paren-inexpr-blocks')."
2166 pike
'("catch" "gauge"))
2168 (c-lang-defconst c-inexpr-class-kwds
2169 "Keywords that can start classes inside expressions."
2174 (c-lang-defconst c-inexpr-brace-list-kwds
2175 "Keywords that can start brace list blocks inside expressions.
2176 Note that Java specific rules are currently applied to tell this from
2177 `c-inexpr-class-kwds'."
2181 (c-lang-defconst c-opt-inexpr-brace-list-key
2182 ;; Regexp matching the start of a brace list in an expression, or
2183 ;; nil in languages that don't have such things. This should not
2184 ;; match brace lists recognized through `c-special-brace-lists'.
2185 t
(and (c-lang-const c-inexpr-brace-list-kwds
)
2186 (c-make-keywords-re t
(c-lang-const c-inexpr-brace-list-kwds
))))
2187 (c-lang-defvar c-opt-inexpr-brace-list-key
2188 (c-lang-const c-opt-inexpr-brace-list-key
))
2190 (c-lang-defconst c-decl-block-key
2191 ;; Regexp matching keywords in any construct that contain another
2192 ;; declaration level, i.e. that isn't followed by a function block
2193 ;; or brace list. When the first submatch matches, it's an
2194 ;; unambiguous construct, otherwise it's an ambiguous match that
2195 ;; might also be the return type of a function declaration.
2196 t
(let* ((decl-kwds (append (c-lang-const c-class-decl-kwds
)
2197 (c-lang-const c-other-block-decl-kwds
)
2198 (c-lang-const c-inexpr-class-kwds
)))
2199 (unambiguous (set-difference decl-kwds
2200 (c-lang-const c-type-start-kwds
)
2201 :test
'string-equal
))
2202 (ambiguous (intersection decl-kwds
2203 (c-lang-const c-type-start-kwds
)
2204 :test
'string-equal
)))
2206 (concat (c-make-keywords-re t unambiguous
)
2208 (c-make-keywords-re t ambiguous
))
2209 (c-make-keywords-re t unambiguous
))))
2210 (c-lang-defvar c-decl-block-key
(c-lang-const c-decl-block-key
))
2212 (c-lang-defconst c-bitfield-kwds
2213 "Keywords that can introduce bitfields."
2215 (c c
++ objc
) '("char" "int" "long" "signed" "unsigned"))
2217 (c-lang-defconst c-opt-bitfield-key
2218 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2219 ;; languages without bitfield support.
2221 (c c
++) (c-make-keywords-re t
(c-lang-const c-bitfield-kwds
)))
2222 (c-lang-defvar c-opt-bitfield-key
(c-lang-const c-opt-bitfield-key
))
2224 (c-lang-defconst c-other-kwds
2225 "Keywords not accounted for by any other `*-kwds' language constant."
2228 ;; In CORBA CIDL: (These are declaration keywords that never
2229 ;; can start a declaration.)
2230 "entity" "process" "service" "session" "storage"))
2233 ;;; Constants built from keywords.
2235 ;; Note: No `*-kwds' language constants may be defined below this point.
2238 (defconst c-kwds-lang-consts
2239 ;; List of all the language constants that contain keyword lists.
2241 (mapatoms (lambda (sym)
2242 (when (and (boundp sym
)
2243 (string-match "-kwds\\'" (symbol-name sym
)))
2244 ;; Make the list of globally interned symbols
2245 ;; instead of ones interned in `c-lang-constants'.
2246 (setq list
(cons (intern (symbol-name sym
)) list
))))
2250 (c-lang-defconst c-keywords
2251 ;; All keywords as a list.
2252 t
(delete-duplicates
2253 (c-lang-defconst-eval-immediately
2254 `(append ,@(mapcar (lambda (kwds-lang-const)
2255 `(c-lang-const ,kwds-lang-const
))
2258 :test
'string-equal
))
2260 (c-lang-defconst c-keywords-regexp
2261 ;; All keywords as an adorned regexp.
2262 t
(c-make-keywords-re t
(c-lang-const c-keywords
)))
2263 (c-lang-defvar c-keywords-regexp
(c-lang-const c-keywords-regexp
))
2265 (c-lang-defconst c-keyword-member-alist
2266 ;; An alist with all the keywords in the cars. The cdr for each
2267 ;; keyword is a list of the symbols for the `*-kwds' lists that
2269 t
(let ((kwd-list-alist
2270 (c-lang-defconst-eval-immediately
2271 `(list ,@(mapcar (lambda (kwds-lang-const)
2272 `(cons ',kwds-lang-const
2273 (c-lang-const ,kwds-lang-const
)))
2274 c-kwds-lang-consts
))))
2275 lang-const kwd-list kwd
2277 (while kwd-list-alist
2278 (setq lang-const
(caar kwd-list-alist
)
2279 kwd-list
(cdar kwd-list-alist
)
2280 kwd-list-alist
(cdr kwd-list-alist
))
2282 (setq kwd
(car kwd-list
)
2283 kwd-list
(cdr kwd-list
))
2284 (unless (setq elem
(assoc kwd result-alist
))
2285 (setq result-alist
(cons (setq elem
(list kwd
)) result-alist
)))
2286 (unless (memq lang-const
(cdr elem
))
2287 (setcdr elem
(cons lang-const
(cdr elem
))))))
2290 (c-lang-defvar c-keywords-obarray
2291 ;; An obarray containing all keywords as symbols. The property list
2292 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2293 ;; lists it's a member of.
2295 ;; E.g. to see whether the string str contains a keyword on
2296 ;; `c-class-decl-kwds', one can do like this:
2297 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2298 ;; Which preferably is written using the associated functions in
2300 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2302 ;; The obarray is not stored directly as a language constant since
2303 ;; the printed representation for obarrays used in .elc files isn't
2306 (let* ((alist (c-lang-const c-keyword-member-alist
))
2308 (obarray (make-vector (* (length alist
) 2) 0)))
2310 (setq kwd
(caar alist
)
2311 lang-const-list
(cdar alist
)
2313 (setplist (intern kwd obarray
)
2314 ;; Emacs has an odd bug that causes `mapcan' to fail
2315 ;; with unintelligible errors. (XEmacs works.)
2316 ;;(mapcan (lambda (lang-const)
2317 ;; (list lang-const t))
2319 (apply 'nconc
(mapcar (lambda (lang-const)
2320 (list lang-const t
))
2324 (c-lang-defconst c-regular-keywords-regexp
2325 ;; Adorned regexp matching all keywords that should be fontified
2326 ;; with the keywords face. I.e. that aren't types or constants.
2327 t
(c-make-keywords-re t
2328 (set-difference (c-lang-const c-keywords
)
2329 (append (c-lang-const c-primitive-type-kwds
)
2330 (c-lang-const c-constant-kwds
))
2331 :test
'string-equal
)))
2332 (c-lang-defvar c-regular-keywords-regexp
2333 (c-lang-const c-regular-keywords-regexp
))
2335 (c-lang-defconst c-primary-expr-regexp
2336 ;; Regexp matching the start of any primary expression, i.e. any
2337 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2338 ;; exclude keywords; they are excluded afterwards unless the second
2339 ;; submatch matches. If the first but not the second submatch
2340 ;; matches then it is an ambiguous primary expression; it could also
2341 ;; be a match of e.g. an infix operator. (The case with ambiguous
2342 ;; keyword operators isn't handled.)
2344 t
(let* ((prefix-ops
2345 (c-filter-ops (c-lang-const c-operators
)
2348 ;; Filter out the special case prefix
2349 ;; operators that are close parens.
2350 (not (string-match "\\s)" op
)))))
2352 (nonkeyword-prefix-ops
2353 (c-filter-ops prefix-ops
2355 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2358 (c-filter-ops (c-lang-const c-operators
)
2363 right-assoc-sequence
)
2366 (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2368 :test
'string-equal
))
2369 (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2371 :test
'string-equal
)))
2375 ;; Take out all symbol class operators from `prefix-ops' and make the
2376 ;; first submatch from them together with `c-primary-expr-kwds'.
2377 (c-make-keywords-re t
2378 (append (c-lang-const c-primary-expr-kwds
)
2379 (set-difference prefix-ops nonkeyword-prefix-ops
2380 :test
'string-equal
)))
2383 ;; Match all ambiguous operators.
2384 (c-make-keywords-re nil
2385 (intersection nonkeyword-prefix-ops in-or-postfix-ops
2386 :test
'string-equal
))
2390 ;; Now match all other symbols.
2391 (c-lang-const c-symbol-start
)
2394 ;; The chars that can start integer and floating point
2399 ;; The nonambiguous operators from `prefix-ops'.
2400 (c-make-keywords-re nil
2401 (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2402 :test
'string-equal
))
2405 ;; Match string and character literals.
2407 (if (memq 'gen-string-delim c-emacs-features
)
2410 (c-lang-defvar c-primary-expr-regexp
(c-lang-const c-primary-expr-regexp
))
2413 ;;; Additional constants for parser-level constructs.
2415 (c-lang-defconst c-decl-prefix-re
2416 "Regexp matching something that might precede a declaration, cast or
2417 label, such as the last token of a preceding statement or declaration.
2418 This is used in the common situation where a declaration or cast
2419 doesn't start with any specific token that can be searched for.
2421 The regexp should not match bob; that is done implicitly. It can't
2422 require a match longer than one token. The end of the token is taken
2423 to be at the end of the first submatch, which is assumed to always
2424 match. It's undefined whether identifier syntax (see
2425 `c-identifier-syntax-table') is in effect or not. This regexp is
2426 assumed to be a superset of `c-label-prefix-re' if
2427 `c-recognize-colon-labels' is set.
2429 Besides this, `c-decl-start-kwds' is used to find declarations.
2431 Note: This variable together with `c-decl-start-re' and
2432 `c-decl-start-kwds' is only used to detect \"likely\"
2433 declaration/cast/label starts. I.e. they might produce more matches
2434 but should not miss anything (or else it's necessary to use text
2435 properties - see the next note). Wherever they match, the following
2436 construct is analyzed to see if it indeed is a declaration, cast or
2437 label. That analysis is not cheap, so it's important that not too
2438 many false matches are triggered.
2440 Note: If a declaration/cast/label start can't be detected with this
2441 variable, it's necessary to use the `c-type' text property with the
2442 value `c-decl-end' on the last char of the last token preceding the
2443 declaration. See the comment blurb at the start of cc-engine.el for
2446 ;; We match a sequence of characters to skip over things like \"};\"
2447 ;; more quickly. We match ")" in C for K&R region declarations, and
2448 ;; in all languages except Java for when a cpp macro definition
2449 ;; begins with a declaration.
2450 t
"\\([\{\}\(\);,]+\\)"
2451 java
"\\([\{\}\(;,]+\\)"
2452 ;; Match "<" in C++ to get the first argument in a template arglist.
2453 ;; In that case there's an additional check in `c-find-decl-spots'
2454 ;; that it got open paren syntax.
2455 c
++ "\\([\{\}\(\);,<]+\\)"
2456 ;; Additionally match the protection directives in Objective-C.
2457 ;; Note that this doesn't cope with the longer directives, which we
2458 ;; would have to match from start to end since they don't end with
2459 ;; any easily recognized characters.
2460 objc
(concat "\\([\{\}\(\);,]+\\|"
2461 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2463 ;; Pike is like C but we also match "[" for multiple value
2464 ;; assignments and type casts.
2465 pike
"\\([\{\}\(\)\[;,]+\\)")
2466 (c-lang-defvar c-decl-prefix-re
(c-lang-const c-decl-prefix-re
)
2469 (c-lang-defconst c-decl-start-re
2470 "Regexp matching the start of any declaration, cast or label.
2471 It's used on the token after the one `c-decl-prefix-re' matched. This
2472 regexp should not try to match those constructs accurately as it's
2473 only used as a sieve to avoid spending more time checking other
2475 t
(c-lang-const c-identifier-start
))
2476 (c-lang-defvar c-decl-start-re
(c-lang-const c-decl-start-re
))
2478 (c-lang-defconst c-decl-prefix-or-start-re
2479 ;; Regexp matching something that might precede or start a
2480 ;; declaration, cast or label.
2482 ;; If the first submatch matches, it's taken to match the end of a
2483 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2484 ;; It's built from `c-decl-prefix-re'.
2486 ;; If the first submatch did not match, the match of the whole
2487 ;; regexp is taken to be at the first token in the declaration.
2488 ;; `c-decl-start-re' is not checked in this case.
2490 ;; Design note: The reason the same regexp is used to match both
2491 ;; tokens that precede declarations and start them is to avoid an
2492 ;; extra regexp search from the previous declaration spot in
2493 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2494 ;; that it finds all declaration/cast/label starts in approximately
2495 ;; linear order, so we can't do the searches in two separate passes.
2496 t
(if (c-lang-const c-decl-start-kwds
)
2497 (concat (c-lang-const c-decl-prefix-re
)
2499 (c-make-keywords-re t
(c-lang-const c-decl-start-kwds
)))
2500 (c-lang-const c-decl-prefix-re
)))
2501 (c-lang-defvar c-decl-prefix-or-start-re
2502 (c-lang-const c-decl-prefix-or-start-re
)
2505 (c-lang-defconst c-cast-parens
2506 ;; List containing the paren characters that can open a cast, or nil in
2507 ;; languages without casts.
2508 t
(c-filter-ops (c-lang-const c-operators
)
2511 (lambda (op) (elt op
0))))
2512 (c-lang-defvar c-cast-parens
(c-lang-const c-cast-parens
))
2514 (c-lang-defconst c-block-prefix-disallowed-chars
2515 "List of syntactically relevant characters that never can occur before
2516 the open brace in any construct that contains a brace block, e.g. in
2517 the \"class Foo: public Bar\" part of:
2519 class Foo: public Bar {int x();} a, *b;
2521 If parens can occur, the chars inside those aren't filtered with this
2524 '<' and '>' should be disallowed even if angle bracket arglists can
2525 occur. That since the search function needs to stop at them anyway to
2526 ensure they are given paren syntax.
2528 This is used to skip backward from the open brace to find the region
2529 in which to look for a construct like \"class\", \"enum\",
2530 \"namespace\" or whatever. That skipping should be as tight as
2531 possible for good performance."
2533 ;; Default to all chars that only occurs in nonsymbol tokens outside
2536 (c-lang-const c-nonsymbol-token-char-list
)
2537 (c-filter-ops (append (c-lang-const c-identifier-ops
)
2539 (c-lang-const c-after-id-concat-ops
))))
2544 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2546 (setq res
(cons (aref op
(match-beginning 1)) res
)
2550 ;; Allow cpp operatios (where applicable).
2551 t
(if (c-lang-const c-opt-cpp-prefix
)
2552 (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2554 (c-lang-const c-block-prefix-disallowed-chars
))
2556 ;; Allow ':' for inherit list starters.
2557 (c++ objc idl
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2560 ;; Allow ',' for multiple inherits.
2561 (c++ java
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2564 ;; Allow parentheses for anonymous inner classes in Java and class
2565 ;; initializer lists in Pike.
2566 (java pike
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2569 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2570 (c c
++ objc
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2573 (c-lang-defconst c-block-prefix-charset
2574 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2575 ;; for `c-syntactic-skip-backward'.
2576 t
(c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars
) t
))
2577 (c-lang-defvar c-block-prefix-charset
(c-lang-const c-block-prefix-charset
))
2579 (c-lang-defconst c-type-decl-prefix-key
2580 "Regexp matching the declarator operators that might precede the
2581 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
2582 regexp should match \"(\" if parentheses are valid in declarators.
2583 The end of the first submatch is taken as the end of the operator.
2584 Identifier syntax is in effect when this is matched \(see
2585 `c-identifier-syntax-table')."
2586 t
(if (c-lang-const c-type-modifier-kwds
)
2587 (concat (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>")
2588 ;; Default to a regexp that never matches.
2590 ;; Check that there's no "=" afterwards to avoid matching tokens
2592 (c objc
) (concat "\\("
2595 (c-lang-const c-type-decl-prefix-key
)
2602 ;; If this matches there's special treatment in
2603 ;; `c-font-lock-declarators' and
2604 ;; `c-font-lock-declarations' that check for a
2605 ;; complete name followed by ":: *".
2606 (c-lang-const c-identifier-start
)
2609 (c-lang-const c-type-decl-prefix-key
)
2612 pike
"\\(\\*\\)\\([^=]\\|$\\)")
2613 (c-lang-defvar c-type-decl-prefix-key
(c-lang-const c-type-decl-prefix-key
)
2616 (c-lang-defconst c-type-decl-suffix-key
2617 "Regexp matching the declarator operators that might follow after the
2618 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
2619 regexp should match \")\" if parentheses are valid in declarators. If
2620 it matches an open paren of some kind, the type declaration check
2621 continues at the corresponding close paren, otherwise the end of the
2622 first submatch is taken as the end of the operator. Identifier syntax
2623 is in effect when this is matched (see `c-identifier-syntax-table')."
2624 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
2625 ;; function argument list parenthesis.
2626 t
(if (c-lang-const c-type-modifier-kwds
)
2628 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>"
2631 (c c
++ objc
) (concat
2634 (if (c-lang-const c-type-modifier-kwds
)
2637 ;; "throw" in `c-type-modifier-kwds' is followed
2638 ;; by a parenthesis list, but no extra measures
2639 ;; are necessary to handle that.
2640 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
)
2644 (java idl
) "\\([\[\(]\\)")
2645 (c-lang-defvar c-type-decl-suffix-key
(c-lang-const c-type-decl-suffix-key
)
2648 (c-lang-defconst c-after-suffixed-type-decl-key
2649 "This regexp is matched after a declarator expression where
2650 `c-type-decl-suffix-key' has matched. If it matches then the
2651 construct is taken as a declaration. It's typically used to match the
2652 beginning of a function body or whatever might occur after the
2653 function header in a function declaration or definition. It's
2654 undefined whether identifier syntax (see `c-identifier-syntax-table')
2655 is in effect or not.
2657 Note that it's used in cases like after \"foo (bar)\" so it should
2658 only match when it's certain that it's a declaration, e.g \"{\" but
2659 not \",\" or \";\"."
2661 ;; If K&R style declarations should be recognized then one could
2662 ;; consider to match the start of any symbol since we want to match
2663 ;; the start of the first declaration in the "K&R region". That
2664 ;; could however produce false matches on code like "FOO(bar) x"
2665 ;; where FOO is a cpp macro, so it's better to leave it out and rely
2666 ;; on the other heuristics in that case.
2667 t
(if (c-lang-const c-postfix-spec-kwds
)
2668 ;; Add on the keywords in `c-postfix-spec-kwds'.
2669 (concat (c-lang-const c-after-suffixed-type-decl-key
)
2671 (c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2672 (c-lang-const c-after-suffixed-type-decl-key
))
2673 ;; Also match the colon that starts a base class initializer list in
2674 ;; C++. That can be confused with a function call before the colon
2675 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
2676 ;; match before such a thing (as a declaration-level construct;
2677 ;; matches inside arglist contexts are already excluded).
2679 (c-lang-defvar c-after-suffixed-type-decl-key
2680 (c-lang-const c-after-suffixed-type-decl-key
)
2683 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
2684 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
2685 ;; matches ";" and ",".
2686 t
(concat "\\(" (c-lang-const c-after-suffixed-type-decl-key
) "\\)"
2688 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
2689 (c-lang-const c-after-suffixed-type-maybe-decl-key
))
2691 (c-lang-defconst c-opt-type-concat-key
2692 "Regexp matching operators that concatenate types, e.g. the \"|\" in
2693 \"int|string\" in Pike. The end of the first submatch is taken as the
2694 end of the operator. nil in languages without such operators. It's
2695 undefined whether identifier syntax (see `c-identifier-syntax-table')
2696 is in effect or not."
2698 pike
"\\([|.&]\\)\\($\\|[^|.&]\\)")
2699 (c-lang-defvar c-opt-type-concat-key
(c-lang-const c-opt-type-concat-key
)
2702 (c-lang-defconst c-opt-type-suffix-key
2703 "Regexp matching operators that might follow after a type, or nil in
2704 languages that don't have such operators. The end of the first
2705 submatch is taken as the end of the operator. This should not match
2706 things like C++ template arglists if `c-recognize-<>-arglists' is set.
2707 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
2708 is in effect or not."
2710 (c c
++ objc pike
) "\\(\\.\\.\\.\\)"
2711 java
(concat "\\(\\[" (c-lang-const c-simple-ws
) "*\\]\\)"))
2712 (c-lang-defvar c-opt-type-suffix-key
(c-lang-const c-opt-type-suffix-key
))
2714 (c-lang-defvar c-known-type-key
2715 ;; Regexp matching the known type identifiers. This is initialized
2716 ;; from the type keywords and `*-font-lock-extra-types'. The first
2717 ;; submatch is the one that matches the type. Note that this regexp
2718 ;; assumes that symbol constituents like '_' and '$' have word
2721 (when (boundp (c-mode-symbol "font-lock-extra-types"))
2722 (c-mode-var "font-lock-extra-types")))
2725 (mapcar (lambda (re)
2726 (when (string-match "[][.*+?^$\\]" re
)
2731 (mapcar (lambda (re)
2732 (unless (string-match "[][.*+?^$\\]" re
)
2737 (append (list (c-make-keywords-re nil
2738 (append (c-lang-const c-primitive-type-kwds
)
2744 (c-lang-defconst c-special-brace-lists
2745 "List of open- and close-chars that makes up a pike-style brace list,
2746 i.e. for a ([Â ]) list there should be a cons (?\\[ . ?\\]) in this
2749 pike
'((?
{ . ?
}) (?\
[ . ?\
]) (?
< . ?
>)))
2750 (c-lang-defvar c-special-brace-lists
(c-lang-const c-special-brace-lists
))
2752 (c-lang-defconst c-recognize-knr-p
2753 "Non-nil means K&R style argument declarations are valid."
2756 (c-lang-defvar c-recognize-knr-p
(c-lang-const c-recognize-knr-p
))
2758 (c-lang-defconst c-recognize-typeless-decls
2759 "Non-nil means function declarations without return type should be
2760 recognized. That can introduce an ambiguity with parenthesized macro
2761 calls before a brace block. This setting does not affect declarations
2762 that are preceded by a declaration starting keyword, so
2763 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2766 (c-lang-defvar c-recognize-typeless-decls
2767 (c-lang-const c-recognize-typeless-decls
))
2769 (c-lang-defconst c-recognize-
<>-arglists
2770 "Non-nil means C++ style template arglists should be handled. More
2771 specifically, this means a comma separated list of types or
2772 expressions surrounded by \"<\" and \">\". It's always preceded by an
2773 identifier or one of the keywords on `c-<>-type-kwds' or
2774 `c-<>-arglist-kwds'. If there's an identifier before then the whole
2775 expression is considered to be a type."
2776 t
(or (consp (c-lang-const c-
<>-type-kwds
))
2777 (consp (c-lang-const c-
<>-arglist-kwds
))))
2778 (c-lang-defvar c-recognize-
<>-arglists
(c-lang-const c-recognize-
<>-arglists
))
2780 (c-lang-defconst c-recognize-paren-inits
2781 "Non-nil means that parenthesis style initializers exist,
2782 i.e. constructs like
2786 in addition to the more classic
2791 (c-lang-defvar c-recognize-paren-inits
(c-lang-const c-recognize-paren-inits
))
2793 (c-lang-defconst c-recognize-paren-inexpr-blocks
2794 "Non-nil to recognize gcc style in-expression blocks,
2795 i.e. compound statements surrounded by parentheses inside expressions."
2798 (c-lang-defvar c-recognize-paren-inexpr-blocks
2799 (c-lang-const c-recognize-paren-inexpr-blocks
))
2801 (c-lang-defconst c-opt-
<>-arglist-start
2802 ;; Regexp matching the start of angle bracket arglists in languages
2803 ;; where `c-recognize-<>-arglists' is set. Does not exclude
2804 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
2805 ;; assumed to surround the preceding symbol. The whole match is
2806 ;; assumed to end directly after the opening "<".
2807 t
(if (c-lang-const c-recognize-
<>-arglists
)
2809 (c-lang-const c-symbol-key
)
2811 (c-lang-const c-syntactic-ws
)
2813 (c-lang-defvar c-opt-
<>-arglist-start
(c-lang-const c-opt-
<>-arglist-start
))
2815 (c-lang-defconst c-opt-
<>-arglist-start-in-paren
2816 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
2817 ;; parens. The first submatch is assumed to surround
2818 ;; `c-opt-<>-arglist-start'.
2819 t
(if (c-lang-const c-opt-
<>-arglist-start
)
2821 (c-lang-const c-opt-
<>-arglist-start
)
2823 (c-lang-defvar c-opt-
<>-arglist-start-in-paren
2824 (c-lang-const c-opt-
<>-arglist-start-in-paren
))
2826 (c-lang-defconst c-opt-postfix-decl-spec-key
2827 ;; Regexp matching the beginning of a declaration specifier in the
2828 ;; region between the header and the body of a declaration.
2830 ;; TODO: This is currently not used uniformly; c++-mode and
2831 ;; java-mode each have their own ways of using it.
2834 (c-lang-const c-simple-ws
) "*"
2835 "\\(virtual" (c-lang-const c-simple-ws
) "+\\)?\\("
2836 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2837 "\\)" (c-lang-const c-simple-ws
) "+"
2838 "\\(" (c-lang-const c-symbol-key
) "\\)")
2839 java
(c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2840 (c-lang-defvar c-opt-postfix-decl-spec-key
2841 (c-lang-const c-opt-postfix-decl-spec-key
))
2843 (c-lang-defconst c-recognize-colon-labels
2844 "Non-nil if generic labels ending with \":\" should be recognized.
2845 That includes labels in code and access keys in classes. This does
2846 not apply to labels recognized by `c-label-kwds' and
2847 `c-opt-extra-label-key'."
2849 (c c
++ objc java pike
) t
)
2850 (c-lang-defvar c-recognize-colon-labels
2851 (c-lang-const c-recognize-colon-labels
))
2853 (c-lang-defconst c-label-prefix-re
2854 "Regexp like `c-decl-prefix-re' that matches any token that can precede
2855 a generic colon label. Not used if `c-recognize-colon-labels' is
2858 (c-lang-defvar c-label-prefix-re
2859 (c-lang-const c-label-prefix-re
))
2861 (c-lang-defconst c-nonlabel-token-key
2862 "Regexp matching things that can't occur in generic colon labels,
2863 neither in a statement nor in a declaration context. The regexp is
2864 tested at the beginning of every sexp in a suspected label,
2865 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
2867 ;; Don't allow string literals.
2869 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
2870 (c-make-keywords-re t
2871 (set-difference (c-lang-const c-keywords
)
2872 (append (c-lang-const c-label-kwds
)
2873 (c-lang-const c-protection-kwds
))
2874 :test
'string-equal
)))
2875 ;; Also check for open parens in C++, to catch member init lists in
2876 ;; constructors. We normally allow it so that macros with arguments
2878 c
++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key
)))
2879 (c-lang-defvar c-nonlabel-token-key
(c-lang-const c-nonlabel-token-key
))
2881 (c-lang-defconst c-opt-extra-label-key
2882 "Optional regexp matching labels.
2883 Normally, labels are detected according to `c-nonlabel-token-key',
2884 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
2885 be used if there are additional labels that aren't recognized that
2888 objc
(c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
2889 (c-lang-defvar c-opt-extra-label-key
(c-lang-const c-opt-extra-label-key
))
2891 (c-lang-defconst c-opt-friend-key
2892 ;; Regexp describing friend declarations classes, or nil in
2893 ;; languages that don't have such things.
2895 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
2896 ;; template skipping isn't done properly. This will disappear soon.
2898 c
++ (concat "friend" (c-lang-const c-simple-ws
) "+"
2901 (c-lang-const c-simple-ws
) "*"
2903 (c-lang-const c-simple-ws
) "*"
2905 (c-lang-const c-simple-ws
) "+")))
2906 (c-lang-defvar c-opt-friend-key
(c-lang-const c-opt-friend-key
))
2908 (c-lang-defconst c-opt-method-key
2909 ;; Special regexp to match the start of Objective-C methods. The
2910 ;; first submatch is assumed to end after the + or - key.
2913 ;; TODO: Ought to use a better method than anchoring on bol.
2916 (c-lang-const c-simple-ws
) "*"
2917 (concat "\\(" ; Return type.
2919 (c-lang-const c-simple-ws
) "*"
2921 "\\(" (c-lang-const c-symbol-key
) "\\)"))
2922 (c-lang-defvar c-opt-method-key
(c-lang-const c-opt-method-key
))
2924 (c-lang-defconst c-type-decl-end-used
2925 ;; Must be set in buffers where the `c-type' text property might be
2926 ;; used with the value `c-decl-end'.
2928 ;; `c-decl-end' is used to mark the ends of labels and access keys
2929 ;; to make interactive refontification work better.
2930 t
(or (c-lang-const c-recognize-colon-labels
)
2931 (and (c-lang-const c-label-kwds
) t
))
2932 ;; `c-decl-end' is used to mark the end of the @-style directives in
2935 (c-lang-defvar c-type-decl-end-used
(c-lang-const c-type-decl-end-used
))
2938 ;;; Wrap up the `c-lang-defvar' system.
2940 ;; Compile in the list of language variables that has been collected
2941 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
2942 ;; first element of each is nil.
2943 (defconst c-lang-variable-inits
(cc-eval-when-compile c-lang-variable-inits
))
2944 (defconst c-emacs-variable-inits
(cc-eval-when-compile c-emacs-variable-inits
))
2946 ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
2947 ;; These are typically standard emacs variables such as `comment-start'.
2948 (defmacro c-make-emacs-variables-local
()
2950 ,@(mapcar (lambda (init)
2951 `(make-local-variable ',(car init
)))
2952 (cdr c-emacs-variable-inits
))))
2954 (defun c-make-init-lang-vars-fun (mode)
2955 "Create a function that initializes all the language dependent variables
2958 This function should be evaluated at compile time, so that the
2959 function it returns is byte compiled with all the evaluated results
2960 from the language constants. Use the `c-init-language-vars' macro to
2961 accomplish that conveniently."
2963 (if (and (not load-in-progress
)
2964 (boundp 'byte-compile-dest-file
)
2965 (stringp byte-compile-dest-file
))
2967 ;; No need to byte compile this lambda since the byte compiler is
2968 ;; smart enough to detect the `funcall' construct in the
2969 ;; `c-init-language-vars' macro below and compile it all straight
2970 ;; into the function that contains `c-init-language-vars'.
2973 ;; This let sets up the context for `c-mode-var' and similar
2974 ;; that could be in the result from `cl-macroexpand-all'.
2975 (let ((c-buffer-is-cc-mode ',mode
)
2976 current-var source-eval
)
2977 (c-make-emacs-variables-local)
2980 (if (eq c-version-sym
',c-version-sym
)
2981 (setq ,@(let ((c-buffer-is-cc-mode mode
)
2982 (c-lang-const-expansion 'immediate
))
2983 ;; `c-lang-const' will expand to the evaluated
2984 ;; constant immediately in `cl-macroexpand-all'
2988 `(current-var ',(car init
)
2989 ,(car init
) ,(cl-macroexpand-all
2991 ;; Note: The following `append' copies the
2992 ;; first argument. That list is small, so
2993 ;; this doesn't matter too much.
2994 (append (cdr c-emacs-variable-inits
)
2995 (cdr c-lang-variable-inits
)))))
2997 ;; This diagnostic message isn't useful for end
2998 ;; users, so it's disabled.
2999 ;;(unless (get ',mode 'c-has-warned-lang-consts)
3000 ;; (message ,(concat "%s compiled with CC Mode %s "
3001 ;; "but loaded with %s - evaluating "
3002 ;; "language constants from source")
3003 ;; ',mode ,c-version c-version)
3004 ;; (put ',mode 'c-has-warned-lang-consts t))
3007 (setq source-eval t
)
3008 (let ((init (append (cdr c-emacs-variable-inits
)
3009 (cdr c-lang-variable-inits
))))
3011 (setq current-var
(caar init
))
3012 (set (caar init
) (eval (cadar init
)))
3013 (setq init
(cdr init
)))))
3017 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
3021 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
3022 ',mode
,c-version c-version
)
3025 (signal (car err
) (cdr err
)))))))
3027 ;; Being evaluated from source. Always use the dynamic method to
3028 ;; work well when `c-lang-defvar's in this file are reevaluated
3032 (let ((c-buffer-is-cc-mode ',mode
)
3033 (init (append (cdr c-emacs-variable-inits
)
3034 (cdr c-lang-variable-inits
)))
3036 (c-make-emacs-variables-local)
3040 (setq current-var
(caar init
))
3041 (set (caar init
) (eval (cadar init
)))
3042 (setq init
(cdr init
)))
3047 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
3049 (signal (car err
) (cdr err
)))))))
3052 (defmacro c-init-language-vars
(mode)
3053 "Initialize all the language dependent variables for the given mode.
3054 This macro is expanded at compile time to a form tailored for the mode
3055 in question, so MODE must be a constant. Therefore MODE is not
3056 evaluated and should not be quoted."
3057 `(funcall ,(c-make-init-lang-vars-fun mode
)))
3060 (cc-provide 'cc-langs
)
3062 ;; arch-tag: 1ab57482-cfc2-4c5b-b628-3539c3098822
3063 ;;; cc-langs.el ends here