1 ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
3 ;; Copyright (C) 1985, 1987, 1992-2017 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 _
))))
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 (cc-external-require (if (eq c--cl-library
'cl-lib
) 'cl-lib
'cl
))
136 ;;; Setup for the `c-lang-defvar' system.
139 ;; These are used to collect the init forms from the subsequent
140 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
141 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
142 ;; and `make-variable-buffer-local's in cc-engine and
143 ;; `make-local-variable's in `c-init-language-vars-for'.
144 (defvar c-lang-variable-inits nil
)
145 (defvar c-lang-variable-inits-tail nil
)
146 (setq c-lang-variable-inits
(list nil
)
147 c-lang-variable-inits-tail c-lang-variable-inits
)
148 (defvar c-emacs-variable-inits nil
)
149 (defvar c-emacs-variable-inits-tail nil
)
150 (setq c-emacs-variable-inits
(list nil
)
151 c-emacs-variable-inits-tail c-emacs-variable-inits
))
153 (defmacro c-lang-defvar
(var val
&optional doc
)
154 "Declares the buffer local variable VAR to get the value VAL. VAL is
155 evaluated and assigned at mode initialization. More precisely, VAL is
156 evaluated and bound to VAR when the result from the macro
157 `c-init-language-vars' is evaluated.
159 `c-lang-const' is typically used in VAL to get the right value for the
160 language being initialized, and such calls will be macro expanded to
161 the evaluated constant value at compile time."
164 (eq (car-safe val
) 'c-lang-const
)
167 ;; Special case: If there's no docstring and the value is a
168 ;; simple (c-lang-const foo) where foo is the same name as VAR
169 ;; then take the docstring from the language constant foo.
170 (setq doc
(get (intern (symbol-name (nth 1 val
)) c-lang-constants
)
171 'variable-documentation
)))
175 (let ((elem (assq var
(cdr c-lang-variable-inits
))))
177 (setcdr elem
(list val doc
))
178 (setcdr c-lang-variable-inits-tail
(list (list var val doc
)))
179 (setq c-lang-variable-inits-tail
(cdr c-lang-variable-inits-tail
))))
181 ;; Return the symbol, like the other def* forms.
184 (defmacro c-lang-setvar
(var val
)
185 "Causes the variable VAR to be made buffer local and to get set to the
186 value VAL. VAL is evaluated and assigned at mode initialization. More
187 precisely, VAL is evaluated and bound to VAR when the result from the
188 macro `c-init-language-vars' is evaluated. VAR is typically a standard
189 Emacs variable like `comment-start'.
191 `c-lang-const' is typically used in VAL to get the right value for the
192 language being initialized, and such calls will be macro expanded to
193 the evaluated constant value at compile time."
194 (let ((elem (assq var
(cdr c-emacs-variable-inits
))))
196 (setcdr elem
(list val
)) ; Maybe remove "list", sometime. 2006-07-19
197 (setcdr c-emacs-variable-inits-tail
(list (list var val
)))
198 (setq c-emacs-variable-inits-tail
(cdr c-emacs-variable-inits-tail
))))
200 ;; Return the symbol, like the other def* forms.
203 (put 'c-lang-defvar
'lisp-indent-function
'defun
)
204 ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
206 (def-edebug-spec c-lang-defvar
207 (&define name def-form
&optional
&or
("quote" symbolp
) stringp
))
209 ;; Suppress "might not be defined at runtime" warning.
210 ;; This file is only used when compiling other cc files.
211 ;; These are defined in cl as aliases to the cl- versions.
212 ;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
213 ;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
216 ;; Some helper functions used when building the language constants.
218 (defun c-filter-ops (ops opgroup-filter op-filter
&optional xlate
)
219 ;; Extract a subset of the operators in the list OPS in a DWIM:ey
220 ;; way. The return value is a plain list of operators:
222 ;; OPS either has the structure of `c-operators', is a single
223 ;; group in `c-operators', or is a plain list of operators.
225 ;; OPGROUP-FILTER specifies how to select the operator groups. It
226 ;; can be t to choose all groups, a list of group type symbols
227 ;; (such as 'prefix) to accept, or a function which will be called
228 ;; with the group symbol for each group and should return non-nil
229 ;; if that group is to be included.
231 ;; OP-FILTER selects the operators. It is either t to select all
232 ;; operators, a string to select all operators for which `string-match'
233 ;; matches the operator with the string, or a function which will be
234 ;; called with the operator and should return non-nil when the operator
235 ;; is to be selected.
237 ;; If XLATE is given, it's a function which is called for each
238 ;; matching operator and its return value is collected instead.
239 ;; If it returns a list, the elements are spliced directly into
240 ;; the final result, which is returned as a list with duplicates
241 ;; removed using `equal'.
243 ;; `c-mode-syntax-table' for the current mode is in effect during
244 ;; the whole procedure.
245 (unless (listp (car-safe ops
))
246 (setq ops
(list ops
)))
247 (cond ((eq opgroup-filter t
)
248 (setq opgroup-filter
(lambda (_opgroup) t
)))
249 ((not (functionp opgroup-filter
))
250 (setq opgroup-filter
`(lambda (opgroup)
251 (memq opgroup
',opgroup-filter
)))))
252 (cond ((eq op-filter t
)
253 (setq op-filter
(lambda (_op) t
)))
255 (setq op-filter
`(lambda (op)
256 (string-match ,op-filter op
)))))
258 (setq xlate
'identity
))
259 (c-with-syntax-table (c-lang-const c-mode-syntax-table
)
260 (c--delete-duplicates
261 (c--mapcan (lambda (opgroup)
262 (when (if (symbolp (car opgroup
))
263 (when (funcall opgroup-filter
(car opgroup
))
264 (setq opgroup
(cdr opgroup
))
267 (c--mapcan (lambda (op)
268 (when (funcall op-filter op
)
269 (let ((res (funcall xlate op
)))
270 (if (listp res
) res
(list res
)))))
276 ;;; Various mode specific values that aren't language related.
278 (c-lang-defconst c-mode-menu
279 ;; The definition for the mode menu. The menu title is prepended to
280 ;; this before it's fed to `easy-menu-define'.
281 t
`(["Comment Out Region" comment-region
282 (c-fn-region-is-active-p)]
283 ["Uncomment Region" (comment-region (region-beginning)
285 (c-fn-region-is-active-p)]
286 ["Indent Expression" c-indent-exp
287 (memq (char-after) '(?\
( ?\
[ ?\
{))]
288 ["Indent Line or Region" c-indent-line-or-region t
]
289 ["Fill Comment Paragraph" c-fill-paragraph t
]
291 ["Backward Statement" c-beginning-of-statement t
]
292 ["Forward Statement" c-end-of-statement t
]
293 ,@(when (c-lang-const c-opt-cpp-prefix
)
294 ;; Only applicable if there's a cpp preprocessor.
295 `(["Up Conditional" c-up-conditional t
]
296 ["Backward Conditional" c-backward-conditional t
]
297 ["Forward Conditional" c-forward-conditional t
]
299 ["Macro Expand Region" c-macro-expand
300 (c-fn-region-is-active-p)]
301 ["Backslashify" c-backslash-region
302 (c-fn-region-is-active-p)]))
305 ["Set Style..." c-set-style t
]
306 ["Show Current Style Name" (message
310 ["Guess Style from this Buffer" c-guess-buffer-no-install t
]
311 ["Install the Last Guessed Style..." c-guess-install
312 (and c-guess-guessed-offsets-alist
313 c-guess-guessed-basic-offset
) ]
314 ["View the Last Guessed Style" c-guess-view
315 (and c-guess-guessed-offsets-alist
316 c-guess-guessed-basic-offset
) ])
319 ["Syntactic indentation" c-toggle-syntactic-indentation
320 :style toggle
:selected c-syntactic-indentation
]
321 ["Electric mode" c-toggle-electric-state
322 :style toggle
:selected c-electric-flag
]
323 ["Auto newline" c-toggle-auto-newline
324 :style toggle
:selected c-auto-newline
]
325 ["Hungry delete" c-toggle-hungry-state
326 :style toggle
:selected c-hungry-delete-key
]
327 ["Subword mode" c-subword-mode
328 :style toggle
:selected
(and (boundp 'c-subword-mode
)
334 (defun c-populate-syntax-table (table)
335 "Populate the given syntax table as necessary for a C-like language.
336 This includes setting \\=' and \" as string delimiters, and setting up
337 the comment syntax to handle both line style \"//\" and block style
338 \"/*\" \"*/\" comments."
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 ?
< "." table
)
347 (modify-syntax-entry ?
> "." table
)
348 (modify-syntax-entry ?
& "." table
)
349 (modify-syntax-entry ?|
"." table
)
350 (modify-syntax-entry ?
\' "\"" table
)
351 (modify-syntax-entry ?
\240 "." table
)
353 ;; Set up block and line oriented comments. The new C
354 ;; standard mandates both comment styles even in C, so since
355 ;; all languages now require dual comments, we make this the
359 ((memq '8-bit c-emacs-features
)
360 (modify-syntax-entry ?
/ ". 1456" table
)
361 (modify-syntax-entry ?
* ". 23" table
))
363 ((memq '1-bit c-emacs-features
)
364 (modify-syntax-entry ?
/ ". 124b" table
)
365 (modify-syntax-entry ?
* ". 23" table
))
367 (t (error "CC Mode is incompatible with this version of Emacs")))
369 (modify-syntax-entry ?
\n "> b" table
)
370 ;; Give CR the same syntax as newline, for selective-display
371 (modify-syntax-entry ?\^m
"> b" table
))
373 (c-lang-defconst c-make-mode-syntax-table
374 "Functions that generates the mode specific syntax tables.
375 The syntax tables aren't stored directly since they're quite large."
377 (let ((table (make-syntax-table)))
378 (c-populate-syntax-table table
)
379 ;; Mode specific syntaxes.
380 ,(cond ((or (c-major-mode-is 'objc-mode
) (c-major-mode-is 'java-mode
))
381 ;; Let '@' be part of symbols in ObjC to cope with
382 ;; its compiler directives as single keyword tokens.
383 ;; This is then necessary since it's assumed that
384 ;; every keyword is a single symbol.
385 `(modify-syntax-entry ?
@ "_" table
))
386 ((c-major-mode-is 'pike-mode
)
387 `(modify-syntax-entry ?
@ "." table
)))
390 (c-lang-defconst c-mode-syntax-table
391 ;; The syntax tables in evaluated form. Only used temporarily when
392 ;; the constants in this file are evaluated.
393 t
(funcall (c-lang-const c-make-mode-syntax-table
)))
395 (c-lang-defconst c
++-make-template-syntax-table
396 ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
397 ;; parenthesis characters. Used temporarily when template argument
398 ;; lists are parsed. Note that this encourages incorrect parsing of
399 ;; templates since they might contain normal operators that uses the
400 ;; '<' and '>' characters. Therefore this syntax table might go
401 ;; away when CC Mode handles templates correctly everywhere. WHILE
402 ;; THIS SYNTAX TABLE IS CURRENT, `c-parse-state' MUST _NOT_ BE
405 (java c
++) `(lambda ()
406 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
407 (modify-syntax-entry ?
< "(>" table
)
408 (modify-syntax-entry ?
> ")<" table
)
410 (c-lang-defvar c
++-template-syntax-table
411 (and (c-lang-const c
++-make-template-syntax-table
)
412 ;; The next eval remove a superfluous ' from '(lambda. This
413 ;; gets rid of compilation warnings.
414 (funcall (eval (c-lang-const c
++-make-template-syntax-table
)))))
416 (c-lang-defconst c-make-no-parens-syntax-table
417 ;; A variant of the standard syntax table which is used to find matching
418 ;; "<"s and ">"s which have been marked as parens using syntax table
419 ;; properties. The other paren characters (e.g. "{", ")" "]") are given a
420 ;; non-paren syntax here. so that the list commands will work on "< ... >"
421 ;; even when there's unbalanced other parens inside them.
423 ;; This variable is nil for languages which don't have template stuff.
424 t
(if (c-lang-const c-recognize-
<>-arglists
)
426 ;(if (c-lang-const c-recognize-<>-arglists)
427 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table
))))
428 (modify-syntax-entry ?\
( "." table
)
429 (modify-syntax-entry ?\
) "." table
)
430 (modify-syntax-entry ?\
[ "." table
)
431 (modify-syntax-entry ?\
] "." table
)
432 (modify-syntax-entry ?\
{ "." table
)
433 (modify-syntax-entry ?\
} "." table
)
435 (c-lang-defvar c-no-parens-syntax-table
436 (and (c-lang-const c-make-no-parens-syntax-table
)
437 ;; See comment in `c++template-syntax-table' about the next `eval'.
438 (funcall (eval (c-lang-const c-make-no-parens-syntax-table
)))))
440 (c-lang-defconst c-identifier-syntax-modifications
441 "A list that describes the modifications that should be done to the
442 mode syntax table to get a syntax table that matches all identifiers
443 and keywords as words.
445 The list is just like the one used in `font-lock-defaults': Each
446 element is a cons where the car is the character to modify and the cdr
447 the new syntax, as accepted by `modify-syntax-entry'."
448 ;; The $ character is not allowed in most languages (one exception
449 ;; is Java which allows it for legacy reasons) but we still classify
450 ;; it as an identifier character since it's often used in various
451 ;; machine generated identifiers.
452 t
'((?_ .
"w") (?$ .
"w"))
453 (objc java
) (append '((?
@ .
"w"))
454 (c-lang-const c-identifier-syntax-modifications
))
456 (c-lang-defvar c-identifier-syntax-modifications
457 (c-lang-const c-identifier-syntax-modifications
))
459 (c-lang-defvar c-identifier-syntax-table
460 (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
461 (mods c-identifier-syntax-modifications
)
466 (modify-syntax-entry (car mod
) (cdr mod
) table
))
468 "Syntax table built on the mode syntax table but additionally
469 classifies symbol constituents like `_' and `$' as word constituents,
470 so that all identifiers are recognized as words.")
472 (c-lang-defconst c-get-state-before-change-functions
473 ;; For documentation see the following c-lang-defvar of the same name.
474 ;; The value here may be a list of functions or a single function.
476 c
++ '(c-extend-region-for-CPP
477 c-before-change-check-raw-strings
478 c-before-change-check-
<>-operators
480 c-invalidate-macro-cache
482 c-parse-quotes-before-change
)
483 (c objc
) '(c-extend-region-for-CPP
485 c-invalidate-macro-cache
487 c-parse-quotes-before-change
)
488 java
'c-parse-quotes-before-change
489 ;; 'c-before-change-check-<>-operators
490 awk
'c-awk-record-region-clear-NL
)
491 (c-lang-defvar c-get-state-before-change-functions
492 (let ((fs (c-lang-const c-get-state-before-change-functions
)))
496 "If non-nil, a list of functions called from c-before-change-hook.
497 Typically these will record enough state to allow
498 `c-before-font-lock-function' to extend the region to fontify,
499 and may do such things as removing text-properties which must be
502 These functions will be run in the order given. Each of them
503 takes 2 parameters, the BEG and END supplied to every
504 before-change function; on entry, the buffer will have been
505 widened and match-data will have been saved; point is undefined
506 on both entry and exit; the return value is ignored.
508 The functions are called even when font locking isn't enabled.
510 When the mode is initialized, the functions are called with
511 parameters \(point-min) and \(point-max).")
513 (c-lang-defconst c-before-font-lock-functions
514 ;; For documentation see the following c-lang-defvar of the same name.
515 ;; The value here may be a list of functions or a single function.
516 t
'(c-depropertize-new-text
517 c-change-expand-fl-region
)
518 (c objc
) '(c-depropertize-new-text
519 c-parse-quotes-after-change
520 c-extend-font-lock-region-for-macros
521 c-neutralize-syntax-in-and-mark-CPP
522 c-change-expand-fl-region
)
523 c
++ '(c-depropertize-new-text
524 c-parse-quotes-after-change
525 c-extend-font-lock-region-for-macros
526 c-after-change-re-mark-raw-strings
527 c-neutralize-syntax-in-and-mark-CPP
528 c-restore-
<>-properties
529 c-change-expand-fl-region
)
530 java
'(c-depropertize-new-text
531 c-parse-quotes-after-change
532 c-restore-
<>-properties
533 c-change-expand-fl-region
)
534 awk
'(c-depropertize-new-text
535 c-awk-extend-and-syntax-tablify-region
))
536 (c-lang-defvar c-before-font-lock-functions
537 (let ((fs (c-lang-const c-before-font-lock-functions
)))
541 "If non-nil, a list of functions called just before font locking.
542 Typically they will extend the region about to be fontified \(see
543 below) and will set `syntax-table' text properties on the region.
545 These functions will be run in the order given. Each of them
546 takes 3 parameters, the BEG, END, and OLD-LEN supplied to every
547 after-change function; point is undefined on both entry and exit;
548 on entry, the buffer will have been widened and match-data will
549 have been saved; the return value is ignored.
551 The functions may extend the region to be fontified by setting the
552 buffer local variables c-new-BEG and c-new-END.
554 The functions are called even when font locking is disabled.
556 When the mode is initialized, these functions are called with
557 parameters \(point-min), \(point-max) and <buffer size>.")
559 (c-lang-defconst c-before-context-fontification-functions
560 t
'c-context-expand-fl-region
562 ;; For documentation see the following c-lang-defvar of the same name.
563 ;; The value here may be a list of functions or a single function.
564 (c-lang-defvar c-before-context-fontification-functions
565 (let ((fs (c-lang-const c-before-context-fontification-functions
)))
569 "If non-nil, a list of functions called just before context (or
570 other non-change) fontification is done. Typically they will
573 These functions will be run in the order given. Each of them
574 takes 2 parameters, the BEG and END of the region to be
575 fontified. Point is undefined on both entry and exit. On entry,
576 the buffer will have been widened and match-data will have been
577 saved; the return value is a cons of the adjusted
578 region, (NEW-BEG . NEW-END).")
581 ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
582 (c-lang-defconst c-at-vsemi-p-fn
583 "Contains a function \"Is there a virtual semicolon at POS or point?\".
584 Such a function takes one optional parameter, a buffer position (defaults to
585 point), and returns nil or t. This variable contains nil for languages which
586 don't have EOL terminated statements. "
588 (c c
++ objc
) 'c-at-macro-vsemi-p
589 awk
'c-awk-at-vsemi-p
)
590 (c-lang-defvar c-at-vsemi-p-fn
(c-lang-const c-at-vsemi-p-fn
))
592 (c-lang-defconst c-vsemi-status-unknown-p-fn
593 "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
594 The (admittedly kludgy) purpose of such a function is to prevent an infinite
595 recursion in c-beginning-of-statement-1 when point starts at a `while' token.
596 The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
597 even indirectly. This variable contains nil for languages which don't have
598 EOL terminated statements."
600 (c c
++ objc
) 'c-macro-vsemi-status-unknown-p
601 awk
'c-awk-vsemi-status-unknown-p
)
602 (c-lang-defvar c-vsemi-status-unknown-p-fn
603 (c-lang-const c-vsemi-status-unknown-p-fn
))
606 ;;; Lexer-level syntax (identifiers, tokens etc).
608 (c-lang-defconst c-has-bitfields
609 "Whether the language has bitfield declarations."
612 (c-lang-defvar c-has-bitfields
(c-lang-const c-has-bitfields
))
614 (c-lang-defconst c-has-quoted-numbers
615 "Whether the language has numbers quoted like 4'294'967'295."
618 (c-lang-defvar c-has-quoted-numbers
(c-lang-const c-has-quoted-numbers
))
620 (c-lang-defconst c-modified-constant
621 "Regexp that matches a “modified” constant literal such as \"L\\='a\\='\",
622 a “long character”. In particular, this recognizes forms of constant
623 which `c-backward-sexp' needs to be called twice to move backwards over."
625 (c c
++ objc
) "L'\\([^\\'\t\f\n\r]\\|\\\\.\\)'")
626 ;; FIXME!!! Extend this to cover strings, if needed. 2008-04-11
627 (c-lang-defvar c-modified-constant
(c-lang-const c-modified-constant
))
629 (c-lang-defconst c-symbol-start
630 "Regexp that matches the start of a symbol, i.e. any identifier or
631 keyword. It's unspecified how far it matches. Does not contain a \\|
632 operator at the top level."
633 t
(concat "[" c-alpha
"_]")
634 java
(concat "[" c-alpha
"_@]")
635 objc
(concat "[" c-alpha
"_@]")
636 pike
(concat "[" c-alpha
"_`]"))
637 (c-lang-defvar c-symbol-start
(c-lang-const c-symbol-start
))
639 (c-lang-defconst c-symbol-chars
640 "Set of characters that can be part of a symbol.
641 This is of the form that fits inside [ ] in a regexp."
642 ;; Pike note: With the backquote identifiers this would include most
643 ;; operator chars too, but they are handled with other means instead.
644 t
(concat c-alnum
"_$")
645 objc
(concat c-alnum
"_$@"))
646 (c-lang-defvar c-symbol-chars
(c-lang-const c-symbol-chars
))
648 (c-lang-defconst c-symbol-char-key
649 "Regexp matching a sequence of at least one identifier character."
650 t
(concat "[" (c-lang-const c-symbol-chars
) "]+"))
651 (c-lang-defvar c-symbol-char-key
(c-lang-const c-symbol-char-key
))
653 (c-lang-defconst c-symbol-key
654 "Regexp matching identifiers and keywords (with submatch 0). Assumed
655 to match if `c-symbol-start' matches on the same position."
656 t
(concat (c-lang-const c-symbol-start
)
657 "[" (c-lang-const c-symbol-chars
) "]*")
659 ;; Use the value from C here since the operator backquote is
660 ;; covered by the other alternative.
661 (c-lang-const c-symbol-key c
)
663 (c-make-keywords-re nil
664 (c-lang-const c-overloadable-operators
))))
665 (c-lang-defvar c-symbol-key
(c-lang-const c-symbol-key
))
667 (c-lang-defconst c-symbol-key-depth
668 ;; Number of regexp grouping parens in `c-symbol-key'.
669 t
(regexp-opt-depth (c-lang-const c-symbol-key
)))
671 (c-lang-defconst c-nonsymbol-chars
672 "This is the set of chars that can't be part of a symbol, i.e. the
673 negation of `c-symbol-chars'."
674 t
(concat "^" (c-lang-const c-symbol-chars
)))
675 (c-lang-defvar c-nonsymbol-chars
(c-lang-const c-nonsymbol-chars
))
677 (c-lang-defconst c-nonsymbol-key
678 "Regexp that matches any character that can't be part of a symbol.
679 It's usually appended to other regexps to avoid matching a prefix.
680 It's assumed to not contain any submatchers."
681 ;; The same thing regarding Unicode identifiers applies here as to
683 t
(concat "[" (c-lang-const c-nonsymbol-chars
) "]"))
685 (c-lang-defconst c-identifier-ops
686 "The operators that make up fully qualified identifiers. nil in
687 languages that don't have such things. See `c-operators' for a
688 description of the format. Binary operators can concatenate symbols,
689 e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
690 e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
692 This value is by default merged into `c-operators'."
694 c
++ '((prefix "~" "??-" "compl")
697 ;; Java has "." to concatenate identifiers but it's also used for
698 ;; normal indexing. There's special code in the Java font lock
699 ;; rules to fontify qualified identifiers based on the standard
700 ;; naming conventions. We still define "." here to make
701 ;; `c-forward-name' move over as long names as possible which is
702 ;; necessary to e.g. handle throws clauses correctly.
703 java
'((left-assoc "."))
704 idl
'((left-assoc "::")
706 pike
'((left-assoc "::")
710 (c-lang-defconst c-opt-identifier-concat-key
711 ;; Appendable adorned regexp matching the operators that join
712 ;; symbols to fully qualified identifiers, or nil in languages that
713 ;; don't have such things.
715 ;; This was a docstring constant in 5.30. It still works but is now
716 ;; considered internal - change `c-identifier-ops' instead.
717 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
718 '(left-assoc right-assoc
)
721 (c-make-keywords-re 'appendable ops
))))
722 (c-lang-defvar c-opt-identifier-concat-key
723 (c-lang-const c-opt-identifier-concat-key
))
725 (c-lang-defconst c-opt-identifier-concat-key-depth
726 ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
727 t
(regexp-opt-depth (c-lang-const c-opt-identifier-concat-key
)))
729 (c-lang-defconst c-opt-identifier-prefix-key
730 ;; Appendable adorned regexp matching operators that might precede
731 ;; an identifier and that are part of the identifier in that case.
732 ;; nil in languages without such things.
733 t
(let ((ops (c-filter-ops (c-lang-const c-identifier-ops
)
737 (c-make-keywords-re 'appendable ops
))))
739 (c-lang-defconst c-after-id-concat-ops
740 "Operators that can occur after a binary operator on `c-identifier-ops'
741 in identifiers. nil in languages that don't have such things.
743 Operators here should also have appropriate entries in `c-operators' -
744 it's not taken care of by default."
746 ;; '~' for destructors in C++, '*' for member pointers.
748 ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
749 ;; in import declarations. (This will also match bogus things like
750 ;; "foo.*bar" but we don't bother.)
753 (c-lang-defconst c-opt-after-id-concat-key
754 ;; Regexp that must match the token after
755 ;; `c-opt-identifier-concat-key' for it to be considered an
756 ;; identifier concatenation operator (which e.g. causes the
757 ;; preceding identifier to be fontified as a reference). Assumed to
758 ;; be a string if `c-opt-identifier-concat-key' is.
760 ;; This was a docstring constant in 5.30. It still works but is now
761 ;; considered internal - change `c-after-id-concat-ops' instead.
762 t
(concat (c-lang-const c-symbol-start
)
763 (if (c-lang-const c-after-id-concat-ops
)
764 (concat "\\|" (c-make-keywords-re 'appendable
765 (c-lang-const c-after-id-concat-ops
)))
768 (c-lang-defconst c-identifier-start
769 "Regexp that matches the start of an (optionally qualified) identifier.
770 It should also match all keywords. It's unspecified how far it
772 t
(concat (c-lang-const c-symbol-start
)
773 (if (c-lang-const c-opt-identifier-prefix-key
)
775 (c-lang-const c-opt-identifier-prefix-key
))
777 (c-lang-defvar c-identifier-start
(c-lang-const c-identifier-start
))
779 (c-lang-defconst c-identifier-key
780 "Regexp matching a fully qualified identifier, like \"A::B::c\" in
781 C++. It does not recognize the full range of syntactic whitespace
782 between the tokens; `c-forward-name' has to be used for that. It
783 should also not match identifiers containing parenthesis groupings,
784 e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
785 ;; This regexp is more complex than strictly necessary to ensure
786 ;; that it can be matched with a minimum of backtracking.
787 t
(concat (if (c-lang-const c-opt-identifier-prefix-key
)
790 (c-lang-const c-opt-identifier-prefix-key
)
791 (c-lang-const c-simple-ws
) "*"
794 "\\(" (c-lang-const c-symbol-key
) "\\)"
795 (if (c-lang-const c-opt-identifier-concat-key
)
798 (c-lang-const c-simple-ws
) "*"
799 (c-lang-const c-opt-identifier-concat-key
)
800 (c-lang-const c-simple-ws
) "*"
801 (if (c-lang-const c-after-id-concat-ops
)
804 (c-make-keywords-re 'appendable
805 (c-lang-const c-after-id-concat-ops
))
807 ;; For flexibility, consider the symbol match
808 ;; optional if we've hit a
809 ;; `c-after-id-concat-ops' operator. This is
810 ;; also necessary to handle the "*" that can
811 ;; end import declaration identifiers in Java.
813 (c-lang-const c-simple-ws
) "*"
814 "\\(" (c-lang-const c-symbol-key
) "\\)"
817 "\\(" (c-lang-const c-symbol-key
) "\\)"
819 (concat "\\(" (c-lang-const c-symbol-key
) "\\)"))
822 (c-lang-defvar c-identifier-key
(c-lang-const c-identifier-key
))
824 (c-lang-defconst c-identifier-last-sym-match
825 ;; This was a docstring constant in 5.30 but it's no longer used.
826 ;; It's only kept to avoid breaking third party code.
828 ;; Used to identify the submatch in `c-identifier-key' that
829 ;; surrounds the last symbol in the qualified identifier. It's a
830 ;; list of submatch numbers, of which the first that has a match is
831 ;; taken. It's assumed that at least one does when the regexp has
835 (c-lang-defconst c-string-escaped-newlines
836 "Set if the language support backslash escaped newlines inside string
840 (c-lang-defvar c-string-escaped-newlines
841 (c-lang-const c-string-escaped-newlines
))
843 (c-lang-defconst c-multiline-string-start-char
844 "Set if the language supports multiline string literals without escaped
845 newlines. If t, all string literals are multiline. If a character,
846 only literals where the open quote is immediately preceded by that
847 literal are multiline."
850 (c-lang-defvar c-multiline-string-start-char
851 (c-lang-const c-multiline-string-start-char
))
853 (c-lang-defconst c-opt-cpp-symbol
854 "The symbol which starts preprocessor constructs when in the margin."
857 (c-lang-defvar c-opt-cpp-symbol
(c-lang-const c-opt-cpp-symbol
))
859 (c-lang-defconst c-opt-cpp-prefix
860 "Regexp matching the prefix of a cpp directive in the languages that
861 normally use that macro preprocessor. Tested at bol or at boi.
862 Assumed to not contain any submatches or \\| operators."
863 ;; TODO (ACM, 2005-04-01). Amend the following to recognize escaped NLs;
864 ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
867 (c-lang-defvar c-opt-cpp-prefix
(c-lang-const c-opt-cpp-prefix
))
869 (c-lang-defconst c-anchored-cpp-prefix
870 "Regexp matching the prefix of a cpp directive anchored to BOL,
871 in the languages that have a macro preprocessor."
872 t
"^\\s *\\(#\\)\\s *"
874 (c-lang-defvar c-anchored-cpp-prefix
(c-lang-const c-anchored-cpp-prefix
))
876 (c-lang-defconst c-opt-cpp-start
877 "Regexp matching the prefix of a cpp directive including the directive
878 name, or nil in languages without preprocessor support. The first
879 submatch surrounds the directive name."
880 t
(if (c-lang-const c-opt-cpp-prefix
)
881 (concat (c-lang-const c-opt-cpp-prefix
)
882 "\\([" c-alnum
"]+\\)"))
883 ;; Pike, being a scripting language, recognizes hash-bangs too.
884 pike
(concat (c-lang-const c-opt-cpp-prefix
)
885 "\\([" c-alnum
"]+\\|!\\)"))
886 (c-lang-defvar c-opt-cpp-start
(c-lang-const c-opt-cpp-start
))
888 (c-lang-defconst c-cpp-message-directives
889 "List of cpp directives (without the prefix) that are followed by a
891 t
(if (c-lang-const c-opt-cpp-prefix
)
893 (c c
++ objc pike
) '("error" "warning"))
895 (c-lang-defconst c-cpp-include-directives
896 "List of cpp directives (without the prefix) that are followed by a
897 file name in angle brackets or quotes."
898 t
(if (c-lang-const c-opt-cpp-prefix
)
900 objc
'("include" "import"))
902 (c-lang-defconst c-opt-cpp-macro-define
903 "Cpp directive (without the prefix) that is followed by a macro
904 definition, or nil if the language doesn't have any."
905 t
(if (c-lang-const c-opt-cpp-prefix
)
907 (c-lang-defvar c-opt-cpp-macro-define
908 (c-lang-const c-opt-cpp-macro-define
))
910 (c-lang-defconst c-opt-cpp-macro-define-start
911 ;; Regexp matching everything up to the macro body of a cpp define, or the
912 ;; end of the logical line if there is none. Submatch 1 is the name of the
913 ;; macro. Set if c-opt-cpp-macro-define is.
914 t
(if (c-lang-const c-opt-cpp-macro-define
)
915 (concat (c-lang-const c-opt-cpp-prefix
)
916 (c-lang-const c-opt-cpp-macro-define
)
917 "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(([^)]*)\\)?"
919 "\\([ \t]\\|\\\\\n\\)*")))
920 (c-lang-defvar c-opt-cpp-macro-define-start
921 (c-lang-const c-opt-cpp-macro-define-start
))
923 (c-lang-defconst c-opt-cpp-macro-define-id
924 ;; Regexp matching everything up to the end of the identifier defined
926 t
(if (c-lang-const c-opt-cpp-macro-define
)
927 (concat (c-lang-const c-opt-cpp-prefix
) ; #
928 (c-lang-const c-opt-cpp-macro-define
) ; define
929 "[ \t]+\\(\\sw\\|_\\)+")))
930 (c-lang-defvar c-opt-cpp-macro-define-id
931 (c-lang-const c-opt-cpp-macro-define-id
))
933 (c-lang-defconst c-cpp-expr-directives
934 "List of cpp directives (without the prefix) that are followed by an
936 t
(if (c-lang-const c-opt-cpp-prefix
)
939 (c-lang-defconst c-cpp-expr-intro-re
940 "Regexp which matches the start of a CPP directive which contains an
941 expression, or nil if there aren't any in the language."
942 t
(if (c-lang-const c-cpp-expr-directives
)
944 (c-lang-const c-opt-cpp-prefix
)
945 (c-make-keywords-re t
(c-lang-const c-cpp-expr-directives
)))))
946 (c-lang-defvar c-cpp-expr-intro-re
947 (c-lang-const c-cpp-expr-intro-re
))
949 (c-lang-defconst c-cpp-expr-functions
950 "List of functions in cpp expressions."
951 t
(if (c-lang-const c-opt-cpp-prefix
)
953 pike
'("defined" "efun" "constant"))
955 (c-lang-defconst c-assignment-operators
956 "List of all assignment operators."
957 t
'("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
958 java
(append (c-lang-const c-assignment-operators
)
960 c
++ (append (c-lang-const c-assignment-operators
)
961 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
964 (c-lang-defconst c-operators
965 "List describing all operators, along with their precedence and
966 associativity. The order in the list corresponds to the precedence of
967 the operators: The operators in each element are a group with the same
968 precedence, and the group has higher precedence than the groups in all
969 following elements. The car of each element describes the type of the
970 operator group, and the cdr is a list of the operator tokens in it.
971 The operator group types are:
973 `prefix' Unary prefix operators.
974 `postfix' Unary postfix operators.
976 Unary postfix operators if and only if the chars have
978 `left-assoc' Binary left associative operators (i.e. a+b+c means (a+b)+c).
979 `right-assoc' Binary right associative operators (i.e. a=b=c means a=(b=c)).
980 `right-assoc-sequence'
981 Right associative operator that constitutes of a
982 sequence of tokens that separate expressions. All the
983 tokens in the group are in this case taken as
984 describing the sequence in one such operator, and the
985 order between them is therefore significant.
987 Operators containing a character with paren syntax are taken to match
988 with a corresponding open/close paren somewhere else. A postfix
989 operator with close paren syntax is taken to end a postfix expression
990 started somewhere earlier, rather than start a new one at point. Vice
991 versa for prefix operators with open paren syntax.
993 Note that operators like \".\" and \"->\" which in language references
994 often are described as postfix operators are considered binary here,
995 since CC Mode treats every identifier as an expression."
997 ;; There's currently no code in CC Mode that exploits all the info
998 ;; in this variable; precedence, associativity etc are present as a
999 ;; preparation for future work.
1001 ;; FIXME!!! C++11's "auto" operators "=" and "->" need to go in here
1002 ;; somewhere. 2012-03-24.
1004 t
`(;; Preprocessor.
1005 ,@(when (c-lang-const c-opt-cpp-prefix
)
1007 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1010 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1011 '("%:%:" "??=??=")))))
1014 ,@(c-lang-const c-identifier-ops
)
1015 ,@(cond ((or (c-major-mode-is 'c
++-mode
) (c-major-mode-is 'java-mode
))
1016 `((postfix-if-paren "<" ">"))) ; Templates.
1017 ((c-major-mode-is 'pike-mode
)
1018 `((prefix "global" "predef")))
1019 ((c-major-mode-is 'java-mode
)
1020 `((prefix "super"))))
1023 ,@(when (c-major-mode-is 'c
++-mode
)
1024 ;; The following need special treatment.
1025 `((prefix "dynamic_cast" "static_cast"
1026 "reinterpret_cast" "const_cast" "typeid"
1029 ,@(unless (c-major-mode-is 'java-mode
)
1031 (postfix "++" "--" "[" "]" "(" ")"
1032 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1033 '("<:" ":>" "??(" "??)")))
1036 (prefix "++" "--" "+" "-" "!" "~"
1037 ,@(when (c-major-mode-is 'c
++-mode
) '("not" "compl"))
1038 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1039 '("*" "&" "sizeof" "??-"))
1040 ,@(when (c-major-mode-is 'objc-mode
)
1041 '("@selector" "@protocol" "@encode"))
1042 ;; The following need special treatment.
1043 ,@(cond ((c-major-mode-is 'c
++-mode
)
1045 ((c-major-mode-is 'java-mode
)
1047 ((c-major-mode-is 'pike-mode
)
1048 '("class" "lambda" "catch" "throw" "gauge")))
1050 ,@(when (c-major-mode-is 'pike-mode
)
1051 '("[" "]"))) ; Type cast.
1053 ;; Member selection.
1054 ,@(when (c-major-mode-is 'c
++-mode
)
1055 `((left-assoc ".*" "->*")))
1058 (left-assoc "*" "/" "%")
1061 (left-assoc "+" "-")
1064 (left-assoc "<<" ">>"
1065 ,@(when (c-major-mode-is 'java-mode
)
1069 (left-assoc "<" ">" "<=" ">="
1070 ,@(when (c-major-mode-is 'java-mode
)
1074 (left-assoc "==" "!="
1075 ,@(when (c-major-mode-is 'c
++-mode
) '("not_eq")))
1079 ,@(when (c-major-mode-is 'c
++-mode
) '("bitand")))
1081 ;; Bitwise exclusive or.
1083 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1085 ,@(when (c-major-mode-is 'c
++-mode
) '("xor")))
1089 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1091 ,@(when (c-major-mode-is 'c
++-mode
) '("bitor")))
1095 ,@(when (c-major-mode-is 'c
++-mode
) '("and")))
1099 ,@(when (c-major-mode-is '(c-mode c
++-mode
))
1101 ,@(when (c-major-mode-is 'c
++-mode
) '("or")))
1104 (right-assoc-sequence "?" ":")
1107 (right-assoc ,@(c-lang-const c-assignment-operators
))
1110 ,@(when (c-major-mode-is 'c
++-mode
)
1111 '((prefix "throw")))
1116 ;; IDL got its own definition since it has a much smaller operator
1117 ;; set than the other languages.
1118 idl
`(;; Preprocessor.
1122 ,@(c-lang-const c-identifier-ops
)
1124 (prefix "+" "-" "~")
1126 (left-assoc "*" "/" "%")
1128 (left-assoc "+" "-")
1130 (left-assoc "<<" ">>")
1138 (c-lang-defconst c-operator-list
1139 ;; The operators as a flat list (without duplicates).
1140 t
(c-filter-ops (c-lang-const c-operators
) t t
))
1142 (c-lang-defconst c-overloadable-operators
1143 "List of the operators that are overloadable, in their \"identifier
1144 form\". See also `c-op-identifier-prefix'."
1146 c
++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
1148 "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
1149 "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
1150 "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
1151 "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
1152 "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
1153 "()" "[]" "<::>" "??(??)")
1154 ;; These work like identifiers in Pike.
1155 pike
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
1156 "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
1157 "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
1160 (c-lang-defconst c-overloadable-operators-regexp
1161 ;; Regexp tested after an "operator" token in C++.
1163 c
++ (c-make-keywords-re nil
(c-lang-const c-overloadable-operators
)))
1164 (c-lang-defvar c-overloadable-operators-regexp
1165 (c-lang-const c-overloadable-operators-regexp
))
1167 (c-lang-defconst c-opt-op-identifier-prefix
1168 "Regexp matching the token before the ones in
1169 `c-overloadable-operators' when operators are specified in their
1170 \"identifier form\". This typically matches \"operator\" in C++ where
1171 operator functions are specified as e.g. \"operator +\". It's nil in
1172 languages without operator functions or where the complete operator
1173 identifier is listed in `c-overloadable-operators'.
1175 This regexp is assumed to not match any non-operator identifier."
1177 c
++ (c-make-keywords-re t
'("operator")))
1178 (c-lang-defvar c-opt-op-identifier-prefix
1179 (c-lang-const c-opt-op-identifier-prefix
))
1181 ;; Note: the following alias is an old name which was a mis-spelling. It has
1182 ;; been corrected above and throughout cc-engine.el. It will be removed at
1183 ;; some release very shortly in the future. ACM, 2006-04-14.
1184 (defvaralias 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
)
1185 (make-obsolete-variable 'c-opt-op-identitier-prefix
'c-opt-op-identifier-prefix
1186 "CC Mode 5.31.4, 2006-04-14")
1188 (c-lang-defconst c-other-op-syntax-tokens
1189 "List of the tokens made up of characters in the punctuation or
1190 parenthesis syntax classes that have uses other than as expression
1192 t
'("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
1193 (c c
++ pike
) (append '("#" "##" ; Used by cpp.
1195 (c-lang-const c-other-op-syntax-tokens
))
1196 (c c
++) (append '("*") (c-lang-const c-other-op-syntax-tokens
))
1197 c
++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
1198 (c-lang-const c-other-op-syntax-tokens
))
1199 objc
(append '("#" "##" ; Used by cpp.
1201 (c-lang-const c-other-op-syntax-tokens
))
1202 idl
(append '("#" "##") ; Used by cpp.
1203 (c-lang-const c-other-op-syntax-tokens
))
1204 pike
(append '("..")
1205 (c-lang-const c-other-op-syntax-tokens
)
1206 (c-lang-const c-overloadable-operators
))
1207 awk
'("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
1209 (c-lang-defconst c-all-op-syntax-tokens
1210 ;; List of all tokens in the punctuation and parenthesis syntax
1212 t
(c--delete-duplicates (append (c-lang-const c-other-op-syntax-tokens
)
1213 (c-lang-const c-operator-list
))
1214 :test
'string-equal
))
1216 (c-lang-defconst c-nonsymbol-token-char-list
1217 ;; List containing all chars not in the word, symbol or
1218 ;; syntactically irrelevant syntax classes, i.e. all punctuation,
1219 ;; parenthesis and string delimiter chars.
1220 t
(c-with-syntax-table (c-lang-const c-mode-syntax-table
)
1221 ;; Only go through the chars in the printable ASCII range. No
1222 ;; language so far has 8-bit or widestring operators.
1223 (let (list (char 32))
1225 (or (memq (char-syntax char
) '(?w ?_ ?
< ?
> ?\
))
1226 (setq list
(cons (c-int-to-char char
) list
)))
1227 (setq char
(1+ char
)))
1230 (c-lang-defconst c-nonsymbol-token-regexp
1231 ;; Regexp matching all tokens in the punctuation and parenthesis
1232 ;; syntax classes. Note that this also matches ".", which can start
1234 t
(c-make-keywords-re nil
1235 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1237 "\\`\\(\\s.\\)+\\'")))
1238 (c-lang-defvar c-nonsymbol-token-regexp
1239 (c-lang-const c-nonsymbol-token-regexp
))
1241 (c-lang-defconst c-assignment-op-regexp
1242 ;; Regexp matching all assignment operators and only them. The
1243 ;; beginning of the first submatch is used to detect the end of the
1244 ;; token, along with the end of the whole match.
1245 t
(if (c-lang-const c-assignment-operators
)
1247 ;; Need special case for "=" since it's a prefix of "==".
1250 (c-make-keywords-re nil
1251 (c--set-difference (c-lang-const c-assignment-operators
)
1253 :test
'string-equal
)))
1255 (c-lang-defvar c-assignment-op-regexp
1256 (c-lang-const c-assignment-op-regexp
))
1258 (c-lang-defconst c-arithmetic-operators
1259 "List of all arithmetic operators, including \"+=\", etc."
1260 ;; Note: in the following, there are too many operators for AWK and IDL.
1261 t
(append (c-lang-const c-assignment-operators
)
1262 '("+" "-" "*" "/" "%"
1269 (c-lang-defconst c-arithmetic-op-regexp
1270 t
(c-make-keywords-re nil
1271 (c-lang-const c-arithmetic-operators
)))
1272 (c-lang-defvar c-arithmetic-op-regexp
(c-lang-const c-arithmetic-op-regexp
))
1274 (c-lang-defconst c-
:$-multichar-token-regexp
1275 ;; Regexp matching all tokens ending in ":" which are longer than one char.
1276 ;; Currently (2016-01-07) only used in C++ Mode.
1277 t
(c-make-keywords-re nil
1278 (c-filter-ops (c-lang-const c-operators
) t
".+:$")))
1279 (c-lang-defvar c-
:$-multichar-token-regexp
1280 (c-lang-const c-
:$-multichar-token-regexp
))
1282 (c-lang-defconst c-
<>-multichar-token-regexp
1283 ;; Regexp matching all tokens containing "<" or ">" which are longer
1285 t
(c-make-keywords-re nil
1286 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1289 (c-lang-defvar c-
<>-multichar-token-regexp
1290 (c-lang-const c-
<>-multichar-token-regexp
))
1292 (c-lang-defconst c-
<-op-cont-regexp
1293 ;; Regexp matching the second and subsequent characters of all
1294 ;; multicharacter tokens that begin with "<".
1295 t
(c-make-keywords-re nil
1296 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1299 (lambda (op) (substring op
1)))))
1300 (c-lang-defvar c-
<-op-cont-regexp
(c-lang-const c-
<-op-cont-regexp
))
1302 (c-lang-defconst c-
>-op-cont-tokens
1303 ;; A list of second and subsequent characters of all multicharacter tokens
1304 ;; that begin with ">".
1305 t
(c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1308 (lambda (op) (substring op
1)))
1309 java
(c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1311 "\\`>[^>]\\|\\`>>[^>]"
1312 (lambda (op) (substring op
1))))
1314 (c-lang-defconst c-
>-op-cont-regexp
1315 ;; Regexp matching the second and subsequent characters of all
1316 ;; multicharacter tokens that begin with ">".
1317 t
(c-make-keywords-re nil
(c-lang-const c-
>-op-cont-tokens
)))
1318 (c-lang-defvar c-
>-op-cont-regexp
(c-lang-const c-
>-op-cont-regexp
))
1320 (c-lang-defconst c-
>-op-without-
>-cont-regexp
1321 ;; Regexp matching the second and subsequent characters of all
1322 ;; multicharacter tokens that begin with ">" except for those beginning with
1324 t
(c-make-keywords-re nil
1326 (c-lang-const c-
>-op-cont-tokens
)
1327 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1330 (lambda (op) (substring op
1)))
1331 :test
'string-equal
)))
1332 (c-lang-defvar c-
>-op-without-
>-cont-regexp
1333 (c-lang-const c-
>-op-without-
>-cont-regexp
))
1335 (c-lang-defconst c-multichar-
>-op-not-
>>-regexp
1336 ;; Regexp matching multichar tokens containing ">", except ">>"
1337 t
(c-make-keywords-re nil
1339 (c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1342 (c-lang-defvar c-multichar-
>-op-not-
>>-regexp
1343 (c-lang-const c-multichar-
>-op-not-
>>-regexp
))
1345 (c-lang-defconst c-
:-op-cont-tokens
1346 ;; A list of second and subsequent characters of all multicharacter tokens
1347 ;; that begin with ":".
1348 t
(c-filter-ops (c-lang-const c-all-op-syntax-tokens
)
1351 (lambda (op) (substring op
1))))
1353 (c-lang-defconst c-
:-op-cont-regexp
1354 ;; Regexp matching the second and subsequent characters of all
1355 ;; multicharacter tokens that begin with ":".
1356 t
(c-make-keywords-re nil
(c-lang-const c-
:-op-cont-tokens
)))
1357 (c-lang-defvar c-
:-op-cont-regexp
1358 (c-lang-const c-
:-op-cont-regexp
))
1360 (c-lang-defconst c-stmt-delim-chars
1361 ;; The characters that should be considered to bound statements. To
1362 ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
1363 ;; begin with "^" to negate the set. If ? : operators should be
1364 ;; detected then the string must end with "?:".
1366 (c-lang-defvar c-stmt-delim-chars
(c-lang-const c-stmt-delim-chars
))
1368 (c-lang-defconst c-stmt-delim-chars-with-comma
1369 ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
1371 (c-lang-defvar c-stmt-delim-chars-with-comma
1372 (c-lang-const c-stmt-delim-chars-with-comma
))
1374 (c-lang-defconst c-pack-ops
1375 "Ops which signal C++11's \"parameter pack\""
1378 (c-lang-defconst c-pack-key
1379 t
(c-make-keywords-re 'appendable
(c-lang-const c-pack-ops
)))
1380 (c-lang-defvar c-pack-key
(c-lang-const c-pack-key
))
1382 (c-lang-defconst c-auto-ops
1383 ;; Ops which signal C++11's new auto uses.
1386 (c-lang-defconst c-auto-ops-re
1387 t
(c-make-keywords-re nil
(c-lang-const c-auto-ops
)))
1388 (c-lang-defvar c-auto-ops-re
(c-lang-const c-auto-ops-re
))
1390 (c-lang-defconst c-haskell-op
1391 ;; Op used in the new C++11 auto function definition, indicating type.
1394 (c-lang-defconst c-haskell-op-re
1395 t
(c-make-keywords-re nil
(c-lang-const c-haskell-op
)))
1396 (c-lang-defvar c-haskell-op-re
(c-lang-const c-haskell-op-re
))
1398 (c-lang-defconst c-pre-start-tokens
1399 "List of operators following which an apparent declaration \(e.g.
1400 \"t1 *fn (t2 *b);\") is most likely to be an actual declaration
1401 \(as opposed to an arithmetic expression)."
1403 (c-lang-defvar c-pre-start-tokens
(c-lang-const c-pre-start-tokens
))
1405 (c-lang-defconst c-pre-lambda-tokens
1406 "List of tokens which may precede a lambda declaration.
1407 In C++ this is something like \"[a,b] (foo, bar) -> int { ... };\".
1408 Currently (2016-08) only used in C++ mode."
1409 t
(c--set-difference
1410 (c--delete-duplicates
1411 (append (c-lang-const c-operator-list
)
1412 (c-lang-const c-other-op-syntax-tokens
)))
1414 '("#" "%:" "??=" "##" "%:%:" "??=??=" "::" "." "->"
1415 "]" "<:" ":>" "??(" "??)" "??-" "new" "delete"
1416 ")" ".*" "->*" "??'" "??!" "??!??!" "??!=" "??'=")
1417 '("<%" "%>" "<:" ":>" "%:" "%:%:" "#" "##" "::" "..."))
1418 :test
#'string-equal
))
1420 (c-lang-defconst c-pre-lambda-tokens-re
1421 ;; Regexp matching any token in the list `c-pre-lambda-tokens'.
1422 t
(regexp-opt (c-lang-const c-pre-lambda-tokens
)))
1423 (c-lang-defvar c-pre-lambda-tokens-re
(c-lang-const c-pre-lambda-tokens-re
))
1425 ;;; Syntactic whitespace.
1427 (c-lang-defconst c-simple-ws
1428 "Regexp matching an ordinary whitespace character.
1429 Does not contain a \\| operator at the top level."
1430 ;; "\\s " is not enough since it doesn't match line breaks.
1431 t
"\\(\\s \\|[\n\r]\\)")
1433 (c-lang-defconst c-simple-ws-depth
1434 ;; Number of regexp grouping parens in `c-simple-ws'.
1435 t
(regexp-opt-depth (c-lang-const c-simple-ws
)))
1437 (c-lang-defconst c-line-comment-starter
1438 "String that starts line comments, or nil if such don't exist.
1439 Line comments are always terminated by newlines. At least one of
1440 `c-block-comment-starter' and this one is assumed to be set.
1442 Note that it's currently not enough to set this to support a new
1443 comment style. Other stuff like the syntax table must also be set up
1447 (c-lang-defvar c-line-comment-starter
(c-lang-const c-line-comment-starter
))
1449 (c-lang-defconst c-block-comment-starter
1450 "String that starts block comments, or nil if such don't exist.
1451 Block comments are ended by `c-block-comment-ender', which is assumed
1452 to be set if this is. At least one of `c-line-comment-starter' and
1453 this one is assumed to be set.
1455 Note that it's currently not enough to set this to support a new
1456 comment style. Other stuff like the syntax table must also be set up
1460 (c-lang-defvar c-block-comment-starter
(c-lang-const c-block-comment-starter
))
1462 (c-lang-defconst c-block-comment-ender
1463 "String that ends block comments, or nil if such don't exist.
1465 Note that it's currently not enough to set this to support a new
1466 comment style. Other stuff like the syntax table must also be set up
1470 (c-lang-defvar c-block-comment-ender
(c-lang-const c-block-comment-ender
))
1472 (c-lang-defconst c-block-comment-ender-regexp
1473 ;; Regexp which matches the end of a block comment (if such exists in the
1475 t
(if (c-lang-const c-block-comment-ender
)
1476 (regexp-quote (c-lang-const c-block-comment-ender
))
1478 (c-lang-defvar c-block-comment-ender-regexp
1479 (c-lang-const c-block-comment-ender-regexp
))
1481 (c-lang-defconst c-comment-start-regexp
1482 ;; Regexp to match the start of any type of comment.
1483 t
(let ((re (c-make-keywords-re nil
1484 (list (c-lang-const c-line-comment-starter
)
1485 (c-lang-const c-block-comment-starter
)))))
1486 (if (memq 'gen-comment-delim c-emacs-features
)
1487 (concat re
"\\|\\s!")
1489 (c-lang-defvar c-comment-start-regexp
(c-lang-const c-comment-start-regexp
))
1491 (c-lang-defconst c-block-comment-start-regexp
1492 ;; Regexp which matches the start of a block comment (if such exists in the
1494 t
(if (c-lang-const c-block-comment-starter
)
1495 (regexp-quote (c-lang-const c-block-comment-starter
))
1497 (c-lang-defvar c-block-comment-start-regexp
1498 (c-lang-const c-block-comment-start-regexp
))
1500 (c-lang-defconst c-line-comment-start-regexp
1501 ;; Regexp which matches the start of a line comment (if such exists in the
1502 ;; language; it does in all 7 CC Mode languages).
1503 t
(if (c-lang-const c-line-comment-starter
)
1504 (regexp-quote (c-lang-const c-line-comment-starter
))
1506 (c-lang-defvar c-line-comment-start-regexp
1507 (c-lang-const c-line-comment-start-regexp
))
1509 (c-lang-defconst c-literal-start-regexp
1510 ;; Regexp to match the start of comments and string literals.
1511 t
(concat (c-lang-const c-comment-start-regexp
)
1513 (if (memq 'gen-string-delim c-emacs-features
)
1516 (c-lang-defvar c-literal-start-regexp
(c-lang-const c-literal-start-regexp
))
1518 (c-lang-defconst c-doc-comment-start-regexp
1519 "Regexp to match the start of documentation comments."
1521 ;; From font-lock.el: `doxygen' uses /*! while others use /**.
1522 (c c
++ objc
) "/\\*[*!]"
1525 (c-lang-defvar c-doc-comment-start-regexp
1526 (c-lang-const c-doc-comment-start-regexp
))
1528 (c-lang-defconst c-block-comment-is-default
1529 "Non-nil when the default comment style is block comment."
1530 ;; Note to maintainers of derived modes: You are responsible for ensuring
1531 ;; the pertinent `c-block-comment-{starter,ender}' or
1532 ;; `c-line-comment-{starter,ender}' are non-nil.
1535 (c-lang-defvar c-block-comment-is-default
1536 (c-lang-const c-block-comment-is-default
))
1538 (c-lang-defconst comment-start
1539 "String that starts comments inserted with M-; etc.
1540 `comment-start' is initialized from this."
1542 (if (c-lang-const c-block-comment-is-default
)
1543 (c-lang-const c-block-comment-starter
)
1544 (c-lang-const c-line-comment-starter
))
1546 (c-lang-setvar comment-start
(c-lang-const comment-start
))
1548 (c-lang-defconst comment-end
1549 "String that ends comments inserted with M-; etc.
1550 `comment-end' is initialized from this."
1551 t
(if (c-lang-const c-block-comment-is-default
)
1552 (concat " " (c-lang-const c-block-comment-ender
))
1554 (c-lang-setvar comment-end
(c-lang-const comment-end
))
1556 (c-lang-defconst comment-start-skip
1557 "Regexp to match the start of a comment plus everything up to its body.
1558 `comment-start-skip' is initialized from this."
1559 ;; Default: Allow the last char of the comment starter(s) to be
1560 ;; repeated, then allow any amount of horizontal whitespace.
1563 (mapcar (lambda (cs)
1565 (concat (regexp-quote cs
) "+")))
1566 (list (c-lang-const c-line-comment-starter
)
1567 (c-lang-const c-block-comment-starter
)))
1570 (c-lang-setvar comment-start-skip
(c-lang-const comment-start-skip
))
1572 (c-lang-defconst comment-end-can-be-escaped
1573 "When non-nil, escaped EOLs inside comments are valid.
1574 This works in Emacs >= 25.1."
1577 (c-lang-setvar comment-end-can-be-escaped
1578 (c-lang-const comment-end-can-be-escaped
))
1580 (c-lang-defconst c-syntactic-ws-start
1581 ;; Regexp matching any sequence that can start syntactic whitespace.
1582 ;; The only uncertain case is '#' when there are cpp directives.
1584 (c-make-keywords-re nil
1585 (append (list (c-lang-const c-line-comment-starter
)
1586 (c-lang-const c-block-comment-starter
)
1587 (when (c-lang-const c-opt-cpp-prefix
)
1591 (when (memq 'gen-comment-delim c-emacs-features
)
1593 (c-lang-defvar c-syntactic-ws-start
(c-lang-const c-syntactic-ws-start
))
1595 (c-lang-defconst c-syntactic-ws-end
1596 ;; Regexp matching any single character that might end syntactic whitespace.
1598 (c-make-keywords-re nil
1599 (append (when (c-lang-const c-block-comment-ender
)
1602 (elt (c-lang-const c-block-comment-ender
)
1604 (c-lang-const c-block-comment-ender
)))))))
1606 (when (memq 'gen-comment-delim c-emacs-features
)
1608 (c-lang-defvar c-syntactic-ws-end
(c-lang-const c-syntactic-ws-end
))
1610 (c-lang-defconst c-unterminated-block-comment-regexp
1611 ;; Regexp matching an unterminated block comment that doesn't
1612 ;; contain line breaks, or nil in languages without block comments.
1613 ;; Does not contain a \| operator at the top level.
1614 t
(when (c-lang-const c-block-comment-starter
)
1616 (regexp-quote (c-lang-const c-block-comment-starter
))
1617 ;; It's messy to cook together a regexp that matches anything
1618 ;; but c-block-comment-ender.
1619 (let ((end (c-lang-const c-block-comment-ender
)))
1620 (cond ((= (length end
) 1)
1621 (concat "[^" end
"\n\r]*"))
1623 (concat "[^" (substring end
0 1) "\n\r]*"
1625 (regexp-quote (substring end
0 1)) "+"
1627 ;; The quoting rules inside char classes are silly. :P
1628 (cond ((= (elt end
0) (elt end
1))
1629 (concat (substring end
0 1) "\n\r"))
1630 ((= (elt end
1) ?\
])
1631 (concat (substring end
1 2) "\n\r"
1632 (substring end
0 1)))
1634 (concat (substring end
0 1) "\n\r"
1635 (substring end
1 2))))
1637 "[^" (substring end
0 1) "\n\r]*"
1640 (error "Can't handle a block comment ender of length %s"
1643 (c-lang-defconst c-block-comment-regexp
1644 ;; Regexp matching a block comment that doesn't contain line breaks,
1645 ;; or nil in languages without block comments. The reason we don't
1646 ;; allow line breaks is to avoid going very far and risk running out
1647 ;; of regexp stack; this regexp is intended to handle only short
1648 ;; comments that might be put in the middle of limited constructs
1649 ;; like declarations. Does not contain a \| operator at the top
1651 t
(when (c-lang-const c-unterminated-block-comment-regexp
)
1653 (c-lang-const c-unterminated-block-comment-regexp
)
1654 (let ((end (c-lang-const c-block-comment-ender
)))
1655 (cond ((= (length end
) 1)
1658 (concat (regexp-quote (substring end
0 1)) "+"
1659 (regexp-quote (substring end
1 2))))
1661 (error "Can't handle a block comment ender of length %s"
1664 (c-lang-defconst c-nonwhite-syntactic-ws
1665 ;; Regexp matching a piece of syntactic whitespace that isn't a
1666 ;; sequence of simple whitespace characters. As opposed to
1667 ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1668 ;; directives as syntactic whitespace.
1669 t
(c-concat-separated
1670 (list (when (c-lang-const c-line-comment-starter
)
1671 (concat (regexp-quote (c-lang-const c-line-comment-starter
))
1673 (c-lang-const c-block-comment-regexp
)
1675 (when (memq 'gen-comment-delim c-emacs-features
)
1679 (c-lang-defconst c-syntactic-ws
1680 ;; Regexp matching syntactic whitespace, including possibly the
1681 ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
1682 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1683 ;; not contain a \| operator at the top level.
1684 t
(concat (c-lang-const c-simple-ws
) "*"
1686 (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws
) "\\)"
1687 (c-lang-const c-simple-ws
) "*")
1690 (c-lang-defconst c-syntactic-ws-depth
1691 ;; Number of regexp grouping parens in `c-syntactic-ws'.
1692 t
(regexp-opt-depth (c-lang-const c-syntactic-ws
)))
1694 (c-lang-defconst c-nonempty-syntactic-ws
1695 ;; Regexp matching syntactic whitespace, which is at least one
1696 ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
1697 ;; this doesn't regard cpp directives as syntactic whitespace. Does
1698 ;; not contain a \| operator at the top level.
1700 (c-lang-const c-simple-ws
)
1702 (c-lang-const c-nonwhite-syntactic-ws
)
1705 (c-lang-defconst c-nonempty-syntactic-ws-depth
1706 ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1707 t
(regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws
)))
1709 (c-lang-defconst c-single-line-syntactic-ws
1710 ;; Regexp matching syntactic whitespace without any line breaks. As
1711 ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1712 ;; regard cpp directives as syntactic whitespace. Does not contain
1713 ;; a \| operator at the top level.
1714 t
(if (c-lang-const c-block-comment-regexp
)
1716 (c-lang-const c-block-comment-regexp
)
1720 (c-lang-defconst c-single-line-syntactic-ws-depth
1721 ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1722 t
(regexp-opt-depth (c-lang-const c-single-line-syntactic-ws
)))
1724 (c-lang-defconst c-syntactic-eol
1725 ;; Regexp that matches when there is no syntactically significant
1726 ;; text before eol. Macros are regarded as syntactically
1727 ;; significant text here.
1728 t
(concat (c-lang-const c-single-line-syntactic-ws
)
1729 ;; Match eol (possibly inside a block comment or preceded
1730 ;; by a line continuation backslash), or the beginning of a
1731 ;; line comment. Note: This has to be modified for awk
1732 ;; where line comments start with '#'.
1735 (list (when (c-lang-const c-line-comment-starter
)
1736 (regexp-quote (c-lang-const c-line-comment-starter
)))
1737 (when (c-lang-const c-unterminated-block-comment-regexp
)
1738 (concat (c-lang-const c-unterminated-block-comment-regexp
)
1744 (c-lang-defvar c-syntactic-eol
(c-lang-const c-syntactic-eol
))
1749 ;; The Emacs variables beginning-of-defun-function and end-of-defun-function
1750 ;; will be set so that commands like `mark-defun' and `narrow-to-defun' work
1751 ;; right. In older Emacsen, the key sequences C-M-a and C-M-e are, however,
1752 ;; bound directly to the CC Mode functions, allowing optimization for large n.
1753 ;; From Emacs 23, this isn't necessary any more, since n is passed to the two
1755 (c-lang-defconst beginning-of-defun-function
1756 "Function to which beginning-of-defun-function will be set."
1757 t
'c-beginning-of-defun
1758 awk
'c-awk-beginning-of-defun
)
1759 (c-lang-setvar beginning-of-defun-function
1760 (c-lang-const beginning-of-defun-function
))
1762 (c-lang-defconst end-of-defun-function
1763 "Function to which end-of-defun-function will be set."
1765 awk
'c-awk-end-of-defun
)
1766 (c-lang-setvar end-of-defun-function
(c-lang-const end-of-defun-function
))
1768 ;;; In-comment text handling.
1770 (c-lang-defconst c-paragraph-start
1771 "Regexp to append to `paragraph-start'."
1773 java
"\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
1774 pike
"\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
1775 (c-lang-defvar c-paragraph-start
(c-lang-const c-paragraph-start
))
1777 (c-lang-defconst c-paragraph-separate
1778 "Regexp to append to `paragraph-separate'."
1780 pike
(c-lang-const c-paragraph-start
))
1781 (c-lang-defvar c-paragraph-separate
(c-lang-const c-paragraph-separate
))
1786 ;; Note: All and only all language constants containing keyword lists
1787 ;; should end with "-kwds"; they're automatically collected into the
1788 ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
1790 (c-lang-defconst c-primitive-type-kwds
1791 "Primitive type keywords. As opposed to the other keyword lists, the
1792 keywords listed here are fontified with the type face instead of the
1795 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1796 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1797 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1800 Do not try to modify this list for end user customizations; the
1801 `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
1802 the appropriate place for that."
1803 t
'("char" "double" "float" "int" "long" "short" "signed"
1806 '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
1807 (c-lang-const c-primitive-type-kwds
))
1809 '("bool" "wchar_t" "char16_t" "char32_t")
1810 (c-lang-const c-primitive-type-kwds
))
1811 ;; Objective-C extends C, but probably not the new stuff in C99.
1813 '("id" "Class" "SEL" "IMP" "BOOL")
1814 (c-lang-const c-primitive-type-kwds
))
1815 java
'("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
1816 idl
'("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
1817 "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
1820 ;; The following can't really end a type, but we have to specify them
1821 ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
1822 ;; doesn't matter that much.
1823 "unsigned" "strong")
1824 pike
'(;; this_program isn't really a keyword, but it's practically
1825 ;; used as a builtin type.
1826 "array" "float" "function" "int" "mapping" "mixed" "multiset"
1827 "object" "program" "string" "this_program" "void"))
1829 (c-lang-defconst c-return-kwds
1830 "Keywords which return a value to the calling function."
1834 (c-lang-defconst c-return-key
1835 ;; Adorned regexp matching `c-return-kwds'.
1836 t
(c-make-keywords-re t
(c-lang-const c-return-kwds
)))
1837 (c-lang-defvar c-return-key
(c-lang-const c-return-key
))
1839 (c-lang-defconst c-primitive-type-key
1840 ;; An adorned regexp that matches `c-primitive-type-kwds'.
1841 t
(c-make-keywords-re t
(c-lang-const c-primitive-type-kwds
)))
1842 (c-lang-defvar c-primitive-type-key
(c-lang-const c-primitive-type-key
))
1844 (c-lang-defconst c-primitive-type-prefix-kwds
1845 "Keywords that might act as prefixes for primitive types. Assumed to
1846 be a subset of `c-primitive-type-kwds'."
1848 (c c
++) '("long" "short" "signed" "unsigned")
1849 idl
'("long" "unsigned"
1853 (c-lang-defconst c-typedef-kwds
1854 "Prefix keyword(s) like \"typedef\" which make a type declaration out
1855 of a variable declaration."
1859 (c-lang-defconst c-typedef-key
1860 ;; Adorned regexp matching `c-typedef-kwds'.
1861 t
(c-make-keywords-re t
(c-lang-const c-typedef-kwds
)))
1862 (c-lang-defvar c-typedef-key
(c-lang-const c-typedef-key
))
1864 (c-lang-defconst c-typeof-kwds
1865 "Keywords followed by a parenthesized expression, which stands for
1866 the type of that expression."
1868 c
'("typeof") ; longstanding GNU C(++) extension.
1869 c
++ '("decltype" "typeof"))
1871 (c-lang-defconst c-typeof-key
1872 ;; Adorned regexp matching `c-typeof-kwds'.
1873 t
(c-make-keywords-re t
(c-lang-const c-typeof-kwds
)))
1874 (c-lang-defvar c-typeof-key
(c-lang-const c-typeof-key
))
1876 (c-lang-defconst c-type-prefix-kwds
1877 "Keywords where the following name - if any - is a type name, and
1878 where the keyword together with the symbol works as a type in
1881 Note that an alternative if the second part doesn't hold is
1882 `c-type-list-kwds'. Keywords on this list are typically also present
1883 on one of the `*-decl-kwds' lists."
1885 c
'("struct" "union" "enum")
1886 c
++ (append '("class" "typename")
1887 (c-lang-const c-type-prefix-kwds c
)))
1889 (c-lang-defconst c-type-prefix-key
1890 ;; Adorned regexp matching `c-type-prefix-kwds'.
1891 t
(c-make-keywords-re t
(c-lang-const c-type-prefix-kwds
)))
1892 (c-lang-defvar c-type-prefix-key
(c-lang-const c-type-prefix-key
))
1894 (c-lang-defconst c-type-modifier-kwds
1895 "Type modifier keywords. These can occur almost anywhere in types
1896 but they don't build a type of themselves. Unlike the keywords on
1897 `c-primitive-type-kwds', they are fontified with the keyword face and
1900 c
'("const" "restrict" "volatile")
1901 c
++ '("const" "noexcept" "volatile" "throw")
1902 objc
'("const" "volatile"))
1904 (c-lang-defconst c-opt-type-modifier-key
1905 ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
1906 ;; languages without such keywords.
1907 t
(and (c-lang-const c-type-modifier-kwds
)
1908 (c-make-keywords-re t
(c-lang-const c-type-modifier-kwds
))))
1909 (c-lang-defvar c-opt-type-modifier-key
(c-lang-const c-opt-type-modifier-key
))
1911 (c-lang-defconst c-opt-type-component-key
1912 ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
1913 ;; `c-type-modifier-kwds', or nil in languages without any of them.
1914 t
(and (or (c-lang-const c-primitive-type-prefix-kwds
)
1915 (c-lang-const c-type-modifier-kwds
))
1916 (c-make-keywords-re t
1917 (append (c-lang-const c-primitive-type-prefix-kwds
)
1918 (c-lang-const c-type-modifier-kwds
)))))
1919 (c-lang-defvar c-opt-type-component-key
1920 (c-lang-const c-opt-type-component-key
))
1922 (c-lang-defconst c-type-start-kwds
1923 ;; All keywords that can start a type (i.e. are either a type prefix
1924 ;; or a complete type).
1925 t
(c--delete-duplicates (append (c-lang-const c-primitive-type-kwds
)
1926 (c-lang-const c-type-prefix-kwds
)
1927 (c-lang-const c-type-modifier-kwds
))
1928 :test
'string-equal
))
1930 (c-lang-defconst c-type-decl-suffix-ws-ids-kwds
1931 "\"Identifiers\" that when immediately following a declarator have semantic
1932 effect in the declaration, but are syntactically like whitespace."
1934 c
++ '("final" "override"))
1936 (c-lang-defconst c-type-decl-suffix-ws-ids-key
1937 ;; An adorned regexp matching `c-type-decl-suffix-ws-ids-kwds'.
1938 t
(c-make-keywords-re t
(c-lang-const c-type-decl-suffix-ws-ids-kwds
)))
1939 (c-lang-defvar c-type-decl-suffix-ws-ids-key
1940 (c-lang-const c-type-decl-suffix-ws-ids-key
))
1942 (c-lang-defconst c-class-decl-kwds
1943 "Keywords introducing declarations where the following block (if any)
1944 contains another declaration level that should be considered a class.
1946 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1947 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1948 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1951 Note that presence on this list does not automatically treat the
1952 following identifier as a type; the keyword must also be present on
1953 `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
1955 c
'("struct" "union")
1956 c
++ '("class" "struct" "union")
1957 objc
'("struct" "union"
1958 "@interface" "@implementation" "@protocol")
1959 java
'("class" "@interface" "interface")
1960 idl
'("component" "eventtype" "exception" "home" "interface" "struct"
1963 "storagehome" "storagetype"
1965 "catalog" "executor" "manages" "segment")
1968 (c-lang-defconst c-class-key
1969 ;; Regexp matching the start of a class.
1970 t
(c-make-keywords-re t
(c-lang-const c-class-decl-kwds
)))
1971 (c-lang-defvar c-class-key
(c-lang-const c-class-key
))
1973 (c-lang-defconst c-brace-list-decl-kwds
1974 "Keywords introducing declarations where the following block (if
1975 any) is a brace list.
1977 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1978 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1979 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1984 (c-lang-defconst c-brace-list-key
1985 ;; Regexp matching the start of declarations where the following
1986 ;; block is a brace list.
1987 t
(c-make-keywords-re t
(c-lang-const c-brace-list-decl-kwds
)))
1988 (c-lang-defvar c-brace-list-key
(c-lang-const c-brace-list-key
))
1990 (c-lang-defconst c-after-brace-list-decl-kwds
1991 "Keywords that might follow keywords in `c-brace-list-decl-kwds'
1992 and precede the opening brace."
1994 c
++ '("class" "struct"))
1996 (c-lang-defconst c-after-brace-list-key
1997 ;; Regexp matching keywords that can fall between a brace-list
1998 ;; keyword and the associated brace list.
1999 t
(c-make-keywords-re t
(c-lang-const c-after-brace-list-decl-kwds
)))
2000 (c-lang-defvar c-after-brace-list-key
(c-lang-const c-after-brace-list-key
))
2002 (c-lang-defconst c-recognize-post-brace-list-type-p
2003 "Set to t when we recognize a colon and then a type after an enum,
2004 e.g., enum foo : int { A, B, C };"
2007 (c-lang-defvar c-recognize-post-brace-list-type-p
2008 (c-lang-const c-recognize-post-brace-list-type-p
))
2010 (c-lang-defconst c-other-block-decl-kwds
2011 "Keywords where the following block (if any) contains another
2012 declaration level that should not be considered a class. For every
2013 keyword here, CC Mode will add a set of special syntactic symbols for
2014 those blocks. E.g. if the keyword is \"foo\" then there will be
2015 `foo-open', `foo-close', and `infoo' symbols.
2017 The intention is that this category should be used for block
2018 constructs that aren't related to object orientation concepts like
2019 classes (which thus also include e.g. interfaces, templates,
2020 contracts, structs, etc). The more pragmatic distinction is that
2021 while most want some indentation inside classes, it's fairly common
2022 that they don't want it in some of these constructs, so it should be
2023 simple to configure that differently from classes. See also
2024 `c-class-decl-kwds'.
2026 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
2027 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2028 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
2031 (c objc
) '("extern")
2032 c
++ '("namespace" "extern")
2037 (c-lang-defconst c-other-decl-block-key
2038 ;; Regexp matching the start of blocks besides classes that contain
2039 ;; another declaration level.
2040 t
(c-make-keywords-re t
(c-lang-const c-other-block-decl-kwds
)))
2041 (c-lang-defvar c-other-decl-block-key
(c-lang-const c-other-decl-block-key
))
2043 (c-lang-defvar c-other-decl-block-key-in-symbols-alist
2047 (if (string= elt
"extern")
2049 (intern (concat "in" elt
)))))
2050 (c-lang-const c-other-block-decl-kwds
))
2051 "Alist associating keywords in c-other-decl-block-decl-kwds with
2052 their matching \"in\" syntactic symbols.")
2054 (c-lang-defconst c-typedef-decl-kwds
2055 "Keywords introducing declarations where the identifier(s) being
2058 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
2059 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2060 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
2062 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
2063 ;; (since e.g. "Foo" is a type that's being defined in "class Foo
2065 t
(append (c-lang-const c-class-decl-kwds
)
2066 (c-lang-const c-brace-list-decl-kwds
))
2067 ;; Languages that have a "typedef" construct.
2068 (c c
++ objc idl pike
) (append (c-lang-const c-typedef-decl-kwds
)
2070 ;; Unlike most other languages, exception names are not handled as
2071 ;; types in IDL since they only can occur in "raises" specs.
2072 idl
(delete "exception" (append (c-lang-const c-typedef-decl-kwds
) nil
)))
2074 (c-lang-defconst c-typedef-decl-key
2075 t
(c-make-keywords-re t
(c-lang-const c-typedef-decl-kwds
)))
2076 (c-lang-defvar c-typedef-decl-key
(c-lang-const c-typedef-decl-key
))
2078 (c-lang-defconst c-typeless-decl-kwds
2079 "Keywords introducing declarations where the \(first) identifier
2080 \(declarator) follows directly after the keyword, without any type.
2082 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
2083 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2084 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
2086 ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
2087 ;; (since e.g. "Foo" is the identifier being defined in "class Foo
2089 t
(append (c-lang-const c-class-decl-kwds
)
2090 (c-lang-const c-brace-list-decl-kwds
))
2091 c
++ (append (c-lang-const c-typeless-decl-kwds
) '("auto")) ; C++11.
2092 ;; Note: "manages" for CORBA CIDL clashes with its presence on
2093 ;; `c-type-list-kwds' for IDL.
2094 idl
(append (c-lang-const c-typeless-decl-kwds
)
2095 '("factory" "finder" "native"
2100 pike
(append (c-lang-const c-class-decl-kwds
)
2103 (c-lang-defconst c-modifier-kwds
2104 "Keywords that can prefix normal declarations of identifiers
2105 \(and typically act as flags). Things like argument declarations
2106 inside function headers are also considered declarations in this
2109 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
2110 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2111 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
2114 (c c
++) '("auto" "extern" "inline" "register" "static")
2115 c
++ (append '("constexpr" "explicit" "friend" "mutable" "template"
2116 "thread_local" "using" "virtual")
2117 (c-lang-const c-modifier-kwds
))
2118 objc
'("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
2119 ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
2120 idl
'("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
2121 "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
2122 "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
2126 "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
2127 ;; Note: "const" is not used in Java, but it's still a reserved keyword.
2128 java
'("abstract" "const" "default" "final" "native" "private" "protected"
2129 "public" "static" "strictfp" "synchronized" "transient" "volatile")
2130 pike
'("final" "inline" "local" "nomask" "optional" "private" "protected"
2131 "public" "static" "variant"))
2133 (c-lang-defconst c-other-decl-kwds
2134 "Keywords that can start or prefix any declaration level construct,
2135 besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
2136 `c-other-block-decl-kwds', `c-typedef-decl-kwds',
2137 `c-typeless-decl-kwds' and `c-modifier-kwds'.
2139 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
2140 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2141 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
2144 objc
'("@class" "@end" "@defs")
2145 java
'("import" "package")
2146 pike
'("import" "inherit"))
2148 (c-lang-defconst c-decl-start-kwds
2149 "Keywords that always start declarations, wherever they occur.
2150 This can be used for declarations that aren't recognized by the normal
2151 combination of `c-decl-prefix-re' and `c-decl-start-re'."
2153 ;; Classes can be declared anywhere in a Pike expression.
2156 (c-lang-defconst c-decl-hangon-kwds
2157 "Keywords that can occur anywhere in a declaration level construct.
2158 This is used for self-contained things that can be tacked on anywhere
2159 on a declaration and that should be ignored to be able to recognize it
2160 correctly. Typical cases are compiler extensions like
2161 \"__attribute__\" or \"__declspec\":
2163 __declspec(noreturn) void foo();
2164 class __declspec(dllexport) classname {...};
2165 void foo() __attribute__((noreturn));
2167 Note that unrecognized plain symbols are skipped anyway if they occur
2168 before the type, so such things are not necessary to mention here.
2169 Mentioning them here is necessary only if they can occur in other
2170 places, or if they are followed by a construct that must be skipped
2171 over \(like the parens in the \"__attribute__\" and \"__declspec\"
2172 examples above). In the last case, they alse need to be present on
2173 one of `c-type-list-kwds', `c-ref-list-kwds',
2174 `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
2175 `c-<>-type-kwds', or `c-<>-arglist-kwds'."
2176 ;; NB: These are currently not recognized in all parts of a
2177 ;; declaration. Specifically, they aren't recognized in the middle
2178 ;; of multi-token types, inside declarators, and between the
2179 ;; identifier and the arglist paren of a function declaration.
2181 ;; FIXME: This ought to be user customizable since compiler stuff
2182 ;; like this usually is wrapped in project specific macros. (It'd
2183 ;; of course be even better if we could cope without knowing this.)
2185 (c c
++) '(;; GCC extension.
2190 (c-lang-defconst c-decl-hangon-key
2191 ;; Adorned regexp matching `c-decl-hangon-kwds'.
2192 t
(c-make-keywords-re t
(c-lang-const c-decl-hangon-kwds
)))
2193 (c-lang-defvar c-decl-hangon-key
(c-lang-const c-decl-hangon-key
))
2195 (c-lang-defconst c-prefix-spec-kwds
2196 ;; All keywords that can occur in the preamble of a declaration.
2197 ;; They typically occur before the type, but they are also matched
2198 ;; after presumptive types since we often can't be sure that
2199 ;; something is a type or just some sort of macro in front of the
2200 ;; declaration. They might be ambiguous with types or type
2202 t
(c--delete-duplicates (append (c-lang-const c-class-decl-kwds
)
2203 (c-lang-const c-brace-list-decl-kwds
)
2204 (c-lang-const c-other-block-decl-kwds
)
2205 (c-lang-const c-typedef-decl-kwds
)
2206 (c-lang-const c-typeless-decl-kwds
)
2207 (c-lang-const c-modifier-kwds
)
2208 (c-lang-const c-other-decl-kwds
)
2209 (c-lang-const c-decl-start-kwds
)
2210 (c-lang-const c-decl-hangon-kwds
))
2211 :test
'string-equal
))
2213 (c-lang-defconst c-prefix-spec-kwds-re
2214 ;; Adorned regexp of `c-prefix-spec-kwds'.
2215 t
(c-make-keywords-re t
(c-lang-const c-prefix-spec-kwds
)))
2217 (c-lang-defvar c-prefix-spec-kwds-re
(c-lang-const c-prefix-spec-kwds-re
))
2219 (c-lang-defconst c-specifier-key
2220 ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
2221 ;; ambiguous with types or type prefixes. These are the keywords (like
2222 ;; extern, namespace, but NOT template) that can modify a declaration.
2223 t
(c-make-keywords-re t
2224 (c--set-difference (c-lang-const c-prefix-spec-kwds
)
2225 (append (c-lang-const c-type-start-kwds
)
2226 (c-lang-const c-
<>-arglist-kwds
))
2227 :test
'string-equal
)))
2228 (c-lang-defvar c-specifier-key
(c-lang-const c-specifier-key
))
2230 (c-lang-defconst c-postfix-spec-kwds
2231 ;; Keywords that can occur after argument list of a function header
2232 ;; declaration, i.e. in the "K&R region".
2233 t
(append (c-lang-const c-postfix-decl-spec-kwds
)
2234 (c-lang-const c-decl-hangon-kwds
)))
2236 (c-lang-defconst c-not-decl-init-keywords
2237 ;; Adorned regexp matching all keywords that can't appear at the
2238 ;; start of a declaration.
2239 t
(c-make-keywords-re t
2240 (c--set-difference (c-lang-const c-keywords
)
2241 (append (c-lang-const c-type-start-kwds
)
2242 (c-lang-const c-prefix-spec-kwds
)
2243 (c-lang-const c-typeof-kwds
))
2244 :test
'string-equal
)))
2245 (c-lang-defvar c-not-decl-init-keywords
2246 (c-lang-const c-not-decl-init-keywords
))
2248 (c-lang-defconst c-not-primitive-type-keywords
2249 "List of all keywords apart from primitive types (like \"int\")."
2250 t
(c--set-difference (c-lang-const c-keywords
)
2251 (c-lang-const c-primitive-type-kwds
)
2252 :test
'string-equal
)
2253 ;; The "more" for C++ is the QT keyword (as in "more slots:").
2254 ;; This variable is intended for use in c-beginning-of-statement-1.
2255 c
++ (append (c-lang-const c-not-primitive-type-keywords
) '("more")))
2257 (c-lang-defconst c-not-primitive-type-keywords-regexp
2258 t
(c-make-keywords-re t
2259 (c-lang-const c-not-primitive-type-keywords
)))
2260 (c-lang-defvar c-not-primitive-type-keywords-regexp
2261 (c-lang-const c-not-primitive-type-keywords-regexp
))
2263 (c-lang-defconst c-protection-kwds
2264 "Access protection label keywords in classes."
2266 c
++ '("private" "protected" "public")
2267 objc
'("@private" "@protected" "@public"))
2269 (c-lang-defconst c-block-decls-with-vars
2270 "Keywords introducing declarations that can contain a block which
2271 might be followed by variable declarations, e.g. like \"foo\" in
2272 \"class Foo { ... } foo;\". So if there is a block in a declaration
2273 like that, it ends with the following `;' and not right away.
2275 The keywords on list are assumed to also be present on one of the
2276 `*-decl-kwds' lists."
2278 (c objc
) '("struct" "union" "enum" "typedef")
2279 c
++ '("class" "struct" "union" "enum" "typedef"))
2281 (c-lang-defconst c-opt-block-decls-with-vars-key
2282 ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
2283 ;; languages without such constructs.
2284 t
(and (c-lang-const c-block-decls-with-vars
)
2285 (c-make-keywords-re t
(c-lang-const c-block-decls-with-vars
))))
2286 (c-lang-defvar c-opt-block-decls-with-vars-key
2287 (c-lang-const c-opt-block-decls-with-vars-key
))
2289 (c-lang-defconst c-postfix-decl-spec-kwds
2290 "Keywords introducing extra declaration specifiers in the region
2291 between the header and the body \(i.e. the \"K&R-region\") in
2294 java
'("extends" "implements" "throws")
2295 idl
'("context" "getraises" "manages" "primarykey" "raises" "setraises"
2298 "as" "const" "implements" "of" "ref"))
2300 (c-lang-defconst c-postfix-decl-spec-key
2301 ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
2302 t
(c-make-keywords-re t
(c-lang-const c-postfix-decl-spec-kwds
)))
2303 (c-lang-defvar c-postfix-decl-spec-key
2304 (c-lang-const c-postfix-decl-spec-key
))
2306 (c-lang-defconst c-nonsymbol-sexp-kwds
2307 "Keywords that may be followed by a nonsymbol sexp before whatever
2308 construct it's part of continues."
2310 (c c
++ objc
) '("extern"))
2312 (c-lang-defconst c-type-list-kwds
2313 "Keywords that may be followed by a comma separated list of type
2314 identifiers, where each optionally can be prefixed by keywords. (Can
2315 also be used for the special case when the list can contain only one
2318 Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
2319 reason to put keywords on this list if they are on `c-type-prefix-kwds'.
2320 There's also no reason to add keywords that prefixes a normal
2321 declaration consisting of a type followed by a declarator (list), so
2322 the keywords on `c-modifier-kwds' should normally not be listed here
2325 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2326 or variable identifier (that's being defined)."
2330 java
'("import" "new" "extends" "super" "implements" "throws")
2331 idl
'("manages" "native" "primarykey" "supports"
2333 "as" "implements" "of" "scope")
2336 (c-lang-defconst c-ref-list-kwds
2337 "Keywords that may be followed by a comma separated list of
2338 reference (i.e. namespace/scope/module) identifiers, where each
2339 optionally can be prefixed by keywords. (Can also be used for the
2340 special case when the list can contain only one element.) Assumed to
2341 be mutually exclusive with `c-type-list-kwds'.
2343 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
2344 or variable identifier (that's being defined)."
2348 idl
'("import" "module"
2353 (c-lang-defconst c-colon-type-list-kwds
2354 "Keywords that may be followed (not necessarily directly) by a colon
2355 and then a comma separated list of type identifiers, where each
2356 optionally can be prefixed by keywords. (Can also be used for the
2357 special case when the list can contain only one element.)"
2359 c
++ '("class" "struct")
2360 idl
'("component" "eventtype" "home" "interface" "valuetype"
2362 "storagehome" "storagetype"))
2364 (c-lang-defconst c-colon-type-list-re
2365 "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
2366 forward to the colon. The end of the match is assumed to be directly
2367 after the colon, so the regexp should end with \":\". Must be a
2368 regexp if `c-colon-type-list-kwds' isn't nil."
2369 t
(if (c-lang-const c-colon-type-list-kwds
)
2370 ;; Disallow various common punctuation chars that can't come
2371 ;; before the ":" that starts the inherit list after "class"
2372 ;; or "struct" in C++. (Also used as default for other
2374 "[^][{}();,/#=:]*:"))
2375 (c-lang-defvar c-colon-type-list-re
(c-lang-const c-colon-type-list-re
))
2377 (c-lang-defconst c-paren-nontype-kwds
2378 "Keywords that may be followed by a parenthesis expression that doesn't
2379 contain type identifiers."
2381 (c c
++) '(;; GCC extension.
2385 c
++ (append (c-lang-const c-paren-nontype-kwds
) '("noexcept")))
2387 (c-lang-defconst c-paren-nontype-key
2388 t
(c-make-keywords-re t
(c-lang-const c-paren-nontype-kwds
)))
2389 (c-lang-defvar c-paren-nontype-key
(c-lang-const c-paren-nontype-key
))
2391 (c-lang-defconst c-paren-type-kwds
2392 "Keywords that may be followed by a parenthesis expression containing
2393 type identifiers separated by arbitrary tokens."
2398 pike
'("array" "function" "int" "mapping" "multiset" "object" "program"))
2400 (c-lang-defconst c-paren-any-kwds
2401 t
(c--delete-duplicates (append (c-lang-const c-paren-nontype-kwds
)
2402 (c-lang-const c-paren-type-kwds
))
2403 :test
'string-equal
))
2405 (c-lang-defconst c-
<>-type-kwds
2406 "Keywords that may be followed by an angle bracket expression
2407 containing type identifiers separated by \",\". The difference from
2408 `c-<>-arglist-kwds' is that unknown names are taken to be types and
2409 not other identifiers. `c-recognize-<>-arglists' is assumed to be set
2417 (c-lang-defconst c-
<>-arglist-kwds
2418 "Keywords that can be followed by a C++ style template arglist; see
2419 `c-recognize-<>-arglists' for details. That language constant is
2420 assumed to be set if this isn't nil."
2423 idl
'("fixed" "string" "wstring"))
2425 (c-lang-defconst c-
<>-sexp-kwds
2426 ;; All keywords that can be followed by an angle bracket sexp.
2427 t
(c--delete-duplicates (append (c-lang-const c-
<>-type-kwds
)
2428 (c-lang-const c-
<>-arglist-kwds
))
2429 :test
'string-equal
))
2431 (c-lang-defconst c-opt-
<>-sexp-key
2432 ;; Adorned regexp matching keywords that can be followed by an angle
2433 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
2434 t
(c-make-keywords-re t
(c-lang-const c-
<>-sexp-kwds
)))
2435 (c-lang-defvar c-opt-
<>-sexp-key
(c-lang-const c-opt-
<>-sexp-key
))
2437 (c-lang-defconst c-inside-
<>-type-kwds
2438 "Keywords which, used inside a C++ style template arglist, introduce a type."
2440 java
'("extends" "super"))
2442 (c-lang-defconst c-inside-
<>-type-key
2443 t
(c-make-keywords-re t
(c-lang-const c-inside-
<>-type-kwds
)))
2444 (c-lang-defvar c-inside-
<>-type-key
(c-lang-const c-inside-
<>-type-key
))
2446 (c-lang-defconst c-brace-id-list-kwds
2447 "Keywords that may be followed by a brace block containing a comma
2448 separated list of identifier definitions, i.e. like the list of
2449 identifiers that follows the type in a normal declaration."
2450 t
(c-lang-const c-brace-list-decl-kwds
))
2452 (c-lang-defconst c-block-stmt-1-kwds
2453 "Statement keywords followed directly by a substatement."
2455 c
++ '("do" "else" "try")
2456 objc
'("do" "else" "@finally" "@try")
2457 java
'("do" "else" "finally" "try")
2460 (c-lang-defconst c-block-stmt-1-key
2461 ;; Regexp matching the start of any statement followed directly by a
2462 ;; substatement (doesn't match a bare block, however).
2463 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-kwds
)))
2464 (c-lang-defvar c-block-stmt-1-key
(c-lang-const c-block-stmt-1-key
))
2466 (c-lang-defconst c-block-stmt-1-2-kwds
2467 "Statement keywords optionally followed by a paren sexp.
2468 Keywords here should also be in `c-block-stmt-1-kwds'."
2472 (c-lang-defconst c-block-stmt-1-2-key
2473 ;; Regexp matching the start of a statement which may be followed by a
2474 ;; paren sexp and will then be followed by a substatement.
2475 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-1-2-kwds
)))
2476 (c-lang-defvar c-block-stmt-1-2-key
(c-lang-const c-block-stmt-1-2-key
))
2478 (c-lang-defconst c-block-stmt-2-kwds
2479 "Statement keywords followed by a paren sexp and then by a substatement."
2480 t
'("for" "if" "switch" "while")
2481 c
++ '("for" "if" "switch" "while" "catch")
2482 objc
'("for" "if" "switch" "while" "@catch" "@synchronized")
2483 java
'("for" "if" "switch" "while" "catch" "synchronized")
2485 pike
'("for" "if" "switch" "while" "foreach")
2486 awk
'("for" "if" "while"))
2488 (c-lang-defconst c-block-stmt-2-key
2489 ;; Regexp matching the start of any statement followed by a paren sexp
2490 ;; and then by a substatement.
2491 t
(c-make-keywords-re t
(c-lang-const c-block-stmt-2-kwds
)))
2492 (c-lang-defvar c-block-stmt-2-key
(c-lang-const c-block-stmt-2-key
))
2494 (c-lang-defconst c-block-stmt-kwds
2495 ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
2496 t
(c--delete-duplicates (append (c-lang-const c-block-stmt-1-kwds
)
2497 (c-lang-const c-block-stmt-2-kwds
))
2498 :test
'string-equal
))
2500 (c-lang-defconst c-opt-block-stmt-key
2501 ;; Regexp matching the start of any statement that has a
2502 ;; substatement (except a bare block). Nil in languages that
2503 ;; don't have such constructs.
2504 t
(if (or (c-lang-const c-block-stmt-1-kwds
)
2505 (c-lang-const c-block-stmt-2-kwds
))
2506 (c-make-keywords-re t
2507 (append (c-lang-const c-block-stmt-1-kwds
)
2508 (c-lang-const c-block-stmt-2-kwds
)))))
2509 (c-lang-defvar c-opt-block-stmt-key
(c-lang-const c-opt-block-stmt-key
))
2511 (c-lang-defconst c-simple-stmt-kwds
2512 "Statement keywords followed by an expression or nothing."
2513 t
'("break" "continue" "goto" "return")
2514 objc
'("break" "continue" "goto" "return" "@throw")
2515 ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
2516 java
'("break" "continue" "goto" "return" "throw")
2518 pike
'("break" "continue" "return")
2519 awk
'(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
2520 "break" "continue" "return" "delete" "exit" "getline" "next"
2521 "nextfile" "print" "printf"))
2523 (c-lang-defconst c-simple-stmt-key
2524 ;; Adorned regexp matching `c-simple-stmt-kwds'.
2525 t
(c-make-keywords-re t
(c-lang-const c-simple-stmt-kwds
)))
2526 (c-lang-defvar c-simple-stmt-key
(c-lang-const c-simple-stmt-key
))
2528 (c-lang-defconst c-paren-stmt-kwds
2529 "Statement keywords followed by a parenthesis expression that
2530 nevertheless contains a list separated with `;' and not `,'."
2534 (c-lang-defconst c-paren-stmt-key
2535 ;; Adorned regexp matching `c-paren-stmt-kwds'.
2536 t
(c-make-keywords-re t
(c-lang-const c-paren-stmt-kwds
)))
2537 (c-lang-defvar c-paren-stmt-key
(c-lang-const c-paren-stmt-key
))
2539 (c-lang-defconst c-asm-stmt-kwds
2540 "Statement keywords followed by an assembler expression."
2542 (c c
++) '("asm" "__asm__")) ;; Not standard, but common.
2544 (c-lang-defconst c-opt-asm-stmt-key
2545 ;; Regexp matching the start of an assembler statement. Nil in
2546 ;; languages that don't support that.
2547 t
(if (c-lang-const c-asm-stmt-kwds
)
2548 (c-make-keywords-re t
(c-lang-const c-asm-stmt-kwds
))))
2549 (c-lang-defvar c-opt-asm-stmt-key
(c-lang-const c-opt-asm-stmt-key
))
2551 (c-lang-defconst c-case-kwds
2552 "The keyword(s) which introduce a \"case\" like construct.
2553 This construct is \"<keyword> <expression> :\"."
2557 (c-lang-defconst c-case-kwds-regexp
2558 ;; Adorned regexp matching any "case"-like keyword.
2559 t
(c-make-keywords-re t
(c-lang-const c-case-kwds
)))
2560 (c-lang-defvar c-case-kwds-regexp
(c-lang-const c-case-kwds-regexp
))
2562 (c-lang-defconst c-label-kwds
2563 "Keywords introducing colon terminated labels in blocks."
2564 t
'("case" "default"))
2566 (c-lang-defconst c-label-kwds-regexp
2567 ;; Adorned regexp matching any keyword that introduces a label.
2568 t
(c-make-keywords-re t
(c-lang-const c-label-kwds
)))
2569 (c-lang-defvar c-label-kwds-regexp
(c-lang-const c-label-kwds-regexp
))
2571 (c-lang-defconst c-before-label-kwds
2572 "Keywords that might be followed by a label identifier."
2574 (java pike
) (append '("break" "continue")
2575 (c-lang-const c-before-label-kwds
))
2579 (c-lang-defconst c-constant-kwds
2580 "Keywords for constants."
2582 c
'("NULL" ;; Not a keyword, but practically works as one.
2583 "false" "true") ; Defined in C99.
2586 (c-lang-const c-constant-kwds c
))
2587 objc
'("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER")
2588 idl
'("TRUE" "FALSE")
2589 java
'("true" "false" "null") ; technically "literals", not keywords
2590 pike
'("UNDEFINED")) ;; Not a keyword, but practically works as one.
2592 (c-lang-defconst c-primary-expr-kwds
2593 "Keywords besides constants and operators that start primary expressions."
2595 c
++ '("operator" "this")
2596 objc
'("super" "self")
2598 pike
'("this")) ;; Not really a keyword, but practically works as one.
2600 (c-lang-defconst c-expr-kwds
2601 ;; Keywords that can occur anywhere in expressions. Built from
2602 ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2603 t
(c--delete-duplicates
2604 (append (c-lang-const c-primary-expr-kwds
)
2605 (c-filter-ops (c-lang-const c-operator-list
)
2607 "\\`\\(\\w\\|\\s_\\)+\\'"))
2608 :test
'string-equal
))
2610 (c-lang-defconst c-lambda-kwds
2611 "Keywords that start lambda constructs, i.e. function definitions in
2616 (c-lang-defconst c-inexpr-block-kwds
2617 "Keywords that start constructs followed by statement blocks which can
2618 be used in expressions \(the gcc extension for this in C and C++ is
2619 handled separately by `c-recognize-paren-inexpr-blocks')."
2621 pike
'("catch" "gauge"))
2623 (c-lang-defconst c-inexpr-class-kwds
2624 "Keywords that can start classes inside expressions."
2629 (c-lang-defconst c-inexpr-brace-list-kwds
2630 "Keywords that can start brace list blocks inside expressions.
2631 Note that Java specific rules are currently applied to tell this from
2632 `c-inexpr-class-kwds'."
2636 (c-lang-defconst c-opt-inexpr-brace-list-key
2637 ;; Regexp matching the start of a brace list in an expression, or
2638 ;; nil in languages that don't have such things. This should not
2639 ;; match brace lists recognized through `c-special-brace-lists'.
2640 t
(and (c-lang-const c-inexpr-brace-list-kwds
)
2641 (c-make-keywords-re t
(c-lang-const c-inexpr-brace-list-kwds
))))
2642 (c-lang-defvar c-opt-inexpr-brace-list-key
2643 (c-lang-const c-opt-inexpr-brace-list-key
))
2645 (c-lang-defconst c-flat-decl-block-kwds
2646 ;; Keywords that can introduce another declaration level, i.e. where a
2647 ;; following "{" isn't a function block or brace list. Note that, for
2648 ;; historical reasons, `c-decl-block-key' is NOT constructed from this lang
2650 t
(c--delete-duplicates
2651 (append (c-lang-const c-class-decl-kwds
)
2652 (c-lang-const c-other-block-decl-kwds
)
2653 (c-lang-const c-inexpr-class-kwds
))
2654 :test
'string-equal
))
2656 (c-lang-defconst c-brace-stack-thing-key
2657 ;; Regexp matching any keyword or operator relevant to the brace stack (see
2658 ;; `c-update-brace-stack' in cc-engine.el).
2659 t
(c-make-keywords-re 'appendable
2661 (c-lang-const c-flat-decl-block-kwds
)
2662 (if (c-lang-const c-recognize-
<>-arglists
)
2663 '("{" "}" ";" "," ")" ":" "<")
2664 '("{" "}" ";" "," ")" ":")))))
2665 (c-lang-defvar c-brace-stack-thing-key
(c-lang-const c-brace-stack-thing-key
))
2667 (c-lang-defconst c-brace-stack-no-semi-key
2668 ;; Regexp matching any keyword or operator relevant to the brace stack when
2669 ;; a semicolon is not relevant (see `c-update-brace-stack' in
2671 t
(c-make-keywords-re 'appendable
2673 (c-lang-const c-flat-decl-block-kwds
)
2674 (if (c-lang-const c-recognize-
<>-arglists
)
2677 (c-lang-defvar c-brace-stack-no-semi-key
2678 (c-lang-const c-brace-stack-no-semi-key
))
2680 (c-lang-defconst c-decl-block-key
2681 ;; Regexp matching keywords in any construct that contain another
2682 ;; declaration level, i.e. that isn't followed by a function block
2683 ;; or brace list. When the first submatch matches, it's an
2684 ;; unambiguous construct, otherwise it's an ambiguous match that
2685 ;; might also be the return type of a function declaration.
2686 t
(let* ((decl-kwds (append (c-lang-const c-class-decl-kwds
)
2687 (c-lang-const c-other-block-decl-kwds
)
2688 (c-lang-const c-inexpr-class-kwds
)))
2689 (unambiguous (c--set-difference decl-kwds
2690 (c-lang-const c-type-start-kwds
)
2691 :test
'string-equal
))
2692 (ambiguous (c--intersection decl-kwds
2693 (c-lang-const c-type-start-kwds
)
2694 :test
'string-equal
)))
2696 (concat (c-make-keywords-re t unambiguous
)
2698 (c-make-keywords-re t ambiguous
))
2699 (c-make-keywords-re t unambiguous
))))
2700 (c-lang-defvar c-decl-block-key
(c-lang-const c-decl-block-key
))
2702 (c-lang-defconst c-bitfield-kwds
2703 "Keywords that can introduce bitfields."
2705 (c c
++ objc
) '("char" "int" "long" "signed" "unsigned"))
2707 (c-lang-defconst c-opt-bitfield-key
2708 ;; Regexp matching the start of a bitfield (not uniquely), or nil in
2709 ;; languages without bitfield support.
2711 (c c
++) (c-make-keywords-re t
(c-lang-const c-bitfield-kwds
)))
2712 (c-lang-defvar c-opt-bitfield-key
(c-lang-const c-opt-bitfield-key
))
2714 (c-lang-defconst c-other-kwds
2715 "Keywords not accounted for by any other `*-kwds' language constant."
2718 ;; In CORBA CIDL: (These are declaration keywords that never
2719 ;; can start a declaration.)
2720 "entity" "process" "service" "session" "storage"))
2723 ;;; Constants built from keywords.
2725 ;; Note: No `*-kwds' language constants may be defined below this point.
2728 (defconst c-kwds-lang-consts
2729 ;; List of all the language constants that contain keyword lists.
2731 (mapatoms (lambda (sym)
2732 (when (and (boundp sym
)
2733 (string-match "-kwds\\'" (symbol-name sym
)))
2734 ;; Make the list of globally interned symbols
2735 ;; instead of ones interned in `c-lang-constants'.
2736 (setq list
(cons (intern (symbol-name sym
)) list
))))
2740 (c-lang-defconst c-keywords
2741 ;; All keywords as a list.
2742 t
(c--delete-duplicates
2743 (c-lang-defconst-eval-immediately
2744 `(append ,@(mapcar (lambda (kwds-lang-const)
2745 `(c-lang-const ,kwds-lang-const
))
2748 :test
'string-equal
))
2750 (c-lang-defconst c-keywords-regexp
2751 ;; All keywords as an adorned regexp.
2752 t
(c-make-keywords-re t
(c-lang-const c-keywords
)))
2753 (c-lang-defvar c-keywords-regexp
(c-lang-const c-keywords-regexp
))
2755 (c-lang-defconst c-keyword-member-alist
2756 ;; An alist with all the keywords in the cars. The cdr for each
2757 ;; keyword is a list of the symbols for the `*-kwds' lists that
2759 t
(let ((kwd-list-alist
2760 (c-lang-defconst-eval-immediately
2761 `(list ,@(mapcar (lambda (kwds-lang-const)
2762 `(cons ',kwds-lang-const
2763 (c-lang-const ,kwds-lang-const
)))
2764 c-kwds-lang-consts
))))
2765 lang-const kwd-list kwd
2767 (while kwd-list-alist
2768 (setq lang-const
(caar kwd-list-alist
)
2769 kwd-list
(cdar kwd-list-alist
)
2770 kwd-list-alist
(cdr kwd-list-alist
))
2772 (setq kwd
(car kwd-list
)
2773 kwd-list
(cdr kwd-list
))
2774 (unless (setq elem
(assoc kwd result-alist
))
2775 (setq result-alist
(cons (setq elem
(list kwd
)) result-alist
)))
2776 (unless (memq lang-const
(cdr elem
))
2777 (setcdr elem
(cons lang-const
(cdr elem
))))))
2780 (c-lang-defvar c-keywords-obarray
2781 ;; An obarray containing all keywords as symbols. The property list
2782 ;; of each symbol has a non-nil entry for the specific `*-kwds'
2783 ;; lists it's a member of.
2785 ;; E.g. to see whether the string str contains a keyword on
2786 ;; `c-class-decl-kwds', one can do like this:
2787 ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
2788 ;; Which preferably is written using the associated functions in
2790 ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
2792 ;; The obarray is not stored directly as a language constant since
2793 ;; the printed representation for obarrays used in .elc files isn't
2796 (let* ((alist (c-lang-const c-keyword-member-alist
))
2798 (obarray (make-vector (* (length alist
) 2) 0)))
2800 (setq kwd
(caar alist
)
2801 lang-const-list
(cdar alist
)
2803 (setplist (intern kwd obarray
)
2804 ;; Emacs has an odd bug that causes `mapcan' to fail
2805 ;; with unintelligible errors. (XEmacs works.)
2806 ;; (2015-06-24): This bug has not yet been fixed.
2807 ;;(mapcan (lambda (lang-const)
2808 ;; (list lang-const t))
2810 (apply 'nconc
(mapcar (lambda (lang-const)
2811 (list lang-const t
))
2815 (c-lang-defconst c-regular-keywords-regexp
2816 ;; Adorned regexp matching all keywords that should be fontified
2817 ;; with the keywords face. I.e. that aren't types or constants.
2818 t
(c-make-keywords-re t
2819 (c--set-difference (c-lang-const c-keywords
)
2820 (append (c-lang-const c-primitive-type-kwds
)
2821 (c-lang-const c-constant-kwds
))
2822 :test
'string-equal
)))
2823 (c-lang-defvar c-regular-keywords-regexp
2824 (c-lang-const c-regular-keywords-regexp
))
2826 (c-lang-defconst c-primary-expr-regexp
2827 ;; Regexp matching the start of any primary expression, i.e. any
2828 ;; literal, symbol, prefix operator, and '('. It doesn't need to
2829 ;; exclude keywords; they are excluded afterwards unless the second
2830 ;; submatch matches. If the first but not the second submatch
2831 ;; matches then it is an ambiguous primary expression; it could also
2832 ;; be a match of e.g. an infix operator. (The case with ambiguous
2833 ;; keyword operators isn't handled.)
2835 t
(let* ((prefix-ops
2836 (c-filter-ops (c-lang-const c-operators
)
2839 ;; Filter out the special case prefix
2840 ;; operators that are close parens.
2841 (not (string-match "\\s)" op
)))))
2843 (nonkeyword-prefix-ops
2844 (c-filter-ops prefix-ops
2846 "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2849 (c-filter-ops (c-lang-const c-operators
)
2854 right-assoc-sequence
)
2859 ;; Take out all symbol class operators from `prefix-ops' and make the
2860 ;; first submatch from them together with `c-primary-expr-kwds'.
2861 (c-make-keywords-re t
2862 (append (c-lang-const c-primary-expr-kwds
)
2863 (c--set-difference prefix-ops nonkeyword-prefix-ops
2864 :test
'string-equal
)))
2867 ;; Match all ambiguous operators.
2868 (c-make-keywords-re nil
2869 (c--intersection nonkeyword-prefix-ops in-or-postfix-ops
2870 :test
'string-equal
))
2874 ;; Now match all other symbols.
2875 (c-lang-const c-symbol-start
)
2878 ;; The chars that can start integer and floating point
2883 ;; The unambiguous operators from `prefix-ops'.
2884 (c-make-keywords-re nil
2885 (c--set-difference nonkeyword-prefix-ops in-or-postfix-ops
2886 :test
'string-equal
))
2889 ;; Match string and character literals.
2891 (if (memq 'gen-string-delim c-emacs-features
)
2894 (c-lang-defvar c-primary-expr-regexp
(c-lang-const c-primary-expr-regexp
))
2897 ;;; Additional constants for parser-level constructs.
2899 (c-lang-defconst c-decl-start-colon-kwd-re
2900 "Regexp matching a keyword that is followed by a colon, where
2901 the whole construct can precede a declaration.
2902 E.g. \"public:\" in C++."
2904 c
++ (c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
2905 (c-lang-defvar c-decl-start-colon-kwd-re
2906 (c-lang-const c-decl-start-colon-kwd-re
))
2908 (c-lang-defconst c-decl-prefix-re
2909 "Regexp matching something that might precede a declaration, cast or
2910 label, such as the last token of a preceding statement or declaration.
2911 This is used in the common situation where a declaration or cast
2912 doesn't start with any specific token that can be searched for.
2914 The regexp should not match bob; that is done implicitly. It can't
2915 require a match longer than one token. The end of the token is taken
2916 to be at the end of the first submatch, which is assumed to always
2917 match. It's undefined whether identifier syntax (see
2918 `c-identifier-syntax-table') is in effect or not. This regexp is
2919 assumed to be a superset of `c-label-prefix-re' if
2920 `c-recognize-colon-labels' is set.
2922 Besides this, `c-decl-start-kwds' is used to find declarations.
2924 Note: This variable together with `c-decl-start-re' and
2925 `c-decl-start-kwds' is only used to detect \"likely\"
2926 declaration/cast/label starts. I.e. they might produce more matches
2927 but should not miss anything (or else it's necessary to use text
2928 properties - see the next note). Wherever they match, the following
2929 construct is analyzed to see if it indeed is a declaration, cast or
2930 label. That analysis is not cheap, so it's important that not too
2931 many false matches are triggered.
2933 Note: If a declaration/cast/label start can't be detected with this
2934 variable, it's necessary to use the `c-type' text property with the
2935 value `c-decl-end' on the last char of the last token preceding the
2936 declaration. See the comment blurb at the start of cc-engine.el for
2939 ;; We match a sequence of characters to skip over things like \"};\"
2940 ;; more quickly. We match ")" in C for K&R region declarations, and
2941 ;; in all languages except Java for when a cpp macro definition
2942 ;; begins with a declaration.
2944 java
"\\([{}(;,<]+\\)"
2945 ;; Match "<" in C++ to get the first argument in a template arglist.
2946 ;; In that case there's an additional check in `c-find-decl-spots'
2947 ;; that it got open paren syntax. Match ":" to aid in picking up
2948 ;; "public:", etc. This involves additional checks in
2949 ;; `c-find-decl-prefix-search' to prevent a match of identifiers
2951 c
++ "\\([{}();:,<]+\\)"
2952 ;; Additionally match the protection directives in Objective-C.
2953 ;; Note that this doesn't cope with the longer directives, which we
2954 ;; would have to match from start to end since they don't end with
2955 ;; any easily recognized characters.
2956 objc
(concat "\\([{}();,]+\\|"
2957 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
2959 ;; Pike is like C but we also match "[" for multiple value
2960 ;; assignments and type casts.
2961 pike
"\\([{}()[;,]+\\)")
2962 (c-lang-defvar c-decl-prefix-re
(c-lang-const c-decl-prefix-re
)
2965 (c-lang-defconst c-decl-start-re
2966 "Regexp matching the start of any declaration, cast or label.
2967 It's used on the token after the one `c-decl-prefix-re' matched. This
2968 regexp should not try to match those constructs accurately as it's
2969 only used as a sieve to avoid spending more time checking other
2971 t
(c-lang-const c-identifier-start
))
2972 (c-lang-defvar c-decl-start-re
(c-lang-const c-decl-start-re
))
2974 (c-lang-defconst c-decl-prefix-or-start-re
2975 ;; Regexp matching something that might precede or start a
2976 ;; declaration, cast or label.
2978 ;; If the first submatch matches, it's taken to match the end of a
2979 ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2980 ;; It's built from `c-decl-prefix-re'.
2982 ;; If the first submatch did not match, the match of the whole
2983 ;; regexp is taken to be at the first token in the declaration.
2984 ;; `c-decl-start-re' is not checked in this case.
2986 ;; Design note: The reason the same regexp is used to match both
2987 ;; tokens that precede declarations and start them is to avoid an
2988 ;; extra regexp search from the previous declaration spot in
2989 ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
2990 ;; that it finds all declaration/cast/label starts in approximately
2991 ;; linear order, so we can't do the searches in two separate passes.
2992 t
(if (c-lang-const c-decl-start-kwds
)
2993 (concat (c-lang-const c-decl-prefix-re
)
2995 (c-make-keywords-re t
(c-lang-const c-decl-start-kwds
)))
2996 (c-lang-const c-decl-prefix-re
)))
2997 (c-lang-defvar c-decl-prefix-or-start-re
2998 (c-lang-const c-decl-prefix-or-start-re
))
3000 (c-lang-defconst c-cast-parens
3001 ;; List containing the paren characters that can open a cast, or nil in
3002 ;; languages without casts.
3003 t
(c-filter-ops (c-lang-const c-operators
)
3006 (lambda (op) (elt op
0))))
3007 (c-lang-defvar c-cast-parens
(c-lang-const c-cast-parens
))
3009 (c-lang-defconst c-block-prefix-disallowed-chars
3010 "List of syntactically relevant characters that never can occur before
3011 the open brace in any construct that contains a brace block, e.g. in
3012 the \"class Foo: public Bar\" part of:
3014 class Foo: public Bar {int x();} a, *b;
3016 If parens can occur, the chars inside those aren't filtered with this
3019 `<' and `>' should be disallowed even if angle bracket arglists can
3020 occur. That since the search function needs to stop at them anyway to
3021 ensure they are given paren syntax.
3023 This is used to skip backward from the open brace to find the region
3024 in which to look for a construct like \"class\", \"enum\",
3025 \"namespace\" or whatever. That skipping should be as tight as
3026 possible for good performance."
3028 ;; Default to all chars that only occurs in nonsymbol tokens outside
3030 t
(c--set-difference
3031 (c-lang-const c-nonsymbol-token-char-list
)
3032 (c-filter-ops (append (c-lang-const c-identifier-ops
)
3034 (c-lang-const c-after-id-concat-ops
))))
3039 (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
3041 (setq res
(cons (aref op
(match-beginning 1)) res
)
3045 ;; Allow cpp operations (where applicable).
3046 t
(if (c-lang-const c-opt-cpp-prefix
)
3047 (c--set-difference (c-lang-const c-block-prefix-disallowed-chars
)
3049 (c-lang-const c-block-prefix-disallowed-chars
))
3051 ;; Allow ':' for inherit list starters.
3052 (c++ objc idl
) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars
)
3055 ;; Allow ',' for multiple inherits.
3056 (c++ java
) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars
)
3059 ;; Allow parentheses for anonymous inner classes in Java and class
3060 ;; initializer lists in Pike.
3061 (java pike
) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars
)
3064 ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
3065 (c c
++ objc
) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars
)
3068 (c-lang-defconst c-block-prefix-charset
3069 ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
3070 ;; for `c-syntactic-skip-backward'.
3071 t
(c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars
) t
))
3072 (c-lang-defvar c-block-prefix-charset
(c-lang-const c-block-prefix-charset
))
3074 (c-lang-defconst c-type-decl-prefix-key
3075 "Regexp matching any declarator operator that might precede the
3076 identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
3077 regexp should match \"(\" if parentheses are valid in declarators.
3078 The end of the first submatch is taken as the end of the operator.
3079 Identifier syntax is in effect when this is matched \(see
3080 `c-identifier-syntax-table')."
3081 t
(if (c-lang-const c-type-modifier-kwds
)
3082 (concat (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>")
3083 ;; Default to a regexp that never matches.
3085 ;; Check that there's no "=" afterwards to avoid matching tokens
3087 (c objc
) (concat "\\("
3090 (c-lang-const c-type-decl-prefix-key
)
3100 (c-lang-const c-type-decl-prefix-key
)
3103 ;; If this matches there's special treatment in
3104 ;; `c-font-lock-declarators' and
3105 ;; `c-font-lock-declarations' that check for a
3106 ;; complete name followed by ":: *".
3107 (c-lang-const c-identifier-start
)
3111 pike
"\\(\\*\\)\\([^=]\\|$\\)")
3112 (c-lang-defvar c-type-decl-prefix-key
(c-lang-const c-type-decl-prefix-key
)
3115 (c-lang-defconst c-type-decl-operator-prefix-key
3116 "Regexp matching any declarator operator which isn't a keyword
3117 that might precede the identifier in a declaration, e.g. the
3118 \"*\" in \"char *argv\". The end of the first submatch is taken
3119 as the end of the operator. Identifier syntax is in effect when
3120 this is matched \(see `c-identifier-syntax-table')."
3121 t
;; Default to a regexp that never matches.
3123 ;; Check that there's no "=" afterwards to avoid matching tokens
3125 (c objc
) (concat "\\(\\*\\)"
3133 pike
"\\(\\*\\)\\([^=]\\|$\\)")
3134 (c-lang-defvar c-type-decl-operator-prefix-key
3135 (c-lang-const c-type-decl-operator-prefix-key
))
3137 (c-lang-defconst c-type-decl-suffix-key
3138 "Regexp matching the declarator operators that might follow after the
3139 identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
3140 regexp should match \")\" if parentheses are valid in declarators. If
3141 it matches an open paren of some kind, the type declaration check
3142 continues at the corresponding close paren, otherwise the end of the
3143 first submatch is taken as the end of the operator. Identifier syntax
3144 is in effect when this is matched (see `c-identifier-syntax-table')."
3145 ;; Default to a regexp that matches `c-type-modifier-kwds' and a
3146 ;; function argument list parenthesis.
3147 t
(if (c-lang-const c-type-modifier-kwds
)
3149 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
) "\\>"
3152 (c c
++ objc
) (concat
3155 (if (c-lang-const c-type-modifier-kwds
)
3158 ;; "throw" in `c-type-modifier-kwds' is followed
3159 ;; by a parenthesis list, but no extra measures
3160 ;; are necessary to handle that.
3161 (regexp-opt (c-lang-const c-type-modifier-kwds
) t
)
3167 (c-lang-defvar c-type-decl-suffix-key
(c-lang-const c-type-decl-suffix-key
)
3170 (c-lang-defconst c-after-suffixed-type-decl-key
3171 "This regexp is matched after a declarator expression where
3172 `c-type-decl-suffix-key' has matched. If it matches then the
3173 construct is taken as a declaration. It's typically used to match the
3174 beginning of a function body or whatever might occur after the
3175 function header in a function declaration or definition. It's
3176 undefined whether identifier syntax (see `c-identifier-syntax-table')
3177 is in effect or not.
3179 Note that it's used in cases like after \"foo (bar)\" so it should
3180 only match when it's certain that it's a declaration, e.g., \"{\" but
3181 not \",\" or \";\"."
3183 ;; If K&R style declarations should be recognized then one could
3184 ;; consider to match the start of any symbol since we want to match
3185 ;; the start of the first declaration in the "K&R region". That
3186 ;; could however produce false matches on code like "FOO(bar) x"
3187 ;; where FOO is a cpp macro, so it's better to leave it out and rely
3188 ;; on the other heuristics in that case.
3189 t
(if (c-lang-const c-postfix-spec-kwds
)
3190 ;; Add on the keywords in `c-postfix-spec-kwds'.
3191 (concat (c-lang-const c-after-suffixed-type-decl-key
)
3193 (c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
3194 (c-lang-const c-after-suffixed-type-decl-key
))
3195 ;; Also match the colon that starts a base class initializer list in
3196 ;; C++. That can be confused with a function call before the colon
3197 ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
3198 ;; match before such a thing (as a declaration-level construct;
3199 ;; matches inside arglist contexts are already excluded).
3201 (c-lang-defvar c-after-suffixed-type-decl-key
3202 (c-lang-const c-after-suffixed-type-decl-key
)
3205 (c-lang-defconst c-after-suffixed-type-maybe-decl-key
3206 ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
3207 ;; matches ";" and ",".
3208 t
(concat "\\(" (c-lang-const c-after-suffixed-type-decl-key
) "\\)"
3210 (c-lang-defvar c-after-suffixed-type-maybe-decl-key
3211 (c-lang-const c-after-suffixed-type-maybe-decl-key
))
3213 (c-lang-defconst c-opt-type-concat-key
3214 "Regexp matching operators that concatenate types, e.g. the \"|\" in
3215 \"int|string\" in Pike. The end of the first submatch is taken as the
3216 end of the operator. nil in languages without such operators. It's
3217 undefined whether identifier syntax (see `c-identifier-syntax-table')
3218 is in effect or not."
3220 pike
"\\([|.&]\\)\\($\\|[^|.&]\\)")
3221 (c-lang-defvar c-opt-type-concat-key
(c-lang-const c-opt-type-concat-key
)
3224 (c-lang-defconst c-opt-type-suffix-key
3225 "Regexp matching operators that might follow after a type, or nil in
3226 languages that don't have such operators. The end of the first
3227 submatch is taken as the end of the operator. This should not match
3228 things like C++ template arglists if `c-recognize-<>-arglists' is set.
3229 It's undefined whether identifier syntax (see `c-identifier-syntax-table')
3230 is in effect or not."
3232 (c c
++ objc pike
) "\\(\\.\\.\\.\\)"
3233 java
(concat "\\(\\[" (c-lang-const c-simple-ws
) "*\\]\\|\\.\\.\\.\\)"))
3234 (c-lang-defvar c-opt-type-suffix-key
(c-lang-const c-opt-type-suffix-key
))
3236 (c-lang-defvar c-known-type-key
3237 ;; Regexp matching the known type identifiers. This is initialized
3238 ;; from the type keywords and `*-font-lock-extra-types'. The first
3239 ;; submatch is the one that matches the type. Note that this regexp
3240 ;; assumes that symbol constituents like '_' and '$' have word
3243 (when (boundp (c-mode-symbol "font-lock-extra-types"))
3244 (c-mode-var "font-lock-extra-types")))
3246 (delq nil
(mapcar (lambda (re)
3247 (when (string-match "[][.*+?^$\\]" re
)
3251 (delq nil
(mapcar (lambda (re)
3252 (unless (string-match "[][.*+?^$\\]" re
)
3257 (append (list (c-make-keywords-re nil
3258 (append (c-lang-const c-primitive-type-kwds
)
3264 (c-lang-defconst c-special-brace-lists
3265 "List of open- and close-chars that makes up a pike-style brace list,
3266 i.e., for a ([ ]) list there should be a cons (?\\[ . ?\\]) in this
3269 pike
'((?
{ . ?
}) (?\
[ . ?\
]) (?
< . ?
>)))
3270 (c-lang-defvar c-special-brace-lists
(c-lang-const c-special-brace-lists
))
3272 (c-lang-defconst c-recognize-knr-p
3273 "Non-nil means K&R style argument declarations are valid."
3276 (c-lang-defvar c-recognize-knr-p
(c-lang-const c-recognize-knr-p
))
3278 (c-lang-defconst c-pre-id-bracelist-key
3279 "A regexp matching tokens which, preceding an identifier, signify a bracelist.
3282 c
++ "new\\([^[:alnum:]_$]\\|$\\)\\|&&?\\(\\S.\\|$\\)")
3283 (c-lang-defvar c-pre-id-bracelist-key
(c-lang-const c-pre-id-bracelist-key
))
3285 (c-lang-defconst c-recognize-typeless-decls
3286 "Non-nil means function declarations without return type should be
3287 recognized. That can introduce an ambiguity with parenthesized macro
3288 calls before a brace block. This setting does not affect declarations
3289 that are preceded by a declaration starting keyword, so
3290 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
3292 (c c
++ objc java
) t
)
3293 (c-lang-defvar c-recognize-typeless-decls
3294 (c-lang-const c-recognize-typeless-decls
))
3296 (c-lang-defconst c-recognize-
<>-arglists
3297 "Non-nil means C++ style template arglists should be handled. More
3298 specifically, this means a comma separated list of types or
3299 expressions surrounded by \"<\" and \">\". It's always preceded by an
3300 identifier or one of the keywords on `c-<>-type-kwds' or
3301 `c-<>-arglist-kwds'. If there's an identifier before then the whole
3302 expression is considered to be a type."
3303 t
(or (consp (c-lang-const c-
<>-type-kwds
))
3304 (consp (c-lang-const c-
<>-arglist-kwds
)))
3305 java t
) ; 2008-10-19. This is crude. The syntax for java
3306 ; generics is not yet coded in CC Mode.
3307 (c-lang-defvar c-recognize-
<>-arglists
(c-lang-const c-recognize-
<>-arglists
))
3309 (c-lang-defconst c-
<>-notable-chars-re
3310 "A regexp matching any single character notable inside a <...> construct.
3311 This must include \"<\" and \">\", and should include \",\", and
3312 any character which cannot be valid inside such a construct.
3313 This is used in `c-forward-<>-arglist-recur' to try to detect
3314 sequences of tokens which cannot be a template/generic construct.
3315 When \"(\" is present, that defun will attempt to parse a
3316 parenthesized expression inside the template. When \")\" is
3317 present it will treat an unbalanced closing paren as a sign of
3318 the invalidity of the putative template construct."
3321 (c-lang-defvar c-
<>-notable-chars-re
(c-lang-const c-
<>-notable-chars-re
))
3323 (c-lang-defconst c-enum-clause-introduction-re
3324 ;; A regexp loosely matching the start of an enum clause, starting at the
3325 ;; keyword itself, and extending up to the "{". It may match text which
3326 ;; isn't such a construct; more accurate tests will rule these out when
3328 t
(if (c-lang-const c-brace-list-decl-kwds
)
3331 (c-make-keywords-re nil
(c-lang-const c-brace-list-decl-kwds
))
3333 ;; Disallow various common punctuation chars that can't come
3334 ;; before the '{' of the enum list, to avoid searching too far.
3338 (c-lang-defvar c-enum-clause-introduction-re
3339 (c-lang-const c-enum-clause-introduction-re
))
3341 (c-lang-defconst c-enums-contain-decls
3342 "Non-nil means that an enum structure can contain declarations."
3345 (c-lang-defvar c-enums-contain-decls
(c-lang-const c-enums-contain-decls
))
3347 (c-lang-defconst c-recognize-paren-inits
3348 "Non-nil means that parenthesis style initializers exist,
3349 i.e. constructs like
3353 in addition to the more classic
3358 (c-lang-defvar c-recognize-paren-inits
(c-lang-const c-recognize-paren-inits
))
3360 (c-lang-defconst c-recognize-paren-inexpr-blocks
3361 "Non-nil to recognize gcc style in-expression blocks,
3362 i.e. compound statements surrounded by parentheses inside expressions."
3365 (c-lang-defvar c-recognize-paren-inexpr-blocks
3366 (c-lang-const c-recognize-paren-inexpr-blocks
))
3368 (c-lang-defconst c-opt-
<>-arglist-start
3369 ;; Regexp matching the start of angle bracket arglists in languages
3370 ;; where `c-recognize-<>-arglists' is set. Does not exclude
3371 ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
3372 ;; assumed to surround the preceding symbol. The whole match is
3373 ;; assumed to end directly after the opening "<".
3374 t
(if (c-lang-const c-recognize-
<>-arglists
)
3376 (c-lang-const c-symbol-key
)
3378 (c-lang-const c-syntactic-ws
)
3380 (c-lang-defvar c-opt-
<>-arglist-start
(c-lang-const c-opt-
<>-arglist-start
))
3382 (c-lang-defconst c-opt-
<>-arglist-start-in-paren
3383 ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
3384 ;; parens. The first submatch is assumed to surround
3385 ;; `c-opt-<>-arglist-start'.
3386 t
(if (c-lang-const c-opt-
<>-arglist-start
)
3388 (c-lang-const c-opt-
<>-arglist-start
)
3390 (c-lang-defvar c-opt-
<>-arglist-start-in-paren
3391 (c-lang-const c-opt-
<>-arglist-start-in-paren
))
3393 (c-lang-defconst c-opt-postfix-decl-spec-key
3394 ;; Regexp matching the beginning of a declaration specifier in the
3395 ;; region between the header and the body of a declaration.
3397 ;; TODO: This is currently not used uniformly; c++-mode and
3398 ;; java-mode each have their own ways of using it.
3401 (c-lang-const c-simple-ws
) "*"
3402 "\\(virtual" (c-lang-const c-simple-ws
) "+\\)?\\("
3403 (c-make-keywords-re nil
(c-lang-const c-protection-kwds
))
3404 "\\)" (c-lang-const c-simple-ws
) "+"
3405 "\\(" (c-lang-const c-symbol-key
) "\\)")
3406 java
(c-make-keywords-re t
(c-lang-const c-postfix-spec-kwds
)))
3407 (c-lang-defvar c-opt-postfix-decl-spec-key
3408 (c-lang-const c-opt-postfix-decl-spec-key
))
3410 (c-lang-defconst c-recognize-colon-labels
3411 "Non-nil if generic labels ending with \":\" should be recognized.
3412 That includes labels in code and access keys in classes. This does
3413 not apply to labels recognized by `c-label-kwds' and
3414 `c-opt-extra-label-key'."
3416 (c c
++ objc java pike
) t
)
3417 (c-lang-defvar c-recognize-colon-labels
3418 (c-lang-const c-recognize-colon-labels
))
3420 (c-lang-defconst c-label-prefix-re
3421 "Regexp like `c-decl-prefix-re' that matches any token that can precede
3422 a generic colon label. Not used if `c-recognize-colon-labels' is
3425 (c-lang-defvar c-label-prefix-re
3426 (c-lang-const c-label-prefix-re
))
3428 (c-lang-defconst c-nonlabel-token-key
3429 "Regexp matching things that can't occur in generic colon labels,
3430 neither in a statement nor in a declaration context. The regexp is
3431 tested at the beginning of every sexp in a suspected label,
3432 i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
3434 ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
3435 (c-make-keywords-re t
3436 (c--set-difference (c-lang-const c-keywords
)
3437 (append (c-lang-const c-label-kwds
)
3438 (c-lang-const c-protection-kwds
))
3439 :test
'string-equal
)))
3440 ;; Don't allow string literals, except in AWK and Java. Character constants are OK.
3441 (c objc pike idl
) (concat "\"\\|"
3442 (c-lang-const c-nonlabel-token-key
))
3443 ;; Also check for open parens in C++, to catch member init lists in
3444 ;; constructors. We normally allow it so that macros with arguments
3446 c
++ (concat "\\s(\\|\"\\|" (c-lang-const c-nonlabel-token-key
)))
3447 (c-lang-defvar c-nonlabel-token-key
(c-lang-const c-nonlabel-token-key
))
3449 (c-lang-defconst c-nonlabel-token-2-key
3450 "Regexp matching things that can't occur two symbols before a colon in
3451 a label construct. This catches C++'s inheritance construct \"class foo
3452 : bar\". Only used if `c-recognize-colon-labels' is set."
3453 t
"\\<\\>" ; matches nothing
3454 c
++ (c-make-keywords-re t
'("class")))
3455 (c-lang-defvar c-nonlabel-token-2-key
(c-lang-const c-nonlabel-token-2-key
))
3457 (c-lang-defconst c-opt-extra-label-key
3458 "Optional regexp matching labels.
3459 Normally, labels are detected according to `c-nonlabel-token-key',
3460 `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
3461 be used if there are additional labels that aren't recognized that
3464 objc
(c-make-keywords-re t
(c-lang-const c-protection-kwds
)))
3465 (c-lang-defvar c-opt-extra-label-key
(c-lang-const c-opt-extra-label-key
))
3467 (c-lang-defconst c-opt-friend-key
3468 ;; Regexp describing friend declarations classes, or nil in
3469 ;; languages that don't have such things.
3471 ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
3472 ;; template skipping isn't done properly. This will disappear soon.
3474 c
++ (concat "friend" (c-lang-const c-simple-ws
) "+"
3477 (c-lang-const c-simple-ws
) "*"
3479 (c-lang-const c-simple-ws
) "*"
3481 (c-lang-const c-simple-ws
) "+")))
3482 (c-lang-defvar c-opt-friend-key
(c-lang-const c-opt-friend-key
))
3484 (c-lang-defconst c-opt-method-key
3485 ;; Special regexp to match the start of Objective-C methods. The
3486 ;; first submatch is assumed to end after the + or - key.
3489 ;; TODO: Ought to use a better method than anchoring on bol.
3492 (c-lang-const c-simple-ws
) "*"
3493 (concat "\\(" ; Return type.
3495 (c-lang-const c-simple-ws
) "*"
3497 "\\(" (c-lang-const c-symbol-key
) "\\)"))
3498 (c-lang-defvar c-opt-method-key
(c-lang-const c-opt-method-key
))
3500 (c-lang-defconst c-type-decl-end-used
3501 ;; Must be set in buffers where the `c-type' text property might be
3502 ;; used with the value `c-decl-end'.
3504 ;; `c-decl-end' is used to mark the ends of labels and access keys
3505 ;; to make interactive refontification work better.
3506 t
(or (c-lang-const c-recognize-colon-labels
)
3507 (and (c-lang-const c-label-kwds
) t
))
3508 ;; `c-decl-end' is used to mark the end of the @-style directives in
3511 (c-lang-defvar c-type-decl-end-used
(c-lang-const c-type-decl-end-used
))
3513 (c-lang-defconst c-maybe-decl-faces
3514 "List of faces that might be put at the start of a type when
3515 `c-font-lock-declarations' runs. This must be evaluated (with `eval') at
3516 runtime to get the actual list of faces. This ensures that face name
3517 aliases in Emacs are resolved."
3520 c-reference-face-name
3521 font-lock-keyword-face
)
3522 java
(append (c-lang-const c-maybe-decl-faces
)
3523 '(font-lock-preprocessor-face)))
3524 (c-lang-defvar c-maybe-decl-faces
(c-lang-const c-maybe-decl-faces
))
3527 ;;; Wrap up the `c-lang-defvar' system.
3529 ;; Compile in the list of language variables that has been collected
3530 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
3531 ;; first element of each is nil.
3532 (defconst c-lang-variable-inits
(cc-eval-when-compile c-lang-variable-inits
))
3533 (defconst c-emacs-variable-inits
(cc-eval-when-compile c-emacs-variable-inits
))
3535 ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
3536 ;; These are typically standard emacs variables such as `comment-start'.
3537 (defmacro c-make-emacs-variables-local
()
3539 ,@(mapcar (lambda (init)
3540 `(make-local-variable ',(car init
)))
3541 (cdr c-emacs-variable-inits
))))
3543 (defun c-make-init-lang-vars-fun (mode)
3544 "Create a function that initializes all the language dependent variables
3547 This function should be evaluated at compile time, so that the
3548 function it returns is byte compiled with all the evaluated results
3549 from the language constants. Use the `c-init-language-vars' macro to
3550 accomplish that conveniently."
3552 (if (cc-bytecomp-is-compiling)
3553 ;; No need to byte compile this lambda since the byte compiler is
3554 ;; smart enough to detect the `funcall' construct in the
3555 ;; `c-init-language-vars' macro below and compile it all straight
3556 ;; into the function that contains `c-init-language-vars'.
3559 ;; This let sets up the context for `c-mode-var' and similar
3560 ;; that could be in the result from `c--macroexpand-all'.
3561 (let ((c-buffer-is-cc-mode ',mode
)
3562 current-var source-eval
)
3563 (c-make-emacs-variables-local)
3566 (if (eq c-version-sym
',c-version-sym
)
3567 (setq ,@(let ((c-buffer-is-cc-mode mode
)
3568 (c-lang-const-expansion 'immediate
))
3569 ;; `c-lang-const' will expand to the evaluated
3570 ;; constant immediately in `c--macroexpand-all'
3574 `(current-var ',(car init
)
3575 ,(car init
) ,(c--macroexpand-all
3577 ;; Note: The following `append' copies the
3578 ;; first argument. That list is small, so
3579 ;; this doesn't matter too much.
3580 (append (cdr c-emacs-variable-inits
)
3581 (cdr c-lang-variable-inits
)))))
3583 ;; This diagnostic message isn't useful for end
3584 ;; users, so it's disabled.
3585 ;;(unless (get ',mode 'c-has-warned-lang-consts)
3586 ;; (message ,(concat "%s compiled with CC Mode %s "
3587 ;; "but loaded with %s - evaluating "
3588 ;; "language constants from source")
3589 ;; ',mode ,c-version c-version)
3590 ;; (put ',mode 'c-has-warned-lang-consts t))
3592 (setq source-eval t
)
3593 (let ((init ',(append (cdr c-emacs-variable-inits
)
3594 (cdr c-lang-variable-inits
))))
3595 (dolist (var-init init
)
3596 (setq current-var
(car var-init
))
3597 (set (car var-init
) (eval (cadr var-init
))))))
3601 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
3605 (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
3606 ',mode
,c-version c-version
)
3609 (signal (car err
) (cdr err
)))))))
3611 ;; Being evaluated from source. Always use the dynamic method to
3612 ;; work well when `c-lang-defvar's in this file are reevaluated
3616 (let ((c-buffer-is-cc-mode ',mode
)
3617 (init (append (cdr c-emacs-variable-inits
)
3618 (cdr c-lang-variable-inits
)))
3620 (c-make-emacs-variables-local)
3623 (dolist (var-init init
)
3624 (setq current-var
(car var-init
))
3625 (set (car var-init
) (eval (cadr var-init
))))
3630 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
3632 (signal (car err
) (cdr err
)))))))
3635 (defmacro c-init-language-vars
(mode)
3636 "Initialize all the language dependent variables for the given mode.
3637 This macro is expanded at compile time to a form tailored for the mode
3638 in question, so MODE must be a constant. Therefore MODE is not
3639 evaluated and should not be quoted."
3640 `(funcall ,(c-make-init-lang-vars-fun mode
)))
3643 (cc-provide 'cc-langs
)
3646 ;; indent-tabs-mode: t
3649 ;;; cc-langs.el ends here