1 ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
3 ;; Copyright (C) 1985, 1987, 1992-2014 Free Software Foundation, Inc.
5 ;; Authors: 2002- Alan Mackenzie
6 ;; 1998- Martin Stjernholm
7 ;; 1992-1999 Barry A. Warsaw
10 ;; 1985 Richard M. Stallman
11 ;; Maintainer: bug-cc-mode@gnu.org
12 ;; Created: 22-Apr-1997 (split from cc-mode.el)
13 ;; Keywords: c languages
16 ;; This file is part of GNU Emacs.
18 ;; GNU Emacs is free software: you can redistribute it and/or modify
19 ;; it under the terms of the GNU General Public License as published by
20 ;; the Free Software Foundation, either version 3 of the License, or
21 ;; (at your option) any later version.
23 ;; GNU Emacs is distributed in the hope that it will be useful,
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;; GNU General Public License for more details.
28 ;; You should have received a copy of the GNU General Public License
29 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
33 ;; HACKERS NOTE: There's heavy macro magic here. If you need to make
34 ;; changes in this or other files containing `c-lang-defconst' but
35 ;; don't want to read through the longer discussion below then read
38 ;; o A change in a `c-lang-defconst' or `c-lang-defvar' will not take
39 ;; effect if the file containing the mode init function (typically
40 ;; cc-mode.el) is byte compiled.
41 ;; o To make changes show in font locking you need to reevaluate the
42 ;; `*-font-lock-keywords-*' constants, which normally is easiest to
43 ;; do with M-x eval-buffer in cc-fonts.el.
44 ;; o In either case it's necessary to reinitialize the mode to make
45 ;; the changes show in an existing buffer.
47 ;;; Introduction to the language dependent variable system:
49 ;; This file contains all the language dependent variables, except
50 ;; those specific for font locking which reside in cc-fonts.el. As
51 ;; far as possible, all the differences between the languages that CC
52 ;; Mode supports are described with these variables only, so that the
53 ;; code can be shared.
55 ;; The language constant system (see cc-defs.el) is used to specify
56 ;; various language dependent info at a high level, such as lists of
57 ;; keywords, and then from them generate - at compile time - the
58 ;; various regexps and other low-level structures actually employed in
59 ;; the code at runtime.
61 ;; This system is also designed to make it easy for developers of
62 ;; derived modes to customize the source constants for new language
63 ;; variants, without having to keep up with the exact regexps etc that
64 ;; are used in each CC Mode version. It's possible from an external
65 ;; package to add a new language by inheriting an existing one, and
66 ;; then change specific constants as necessary for the new language.
67 ;; The old values for those constants (and the values of all the other
68 ;; high-level constants) may be used to build the new ones, and those
69 ;; new values will in turn be used by the low-level definitions here
70 ;; to build the runtime constants appropriately for the new language
71 ;; in the current version of CC Mode.
73 ;; Like elsewhere in CC Mode, the existence of a doc string signifies
74 ;; that a language constant is part of the external API, and that it
75 ;; therefore can be used with a high confidence that it will continue
76 ;; to work with future versions of CC Mode. Even so, it's not
77 ;; unlikely that such constants will change meaning slightly as this
78 ;; system is refined further; a certain degree of dependence on the CC
79 ;; Mode version is unavoidable when hooking in at this level. Also
80 ;; note that there's still work to be done to actually use these
81 ;; constants everywhere inside CC Mode; there are still hardcoded
82 ;; values in many places in the code.
84 ;; Separate packages will also benefit from the compile time
85 ;; evaluation; the byte compiled file(s) for them will contain the
86 ;; compiled runtime constants ready for use by (the byte compiled) CC
87 ;; Mode, and the source definitions in this file don't have to be
88 ;; loaded then. However, if a byte compiled package is loaded that
89 ;; has been compiled with a different version of CC Mode than the one
90 ;; currently loaded, then the compiled-in values will be discarded and
91 ;; new ones will be built when the mode is initialized. That will
92 ;; automatically trig a load of the file(s) containing the source
93 ;; definitions (i.e. this file and/or cc-fonts.el) if necessary.
95 ;; A small example of a derived mode is available at
96 ;; <http://cc-mode.sourceforge.net/derived-mode-ex.el>. It also
97 ;; contains some useful hints for derived mode developers.
99 ;;; Using language variables:
101 ;; The `c-lang-defvar' forms in this file comprise the language
102 ;; variables that CC Mode uses. It does not work to use
103 ;; `c-lang-defvar' anywhere else (which isn't much of a limitation
104 ;; since these variables sole purpose is to interface with the CC Mode
105 ;; core functions). The values in these `c-lang-defvar's are not
106 ;; evaluated right away but instead collected to a single large `setq'
107 ;; that can be inserted for a particular language with the
108 ;; `c-init-language-vars' macro.
110 ;; This file is only required at compile time, or when not running
111 ;; from byte compiled files, or when the source definitions for the
112 ;; language constants are requested.
118 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
122 (if (and (boundp 'byte-compile-dest-file
)
123 (stringp byte-compile-dest-file
))
124 (cons (file-name-directory byte-compile-dest-file
) load-path
)
126 (load "cc-bytecomp" nil t
)))
128 (cc-require 'cc-defs
)
129 (cc-require 'cc-vars
)
132 ;; This file is not always loaded. See note above.
133 ;; Except it is always loaded - see bug#17463.
134 ;;;(cc-external-require 'cl)
138 ;;; Setup for the `c-lang-defvar' system.
141 ;; These are used to collect the init forms from the subsequent
142 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
143 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
144 ;; and `make-variable-buffer-local's in cc-engine and
145 ;; `make-local-variable's in `c-init-language-vars-for'.
146 (defvar c-lang-variable-inits nil
)
147 (defvar c-lang-variable-inits-tail nil
)
148 (setq c-lang-variable-inits
(list nil
)
149 c-lang-variable-inits-tail c-lang-variable-inits
)
150 (defvar c-emacs-variable-inits nil
)
151 (defvar c-emacs-variable-inits-tail nil
)
152 (setq c-emacs-variable-inits
(list nil
)
153 c-emacs-variable-inits-tail c-emacs-variable-inits
))
155 (defmacro c-lang-defvar
(var val
&optional doc
)
156 "Declares the buffer local variable VAR to get the value VAL. VAL is
157 evaluated and assigned at mode initialization. More precisely, VAL is
158 evaluated and bound to VAR when the result from the macro
159 `c-init-language-vars' is evaluated.
161 `c-lang-const' is typically used in VAL to get the right value for the
162 language being initialized, and such calls will be macro expanded to
163 the evaluated constant value at compile time."
166 (eq (car-safe val
) 'c-lang-const
)
169 ;; Special case: If there's no docstring and the value is a
170 ;; simple (c-lang-const foo) where foo is the same name as VAR
171 ;; then take the docstring from the language constant foo.
172 (setq doc
(get (intern (symbol-name (nth 1 val
)) c-lang-constants
)
173 'variable-documentation
)))
177 (let ((elem (assq var
(cdr c-lang-variable-inits
))))
179 (setcdr elem
(list val doc
))
180 (setcdr c-lang-variable-inits-tail
(list (list var val doc
)))
181 (setq c-lang-variable-inits-tail
(cdr c-lang-variable-inits-tail
))))
183 ;; Return the symbol, like the other def* forms.
186 (defmacro c-lang-setvar
(var val
)
187 "Causes the variable VAR to be made buffer local and to get set to the
188 value VAL. VAL is evaluated and assigned at mode initialization. More
189 precisely, VAL is evaluated and bound to VAR when the result from the
190 macro `c-init-language-vars' is evaluated. VAR is typically a standard
191 Emacs variable like `comment-start'.
193 `c-lang-const' is typically used in VAL to get the right value for the
194 language being initialized, and such calls will be macro expanded to
195 the evaluated constant value at compile time."
196 (let ((elem (assq var
(cdr c-emacs-variable-inits
))))
198 (setcdr elem
(list val
)) ; Maybe remove "list", sometime. 2006-07-19
199 (setcdr c-emacs-variable-inits-tail
(list (list var val
)))
200 (setq c-emacs-variable-inits-tail
(cdr c-emacs-variable-inits-tail
))))
202 ;; Return the symbol, like the other def* forms.
205 (put 'c-lang-defvar
'lisp-indent-function
'defun
)
206 ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
208 (def-edebug-spec c-lang-defvar
209 (&define name def-form
&optional stringp
)) ;)
211 ;; Suppress "might not be defined at runtime" warning.
212 ;; This file is only used when compiling other cc files.
213 ;; These are defined in cl as aliases to the cl- versions.
214 ;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
215 ;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
218 ;; Some helper functions used when building the language constants.
220 (defun c-filter-ops (ops opgroup-filter op-filter
&optional xlate
)
221 ;; Extract a subset of the operators in the list OPS in a DWIM:ey
222 ;; way. The return value is a plain list of operators:
224 ;; OPS either has the structure of `c-operators', is a single
225 ;; group in `c-operators', or is a plain list of operators.
227 ;; OPGROUP-FILTER specifies how to select the operator groups. It
228 ;; can be t to choose all groups, a list of group type symbols
229 ;; (such as 'prefix) to accept, or a function which will be called
230 ;; with the group symbol for each group and should return non-nil
231 ;; if that group is to be included.
233 ;; If XLATE is given, it's a function which is called for each
234 ;; matching operator and its return value is collected instead.
235 ;; If it returns a list, the elements are spliced directly into
236 ;; the final result, which is returned as a list with duplicates
237 ;; removed using `equal'.
239 ;; `c-mode-syntax-table' for the current mode is in effect during
240 ;; the whole procedure.
241 (unless (listp (car-safe ops
))
242 (setq ops
(list ops
)))
243 (cond ((eq opgroup-filter t
)
244 (setq opgroup-filter
(lambda (opgroup) t
)))
245 ((not (functionp opgroup-filter
))
246 (setq opgroup-filter
`(lambda (opgroup)
247 (memq opgroup
',opgroup-filter
)))))
248 (cond ((eq op-filter t
)
249 (setq op-filter
(lambda (op) t
)))
251 (setq op-filter
`(lambda (op)
252 (string-match ,op-filter op
)))))
254 (setq xlate
'identity
))
255 (c-with-syntax-table (c-lang-const c-mode-syntax-table
)
256 (cl-delete-duplicates
257 (cl-mapcan (lambda (opgroup)
258 (when (if (symbolp (car opgroup
))
259 (when (funcall opgroup-filter
(car opgroup
))
260 (setq opgroup
(cdr opgroup
))
263 (cl-mapcan (lambda (op)
264 (when (funcall op-filter op
)
265 (let ((res (funcall xlate op
)))
266 (if (listp res
) res
(list res
)))))
272 ;;; Various mode specific values that aren't language related.
274 (c-lang-defconst c-mode-menu
275 ;; The definition for the mode menu. The menu title is prepended to
276 ;; this before it's fed to `easy-menu-define'.
277 t
`(["Comment Out Region" comment-region
278 (c-fn-region-is-active-p)]
279 ["Uncomment Region" (comment-region (region-beginning)
281 (c-fn-region-is-active-p)]
282 ["Indent Expression" c-indent-exp
283 (memq (char-after) '(?\
( ?\
[ ?\
{))]
284 ["Indent Line or Region" c-indent-line-or-region t
]
285 ["Fill Comment Paragraph" c-fill-paragraph t
]
287 ["Backward Statement" c-beginning-of-statement t
]
288 ["Forward Statement" c-end-of-statement t
]
289 ,@(when (c-lang-const c-opt-cpp-prefix
)
290 ;; Only applicable if there's a cpp preprocessor.
291 `(["Up Conditional" c-up-conditional t
]
292 ["Backward Conditional" c-backward-conditional t
]
293 ["Forward Conditional" c-forward-conditional t
]
295 ["Macro Expand Region" c-macro-expand
296 (c-fn-region-is-active-p)]
297 ["Backslashify" c-backslash-region
298 (c-fn-region-is-active-p)]))
301 ["Set Style..." c-set-style t
]
302 ["Show Current Style Name" (message
304 c-indentation-style
) t
]
305 ["Guess Style from this Buffer" c-guess-buffer-no-install t
]
306 ["Install the Last Guessed Style..." c-guess-install
307 (and c-guess-guessed-offsets-alist
308 c-guess-guessed-basic-offset
) ]
309 ["View the Last Guessed Style" c-guess-view
310 (and c-guess-guessed-offsets-alist
311 c-guess-guessed-basic-offset
) ])
314 ["Syntactic indentation" c-toggle-syntactic-indentation
315 :style toggle
:selected c-syntactic-indentation
]
316 ["Electric mode" c-toggle-electric-state
317 :style toggle
:selected c-electric-flag
]
318 ["Auto newline" c-toggle-auto-newline
319 :style toggle
:selected c-auto-newline
]
320 ["Hungry delete" c-toggle-hungry-state
321 :style toggle
:selected c-hungry-delete-key
]
322 ["Subword mode" subword-mode
323 :style toggle
:selected
(and (boundp 'subword-mode
)
329 (defun c-populate-syntax-table (table)
330 "Populate the given syntax table as necessary for a C-like language.
331 This includes setting ' and \" as string delimiters, and setting up
332 the comment syntax to handle both line style \"//\" and block style
333 \"/*\" \"*/\" comments."
335 (modify-syntax-entry ?_
"_" table
)
336 (modify-syntax-entry ?
\\ "\\" table
)
337 (modify-syntax-entry ?
+ "." table
)
338 (modify-syntax-entry ?-
"." table
)
339 (modify-syntax-entry ?
= "." table
)
340 (modify-syntax-entry ?%
"." table
)
341 (modify-syntax-entry ?
< "." table
)
342 (modify-syntax-entry ?
> "." table
)
343 (modify-syntax-entry ?
& "." table
)
344 (modify-syntax-entry ?|
"." table
)
345 (modify-syntax-entry ?
\' "\"" table
)
346 (modify-syntax-entry ?
\240 "." table
)
348 ;; Set up block and line oriented comments. The new C
349 ;; standard mandates both comment styles even in C, so since
350 ;; all languages now require dual comments, we make this the
354 ((memq '8-bit c-emacs-features
)
355 (modify-syntax-entry ?
/ ". 1456" table
)
356 (modify-syntax-entry ?
* ". 23" table
))
358 ((memq '1-bit c-emacs-features
)
359 (modify-syntax-entry ?
/ ". 124b" table
)
360 (modify-syntax-entry ?
* ". 23" table
))
362 (t (error "CC Mode is incompatible with this version of Emacs")))
364 (modify-syntax-entry ?
\n "> b" table
)
365 ;; Give CR the same syntax as newline, for selective-display
366 (modify-syntax-entry ?\^m
"> b" table
))
368 (c-lang-defconst c-make-mode-syntax-table
369 "Functions that generates the mode specific syntax tables.
370 The syntax tables aren't stored directly since they're quite large."
372 (let ((table (make-syntax-table)))
373 (c-populate-syntax-table table
)
374 ;; Mode specific syntaxes.
375 ,(cond ((or (c-major-mode-is 'objc-mode
) (c-major-mode-is 'java-mode
))
376 ;; Let '@' be part of symbols in ObjC to cope with
377 ;; its compiler directives as single keyword tokens.
378 ;; This is then necessary since it's assumed that
379 ;; every keyword is a single symbol.
380 `(modify-syntax-entry ?
@ "_" table
))
381 ((c-major-mode-is 'pike-mode
)
382 `(modify-syntax-entry ?
@ "." table
)))
385 (c-lang-defconst c-mode-syntax-table
386 ;; The syntax tables in evaluated form. Only used temporarily when
387 ;; the constants in this file are evaluated.
388 t
(funcall (c-lang-const c-make-mode-syntax-table
)))
390 (c-lang-defconst c
++-make-template-syntax-table
391 ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
392 ;; parenthesis characters. Used temporarily when template argument
393 ;; lists are parsed. Note that this encourages incorrect parsing of
394 ;; templates since they might contain normal operators that uses the
395 ;; '<' and '>' characters. Therefore this syntax table might go
396 ;; away when CC Mode handles templates correctly everywhere. WHILE
397 ;; THIS SYNTAX TABLE IS CURRENT, `c-parse-state' MUST _NOT_ BE
400 (java c
++) `(lambda ()
401 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
402 (modify-syntax-entry ?
< "(>" table
)
403 (modify-syntax-entry ?
> ")<" table
)
405 (c-lang-defvar c
++-template-syntax-table
406 (and (c-lang-const c
++-make-template-syntax-table
)
407 (funcall (c-lang-const c
++-make-template-syntax-table
))))
409 (c-lang-defconst c-no-parens-syntax-table
410 ;; A variant of the standard syntax table which is used to find matching
411 ;; "<"s and ">"s which have been marked as parens using syntax table
412 ;; properties. The other paren characters (e.g. "{", ")" "]") are given a
413 ;; non-paren syntax here. so that the list commands will work on "< ... >"
414 ;; even when there's unbalanced other parens inside them.
416 ;; This variable is nil for languages which don't have template stuff.
418 (if (c-lang-const c-recognize-
<>-arglists
)
419 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
420 (modify-syntax-entry ?\
( "." table
)
421 (modify-syntax-entry ?\
) "." table
)
422 (modify-syntax-entry ?\
[ "." table
)
423 (modify-syntax-entry ?\
] "." table
)
424 (modify-syntax-entry ?\
{ "." table
)
425 (modify-syntax-entry ?\
} "." table
)
427 (c-lang-defvar c-no-parens-syntax-table
428 (funcall (c-lang-const c-no-parens-syntax-table
)))
430 (c-lang-defconst c-identifier-syntax-modifications
431 "A list that describes the modifications that should be done to the
432 mode syntax table to get a syntax table that matches all identifiers
433 and keywords as words.
435 The list is just like the one used in `font-lock-defaults': Each
436 element is a cons where the car is the character to modify and the cdr
437 the new syntax, as accepted by `modify-syntax-entry'."
438 ;; The $ character is not allowed in most languages (one exception
439 ;; is Java which allows it for legacy reasons) but we still classify
440 ;; it as an identifier character since it's often used in various
441 ;; machine generated identifiers.
442 t
'((?_ .
"w") (?$ .
"w"))
443 (objc java
) (append '((?
@ .
"w"))
444 (c-lang-const c-identifier-syntax-modifications
))
446 (c-lang-defvar c-identifier-syntax-modifications
447 (c-lang-const c-identifier-syntax-modifications
))
449 (c-lang-defvar c-identifier-syntax-table
450 (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
451 (mods c-identifier-syntax-modifications
)
456 (modify-syntax-entry (car mod
) (cdr mod
) table
))
458 "Syntax table built on the mode syntax table but additionally
459 classifies symbol constituents like '_' and '$' as word constituents,
460 so that all identifiers are recognized as words.")
462 (c-lang-defconst c-get-state-before-change-functions
463 ;; For documentation see the following c-lang-defvar of the same name.
464 ;; The value here may be a list of functions or a single function.
466 c
++ '(c-extend-region-for-CPP
467 c-before-change-check-
<>-operators
468 c-invalidate-macro-cache
)
469 (c objc
) '(c-extend-region-for-CPP c-invalidate-macro-cache
)
470 ;; java 'c-before-change-check-<>-operators
471 awk
'c-awk-record-region-clear-NL
)
472 (c-lang-defvar c-get-state-before-change-functions
473 (let ((fs (c-lang-const c-get-state-before-change-functions
)))
477 "If non-nil, a list of functions called from c-before-change-hook.
478 Typically these will record enough state to allow
479 `c-before-font-lock-function' to extend the region to fontify,
480 and may do such things as removing text-properties which must be
483 These functions will be run in the order given. Each of them
484 takes 2 parameters, the BEG and END supplied to every
485 before-change function; on entry, the buffer will have been
486 widened and match-data will have been saved; point is undefined
487 on both entry and exit; the return value is ignored.
489 The functions are called even when font locking isn't enabled.
491 When the mode is initialized, the functions are called with
492 parameters \(point-min) and \(point-max).")
494 (c-lang-defconst c-before-font-lock-functions
495 ;; For documentation see the following c-lang-defvar of the same name.
496 ;; The value here may be a list of functions or a single function.
497 t
'c-change-set-fl-decl-start
498 (c c
++ objc
) '(c-neutralize-syntax-in-and-mark-CPP
499 c-change-set-fl-decl-start
)
500 awk
'c-awk-extend-and-syntax-tablify-region
)
501 (c-lang-defvar c-before-font-lock-functions
502 (let ((fs (c-lang-const c-before-font-lock-functions
)))
506 "If non-nil, a list of functions called just before font locking.
507 Typically they will extend the region about to be fontified \(see
508 below) and will set `syntax-table' text properties on the region.
510 These functions will be run in the order given. Each of them
511 takes 3 parameters, the BEG, END, and OLD-LEN supplied to every
512 after-change function; point is undefined on both entry and exit;
513 on entry, the buffer will have been widened and match-data will
514 have been saved; the return value is ignored.
516 The functions may extend the region to be fontified by setting the
517 buffer local variables c-new-BEG and c-new-END.
519 The functions are called even when font locking is disabled.
521 When the mode is initialized, these functions are called with
522 parameters \(point-min), \(point-max) and <buffer size>.")
524 (c-lang-defconst c-before-context-fontification-functions
526 t
'c-context-set-fl-decl-start
)
527 ;; For documentation see the following c-lang-defvar of the same name.
528 ;; The value here may be a list of functions or a single function.
529 (c-lang-defvar c-before-context-fontification-functions
530 (let ((fs (c-lang-const c-before-context-fontification-functions
)))
534 "If non-nil, a list of functions called just before context (or
535 other non-change) fontification is done. Typically they will
538 These functions will be run in the order given. Each of them
539 takes 2 parameters, the BEG and END of the region to be
540 fontified. Point is undefined on both entry and exit. On entry,
541 the buffer will have been widened and match-data will have been
542 saved; the return value is a cons of the adjusted
543 region, (NEW-BEG . NEW-END).")
546 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
547 (c-lang-defconst c-at-vsemi-p-fn
548 "Contains a function \"Is there a virtual semicolon at POS or point?\".
549 Such a function takes one optional parameter, a buffer position (defaults to
550 point), and returns nil or t. This variable contains nil for languages which
551 don't have EOL terminated statements. "
553 (c c
++ objc
) 'c-at-macro-vsemi-p
554 awk
'c-awk-at-vsemi-p
)
555 (c-lang-defvar c-at-vsemi-p-fn
(c-lang-const c-at-vsemi-p-fn
))
557 (c-lang-defconst c-vsemi-status-unknown-p-fn
558 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
559 The (admittedly kludgy) purpose of such a function is to prevent an infinite
560 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
561 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
562 even indirectly. This variable contains nil for languages which don't have
563 EOL terminated statements."
565 (c c
++ objc
) 'c-macro-vsemi-status-unknown-p
566 awk
'c-awk-vsemi-status-unknown-p
)
567 (c-lang-defvar c-vsemi-status-unknown-p-fn
568 (c-lang-const c-vsemi-status-unknown-p-fn
))
571 ;;; Lexer-level syntax (identifiers, tokens etc).
573 (c-lang-defconst c-has-bitfields
574 "Whether the language has bitfield declarations."
577 (c-lang-defvar c-has-bitfields
(c-lang-const c-has-bitfields
))
579 (c-lang-defconst c-symbol-start
580 "Regexp that matches the start of a symbol, i.e. any identifier or
581 keyword. It's unspecified how far it matches. Does not contain a \\|
582 operator at the top level."
583 t
(concat "[" c-alpha
"_]")
584 java
(concat "[" c-alpha
"_@]")
585 objc
(concat "[" c-alpha
"_@]")
586 pike
(concat "[" c-alpha
"_`]"))
587 (c-lang-defvar c-symbol-start
(c-lang-const c-symbol-start
))
589 (c-lang-defconst c-symbol-chars
590 "Set of characters that can be part of a symbol.
591 This is of the form that fits inside [ ] in a regexp."
592 ;; Pike note: With the backquote identifiers this would include most
593 ;; operator chars too, but they are handled with other means instead.
594 t
(concat c-alnum
"_$")
595 objc
(concat c-alnum
"_$@"))
596 (c-lang-defvar c-symbol-chars
(c-lang-const c-symbol-chars
))
598 (c-lang-defconst c-symbol-key
599 "Regexp matching identifiers and keywords (with submatch 0). Assumed
600 to match if `c-symbol-start' matches on the same position."
601 t
(concat (c-lang-const c-symbol-start
)
602 "[" (c-lang-const c-symbol-chars
) "]*")
604 ;; Use the value from C here since the operator backquote is
605 ;; covered by the other alternative.
606 (c-lang-const c-symbol-key c
)
608 (c-make-keywords-re nil
609 (c-lang-const c-overloadable-operators
))))
610 (c-lang-defvar c-symbol-key
(c-lang-const c-symbol-key
))
612 (c-lang-defconst c-symbol-key-depth
613 ;; Number of regexp grouping parens in `c-symbol-key'.
614 t
(regexp-opt-depth (c-lang-const c-symbol-key
)))
616 (c-lang-defconst c-nonsymbol-chars
617 "This is the set of chars that can't be part of a symbol, i.e. the
618 negation of `c-symbol-chars'."
619 t
(concat "^" (c-lang-const c-symbol-chars
)))
620 (c-lang-defvar c-nonsymbol-chars
(c-lang-const c-nonsymbol-chars
))
622 (c-lang-defconst c-nonsymbol-key
623 "Regexp that matches any character that can't be part of a symbol.
624 It's usually appended to other regexps to avoid matching a prefix.
625 It's assumed to not contain any submatchers."
626 ;; The same thing regarding Unicode identifiers applies here as to
628 t
(concat "[" (c-lang-const c-nonsymbol-chars
) "]"))
630 (c-lang-defconst c-identifier-ops
631 "The operators that make up fully qualified identifiers. nil in
632 languages that don't have such things. See `c-operators' for a
633 description of the format. Binary operators can concatenate symbols,
634 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
635 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
637 This value is by default merged into `c-operators'."
639 c
++ '((prefix "~" "??-" "compl")
642 ;; Java has "." to concatenate identifiers but it's also used for
643 ;; normal indexing. There's special code in the Java font lock
644 ;; rules to fontify qualified identifiers based on the standard
645 ;; naming conventions. We still define "." here to make
646 ;; `c-forward-name' move over as long names as possible which is
647 ;; necessary to e.g. handle throws clauses correctly.
648 java
'((left-assoc "."))
649 idl
'((left-assoc "::")
651 pike
'((left-assoc "::")
655 (c-lang-defconst c-opt-identifier-concat-key
656 ;; Appendable adorned regexp matching the operators that join
657 ;; symbols to fully qualified identifiers, or nil in languages that
658 ;; don't have such things.
660 ;; This was a docstring constant in 5.30. It still works but is now
661 ;; considered internal - change `c-identifier-ops' instead.
662 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
663 '(left-assoc right-assoc
)
666 (c-make-keywords-re 'appendable ops
))))
667 (c-lang-defvar c-opt-identifier-concat-key
668 (c-lang-const c-opt-identifier-concat-key
)
671 (c-lang-defconst c-opt-identifier-concat-key-depth
672 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
673 t
(regexp-opt-depth (c-lang-const c-opt-identifier-concat-key
)))
675 (c-lang-defconst c-opt-identifier-prefix-key
676 ;; Appendable adorned regexp matching operators that might precede
677 ;; an identifier and that are part of the identifier in that case.
678 ;; nil in languages without such things.
679 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
683 (c-make-keywords-re 'appendable ops
))))
685 (c-lang-defconst c-after-id-concat-ops
686 "Operators that can occur after a binary operator on `c-identifier-ops'
687 in identifiers. nil in languages that don't have such things.
689 Operators here should also have appropriate entries in `c-operators' -
690 it's not taken care of by default."
692 ;; '~' for destructors in C++, '*' for member pointers.
694 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
695 ;; in import declarations. (This will also match bogus things like
696 ;; "foo.*bar" but we don't bother.)
699 (c-lang-defconst c-opt-after-id-concat-key
700 ;; Regexp that must match the token after
701 ;; `c-opt-identifier-concat-key' for it to be considered an
702 ;; identifier concatenation operator (which e.g. causes the
703 ;; preceding identifier to be fontified as a reference). Assumed to
704 ;; be a string if `c-opt-identifier-concat-key' is.
706 ;; This was a docstring constant in 5.30. It still works but is now
707 ;; considered internal - change `c-after-id-concat-ops' instead.
708 t
(concat (c-lang-const c-symbol-start
)
709 (if (c-lang-const c-after-id-concat-ops
)
710 (concat "\\|" (c-make-keywords-re 'appendable
711 (c-lang-const c-after-id-concat-ops
)))
714 (c-lang-defconst c-identifier-start
715 "Regexp that matches the start of an (optionally qualified) identifier.
716 It should also match all keywords. It's unspecified how far it
718 t
(concat (c-lang-const c-symbol-start
)
719 (if (c-lang-const c-opt-identifier-prefix-key
)
721 (c-lang-const c-opt-identifier-prefix-key
))
723 (c-lang-defvar c-identifier-start
(c-lang-const c-identifier-start
))
725 (c-lang-defconst c-identifier-key
726 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
727 C++. It does not recognize the full range of syntactic whitespace
728 between the tokens; `c-forward-name' has to be used for that. It
729 should also not match identifiers containing parenthesis groupings,
730 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
731 ;; This regexp is more complex than strictly necessary to ensure
732 ;; that it can be matched with a minimum of backtracking.
733 t
(concat (if (c-lang-const c-opt-identifier-prefix-key
)
736 (c-lang-const c-opt-identifier-prefix-key
)
737 (c-lang-const c-simple-ws
) "*"
740 "\\(" (c-lang-const c-symbol-key
) "\\)"
741 (if (c-lang-const c-opt-identifier-concat-key
)
744 (c-lang-const c-simple-ws
) "*"
745 (c-lang-const c-opt-identifier-concat-key
)
746 (c-lang-const c-simple-ws
) "*"
747 (if (c-lang-const c-after-id-concat-ops
)
750 (c-make-keywords-re 'appendable
751 (c-lang-const c-after-id-concat-ops
))
753 ;; For flexibility, consider the symbol match
754 ;; optional if we've hit a
755 ;; `c-after-id-concat-ops' operator. This is
756 ;; also necessary to handle the "*" that can
757 ;; end import declaration identifiers in Java.
759 (c-lang-const c-simple-ws
) "*"
760 "\\(" (c-lang-const c-symbol-key
) "\\)"
763 "\\(" (c-lang-const c-symbol-key
) "\\)"
765 (concat "\\(" (c-lang-const c-symbol-key
) "\\)"))
768 (c-lang-defvar c-identifier-key
(c-lang-const c-identifier-key
))
770 (c-lang-defconst c-identifier-last-sym-match
771 ;; This was a docstring constant in 5.30 but it's no longer used.
772 ;; It's only kept to avoid breaking third party code.
774 ;; Used to identify the submatch in `c-identifier-key' that
775 ;; surrounds the last symbol in the qualified identifier. It's a
776 ;; list of submatch numbers, of which the first that has a match is
777 ;; taken. It's assumed that at least one does when the regexp has
781 (c-lang-defconst c-string-escaped-newlines
782 "Set if the language support backslash escaped newlines inside string
786 (c-lang-defvar c-string-escaped-newlines
787 (c-lang-const c-string-escaped-newlines
))
789 (c-lang-defconst c-multiline-string-start-char
790 "Set if the language supports multiline string literals without escaped
791 newlines. If t, all string literals are multiline. If a character,
792 only literals where the open quote is immediately preceded by that
793 literal are multiline."
796 (c-lang-defvar c-multiline-string-start-char
797 (c-lang-const c-multiline-string-start-char
))
799 (c-lang-defconst c-opt-cpp-symbol
800 "The symbol which starts preprocessor constructs when in the margin."
803 (c-lang-defvar c-opt-cpp-symbol
(c-lang-const c-opt-cpp-symbol
))
805 (c-lang-defconst c-opt-cpp-prefix
806 "Regexp matching the prefix of a cpp directive in the languages that
807 normally use that macro preprocessor. Tested at bol or at boi.
808 Assumed to not contain any submatches or \\| operators."
809 ;; TODO (ACM, 2005-04-01). Amend the following to recognize escaped NLs;
810 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
813 (c-lang-defvar c-opt-cpp-prefix
(c-lang-const c-opt-cpp-prefix
))
815 (c-lang-defconst c-anchored-cpp-prefix
816 "Regexp matching the prefix of a cpp directive anchored to BOL,
817 in the languages that have a macro preprocessor."
818 t
"^\\s *\\(#\\)\\s *"
820 (c-lang-defvar c-anchored-cpp-prefix
(c-lang-const c-anchored-cpp-prefix
))
822 (c-lang-defconst c-opt-cpp-start
823 "Regexp matching the prefix of a cpp directive including the directive
824 name, or nil in languages without preprocessor support. The first
825 submatch surrounds the directive name."
826 t
(if (c-lang-const c-opt-cpp-prefix
)
827 (concat (c-lang-const c-opt-cpp-prefix
)
828 "\\([" c-alnum
"]+\\)"))
829 ;; Pike, being a scripting language, recognizes hash-bangs too.
830 pike
(concat (c-lang-const c-opt-cpp-prefix
)
831 "\\([" c-alnum
"]+\\|!\\)"))
832 (c-lang-defvar c-opt-cpp-start
(c-lang-const c-opt-cpp-start
))
834 (c-lang-defconst c-cpp-message-directives
835 "List of cpp directives (without the prefix) that are followed by a
837 t
(if (c-lang-const c-opt-cpp-prefix
)
839 (c c
++ objc pike
) '("error" "warning"))
841 (c-lang-defconst c-cpp-include-directives
842 "List of cpp directives (without the prefix) that are followed by a
843 file name in angle brackets or quotes."
844 t
(if (c-lang-const c-opt-cpp-prefix
)
846 objc
'("include" "import"))
848 (c-lang-defconst c-opt-cpp-macro-define
849 "Cpp directive (without the prefix) that is followed by a macro
850 definition, or nil if the language doesn't have any."
851 t
(if (c-lang-const c-opt-cpp-prefix
)
853 (c-lang-defvar c-opt-cpp-macro-define
854 (c-lang-const c-opt-cpp-macro-define
))
856 (c-lang-defconst c-opt-cpp-macro-define-start
857 ;; Regexp matching everything up to the macro body of a cpp define, or the
858 ;; end of the logical line if there is none. Submatch 1 is the name of the
859 ;; macro. Set if c-opt-cpp-macro-define is.
860 t
(if (c-lang-const c-opt-cpp-macro-define
)
861 (concat (c-lang-const c-opt-cpp-prefix
)
862 (c-lang-const c-opt-cpp-macro-define
)
863 "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(\([^\)]*\)\\)?"
865 "\\([ \t]\\|\\\\\n\\)*")))
866 (c-lang-defvar c-opt-cpp-macro-define-start
867 (c-lang-const c-opt-cpp-macro-define-start
))
869 (c-lang-defconst c-opt-cpp-macro-define-id
870 ;; Regexp matching everything up to the end of the identifier defined
872 t
(if (c-lang-const c-opt-cpp-macro-define
)
873 (concat (c-lang-const c-opt-cpp-prefix
) ; #
874 (c-lang-const c-opt-cpp-macro-define
) ; define
875 "[ \t]+\\(\\sw\\|_\\)+")))
876 (c-lang-defvar c-opt-cpp-macro-define-id
877 (c-lang-const c-opt-cpp-macro-define-id
))
879 (c-lang-defconst c-cpp-expr-directives
880 "List of cpp directives (without the prefix) that are followed by an
882 t
(if (c-lang-const c-opt-cpp-prefix
)
885 (c-lang-defconst c-cpp-expr-intro-re
886 "Regexp which matches the start of a CPP directive which contains an
887 expression, or nil if there aren't any in the language."
888 t
(if (c-lang-const c-cpp-expr-directives
)
890 (c-lang-const c-opt-cpp-prefix
)
891 (c-make-keywords-re t
(c-lang-const c-cpp-expr-directives
)))))
892 (c-lang-defvar c-cpp-expr-intro-re
893 (c-lang-const c-cpp-expr-intro-re
))
895 (c-lang-defconst c-cpp-expr-functions
896 "List of functions in cpp expressions."
897 t
(if (c-lang-const c-opt-cpp-prefix
)
899 pike
'("defined" "efun" "constant"))
901 (c-lang-defconst c-assignment-operators
902 "List of all assignment operators."
903 t
'("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
904 java
(append (c-lang-const c-assignment-operators
)
906 c
++ (append (c-lang-const c-assignment-operators
)
907 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
910 (c-lang-defconst c-operators
911 "List describing all operators, along with their precedence and
912 associativity. The order in the list corresponds to the precedence of
913 the operators: The operators in each element are a group with the same
914 precedence, and the group has higher precedence than the groups in all
915 following elements. The car of each element describes the type of the
916 operator group, and the cdr is a list of the operator tokens in it.
917 The operator group types are:
919 'prefix Unary prefix operators.
920 'postfix Unary postfix operators.
922 Unary postfix operators if and only if the chars have
924 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
925 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
926 'right-assoc-sequence
927 Right associative operator that constitutes of a
928 sequence of tokens that separate expressions. All the
929 tokens in the group are in this case taken as
930 describing the sequence in one such operator, and the
931 order between them is therefore significant.
933 Operators containing a character with paren syntax are taken to match
934 with a corresponding open/close paren somewhere else. A postfix
935 operator with close paren syntax is taken to end a postfix expression
936 started somewhere earlier, rather than start a new one at point. Vice
937 versa for prefix operators with open paren syntax.
939 Note that operators like \".\" and \"->\" which in language references
940 often are described as postfix operators are considered binary here,
941 since CC Mode treats every identifier as an expression."
943 ;; There's currently no code in CC Mode that exploit all the info
944 ;; in this variable; precedence, associativity etc are present as a
945 ;; preparation for future work.
948 ,@(when (c-lang-const c-opt-cpp-prefix
)
950 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
953 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
954 '("%:%:" "??=??=")))))
957 ,@(c-lang-const c-identifier-ops
)
958 ,@(cond ((or (c-major-mode-is 'c
++-mode
) (c-major-mode-is 'java-mode
))
959 `((postfix-if-paren "<" ">"))) ; Templates.
960 ((c-major-mode-is 'pike-mode
)
961 `((prefix "global" "predef")))
962 ((c-major-mode-is 'java-mode
)
963 `((prefix "super"))))
966 ,@(when (c-major-mode-is 'c
++-mode
)
967 ;; The following need special treatment.
968 `((prefix "dynamic_cast" "static_cast"
969 "reinterpret_cast" "const_cast" "typeid")))
971 ,@(unless (c-major-mode-is 'java-mode
)
973 (postfix "++" "--" "[" "]" "(" ")"
974 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
975 '("<:" ":>" "??(" "??)")))
978 (prefix "++" "--" "+" "-" "!" "~"
979 ,@(when (c-major-mode-is 'c
++-mode
) '("not" "compl"))
980 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
981 '("*" "&" "sizeof" "??-"))
982 ,@(when (c-major-mode-is 'objc-mode
)
983 '("@selector" "@protocol" "@encode"))
984 ;; The following need special treatment.
985 ,@(cond ((c-major-mode-is 'c
++-mode
)
987 ((c-major-mode-is 'java-mode
)
989 ((c-major-mode-is 'pike-mode
)
990 '("class" "lambda" "catch" "throw" "gauge")))
992 ,@(when (c-major-mode-is 'pike-mode
)
993 '("[" "]"))) ; Type cast.
996 ,@(when (c-major-mode-is 'c
++-mode
)
997 `((left-assoc ".*" "->*")))
1000 (left-assoc "*" "/" "%")
1003 (left-assoc "+" "-")
1006 (left-assoc "<<" ">>"
1007 ,@(when (c-major-mode-is 'java-mode
)
1011 (left-assoc "<" ">" "<=" ">="
1012 ,@(when (c-major-mode-is 'java-mode
)
1016 (left-assoc "==" "!="
1017 ,@(when (c-major-mode-is 'c
++-mode
) '("not_eq")))
1021 ,@(when (c-major-mode-is 'c
++-mode
) '("bitand")))
1023 ;; Bitwise exclusive or.
1025 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1027 ,@(when (c-major-mode-is 'c
++-mode
) '("xor")))
1031 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1033 ,@(when (c-major-mode-is 'c
++-mode
) '("bitor")))
1037 ,@(when (c-major-mode-is 'c
++-mode
) '("and")))
1041 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1043 ,@(when (c-major-mode-is 'c
++-mode
) '("or")))
1046 (right-assoc-sequence "?" ":")
1049 (right-assoc ,@(c-lang-const c-assignment-operators
))
1052 ,@(when (c-major-mode-is 'c
++-mode
)
1053 '((prefix "throw")))
1058 ;; IDL got its own definition since it has a much smaller operator
1059 ;; set than the other languages.
1060 idl
`(;; Preprocessor.
1064 ,@(c-lang-const c-identifier-ops
)
1066 (prefix "+" "-" "~")
1068 (left-assoc "*" "/" "%")
1070 (left-assoc "+" "-")
1072 (left-assoc "<<" ">>")
1080 (c-lang-defconst c-operator-list
1081 ;; The operators as a flat list (without duplicates).
1082 t
(c-filter-ops (c-lang-const c-operators
) t t
))
1084 (c-lang-defconst c-overloadable-operators
1085 "List of the operators that are overloadable, in their \"identifier
1086 form\". See also `c-op-identifier-prefix'."
1088 c
++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
1090 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
1091 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
1092 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
1093 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
1094 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
1095 "()" "[]" "<::>" "??(??)")
1096 ;; These work like identifiers in Pike.
1097 pike
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
1098 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
1099 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
1102 (c-lang-defconst c-overloadable-operators-regexp
1103 ;; Regexp tested after an "operator" token in C++.
1105 c
++ (c-make-keywords-re nil
(c-lang-const c-overloadable-operators
)))
1106 (c-lang-defvar c-overloadable-operators-regexp
1107 (c-lang-const c-overloadable-operators-regexp
))
1109 (c-lang-defconst c-opt-op-identifier-prefix
1110 "Regexp matching the token before the ones in
1111 `c-overloadable-operators' when operators are specified in their
1112 \"identifier form\". This typically matches \"operator\" in C++ where
1113 operator functions are specified as e.g. \"operator +\". It's nil in
1114 languages without operator functions or where the complete operator
1115 identifier is listed in `c-overloadable-operators'.
1117 This regexp is assumed to not match any non-operator identifier."
1119 c
++ (c-make-keywords-re t
'("operator")))
1120 (c-lang-defvar c-opt-op-identifier-prefix
1121 (c-lang-const c-opt-op-identifier-prefix
))
1123 ;; Note: the following alias is an old name which was a mis-spelling. It has
1124 ;; been corrected above and throughout cc-engine.el. It will be removed at
1125 ;; some release very shortly in the future. ACM, 2006-04-14.
1126 (defvaralias 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
)
1127 (make-obsolete-variable 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
1128 "CC Mode 5.31.4, 2006-04-14")
1130 (c-lang-defconst c-other-op-syntax-tokens
1131 "List of the tokens made up of characters in the punctuation or
1132 parenthesis syntax classes that have uses other than as expression
1134 t
'("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
1135 (c c
++ pike
) (append '("#" "##" ; Used by cpp.
1137 (c-lang-const c-other-op-syntax-tokens
))
1138 (c c
++) (append '("*") (c-lang-const c-other-op-syntax-tokens
))
1139 c
++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
1140 (c-lang-const c-other-op-syntax-tokens
))
1141 objc
(append '("#" "##" ; Used by cpp.
1142 "+" "-") (c-lang-const c-other-op-syntax-tokens
))
1143 idl
(append '("#" "##") ; Used by cpp.
1144 (c-lang-const c-other-op-syntax-tokens
))
1145 pike
(append '("..")
1146 (c-lang-const c-other-op-syntax-tokens
)
1147 (c-lang-const c-overloadable-operators
))
1148 awk
'("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
1150 (c-lang-defconst c-all-op-syntax-tokens
1151 ;; List of all tokens in the punctuation and parenthesis syntax
1153 t
(cl-delete-duplicates (append (c-lang-const c-other-op-syntax-tokens
)
1154 (c-lang-const c-operator-list
))
1155 :test
'string-equal
))
1157 (c-lang-defconst c-nonsymbol-token-char-list
1158 ;; List containing all chars not in the word, symbol or
1159 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
1160 ;; parenthesis and string delimiter chars.
1161 t
(c-with-syntax-table (c-lang-const c-mode-syntax-table
)
1162 ;; Only go through the chars in the printable ASCII range. No
1163 ;; language so far has 8-bit or widestring operators.
1164 (let (list (char 32))
1166 (or (memq (char-syntax char
) '(?w ?_ ?
< ?
> ?\
))
1167 (setq list
(cons (c-int-to-char char
) list
)))
1168 (setq char
(1+ char
)))
1171 (c-lang-defconst c-nonsymbol-token-regexp
1172 ;; Regexp matching all tokens in the punctuation and parenthesis
1173 ;; syntax classes. Note that this also matches ".", which can start
1175 t
(c-make-keywords-re nil
1176 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1178 "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
1179 (c-lang-defvar c-nonsymbol-token-regexp
1180 (c-lang-const c-nonsymbol-token-regexp
))
1182 (c-lang-defconst c-assignment-op-regexp
1183 ;; Regexp matching all assignment operators and only them. The
1184 ;; beginning of the first submatch is used to detect the end of the
1185 ;; token, along with the end of the whole match.
1186 t
(if (c-lang-const c-assignment-operators
)
1188 ;; Need special case for "=" since it's a prefix of "==".
1191 (c-make-keywords-re nil
1192 (set-difference (c-lang-const c-assignment-operators
)
1194 :test
'string-equal
)))
1196 (c-lang-defvar c-assignment-op-regexp
1197 (c-lang-const c-assignment-op-regexp
))
1199 (c-lang-defconst c-
<>-multichar-token-regexp
1200 ;; Regexp matching all tokens containing "<" or ">" which are longer
1202 t
(c-make-keywords-re nil
1203 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1206 (c-lang-defvar c-
<>-multichar-token-regexp
1207 (c-lang-const c-
<>-multichar-token-regexp
))
1209 (c-lang-defconst c-
<-op-cont-regexp
1210 ;; Regexp matching the second and subsequent characters of all
1211 ;; multicharacter tokens that begin with "<".
1212 t
(c-make-keywords-re nil
1213 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1216 (lambda (op) (substring op
1)))))
1218 (c-lang-defvar c-
<-op-cont-regexp
(c-lang-const c-
<-op-cont-regexp
))
1220 (c-lang-defconst c-
>-op-cont-tokens
1221 ;; A list of second and subsequent characters of all multicharacter tokens
1222 ;; that begin with ">".
1223 t
(c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1226 (lambda (op) (substring op
1)))
1227 java
(c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1229 "\\`>[^>]\\|\\`>>[^>]"
1230 (lambda (op) (substring op
1))))
1232 (c-lang-defconst c-
>-op-cont-regexp
1233 ;; Regexp matching the second and subsequent characters of all
1234 ;; multicharacter tokens that begin with ">".
1235 t
(c-make-keywords-re nil
(c-lang-const c-
>-op-cont-tokens
)))
1237 (c-lang-defvar c-
>-op-cont-regexp
(c-lang-const c-
>-op-cont-regexp
))
1239 (c-lang-defconst c-
>-op-without-
>-cont-regexp
1240 ;; Regexp matching the second and subsequent characters of all
1241 ;; multicharacter tokens that begin with ">" except for those beginning with
1243 t
(c-make-keywords-re nil
1245 (c-lang-const c-
>-op-cont-tokens
)
1246 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1249 (lambda (op) (substring op
1)))
1250 :test
'string-equal
)))
1252 (c-lang-defvar c-
>-op-without-
>-cont-regexp
1253 (c-lang-const c-
>-op-without-
>-cont-regexp
))
1255 (c-lang-defconst c-stmt-delim-chars
1256 ;; The characters that should be considered to bound statements. To
1257 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1258 ;; begin with "^" to negate the set. If ? : operators should be
1259 ;; detected then the string must end with "?:".
1261 (c-lang-defvar c-stmt-delim-chars
(c-lang-const c-stmt-delim-chars
))
1263 (c-lang-defconst c-stmt-delim-chars-with-comma
1264 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1266 (c-lang-defvar c-stmt-delim-chars-with-comma
1267 (c-lang-const c-stmt-delim-chars-with-comma
))
1270 ;;; Syntactic whitespace.
1272 (c-lang-defconst c-simple-ws
1273 "Regexp matching an ordinary whitespace character.
1274 Does not contain a \\| operator at the top level."
1275 ;; "\\s " is not enough since it doesn't match line breaks.
1276 t
"\\(\\s \\|[\n\r]\\)")
1278 (c-lang-defconst c-simple-ws-depth
1279 ;; Number of regexp grouping parens in `c-simple-ws'.
1280 t
(regexp-opt-depth (c-lang-const c-simple-ws
)))
1282 (c-lang-defconst c-line-comment-starter
1283 "String that starts line comments, or nil if such don't exist.
1284 Line comments are always terminated by newlines. At least one of
1285 `c-block-comment-starter' and this one is assumed to be set.
1287 Note that it's currently not enough to set this to support a new
1288 comment style. Other stuff like the syntax table must also be set up
1292 (c-lang-defvar c-line-comment-starter
(c-lang-const c-line-comment-starter
))
1294 (c-lang-defconst c-block-comment-starter
1295 "String that starts block comments, or nil if such don't exist.
1296 Block comments are ended by `c-block-comment-ender', which is assumed
1297 to be set if this is. At least one of `c-line-comment-starter' and
1298 this one is assumed to be set.
1300 Note that it's currently not enough to set this to support a new
1301 comment style. Other stuff like the syntax table must also be set up
1306 (c-lang-defconst c-block-comment-ender
1307 "String that ends block comments, or nil if such don't exist.
1309 Note that it's currently not enough to set this to support a new
1310 comment style. Other stuff like the syntax table must also be set up
1315 (c-lang-defconst c-comment-start-regexp
1316 ;; Regexp to match the start of any type of comment.
1317 t
(let ((re (c-make-keywords-re nil
1318 (list (c-lang-const c-line-comment-starter
)
1319 (c-lang-const c-block-comment-starter
)))))
1320 (if (memq 'gen-comment-delim c-emacs-features
)
1321 (concat re
"\\|\\s!")
1323 (c-lang-defvar c-comment-start-regexp
(c-lang-const c-comment-start-regexp
))
1325 (c-lang-defconst c-block-comment-start-regexp
1326 ;; Regexp which matches the start of a block comment (if such exists in the
1328 t
(if (c-lang-const c-block-comment-starter
)
1329 (regexp-quote (c-lang-const c-block-comment-starter
))
1331 (c-lang-defvar c-block-comment-start-regexp
1332 (c-lang-const c-block-comment-start-regexp
))
1334 (c-lang-defconst c-line-comment-start-regexp
1335 ;; Regexp which matches the start of a line comment (if such exists in the
1336 ;; language; it does in all 7 CC Mode languages).
1337 t
(if (c-lang-const c-line-comment-starter
)
1338 (regexp-quote (c-lang-const c-line-comment-starter
))
1340 (c-lang-defvar c-line-comment-start-regexp
1341 (c-lang-const c-line-comment-start-regexp
))
1343 (c-lang-defconst c-literal-start-regexp
1344 ;; Regexp to match the start of comments and string literals.
1345 t
(concat (c-lang-const c-comment-start-regexp
)
1347 (if (memq 'gen-string-delim c-emacs-features
)
1350 (c-lang-defvar c-literal-start-regexp
(c-lang-const c-literal-start-regexp
))
1352 (c-lang-defconst c-doc-comment-start-regexp
1353 "Regexp to match the start of documentation comments."
1355 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1356 (c c
++ objc
) "/\\*[*!]"
1359 (c-lang-defvar c-doc-comment-start-regexp
1360 (c-lang-const c-doc-comment-start-regexp
))
1362 (c-lang-defconst comment-start
1363 "String that starts comments inserted with M-; etc.
1364 `comment-start' is initialized from this."
1365 ;; Default: Prefer line comments to block comments, and pad with a space.
1366 t
(concat (or (c-lang-const c-line-comment-starter
)
1367 (c-lang-const c-block-comment-starter
))
1369 ;; In C we still default to the block comment style since line
1370 ;; comments aren't entirely portable.
1372 (c-lang-setvar comment-start
(c-lang-const comment-start
))
1374 (c-lang-defconst comment-end
1375 "String that ends comments inserted with M-; etc.
1376 `comment-end' is initialized from this."
1377 ;; Default: Use block comment style if comment-start uses block
1378 ;; comments, and pad with a space in that case.
1379 t
(if (string-match (concat "\\`\\("
1380 (c-lang-const c-block-comment-start-regexp
)
1382 (c-lang-const comment-start
))
1383 (concat " " (c-lang-const c-block-comment-ender
))
1385 (c-lang-setvar comment-end
(c-lang-const comment-end
))
1387 (c-lang-defconst comment-start-skip
1388 "Regexp to match the start of a comment plus everything up to its body.
1389 `comment-start-skip' is initialized from this."
1390 ;; Default: Allow the last char of the comment starter(s) to be
1391 ;; repeated, then allow any amount of horizontal whitespace.
1394 (mapcar (lambda (cs)
1396 (concat (regexp-quote cs
) "+")))
1397 (list (c-lang-const c-line-comment-starter
)
1398 (c-lang-const c-block-comment-starter
)))
1401 (c-lang-setvar comment-start-skip
(c-lang-const comment-start-skip
))
1403 (c-lang-defconst c-syntactic-ws-start
1404 ;; Regexp matching any sequence that can start syntactic whitespace.
1405 ;; The only uncertain case is '#' when there are cpp directives.
1407 (c-make-keywords-re nil
1408 (append (list (c-lang-const c-line-comment-starter
)
1409 (c-lang-const c-block-comment-starter
)
1410 (when (c-lang-const c-opt-cpp-prefix
)
1414 (when (memq 'gen-comment-delim c-emacs-features
)
1416 (c-lang-defvar c-syntactic-ws-start
(c-lang-const c-syntactic-ws-start
))
1418 (c-lang-defconst c-syntactic-ws-end
1419 ;; Regexp matching any single character that might end syntactic whitespace.
1421 (c-make-keywords-re nil
1422 (append (when (c-lang-const c-block-comment-ender
)
1425 (elt (c-lang-const c-block-comment-ender
)
1427 (c-lang-const c-block-comment-ender
)))))))
1429 (when (memq 'gen-comment-delim c-emacs-features
)
1431 (c-lang-defvar c-syntactic-ws-end
(c-lang-const c-syntactic-ws-end
))
1433 (c-lang-defconst c-unterminated-block-comment-regexp
1434 ;; Regexp matching an unterminated block comment that doesn't
1435 ;; contain line breaks, or nil in languages without block comments.
1436 ;; Does not contain a \| operator at the top level.
1437 t
(when (c-lang-const c-block-comment-starter
)
1439 (regexp-quote (c-lang-const c-block-comment-starter
))
1440 ;; It's messy to cook together a regexp that matches anything
1441 ;; but c-block-comment-ender.
1442 (let ((end (c-lang-const c-block-comment-ender
)))
1443 (cond ((= (length end
) 1)
1444 (concat "[^" end
"\n\r]*"))
1446 (concat "[^" (substring end
0 1) "\n\r]*"
1448 (regexp-quote (substring end
0 1)) "+"
1450 ;; The quoting rules inside char classes are silly. :P
1451 (cond ((= (elt end
0) (elt end
1))
1452 (concat (substring end
0 1) "\n\r"))
1453 ((= (elt end
1) ?\
])
1454 (concat (substring end
1 2) "\n\r"
1455 (substring end
0 1)))
1457 (concat (substring end
0 1) "\n\r"
1458 (substring end
1 2))))
1460 "[^" (substring end
0 1) "\n\r]*"
1463 (error "Can't handle a block comment ender of length %s"
1466 (c-lang-defconst c-block-comment-regexp
1467 ;; Regexp matching a block comment that doesn't contain line breaks,
1468 ;; or nil in languages without block comments. The reason we don't
1469 ;; allow line breaks is to avoid going very far and risk running out
1470 ;; of regexp stack; this regexp is intended to handle only short
1471 ;; comments that might be put in the middle of limited constructs
1472 ;; like declarations. Does not contain a \| operator at the top
1474 t
(when (c-lang-const c-unterminated-block-comment-regexp
)
1476 (c-lang-const c-unterminated-block-comment-regexp
)
1477 (let ((end (c-lang-const c-block-comment-ender
)))
1478 (cond ((= (length end
) 1)
1481 (concat (regexp-quote (substring end
0 1)) "+"
1482 (regexp-quote (substring end
1 2))))
1484 (error "Can't handle a block comment ender of length %s"
1487 (c-lang-defconst c-nonwhite-syntactic-ws
1488 ;; Regexp matching a piece of syntactic whitespace that isn't a
1489 ;; sequence of simple whitespace characters. As opposed to
1490 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1491 ;; directives as syntactic whitespace.
1492 t
(c-concat-separated
1493 (list (when (c-lang-const c-line-comment-starter
)
1494 (concat (regexp-quote (c-lang-const c-line-comment-starter
))
1496 (c-lang-const c-block-comment-regexp
)
1498 (when (memq 'gen-comment-delim c-emacs-features
)
1502 (c-lang-defconst c-syntactic-ws
1503 ;; Regexp matching syntactic whitespace, including possibly the
1504 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1505 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1506 ;; not contain a \| operator at the top level.
1507 t
(concat (c-lang-const c-simple-ws
) "*"
1509 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws
) "\\)"
1510 (c-lang-const c-simple-ws
) "*")
1513 (c-lang-defconst c-syntactic-ws-depth
1514 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1515 t
(regexp-opt-depth (c-lang-const c-syntactic-ws
)))
1517 (c-lang-defconst c-nonempty-syntactic-ws
1518 ;; Regexp matching syntactic whitespace, which is at least one
1519 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1520 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1521 ;; not contain a \| operator at the top level.
1523 (c-lang-const c-simple-ws
)
1525 (c-lang-const c-nonwhite-syntactic-ws
)
1528 (c-lang-defconst c-nonempty-syntactic-ws-depth
1529 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1530 t
(regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws
)))
1532 (c-lang-defconst c-single-line-syntactic-ws
1533 ;; Regexp matching syntactic whitespace without any line breaks. As
1534 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1535 ;; regard cpp directives as syntactic whitespace. Does not contain
1536 ;; a \| operator at the top level.
1537 t
(if (c-lang-const c-block-comment-regexp
)
1539 (c-lang-const c-block-comment-regexp
)
1543 (c-lang-defconst c-single-line-syntactic-ws-depth
1544 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1545 t
(regexp-opt-depth (c-lang-const c-single-line-syntactic-ws
)))
1547 (c-lang-defconst c-syntactic-eol
1548 ;; Regexp that matches when there is no syntactically significant
1549 ;; text before eol. Macros are regarded as syntactically
1550 ;; significant text here.
1551 t
(concat (c-lang-const c-single-line-syntactic-ws
)
1552 ;; Match eol (possibly inside a block comment or preceded
1553 ;; by a line continuation backslash), or the beginning of a
1554 ;; line comment. Note: This has to be modified for awk
1555 ;; where line comments start with '#'.
1558 (list (when (c-lang-const c-line-comment-starter
)
1559 (regexp-quote (c-lang-const c-line-comment-starter
)))
1560 (when (c-lang-const c-unterminated-block-comment-regexp
)
1561 (concat (c-lang-const c-unterminated-block-comment-regexp
)
1567 (c-lang-defvar c-syntactic-eol
(c-lang-const c-syntactic-eol
))
1572 ;; The Emacs variables beginning-of-defun-function and
1573 ;; end-of-defun-function will be set so that commands like
1574 ;; `mark-defun' and `narrow-to-defun' work right. The key sequences
1575 ;; C-M-a and C-M-e are, however, bound directly to the CC Mode
1576 ;; functions, allowing optimization for large n.
1577 (c-lang-defconst beginning-of-defun-function
1578 "Function to which beginning-of-defun-function will be set."
1579 t
'c-beginning-of-defun
1580 awk
'c-awk-beginning-of-defun
)
1581 (c-lang-setvar beginning-of-defun-function
1582 (c-lang-const beginning-of-defun-function
))
1584 (c-lang-defconst end-of-defun-function
1585 "Function to which end-of-defun-function will be set."
1587 awk
'c-awk-end-of-defun
)
1588 (c-lang-setvar end-of-defun-function
(c-lang-const end-of-defun-function
))
1590 ;;; In-comment text handling.
1592 (c-lang-defconst c-paragraph-start
1593 "Regexp to append to `paragraph-start'."
1595 java
"\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1596 pike
"\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1597 (c-lang-defvar c-paragraph-start
(c-lang-const c-paragraph-start
))
1599 (c-lang-defconst c-paragraph-separate
1600 "Regexp to append to `paragraph-separate'."
1602 pike
(c-lang-const c-paragraph-start
))
1603 (c-lang-defvar c-paragraph-separate
(c-lang-const c-paragraph-separate
))
1608 ;; Note: All and only all language constants containing keyword lists
1609 ;; should end with "-kwds"; they're automatically collected into the
1610 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1612 (c-lang-defconst c-primitive-type-kwds
1613 "Primitive type keywords. As opposed to the other keyword lists, the
1614 keywords listed here are fontified with the type face instead of the
1617 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1618 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1619 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1622 Do not try to modify this list for end user customizations; the
1623 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1624 the appropriate place for that."
1625 t
'("char" "double" "float" "int" "long" "short" "signed"
1628 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1629 (c-lang-const c-primitive-type-kwds
))
1632 (c-lang-const c-primitive-type-kwds
))
1633 ;; Objective-C extends C, but probably not the new stuff in C99.
1635 '("id" "Class" "SEL" "IMP" "BOOL")
1636 (c-lang-const c-primitive-type-kwds
))
1637 java
'("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1638 idl
'("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1639 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1642 ;; The following can't really end a type, but we have to specify them
1643 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1644 ;; doesn't matter that much.
1645 "unsigned" "strong")
1646 pike
'(;; this_program isn't really a keyword, but it's practically
1647 ;; used as a builtin type.
1648 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1649 "object" "program" "string" "this_program" "void"))
1651 (c-lang-defconst c-primitive-type-key
1652 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1653 t
(c-make-keywords-re t
(c-lang-const c-primitive-type-kwds
)))
1654 (c-lang-defvar c-primitive-type-key
(c-lang-const c-primitive-type-key
))
1656 (c-lang-defconst c-primitive-type-prefix-kwds
1657 "Keywords that might act as prefixes for primitive types. Assumed to
1658 be a subset of `c-primitive-type-kwds'."
1660 (c c
++) '("long" "short" "signed" "unsigned")
1661 idl
'("long" "unsigned"
1665 (c-lang-defconst c-typedef-kwds
1666 "Prefix keyword\(s\) like \"typedef\" which make a type declaration out
1667 of a variable declaration."
1671 (c-lang-defconst c-typedef-key
1672 ;; Adorned regexp matching `c-typedef-kwds'.
1673 t
(c-make-keywords-re t
(c-lang-const c-typedef-kwds
)))
1674 (c-lang-defvar c-typedef-key
(c-lang-const c-typedef-key
))
1676 (c-lang-defconst c-type-prefix-kwds
1677 "Keywords where the following name - if any - is a type name, and
1678 where the keyword together with the symbol works as a type in
1681 Note that an alternative if the second part doesn't hold is
1682 `c-type-list-kwds'. Keywords on this list are typically also present
1683 on one of the `*-decl-kwds' lists."
1685 c
'("struct" "union" "enum")
1686 c
++ (append '("class" "typename")
1687 (c-lang-const c-type-prefix-kwds c
)))
1689 (c-lang-defconst c-type-prefix-key
1690 ;; Adorned regexp matching `c-type-prefix-kwds'.
1691 t
(c-make-keywords-re t
(c-lang-const c-type-prefix-kwds
)))
1692 (c-lang-defvar c-type-prefix-key
(c-lang-const c-type-prefix-key
))
1694 (c-lang-defconst c-type-modifier-kwds
1695 "Type modifier keywords. These can occur almost anywhere in types
1696 but they don't build a type of themselves. Unlike the keywords on
1697 `c-primitive-type-kwds', they are fontified with the keyword face and
1700 c
'("const" "restrict" "volatile")
1701 c
++ '("const" "volatile" "throw")
1702 objc
'("const" "volatile"))
1704 (c-lang-defconst c-opt-type-modifier-key
1705 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1706 ;; languages without such keywords.
1707 t
(and (c-lang-const c-type-modifier-kwds
)
1708 (c-make-keywords-re t
(c-lang-const c-type-modifier-kwds
))))
1709 (c-lang-defvar c-opt-type-modifier-key
(c-lang-const c-opt-type-modifier-key
))
1711 (c-lang-defconst c-opt-type-component-key
1712 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1713 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1714 t
(and (or (c-lang-const c-primitive-type-prefix-kwds
)
1715 (c-lang-const c-type-modifier-kwds
))
1716 (c-make-keywords-re t
1717 (append (c-lang-const c-primitive-type-prefix-kwds
)
1718 (c-lang-const c-type-modifier-kwds
)))))
1719 (c-lang-defvar c-opt-type-component-key
1720 (c-lang-const c-opt-type-component-key
))
1722 (c-lang-defconst c-type-start-kwds
1723 ;; All keywords that can start a type (i.e. are either a type prefix
1724 ;; or a complete type).
1725 t
(cl-delete-duplicates (append (c-lang-const c-primitive-type-kwds
)
1726 (c-lang-const c-type-prefix-kwds
)
1727 (c-lang-const c-type-modifier-kwds
))
1728 :test
'string-equal
))
1730 (c-lang-defconst c-class-decl-kwds
1731 "Keywords introducing declarations where the following block (if any)
1732 contains another declaration level that should be considered a class.
1734 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1735 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1736 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1739 Note that presence on this list does not automatically treat the
1740 following identifier as a type; the keyword must also be present on
1741 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1743 c
'("struct" "union")
1744 c
++ '("class" "struct" "union")
1745 objc
'("struct" "union"
1746 "@interface" "@implementation" "@protocol")
1747 java
'("class" "@interface" "interface")
1748 idl
'("component" "eventtype" "exception" "home" "interface" "struct"
1751 "storagehome" "storagetype"
1753 "catalog" "executor" "manages" "segment")
1756 (c-lang-defconst c-class-key
1757 ;; Regexp matching the start of a class.
1758 t
(c-make-keywords-re t
(c-lang-const c-class-decl-kwds
)))
1759 (c-lang-defvar c-class-key
(c-lang-const c-class-key
))
1761 (c-lang-defconst c-brace-list-decl-kwds
1762 "Keywords introducing declarations where the following block (if
1763 any) is a brace list.
1765 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1766 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1767 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1772 (c-lang-defconst c-brace-list-key
1773 ;; Regexp matching the start of declarations where the following
1774 ;; block is a brace list.
1775 t
(c-make-keywords-re t
(c-lang-const c-brace-list-decl-kwds
)))
1776 (c-lang-defvar c-brace-list-key
(c-lang-const c-brace-list-key
))
1778 (c-lang-defconst c-other-block-decl-kwds
1779 "Keywords where the following block (if any) contains another
1780 declaration level that should not be considered a class. For every
1781 keyword here, CC Mode will add a set of special syntactic symbols for
1782 those blocks. E.g. if the keyword is \"foo\" then there will be
1783 `foo-open', `foo-close', and `infoo' symbols.
1785 The intention is that this category should be used for block
1786 constructs that aren't related to object orientation concepts like
1787 classes (which thus also include e.g. interfaces, templates,
1788 contracts, structs, etc). The more pragmatic distinction is that
1789 while most want some indentation inside classes, it's fairly common
1790 that they don't want it in some of these constructs, so it should be
1791 simple to configure that differently from classes. See also
1792 `c-class-decl-kwds'.
1794 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1795 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1796 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1799 (c objc
) '("extern")
1800 c
++ '("namespace" "extern")
1805 (c-lang-defconst c-other-decl-block-key
1806 ;; Regexp matching the start of blocks besides classes that contain
1807 ;; another declaration level.
1808 t
(c-make-keywords-re t
(c-lang-const c-other-block-decl-kwds
)))
1809 (c-lang-defvar c-other-decl-block-key
(c-lang-const c-other-decl-block-key
))
1811 (c-lang-defvar c-other-decl-block-key-in-symbols-alist
1815 (if (string= elt
"extern")
1817 (intern (concat "in" elt
)))))
1818 (c-lang-const c-other-block-decl-kwds
))
1819 "Alist associating keywords in c-other-decl-block-decl-kwds with
1820 their matching \"in\" syntactic symbols.")
1822 (c-lang-defconst c-typedef-decl-kwds
1823 "Keywords introducing declarations where the identifier(s) being
1826 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1827 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1828 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1830 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1831 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1833 t
(append (c-lang-const c-class-decl-kwds
)
1834 (c-lang-const c-brace-list-decl-kwds
))
1835 ;; Languages that have a "typedef" construct.
1836 (c c
++ objc idl pike
) (append (c-lang-const c-typedef-decl-kwds
)
1838 ;; Unlike most other languages, exception names are not handled as
1839 ;; types in IDL since they only can occur in "raises" specs.
1840 idl
(delete "exception" (append (c-lang-const c-typedef-decl-kwds
) nil
)))
1842 (c-lang-defconst c-typedef-decl-key
1843 t
(c-make-keywords-re t
(c-lang-const c-typedef-decl-kwds
)))
1844 (c-lang-defvar c-typedef-decl-key
(c-lang-const c-typedef-decl-key
))
1846 (c-lang-defconst c-typeless-decl-kwds
1847 "Keywords introducing declarations where the \(first) identifier
1848 \(declarator) follows directly after the keyword, without any type.
1850 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1851 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1852 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1854 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1855 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1857 t
(append (c-lang-const c-class-decl-kwds
)
1858 (c-lang-const c-brace-list-decl-kwds
))
1859 ;; Note: "manages" for CORBA CIDL clashes with its presence on
1860 ;; `c-type-list-kwds' for IDL.
1861 idl
(append (c-lang-const c-typeless-decl-kwds
)
1862 '("factory" "finder" "native"
1867 pike
(append (c-lang-const c-class-decl-kwds
)
1870 (c-lang-defconst c-modifier-kwds
1871 "Keywords that can prefix normal declarations of identifiers
1872 \(and typically act as flags). Things like argument declarations
1873 inside function headers are also considered declarations in this
1876 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1877 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1878 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1881 (c c
++) '("auto" "extern" "inline" "register" "static")
1882 c
++ (append '("explicit" "friend" "mutable" "template" "using" "virtual")
1883 (c-lang-const c-modifier-kwds
))
1884 objc
'("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
1885 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
1886 idl
'("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
1887 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
1888 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
1892 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
1893 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
1894 java
'("abstract" "const" "final" "native" "private" "protected" "public"
1895 "static" "strictfp" "synchronized" "transient" "volatile")
1896 pike
'("final" "inline" "local" "nomask" "optional" "private" "protected"
1897 "public" "static" "variant"))
1899 (c-lang-defconst c-other-decl-kwds
1900 "Keywords that can start or prefix any declaration level construct,
1901 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1902 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1903 `c-typeless-decl-kwds' and `c-modifier-kwds'.
1905 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1906 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1907 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1910 objc
'("@class" "@end" "@defs")
1911 java
'("import" "package")
1912 pike
'("import" "inherit"))
1914 (c-lang-defconst c-decl-start-kwds
1915 "Keywords that always start declarations, wherever they occur.
1916 This can be used for declarations that aren't recognized by the normal
1917 combination of `c-decl-prefix-re' and `c-decl-start-re'."
1919 ;; Classes can be declared anywhere in a Pike expression.
1922 (c-lang-defconst c-decl-hangon-kwds
1923 "Keywords that can occur anywhere in a declaration level construct.
1924 This is used for self-contained things that can be tacked on anywhere
1925 on a declaration and that should be ignored to be able to recognize it
1926 correctly. Typical cases are compiler extensions like
1927 \"__attribute__\" or \"__declspec\":
1929 __declspec(noreturn) void foo();
1930 class __declspec(dllexport) classname {...};
1931 void foo() __attribute__((noreturn));
1933 Note that unrecognized plain symbols are skipped anyway if they occur
1934 before the type, so such things are not necessary to mention here.
1935 Mentioning them here is necessary only if they can occur in other
1936 places, or if they are followed by a construct that must be skipped
1937 over \(like the parens in the \"__attribute__\" and \"__declspec\"
1938 examples above). In the last case, they alse need to be present on
1939 one of `c-type-list-kwds', `c-ref-list-kwds',
1940 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1941 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1942 ;; NB: These are currently not recognized in all parts of a
1943 ;; declaration. Specifically, they aren't recognized in the middle
1944 ;; of multi-token types, inside declarators, and between the
1945 ;; identifier and the arglist paren of a function declaration.
1947 ;; FIXME: This ought to be user customizable since compiler stuff
1948 ;; like this usually is wrapped in project specific macros. (It'd
1949 ;; of course be even better if we could cope without knowing this.)
1951 (c c
++) '(;; GCC extension.
1956 (c-lang-defconst c-decl-hangon-key
1957 ;; Adorned regexp matching `c-decl-hangon-kwds'.
1958 t
(c-make-keywords-re t
(c-lang-const c-decl-hangon-kwds
)))
1959 (c-lang-defvar c-decl-hangon-key
(c-lang-const c-decl-hangon-key
))
1961 (c-lang-defconst c-prefix-spec-kwds
1962 ;; All keywords that can occur in the preamble of a declaration.
1963 ;; They typically occur before the type, but they are also matched
1964 ;; after presumptive types since we often can't be sure that
1965 ;; something is a type or just some sort of macro in front of the
1966 ;; declaration. They might be ambiguous with types or type
1968 t
(cl-delete-duplicates (append (c-lang-const c-class-decl-kwds
)
1969 (c-lang-const c-brace-list-decl-kwds
)
1970 (c-lang-const c-other-block-decl-kwds
)
1971 (c-lang-const c-typedef-decl-kwds
)
1972 (c-lang-const c-typeless-decl-kwds
)
1973 (c-lang-const c-modifier-kwds
)
1974 (c-lang-const c-other-decl-kwds
)
1975 (c-lang-const c-decl-start-kwds
)
1976 (c-lang-const c-decl-hangon-kwds
))
1977 :test
'string-equal
))
1979 (c-lang-defconst c-prefix-spec-kwds-re
1980 ;; Adorned regexp of `c-prefix-spec-kwds'.
1981 t
(c-make-keywords-re t
(c-lang-const c-prefix-spec-kwds
)))
1983 (c-lang-defvar c-prefix-spec-kwds-re
(c-lang-const c-prefix-spec-kwds-re
))
1985 (c-lang-defconst c-specifier-key
1986 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
1987 ;; ambiguous with types or type prefixes. These are the keywords (like
1988 ;; extern, namespace, but NOT template) that can modify a declaration.
1989 t
(c-make-keywords-re t
1990 (set-difference (c-lang-const c-prefix-spec-kwds
)
1991 (append (c-lang-const c-type-start-kwds
)
1992 (c-lang-const c-
<>-arglist-kwds
))
1993 :test
'string-equal
)))
1994 (c-lang-defvar c-specifier-key
(c-lang-const c-specifier-key
))
1996 (c-lang-defconst c-postfix-spec-kwds
1997 ;; Keywords that can occur after argument list of a function header
1998 ;; declaration, i.e. in the "K&R region".
1999 t
(append (c-lang-const c-postfix-decl-spec-kwds
)
2000 (c-lang-const c-decl-hangon-kwds
)))
2002 (c-lang-defconst c-not-decl-init-keywords
2003 ;; Adorned regexp matching all keywords that can't appear at the
2004 ;; start of a declaration.
2005 t
(c-make-keywords-re t
2006 (set-difference (c-lang-const c-keywords
)
2007 (append (c-lang-const c-type-start-kwds
)
2008 (c-lang-const c-prefix-spec-kwds
))
2009 :test
'string-equal
)))
2010 (c-lang-defvar c-not-decl-init-keywords
2011 (c-lang-const c-not-decl-init-keywords
))
2013 (c-lang-defconst c-not-primitive-type-keywords
2014 "List of all keywords apart from primitive types (like \"int\")."
2015 t
(set-difference (c-lang-const c-keywords
)
2016 (c-lang-const c-primitive-type-kwds
)
2017 :test
'string-equal
)
2018 ;; The "more" for C++ is the QT keyword (as in "more slots:").
2019 ;; This variable is intended for use in c-beginning-of-statement-1.
2020 c
++ (append (c-lang-const c-not-primitive-type-keywords
) '("more")))
2022 (c-lang-defconst c-not-primitive-type-keywords-regexp
2023 t
(c-make-keywords-re t
2024 (c-lang-const c-not-primitive-type-keywords
)))
2025 (c-lang-defvar c-not-primitive-type-keywords-regexp
2026 (c-lang-const c-not-primitive-type-keywords-regexp
))
2028 (c-lang-defconst c-protection-kwds
2029 "Access protection label keywords in classes."
2031 c
++ '("private" "protected" "public")
2032 objc
'("@private" "@protected" "@public"))
2034 (c-lang-defconst c-block-decls-with-vars
2035 "Keywords introducing declarations that can contain a block which
2036 might be followed by variable declarations, e.g. like \"foo\" in
2037 \"class Foo { ... } foo;\". So if there is a block in a declaration
2038 like that, it ends with the following ';' and not right away.
2040 The keywords on list are assumed to also be present on one of the
2041 `*-decl-kwds' lists."
2043 (c objc
) '("struct" "union" "enum" "typedef")
2044 c
++ '("class" "struct" "union" "enum" "typedef"))
2046 (c-lang-defconst c-opt-block-decls-with-vars-key
2047 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
2048 ;; languages without such constructs.
2049 t
(and (c-lang-const c-block-decls-with-vars
)
2050 (c-make-keywords-re t
(c-lang-const c-block-decls-with-vars
))))
2051 (c-lang-defvar c-opt-block-decls-with-vars-key
2052 (c-lang-const c-opt-block-decls-with-vars-key
))
2054 (c-lang-defconst c-postfix-decl-spec-kwds
2055 "Keywords introducing extra declaration specifiers in the region
2056 between the header and the body \(i.e. the \"K&R-region\") in
2059 java
'("extends" "implements" "throws")
2060 idl
'("context" "getraises" "manages" "primarykey" "raises" "setraises"
2063 "as" "const" "implements" "of" "ref"))
2065 (c-lang-defconst c-postfix-decl-spec-key
2066 ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
2067 t
(c-make-keywords-re t
(c-lang-const c-postfix-decl-spec-kwds
)))
2068 (c-lang-defvar c-postfix-decl-spec-key
2069 (c-lang-const c-postfix-decl-spec-key
))
2071 (c-lang-defconst c-nonsymbol-sexp-kwds
2072 "Keywords that may be followed by a nonsymbol sexp before whatever
2073 construct it's part of continues."
2075 (c c
++ objc
) '("extern"))
2077 (c-lang-defconst c-type-list-kwds
2078 "Keywords that may be followed by a comma separated list of type
2079 identifiers, where each optionally can be prefixed by keywords. (Can
2080 also be used for the special case when the list can contain only one
2083 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
2084 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
2085 There's also no reason to add keywords that prefixes a normal
2086 declaration consisting of a type followed by a declarator (list), so
2087 the keywords on `c-modifier-kwds' should normally not be listed here
2090 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2091 or variable identifier (that's being defined)."
2095 java
'("import" "new" "extends" "super" "implements" "throws")
2096 idl
'("manages" "native" "primarykey" "supports"
2098 "as" "implements" "of" "scope")
2101 (c-lang-defconst c-ref-list-kwds
2102 "Keywords that may be followed by a comma separated list of
2103 reference (i.e. namespace/scope/module) identifiers, where each
2104 optionally can be prefixed by keywords. (Can also be used for the
2105 special case when the list can contain only one element.) Assumed to
2106 be mutually exclusive with `c-type-list-kwds'.
2108 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2109 or variable identifier (that's being defined)."
2113 idl
'("import" "module"
2118 (c-lang-defconst c-colon-type-list-kwds
2119 "Keywords that may be followed (not necessarily directly) by a colon
2120 and then a comma separated list of type identifiers, where each
2121 optionally can be prefixed by keywords. (Can also be used for the
2122 special case when the list can contain only one element.)"
2124 c
++ '("class" "struct")
2125 idl
'("component" "eventtype" "home" "interface" "valuetype"
2127 "storagehome" "storagetype"))
2129 (c-lang-defconst c-colon-type-list-re
2130 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
2131 forward to the colon. The end of the match is assumed to be directly
2132 after the colon, so the regexp should end with \":\". Must be a
2133 regexp if `c-colon-type-list-kwds' isn't nil."
2134 t
(if (c-lang-const c-colon-type-list-kwds
)
2135 ;; Disallow various common punctuation chars that can't come
2136 ;; before the ":" that starts the inherit list after "class"
2137 ;; or "struct" in C++. (Also used as default for other
2139 "[^\]\[{}();,/#=:]*:"))
2140 (c-lang-defvar c-colon-type-list-re
(c-lang-const c-colon-type-list-re
))
2142 (c-lang-defconst c-paren-nontype-kwds
2143 "Keywords that may be followed by a parenthesis expression that doesn't
2144 contain type identifiers."
2146 (c c
++) '(;; GCC extension.
2151 (c-lang-defconst c-paren-type-kwds
2152 "Keywords that may be followed by a parenthesis expression containing
2153 type identifiers separated by arbitrary tokens."
2158 pike
'("array" "function" "int" "mapping" "multiset" "object" "program"))
2160 (c-lang-defconst c-paren-any-kwds
2161 t
(cl-delete-duplicates (append (c-lang-const c-paren-nontype-kwds
)
2162 (c-lang-const c-paren-type-kwds
))
2163 :test
'string-equal
))
2165 (c-lang-defconst c-
<>-type-kwds
2166 "Keywords that may be followed by an angle bracket expression
2167 containing type identifiers separated by \",\". The difference from
2168 `c-<>-arglist-kwds' is that unknown names are taken to be types and
2169 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
2177 (c-lang-defconst c-
<>-arglist-kwds
2178 "Keywords that can be followed by a C++ style template arglist; see
2179 `c-recognize-<>-arglists' for details. That language constant is
2180 assumed to be set if this isn't nil."
2183 idl
'("fixed" "string" "wstring"))
2185 (c-lang-defconst c-
<>-sexp-kwds
2186 ;; All keywords that can be followed by an angle bracket sexp.
2187 t
(cl-delete-duplicates (append (c-lang-const c-
<>-type-kwds
)
2188 (c-lang-const c-
<>-arglist-kwds
))
2189 :test
'string-equal
))
2191 (c-lang-defconst c-opt-
<>-sexp-key
2192 ;; Adorned regexp matching keywords that can be followed by an angle
2193 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
2194 t
(c-make-keywords-re t
(c-lang-const c-
<>-sexp-kwds
)))
2195 (c-lang-defvar c-opt-
<>-sexp-key
(c-lang-const c-opt-
<>-sexp-key
))
2197 (c-lang-defconst c-brace-id-list-kwds
2198 "Keywords that may be followed by a brace block containing a comma
2199 separated list of identifier definitions, i.e. like the list of
2200 identifiers that follows the type in a normal declaration."
2201 t
(c-lang-const c-brace-list-decl-kwds
))
2203 (c-lang-defconst c-block-stmt-1-kwds
2204 "Statement keywords followed directly by a substatement."
2206 c
++ '("do" "else" "try")
2207 objc
'("do" "else" "@finally" "@try")
2208 java
'("do" "else" "finally" "try")
2211 (c-lang-defconst c-block-stmt-1-key
2212 ;; Regexp matching the start of any statement followed directly by a
2213 ;; substatement (doesn't match a bare block, however).
2214 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-kwds
)))
2215 (c-lang-defvar c-block-stmt-1-key
(c-lang-const c-block-stmt-1-key
))
2217 (c-lang-defconst c-block-stmt-1-2-kwds
2218 "Statement keywords optionally followed by a paren sexp.
2219 Keywords here should also be in `c-block-stmt-1-kwds'."
2223 (c-lang-defconst c-block-stmt-1-2-key
2224 ;; Regexp matching the start of a statement which may be followed by a
2225 ;; paren sexp and will then be followed by a substatement.
2226 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-2-kwds
)))
2227 (c-lang-defvar c-block-stmt-1-2-key
(c-lang-const c-block-stmt-1-2-key
))
2229 (c-lang-defconst c-block-stmt-2-kwds
2230 "Statement keywords followed by a paren sexp and then by a substatement."
2231 t
'("for" "if" "switch" "while")
2232 c
++ '("for" "if" "switch" "while" "catch")
2233 objc
'("for" "if" "switch" "while" "@catch" "@synchronized")
2234 java
'("for" "if" "switch" "while" "catch" "synchronized")
2236 pike
'("for" "if" "switch" "while" "foreach")
2237 awk
'("for" "if" "while"))
2239 (c-lang-defconst c-block-stmt-2-key
2240 ;; Regexp matching the start of any statement followed by a paren sexp
2241 ;; and then by a substatement.
2242 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-2-kwds
)))
2243 (c-lang-defvar c-block-stmt-2-key
(c-lang-const c-block-stmt-2-key
))
2245 (c-lang-defconst c-block-stmt-kwds
2246 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
2247 t
(cl-delete-duplicates (append (c-lang-const c-block-stmt-1-kwds
)
2248 (c-lang-const c-block-stmt-2-kwds
))
2249 :test
'string-equal
))
2251 (c-lang-defconst c-opt-block-stmt-key
2252 ;; Regexp matching the start of any statement that has a
2253 ;; substatement (except a bare block). Nil in languages that
2254 ;; don't have such constructs.
2255 t
(if (or (c-lang-const c-block-stmt-1-kwds
)
2256 (c-lang-const c-block-stmt-2-kwds
))
2257 (c-make-keywords-re t
2258 (append (c-lang-const c-block-stmt-1-kwds
)
2259 (c-lang-const c-block-stmt-2-kwds
)))))
2260 (c-lang-defvar c-opt-block-stmt-key
(c-lang-const c-opt-block-stmt-key
))
2262 (c-lang-defconst c-simple-stmt-kwds
2263 "Statement keywords followed by an expression or nothing."
2264 t
'("break" "continue" "goto" "return")
2265 objc
'("break" "continue" "goto" "return" "@throw")
2266 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
2267 java
'("break" "continue" "goto" "return" "throw")
2269 pike
'("break" "continue" "return")
2270 awk
'(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
2271 "break" "continue" "return" "delete" "exit" "getline" "next"
2272 "nextfile" "print" "printf"))
2274 (c-lang-defconst c-simple-stmt-key
2275 ;; Adorned regexp matching `c-simple-stmt-kwds'.
2276 t
(c-make-keywords-re t
(c-lang-const c-simple-stmt-kwds
)))
2277 (c-lang-defvar c-simple-stmt-key
(c-lang-const c-simple-stmt-key
))
2279 (c-lang-defconst c-paren-stmt-kwds
2280 "Statement keywords followed by a parenthesis expression that
2281 nevertheless contains a list separated with ';' and not ','."
2285 (c-lang-defconst c-paren-stmt-key
2286 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2287 t
(c-make-keywords-re t
(c-lang-const c-paren-stmt-kwds
)))
2288 (c-lang-defvar c-paren-stmt-key
(c-lang-const c-paren-stmt-key
))
2290 (c-lang-defconst c-asm-stmt-kwds
2291 "Statement keywords followed by an assembler expression."
2293 (c c
++) '("asm" "__asm__")) ;; Not standard, but common.
2295 (c-lang-defconst c-opt-asm-stmt-key
2296 ;; Regexp matching the start of an assembler statement. Nil in
2297 ;; languages that don't support that.
2298 t
(if (c-lang-const c-asm-stmt-kwds
)
2299 (c-make-keywords-re t
(c-lang-const c-asm-stmt-kwds
))))
2300 (c-lang-defvar c-opt-asm-stmt-key
(c-lang-const c-opt-asm-stmt-key
))
2302 (c-lang-defconst c-case-kwds
2303 "The keyword\(s) which introduce a \"case\" like construct.
2304 This construct is \"<keyword> <expression> :\"."
2308 (c-lang-defconst c-case-kwds-regexp
2309 ;; Adorned regexp matching any "case"-like keyword.
2310 t
(c-make-keywords-re t
(c-lang-const c-case-kwds
)))
2311 (c-lang-defvar c-case-kwds-regexp
(c-lang-const c-case-kwds-regexp
))
2313 (c-lang-defconst c-label-kwds
2314 "Keywords introducing colon terminated labels in blocks."
2315 t
'("case" "default"))
2317 (c-lang-defconst c-label-kwds-regexp
2318 ;; Adorned regexp matching any keyword that introduces a label.
2319 t
(c-make-keywords-re t
(c-lang-const c-label-kwds
)))
2320 (c-lang-defvar c-label-kwds-regexp
(c-lang-const c-label-kwds-regexp
))
2322 (c-lang-defconst c-before-label-kwds
2323 "Keywords that might be followed by a label identifier."
2325 (java pike
) (append '("break" "continue")
2326 (c-lang-const c-before-label-kwds
))
2330 (c-lang-defconst c-constant-kwds
2331 "Keywords for constants."
2333 (c c
++) '("NULL" ;; Not a keyword, but practically works as one.
2334 "false" "true") ; Defined in C99.
2335 objc
'("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER")
2336 idl
'("TRUE" "FALSE")
2337 java
'("true" "false" "null") ; technically "literals", not keywords
2338 pike
'("UNDEFINED")) ;; Not a keyword, but practically works as one.
2340 (c-lang-defconst c-primary-expr-kwds
2341 "Keywords besides constants and operators that start primary expressions."
2343 c
++ '("operator" "this")
2344 objc
'("super" "self")
2346 pike
'("this")) ;; Not really a keyword, but practically works as one.
2348 (c-lang-defconst c-expr-kwds
2349 ;; Keywords that can occur anywhere in expressions. Built from
2350 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2351 t
(cl-delete-duplicates
2352 (append (c-lang-const c-primary-expr-kwds
)
2353 (c-filter-ops (c-lang-const c-operator-list
)
2355 "\\`\\(\\w\\|\\s_\\)+\\'"))
2356 :test
'string-equal
))
2358 (c-lang-defconst c-lambda-kwds
2359 "Keywords that start lambda constructs, i.e. function definitions in
2364 (c-lang-defconst c-inexpr-block-kwds
2365 "Keywords that start constructs followed by statement blocks which can
2366 be used in expressions \(the gcc extension for this in C and C++ is
2367 handled separately by `c-recognize-paren-inexpr-blocks')."
2369 pike
'("catch" "gauge"))
2371 (c-lang-defconst c-inexpr-class-kwds
2372 "Keywords that can start classes inside expressions."
2377 (c-lang-defconst c-inexpr-brace-list-kwds
2378 "Keywords that can start brace list blocks inside expressions.
2379 Note that Java specific rules are currently applied to tell this from
2380 `c-inexpr-class-kwds'."
2384 (c-lang-defconst c-opt-inexpr-brace-list-key
2385 ;; Regexp matching the start of a brace list in an expression, or
2386 ;; nil in languages that don't have such things. This should not
2387 ;; match brace lists recognized through `c-special-brace-lists'.
2388 t
(and (c-lang-const c-inexpr-brace-list-kwds
)
2389 (c-make-keywords-re t
(c-lang-const c-inexpr-brace-list-kwds
))))
2390 (c-lang-defvar c-opt-inexpr-brace-list-key
2391 (c-lang-const c-opt-inexpr-brace-list-key
))
2393 (c-lang-defconst c-decl-block-key
2394 ;; Regexp matching keywords in any construct that contain another
2395 ;; declaration level, i.e. that isn't followed by a function block
2396 ;; or brace list. When the first submatch matches, it's an
2397 ;; unambiguous construct, otherwise it's an ambiguous match that
2398 ;; might also be the return type of a function declaration.
2399 t
(let* ((decl-kwds (append (c-lang-const c-class-decl-kwds
)
2400 (c-lang-const c-other-block-decl-kwds
)
2401 (c-lang-const c-inexpr-class-kwds
)))
2402 (unambiguous (set-difference decl-kwds
2403 (c-lang-const c-type-start-kwds
)
2404 :test
'string-equal
))
2405 (ambiguous (intersection decl-kwds
2406 (c-lang-const c-type-start-kwds
)
2407 :test
'string-equal
)))
2409 (concat (c-make-keywords-re t unambiguous
)
2411 (c-make-keywords-re t ambiguous
))
2412 (c-make-keywords-re t unambiguous
))))
2413 (c-lang-defvar c-decl-block-key
(c-lang-const c-decl-block-key
))
2415 (c-lang-defconst c-bitfield-kwds
2416 "Keywords that can introduce bitfields."
2418 (c c
++ objc
) '("char" "int" "long" "signed" "unsigned"))
2420 (c-lang-defconst c-opt-bitfield-key
2421 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2422 ;; languages without bitfield support.
2424 (c c
++) (c-make-keywords-re t
(c-lang-const c-bitfield-kwds
)))
2425 (c-lang-defvar c-opt-bitfield-key
(c-lang-const c-opt-bitfield-key
))
2427 (c-lang-defconst c-other-kwds
2428 "Keywords not accounted for by any other `*-kwds' language constant."
2431 ;; In CORBA CIDL: (These are declaration keywords that never
2432 ;; can start a declaration.)
2433 "entity" "process" "service" "session" "storage"))
2436 ;;; Constants built from keywords.
2438 ;; Note: No `*-kwds' language constants may be defined below this point.
2441 (defconst c-kwds-lang-consts
2442 ;; List of all the language constants that contain keyword lists.
2444 (mapatoms (lambda (sym)
2445 (when (and (boundp sym
)
2446 (string-match "-kwds\\'" (symbol-name sym
)))
2447 ;; Make the list of globally interned symbols
2448 ;; instead of ones interned in `c-lang-constants'.
2449 (setq list
(cons (intern (symbol-name sym
)) list
))))
2453 (c-lang-defconst c-keywords
2454 ;; All keywords as a list.
2455 t
(cl-delete-duplicates
2456 (c-lang-defconst-eval-immediately
2457 `(append ,@(mapcar (lambda (kwds-lang-const)
2458 `(c-lang-const ,kwds-lang-const
))
2461 :test
'string-equal
))
2463 (c-lang-defconst c-keywords-regexp
2464 ;; All keywords as an adorned regexp.
2465 t
(c-make-keywords-re t
(c-lang-const c-keywords
)))
2466 (c-lang-defvar c-keywords-regexp
(c-lang-const c-keywords-regexp
))
2468 (c-lang-defconst c-keyword-member-alist
2469 ;; An alist with all the keywords in the cars. The cdr for each
2470 ;; keyword is a list of the symbols for the `*-kwds' lists that
2472 t
(let ((kwd-list-alist
2473 (c-lang-defconst-eval-immediately
2474 `(list ,@(mapcar (lambda (kwds-lang-const)
2475 `(cons ',kwds-lang-const
2476 (c-lang-const ,kwds-lang-const
)))
2477 c-kwds-lang-consts
))))
2478 lang-const kwd-list kwd
2480 (while kwd-list-alist
2481 (setq lang-const
(caar kwd-list-alist
)
2482 kwd-list
(cdar kwd-list-alist
)
2483 kwd-list-alist
(cdr kwd-list-alist
))
2485 (setq kwd
(car kwd-list
)
2486 kwd-list
(cdr kwd-list
))
2487 (unless (setq elem
(assoc kwd result-alist
))
2488 (setq result-alist
(cons (setq elem
(list kwd
)) result-alist
)))
2489 (unless (memq lang-const
(cdr elem
))
2490 (setcdr elem
(cons lang-const
(cdr elem
))))))
2493 (c-lang-defvar c-keywords-obarray
2494 ;; An obarray containing all keywords as symbols. The property list
2495 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2496 ;; lists it's a member of.
2498 ;; E.g. to see whether the string str contains a keyword on
2499 ;; `c-class-decl-kwds', one can do like this:
2500 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2501 ;; Which preferably is written using the associated functions in
2503 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2505 ;; The obarray is not stored directly as a language constant since
2506 ;; the printed representation for obarrays used in .elc files isn't
2509 (let* ((alist (c-lang-const c-keyword-member-alist
))
2511 (obarray (make-vector (* (length alist
) 2) 0)))
2513 (setq kwd
(caar alist
)
2514 lang-const-list
(cdar alist
)
2516 (setplist (intern kwd obarray
)
2517 ;; Emacs has an odd bug that causes `mapcan' to fail
2518 ;; with unintelligible errors. (XEmacs works.)
2519 ;;(mapcan (lambda (lang-const)
2520 ;; (list lang-const t))
2522 (apply 'nconc
(mapcar (lambda (lang-const)
2523 (list lang-const t
))
2527 (c-lang-defconst c-regular-keywords-regexp
2528 ;; Adorned regexp matching all keywords that should be fontified
2529 ;; with the keywords face. I.e. that aren't types or constants.
2530 t
(c-make-keywords-re t
2531 (set-difference (c-lang-const c-keywords
)
2532 (append (c-lang-const c-primitive-type-kwds
)
2533 (c-lang-const c-constant-kwds
))
2534 :test
'string-equal
)))
2535 (c-lang-defvar c-regular-keywords-regexp
2536 (c-lang-const c-regular-keywords-regexp
))
2538 (c-lang-defconst c-primary-expr-regexp
2539 ;; Regexp matching the start of any primary expression, i.e. any
2540 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2541 ;; exclude keywords; they are excluded afterwards unless the second
2542 ;; submatch matches. If the first but not the second submatch
2543 ;; matches then it is an ambiguous primary expression; it could also
2544 ;; be a match of e.g. an infix operator. (The case with ambiguous
2545 ;; keyword operators isn't handled.)
2547 t
(let* ((prefix-ops
2548 (c-filter-ops (c-lang-const c-operators
)
2551 ;; Filter out the special case prefix
2552 ;; operators that are close parens.
2553 (not (string-match "\\s)" op
)))))
2555 (nonkeyword-prefix-ops
2556 (c-filter-ops prefix-ops
2558 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2561 (c-filter-ops (c-lang-const c-operators
)
2566 right-assoc-sequence
)
2569 (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2571 :test
'string-equal
))
2572 (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2574 :test
'string-equal
)))
2578 ;; Take out all symbol class operators from `prefix-ops' and make the
2579 ;; first submatch from them together with `c-primary-expr-kwds'.
2580 (c-make-keywords-re t
2581 (append (c-lang-const c-primary-expr-kwds
)
2582 (set-difference prefix-ops nonkeyword-prefix-ops
2583 :test
'string-equal
)))
2586 ;; Match all ambiguous operators.
2587 (c-make-keywords-re nil
2588 (intersection nonkeyword-prefix-ops in-or-postfix-ops
2589 :test
'string-equal
))
2593 ;; Now match all other symbols.
2594 (c-lang-const c-symbol-start
)
2597 ;; The chars that can start integer and floating point
2602 ;; The unambiguous operators from `prefix-ops'.
2603 (c-make-keywords-re nil
2604 (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2605 :test
'string-equal
))
2608 ;; Match string and character literals.
2610 (if (memq 'gen-string-delim c-emacs-features
)
2613 (c-lang-defvar c-primary-expr-regexp
(c-lang-const c-primary-expr-regexp
))
2616 ;;; Additional constants for parser-level constructs.
2618 (c-lang-defconst c-decl-start-colon-kwd-re
2619 "Regexp matching a keyword that is followed by a colon, where
2620 the whole construct can precede a declaration.
2621 E.g. \"public:\" in C++."
2623 c
++ (c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
2624 (c-lang-defvar c-decl-start-colon-kwd-re
2625 (c-lang-const c-decl-start-colon-kwd-re
))
2627 (c-lang-defconst c-decl-prefix-re
2628 "Regexp matching something that might precede a declaration, cast or
2629 label, such as the last token of a preceding statement or declaration.
2630 This is used in the common situation where a declaration or cast
2631 doesn't start with any specific token that can be searched for.
2633 The regexp should not match bob; that is done implicitly. It can't
2634 require a match longer than one token. The end of the token is taken
2635 to be at the end of the first submatch, which is assumed to always
2636 match. It's undefined whether identifier syntax (see
2637 `c-identifier-syntax-table') is in effect or not. This regexp is
2638 assumed to be a superset of `c-label-prefix-re' if
2639 `c-recognize-colon-labels' is set.
2641 Besides this, `c-decl-start-kwds' is used to find declarations.
2643 Note: This variable together with `c-decl-start-re' and
2644 `c-decl-start-kwds' is only used to detect \"likely\"
2645 declaration/cast/label starts. I.e. they might produce more matches
2646 but should not miss anything (or else it's necessary to use text
2647 properties - see the next note). Wherever they match, the following
2648 construct is analyzed to see if it indeed is a declaration, cast or
2649 label. That analysis is not cheap, so it's important that not too
2650 many false matches are triggered.
2652 Note: If a declaration/cast/label start can't be detected with this
2653 variable, it's necessary to use the `c-type' text property with the
2654 value `c-decl-end' on the last char of the last token preceding the
2655 declaration. See the comment blurb at the start of cc-engine.el for
2658 ;; We match a sequence of characters to skip over things like \"};\"
2659 ;; more quickly. We match ")" in C for K&R region declarations, and
2660 ;; in all languages except Java for when a cpp macro definition
2661 ;; begins with a declaration.
2662 t
"\\([\{\}\(\);,]+\\)"
2663 java
"\\([\{\}\(;,<]+\\)"
2664 ;; Match "<" in C++ to get the first argument in a template arglist.
2665 ;; In that case there's an additional check in `c-find-decl-spots'
2666 ;; that it got open paren syntax. Match ":" to aid in picking up
2667 ;; "public:", etc. This involves additional checks in
2668 ;; `c-find-decl-prefix-search' to prevent a match of identifiers
2670 c
++ "\\([\{\}\(\);:,<]+\\)"
2671 ;; Additionally match the protection directives in Objective-C.
2672 ;; Note that this doesn't cope with the longer directives, which we
2673 ;; would have to match from start to end since they don't end with
2674 ;; any easily recognized characters.
2675 objc
(concat "\\([\{\}\(\);,]+\\|"
2676 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2678 ;; Pike is like C but we also match "[" for multiple value
2679 ;; assignments and type casts.
2680 pike
"\\([\{\}\(\)\[;,]+\\)")
2681 (c-lang-defvar c-decl-prefix-re
(c-lang-const c-decl-prefix-re
)
2684 (c-lang-defconst c-decl-start-re
2685 "Regexp matching the start of any declaration, cast or label.
2686 It's used on the token after the one `c-decl-prefix-re' matched. This
2687 regexp should not try to match those constructs accurately as it's
2688 only used as a sieve to avoid spending more time checking other
2690 t
(c-lang-const c-identifier-start
))
2691 (c-lang-defvar c-decl-start-re
(c-lang-const c-decl-start-re
))
2693 (c-lang-defconst c-decl-prefix-or-start-re
2694 ;; Regexp matching something that might precede or start a
2695 ;; declaration, cast or label.
2697 ;; If the first submatch matches, it's taken to match the end of a
2698 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2699 ;; It's built from `c-decl-prefix-re'.
2701 ;; If the first submatch did not match, the match of the whole
2702 ;; regexp is taken to be at the first token in the declaration.
2703 ;; `c-decl-start-re' is not checked in this case.
2705 ;; Design note: The reason the same regexp is used to match both
2706 ;; tokens that precede declarations and start them is to avoid an
2707 ;; extra regexp search from the previous declaration spot in
2708 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2709 ;; that it finds all declaration/cast/label starts in approximately
2710 ;; linear order, so we can't do the searches in two separate passes.
2711 t
(if (c-lang-const c-decl-start-kwds
)
2712 (concat (c-lang-const c-decl-prefix-re
)
2714 (c-make-keywords-re t
(c-lang-const c-decl-start-kwds
)))
2715 (c-lang-const c-decl-prefix-re
)))
2716 (c-lang-defvar c-decl-prefix-or-start-re
2717 (c-lang-const c-decl-prefix-or-start-re
)
2720 (c-lang-defconst c-cast-parens
2721 ;; List containing the paren characters that can open a cast, or nil in
2722 ;; languages without casts.
2723 t
(c-filter-ops (c-lang-const c-operators
)
2726 (lambda (op) (elt op
0))))
2727 (c-lang-defvar c-cast-parens
(c-lang-const c-cast-parens
))
2729 (c-lang-defconst c-block-prefix-disallowed-chars
2730 "List of syntactically relevant characters that never can occur before
2731 the open brace in any construct that contains a brace block, e.g. in
2732 the \"class Foo: public Bar\" part of:
2734 class Foo: public Bar {int x();} a, *b;
2736 If parens can occur, the chars inside those aren't filtered with this
2739 '<' and '>' should be disallowed even if angle bracket arglists can
2740 occur. That since the search function needs to stop at them anyway to
2741 ensure they are given paren syntax.
2743 This is used to skip backward from the open brace to find the region
2744 in which to look for a construct like \"class\", \"enum\",
2745 \"namespace\" or whatever. That skipping should be as tight as
2746 possible for good performance."
2748 ;; Default to all chars that only occurs in nonsymbol tokens outside
2751 (c-lang-const c-nonsymbol-token-char-list
)
2752 (c-filter-ops (append (c-lang-const c-identifier-ops
)
2754 (c-lang-const c-after-id-concat-ops
))))
2759 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2761 (setq res
(cons (aref op
(match-beginning 1)) res
)
2765 ;; Allow cpp operations (where applicable).
2766 t
(if (c-lang-const c-opt-cpp-prefix
)
2767 (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2769 (c-lang-const c-block-prefix-disallowed-chars
))
2771 ;; Allow ':' for inherit list starters.
2772 (c++ objc idl
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2775 ;; Allow ',' for multiple inherits.
2776 (c++ java
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2779 ;; Allow parentheses for anonymous inner classes in Java and class
2780 ;; initializer lists in Pike.
2781 (java pike
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2784 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2785 (c c
++ objc
) (set-difference (c-lang-const c-block-prefix-disallowed-chars
)
2788 (c-lang-defconst c-block-prefix-charset
2789 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2790 ;; for `c-syntactic-skip-backward'.
2791 t
(c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars
) t
))
2792 (c-lang-defvar c-block-prefix-charset
(c-lang-const c-block-prefix-charset
))
2794 (c-lang-defconst c-type-decl-prefix-key
2795 "Regexp matching the declarator operators that might precede the
2796 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
2797 regexp should match \"(\" if parentheses are valid in declarators.
2798 The end of the first submatch is taken as the end of the operator.
2799 Identifier syntax is in effect when this is matched \(see
2800 `c-identifier-syntax-table')."
2801 t
(if (c-lang-const c-type-modifier-kwds
)
2802 (concat (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>")
2803 ;; Default to a regexp that never matches.
2805 ;; Check that there's no "=" afterwards to avoid matching tokens
2807 (c objc
) (concat "\\("
2810 (c-lang-const c-type-decl-prefix-key
)
2816 (c-lang-const c-type-decl-prefix-key
)
2819 ;; If this matches there's special treatment in
2820 ;; `c-font-lock-declarators' and
2821 ;; `c-font-lock-declarations' that check for a
2822 ;; complete name followed by ":: *".
2823 (c-lang-const c-identifier-start
)
2827 pike
"\\(\\*\\)\\([^=]\\|$\\)")
2828 (c-lang-defvar c-type-decl-prefix-key
(c-lang-const c-type-decl-prefix-key
)
2831 (c-lang-defconst c-type-decl-suffix-key
2832 "Regexp matching the declarator operators that might follow after the
2833 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
2834 regexp should match \")\" if parentheses are valid in declarators. If
2835 it matches an open paren of some kind, the type declaration check
2836 continues at the corresponding close paren, otherwise the end of the
2837 first submatch is taken as the end of the operator. Identifier syntax
2838 is in effect when this is matched (see `c-identifier-syntax-table')."
2839 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
2840 ;; function argument list parenthesis.
2841 t
(if (c-lang-const c-type-modifier-kwds
)
2843 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>"
2846 (c c
++ objc
) (concat
2849 (if (c-lang-const c-type-modifier-kwds
)
2852 ;; "throw" in `c-type-modifier-kwds' is followed
2853 ;; by a parenthesis list, but no extra measures
2854 ;; are necessary to handle that.
2855 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
)
2859 java
"\\([\[\(\)]\\)"
2861 (c-lang-defvar c-type-decl-suffix-key
(c-lang-const c-type-decl-suffix-key
)
2864 (c-lang-defconst c-after-suffixed-type-decl-key
2865 "This regexp is matched after a declarator expression where
2866 `c-type-decl-suffix-key' has matched. If it matches then the
2867 construct is taken as a declaration. It's typically used to match the
2868 beginning of a function body or whatever might occur after the
2869 function header in a function declaration or definition. It's
2870 undefined whether identifier syntax (see `c-identifier-syntax-table')
2871 is in effect or not.
2873 Note that it's used in cases like after \"foo (bar)\" so it should
2874 only match when it's certain that it's a declaration, e.g., \"{\" but
2875 not \",\" or \";\"."
2877 ;; If K&R style declarations should be recognized then one could
2878 ;; consider to match the start of any symbol since we want to match
2879 ;; the start of the first declaration in the "K&R region". That
2880 ;; could however produce false matches on code like "FOO(bar) x"
2881 ;; where FOO is a cpp macro, so it's better to leave it out and rely
2882 ;; on the other heuristics in that case.
2883 t
(if (c-lang-const c-postfix-spec-kwds
)
2884 ;; Add on the keywords in `c-postfix-spec-kwds'.
2885 (concat (c-lang-const c-after-suffixed-type-decl-key
)
2887 (c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
2888 (c-lang-const c-after-suffixed-type-decl-key
))
2889 ;; Also match the colon that starts a base class initializer list in
2890 ;; C++. That can be confused with a function call before the colon
2891 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
2892 ;; match before such a thing (as a declaration-level construct;
2893 ;; matches inside arglist contexts are already excluded).
2895 (c-lang-defvar c-after-suffixed-type-decl-key
2896 (c-lang-const c-after-suffixed-type-decl-key
)
2899 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
2900 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
2901 ;; matches ";" and ",".
2902 t
(concat "\\(" (c-lang-const c-after-suffixed-type-decl-key
) "\\)"
2904 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
2905 (c-lang-const c-after-suffixed-type-maybe-decl-key
))
2907 (c-lang-defconst c-opt-type-concat-key
2908 "Regexp matching operators that concatenate types, e.g. the \"|\" in
2909 \"int|string\" in Pike. The end of the first submatch is taken as the
2910 end of the operator. nil in languages without such operators. It's
2911 undefined whether identifier syntax (see `c-identifier-syntax-table')
2912 is in effect or not."
2914 pike
"\\([|.&]\\)\\($\\|[^|.&]\\)")
2915 (c-lang-defvar c-opt-type-concat-key
(c-lang-const c-opt-type-concat-key
)
2918 (c-lang-defconst c-opt-type-suffix-key
2919 "Regexp matching operators that might follow after a type, or nil in
2920 languages that don't have such operators. The end of the first
2921 submatch is taken as the end of the operator. This should not match
2922 things like C++ template arglists if `c-recognize-<>-arglists' is set.
2923 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
2924 is in effect or not."
2926 (c c
++ objc pike
) "\\(\\.\\.\\.\\)"
2927 java
(concat "\\(\\[" (c-lang-const c-simple-ws
) "*\\]\\|\\.\\.\\.\\)"))
2928 (c-lang-defvar c-opt-type-suffix-key
(c-lang-const c-opt-type-suffix-key
))
2930 (c-lang-defvar c-known-type-key
2931 ;; Regexp matching the known type identifiers. This is initialized
2932 ;; from the type keywords and `*-font-lock-extra-types'. The first
2933 ;; submatch is the one that matches the type. Note that this regexp
2934 ;; assumes that symbol constituents like '_' and '$' have word
2937 (when (boundp (c-mode-symbol "font-lock-extra-types"))
2938 (c-mode-var "font-lock-extra-types")))
2941 (mapcar (lambda (re)
2942 (when (string-match "[][.*+?^$\\]" re
)
2947 (mapcar (lambda (re)
2948 (unless (string-match "[][.*+?^$\\]" re
)
2953 (append (list (c-make-keywords-re nil
2954 (append (c-lang-const c-primitive-type-kwds
)
2960 (c-lang-defconst c-special-brace-lists
2961 "List of open- and close-chars that makes up a pike-style brace list,
2962 i.e. for a ([Â ]) list there should be a cons (?\\[ . ?\\]) in this
2965 pike
'((?
{ . ?
}) (?\
[ . ?\
]) (?
< . ?
>)))
2966 (c-lang-defvar c-special-brace-lists
(c-lang-const c-special-brace-lists
))
2968 (c-lang-defconst c-recognize-knr-p
2969 "Non-nil means K&R style argument declarations are valid."
2972 (c-lang-defvar c-recognize-knr-p
(c-lang-const c-recognize-knr-p
))
2974 (c-lang-defconst c-recognize-typeless-decls
2975 "Non-nil means function declarations without return type should be
2976 recognized. That can introduce an ambiguity with parenthesized macro
2977 calls before a brace block. This setting does not affect declarations
2978 that are preceded by a declaration starting keyword, so
2979 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2981 (c c
++ objc java
) t
)
2982 (c-lang-defvar c-recognize-typeless-decls
2983 (c-lang-const c-recognize-typeless-decls
))
2985 (c-lang-defconst c-recognize-
<>-arglists
2986 "Non-nil means C++ style template arglists should be handled. More
2987 specifically, this means a comma separated list of types or
2988 expressions surrounded by \"<\" and \">\". It's always preceded by an
2989 identifier or one of the keywords on `c-<>-type-kwds' or
2990 `c-<>-arglist-kwds'. If there's an identifier before then the whole
2991 expression is considered to be a type."
2992 t
(or (consp (c-lang-const c-
<>-type-kwds
))
2993 (consp (c-lang-const c-
<>-arglist-kwds
)))
2995 (c-lang-defvar c-recognize-
<>-arglists
(c-lang-const c-recognize-
<>-arglists
))
2997 (c-lang-defconst c-enums-contain-decls
2998 "Non-nil means that an enum structure can contain declarations."
3001 (c-lang-defvar c-enums-contain-decls
(c-lang-const c-enums-contain-decls
))
3003 (c-lang-defconst c-recognize-paren-inits
3004 "Non-nil means that parenthesis style initializers exist,
3005 i.e. constructs like
3009 in addition to the more classic
3014 (c-lang-defvar c-recognize-paren-inits
(c-lang-const c-recognize-paren-inits
))
3016 (c-lang-defconst c-recognize-paren-inexpr-blocks
3017 "Non-nil to recognize gcc style in-expression blocks,
3018 i.e. compound statements surrounded by parentheses inside expressions."
3021 (c-lang-defvar c-recognize-paren-inexpr-blocks
3022 (c-lang-const c-recognize-paren-inexpr-blocks
))
3024 (c-lang-defconst c-opt-
<>-arglist-start
3025 ;; Regexp matching the start of angle bracket arglists in languages
3026 ;; where `c-recognize-<>-arglists' is set. Does not exclude
3027 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
3028 ;; assumed to surround the preceding symbol. The whole match is
3029 ;; assumed to end directly after the opening "<".
3030 t
(if (c-lang-const c-recognize-
<>-arglists
)
3032 (c-lang-const c-symbol-key
)
3034 (c-lang-const c-syntactic-ws
)
3036 (c-lang-defvar c-opt-
<>-arglist-start
(c-lang-const c-opt-
<>-arglist-start
))
3038 (c-lang-defconst c-opt-
<>-arglist-start-in-paren
3039 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
3040 ;; parens. The first submatch is assumed to surround
3041 ;; `c-opt-<>-arglist-start'.
3042 t
(if (c-lang-const c-opt-
<>-arglist-start
)
3044 (c-lang-const c-opt-
<>-arglist-start
)
3046 (c-lang-defvar c-opt-
<>-arglist-start-in-paren
3047 (c-lang-const c-opt-
<>-arglist-start-in-paren
))
3049 (c-lang-defconst c-opt-postfix-decl-spec-key
3050 ;; Regexp matching the beginning of a declaration specifier in the
3051 ;; region between the header and the body of a declaration.
3053 ;; TODO: This is currently not used uniformly; c++-mode and
3054 ;; java-mode each have their own ways of using it.
3057 (c-lang-const c-simple-ws
) "*"
3058 "\\(virtual" (c-lang-const c-simple-ws
) "+\\)?\\("
3059 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
3060 "\\)" (c-lang-const c-simple-ws
) "+"
3061 "\\(" (c-lang-const c-symbol-key
) "\\)")
3062 java
(c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
3063 (c-lang-defvar c-opt-postfix-decl-spec-key
3064 (c-lang-const c-opt-postfix-decl-spec-key
))
3066 (c-lang-defconst c-recognize-colon-labels
3067 "Non-nil if generic labels ending with \":\" should be recognized.
3068 That includes labels in code and access keys in classes. This does
3069 not apply to labels recognized by `c-label-kwds' and
3070 `c-opt-extra-label-key'."
3072 (c c
++ objc java pike
) t
)
3073 (c-lang-defvar c-recognize-colon-labels
3074 (c-lang-const c-recognize-colon-labels
))
3076 (c-lang-defconst c-label-prefix-re
3077 "Regexp like `c-decl-prefix-re' that matches any token that can precede
3078 a generic colon label. Not used if `c-recognize-colon-labels' is
3081 (c-lang-defvar c-label-prefix-re
3082 (c-lang-const c-label-prefix-re
))
3084 (c-lang-defconst c-nonlabel-token-key
3085 "Regexp matching things that can't occur in generic colon labels,
3086 neither in a statement nor in a declaration context. The regexp is
3087 tested at the beginning of every sexp in a suspected label,
3088 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
3090 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
3091 (c-make-keywords-re t
3092 (set-difference (c-lang-const c-keywords
)
3093 (append (c-lang-const c-label-kwds
)
3094 (c-lang-const c-protection-kwds
))
3095 :test
'string-equal
)))
3096 ;; Don't allow string literals, except in AWK. Character constants are OK.
3097 (c objc java pike idl
) (concat "\"\\|"
3098 (c-lang-const c-nonlabel-token-key
))
3099 ;; Also check for open parens in C++, to catch member init lists in
3100 ;; constructors. We normally allow it so that macros with arguments
3102 c
++ (concat "\\s\(\\|\"\\|" (c-lang-const c-nonlabel-token-key
)))
3103 (c-lang-defvar c-nonlabel-token-key
(c-lang-const c-nonlabel-token-key
))
3105 (c-lang-defconst c-nonlabel-token-2-key
3106 "Regexp matching things that can't occur two symbols before a colon in
3107 a label construct. This catches C++'s inheritance construct \"class foo
3108 : bar\". Only used if `c-recognize-colon-labels' is set."
3109 t
"\\<\\>" ; matches nothing
3110 c
++ (c-make-keywords-re t
'("class")))
3111 (c-lang-defvar c-nonlabel-token-2-key
(c-lang-const c-nonlabel-token-2-key
))
3113 (c-lang-defconst c-opt-extra-label-key
3114 "Optional regexp matching labels.
3115 Normally, labels are detected according to `c-nonlabel-token-key',
3116 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
3117 be used if there are additional labels that aren't recognized that
3120 objc
(c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
3121 (c-lang-defvar c-opt-extra-label-key
(c-lang-const c-opt-extra-label-key
))
3123 (c-lang-defconst c-opt-friend-key
3124 ;; Regexp describing friend declarations classes, or nil in
3125 ;; languages that don't have such things.
3127 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
3128 ;; template skipping isn't done properly. This will disappear soon.
3130 c
++ (concat "friend" (c-lang-const c-simple-ws
) "+"
3133 (c-lang-const c-simple-ws
) "*"
3135 (c-lang-const c-simple-ws
) "*"
3137 (c-lang-const c-simple-ws
) "+")))
3138 (c-lang-defvar c-opt-friend-key
(c-lang-const c-opt-friend-key
))
3140 (c-lang-defconst c-opt-method-key
3141 ;; Special regexp to match the start of Objective-C methods. The
3142 ;; first submatch is assumed to end after the + or - key.
3145 ;; TODO: Ought to use a better method than anchoring on bol.
3148 (c-lang-const c-simple-ws
) "*"
3149 (concat "\\(" ; Return type.
3151 (c-lang-const c-simple-ws
) "*"
3153 "\\(" (c-lang-const c-symbol-key
) "\\)"))
3154 (c-lang-defvar c-opt-method-key
(c-lang-const c-opt-method-key
))
3156 (c-lang-defconst c-type-decl-end-used
3157 ;; Must be set in buffers where the `c-type' text property might be
3158 ;; used with the value `c-decl-end'.
3160 ;; `c-decl-end' is used to mark the ends of labels and access keys
3161 ;; to make interactive refontification work better.
3162 t
(or (c-lang-const c-recognize-colon-labels
)
3163 (and (c-lang-const c-label-kwds
) t
))
3164 ;; `c-decl-end' is used to mark the end of the @-style directives in
3167 (c-lang-defvar c-type-decl-end-used
(c-lang-const c-type-decl-end-used
))
3170 ;;; Wrap up the `c-lang-defvar' system.
3172 ;; Compile in the list of language variables that has been collected
3173 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
3174 ;; first element of each is nil.
3175 (defconst c-lang-variable-inits
(cc-eval-when-compile c-lang-variable-inits
))
3176 (defconst c-emacs-variable-inits
(cc-eval-when-compile c-emacs-variable-inits
))
3178 ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
3179 ;; These are typically standard emacs variables such as `comment-start'.
3180 (defmacro c-make-emacs-variables-local
()
3182 ,@(mapcar (lambda (init)
3183 `(make-local-variable ',(car init
)))
3184 (cdr c-emacs-variable-inits
))))
3186 (defun c-make-init-lang-vars-fun (mode)
3187 "Create a function that initializes all the language dependent variables
3190 This function should be evaluated at compile time, so that the
3191 function it returns is byte compiled with all the evaluated results
3192 from the language constants. Use the `c-init-language-vars' macro to
3193 accomplish that conveniently."
3195 (if (and (not load-in-progress
)
3196 (boundp 'byte-compile-dest-file
)
3197 (stringp byte-compile-dest-file
))
3199 ;; No need to byte compile this lambda since the byte compiler is
3200 ;; smart enough to detect the `funcall' construct in the
3201 ;; `c-init-language-vars' macro below and compile it all straight
3202 ;; into the function that contains `c-init-language-vars'.
3205 ;; This let sets up the context for `c-mode-var' and similar
3206 ;; that could be in the result from `macroexpand-all'.
3207 (let ((c-buffer-is-cc-mode ',mode
)
3208 current-var source-eval
)
3209 (c-make-emacs-variables-local)
3212 (if (eq c-version-sym
',c-version-sym
)
3213 (setq ,@(let ((c-buffer-is-cc-mode mode
)
3214 (c-lang-const-expansion 'immediate
))
3215 ;; `c-lang-const' will expand to the evaluated
3216 ;; constant immediately in `macroexpand-all'
3220 `(current-var ',(car init
)
3221 ,(car init
) ,(macroexpand-all
3223 ;; Note: The following `append' copies the
3224 ;; first argument. That list is small, so
3225 ;; this doesn't matter too much.
3226 (append (cdr c-emacs-variable-inits
)
3227 (cdr c-lang-variable-inits
)))))
3229 ;; This diagnostic message isn't useful for end
3230 ;; users, so it's disabled.
3231 ;;(unless (get ',mode 'c-has-warned-lang-consts)
3232 ;; (message ,(concat "%s compiled with CC Mode %s "
3233 ;; "but loaded with %s - evaluating "
3234 ;; "language constants from source")
3235 ;; ',mode ,c-version c-version)
3236 ;; (put ',mode 'c-has-warned-lang-consts t))
3238 (setq source-eval t
)
3239 (let ((init ',(append (cdr c-emacs-variable-inits
)
3240 (cdr c-lang-variable-inits
))))
3242 (setq current-var
(caar init
))
3243 (set (caar init
) (eval (cadar init
)))
3244 (setq init
(cdr init
)))))
3248 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
3252 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
3253 ',mode
,c-version c-version
)
3256 (signal (car err
) (cdr err
)))))))
3258 ;; Being evaluated from source. Always use the dynamic method to
3259 ;; work well when `c-lang-defvar's in this file are reevaluated
3263 (let ((c-buffer-is-cc-mode ',mode
)
3264 (init (append (cdr c-emacs-variable-inits
)
3265 (cdr c-lang-variable-inits
)))
3267 (c-make-emacs-variables-local)
3271 (setq current-var
(caar init
))
3272 (set (caar init
) (eval (cadar init
)))
3273 (setq init
(cdr init
)))
3278 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
3280 (signal (car err
) (cdr err
)))))))
3283 (defmacro c-init-language-vars
(mode)
3284 "Initialize all the language dependent variables for the given mode.
3285 This macro is expanded at compile time to a form tailored for the mode
3286 in question, so MODE must be a constant. Therefore MODE is not
3287 evaluated and should not be quoted."
3288 `(funcall ,(c-make-init-lang-vars-fun mode
)))
3291 (cc-provide 'cc-langs
)
3293 ;;; cc-langs.el ends here