/[emacs]/emacs/lisp/progmodes/cc-langs.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/cc-langs.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by nickrob, Mon Aug 1 08:37:49 2005 UTC revision 1.34 by acmacm, Fri Dec 2 12:30:36 2005 UTC
# Line 1  Line 1 
1  ;;; cc-langs.el --- language specific settings for CC Mode  ;;; cc-langs.el --- language specific settings for CC Mode
2    
3  ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation, Inc.  ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation,
4    ;; Inc.
5    
6  ;; Authors:    1998- Martin Stjernholm  ;; Authors:    1998- Martin Stjernholm
7  ;;             1992-1999 Barry A. Warsaw  ;;             1992-1999 Barry A. Warsaw
# Line 24  Line 25 
25  ;; GNU General Public License for more details.  ;; GNU General Public License for more details.
26    
27  ;; You should have received a copy of the GNU General Public License  ;; You should have received a copy of the GNU General Public License
28  ;; along with GNU Emacs; see the file COPYING.  If not, write to  ;; along with this program; see the file COPYING.  If not, write to
29  ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
30  ;; Boston, MA 02110-1301, USA.  ;; Boston, MA 02110-1301, USA.
31    
# Line 124  Line 125 
125  (cc-require 'cc-defs)  (cc-require 'cc-defs)
126  (cc-require 'cc-vars)  (cc-require 'cc-vars)
127    
128    
129  ;; This file is not always loaded.  See note above.  ;; This file is not always loaded.  See note above.
130  (cc-external-require 'cl)  (cc-external-require 'cl)
131    
# Line 140  Line 142 
142          c-lang-variable-inits-tail c-lang-variable-inits))          c-lang-variable-inits-tail c-lang-variable-inits))
143    
144  (defmacro c-lang-defvar (var val &optional doc)  (defmacro c-lang-defvar (var val &optional doc)
145    "Declares the buffer local variable VAR to get the value VAL at mode    "Declares the buffer local variable VAR to get the value VAL.  VAL is
146  initialization, at which point VAL is evaluated.  More accurately, VAL  evaluated and assigned at mode initialization.  More precisely, VAL is
147  is evaluated and bound to VAR when the result from the macro  evaluated and bound to VAR when the result from the macro
148  `c-init-language-vars' is evaluated.  `c-init-language-vars' is evaluated.
149    
150  `c-lang-const' is typically used in VAL to get the right value for the  `c-lang-const' is typically used in VAL to get the right value for the
151  language being initialized, and such calls will be macro expanded to  language being initialized, and such calls will be macro expanded to
152  the evaluated constant value at compile time.  the evaluated constant value at compile time."
   
 This macro does not do any hidden buffer changes."  
153    
154    (when (and (not doc)    (when (and (not doc)
155               (eq (car-safe val) 'c-lang-const)               (eq (car-safe val) 'c-lang-const)
# Line 177  This macro does not do any hidden buffer Line 177  This macro does not do any hidden buffer
177    '(def-edebug-spec c-lang-defvar    '(def-edebug-spec c-lang-defvar
178       (&define name def-form &optional stringp)))       (&define name def-form &optional stringp)))
179    
180    (eval-when-compile
181      ;; Some helper functions used when building the language constants.
182    
183      (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
184        ;; Used to filter operators from the list OPS in a DWIM:ey way:
185        ;; OPS either has the structure of `c-operators', as a single
186        ;; group in `c-operators', or is a plain list of operators.
187        ;; OPGROUP-FILTER is used filter out the operator groups.  It can
188        ;; be t to choose all groups, a list of the group type symbols to
189        ;; accept, or a function which will be called with the group
190        ;; symbol for each group and should return non-nil for those to
191        ;; include.  OP-FILTER filters the individual operators in each
192        ;; group.  It can be t to choose all operators, a regexp to test
193        ;; against each operator, or a function which will be called for
194        ;; each operator and should return non-nil for those to include.
195        ;; If XLATE is given, it's a function which is called for each
196        ;; matching operator and its return value is collected instead.
197        ;; If it returns a list, the elements are spliced directly into
198        ;; the final result, which is returned as a list with duplicates
199        ;; removed using `equal'.  `c-mode-syntax-table' for the current
200        ;; mode is in effect during the whole procedure.
201        (unless (listp (car-safe ops))
202          (setq ops (list ops)))
203        (cond ((eq opgroup-filter t)
204               (setq opgroup-filter (lambda (opgroup) t)))
205              ((not (functionp opgroup-filter))
206               (setq opgroup-filter `(lambda (opgroup)
207                                       (memq opgroup ',opgroup-filter)))))
208        (cond ((eq op-filter t)
209               (setq op-filter (lambda (op) t)))
210              ((stringp op-filter)
211               (setq op-filter `(lambda (op)
212                                  (string-match ,op-filter op)))))
213        (unless xlate
214          (setq xlate 'identity))
215        (c-with-syntax-table (c-lang-const c-mode-syntax-table)
216          (delete-duplicates
217           (mapcan (lambda (opgroup)
218                     (when (if (symbolp (car opgroup))
219                               (when (funcall opgroup-filter (car opgroup))
220                                 (setq opgroup (cdr opgroup))
221                                 t)
222                             t)
223                       (mapcan (lambda (op)
224                                 (when (funcall op-filter op)
225                                   (let ((res (funcall xlate op)))
226                                     (if (listp res) res (list res)))))
227                               opgroup)))
228                   ops)
229           :test 'equal))))
230    
231    
232  ;;; Various mode specific values that aren't language related.  ;;; Various mode specific values that aren't language related.
233    
# Line 208  This macro does not do any hidden buffer Line 259  This macro does not do any hidden buffer
259        "----"        "----"
260        ("Toggle..."        ("Toggle..."
261         ["Syntactic indentation" c-toggle-syntactic-indentation t]         ["Syntactic indentation" c-toggle-syntactic-indentation t]
262         ["Auto newline"          c-toggle-auto-state t]         ["Auto newline"          c-toggle-auto-newline t]
263         ["Hungry delete"         c-toggle-hungry-state t])))         ["Hungry delete"         c-toggle-hungry-state t])))
264    
265    
# Line 261  The syntax tables aren't stored directly Line 312  The syntax tables aren't stored directly
312           (c-populate-syntax-table table)           (c-populate-syntax-table table)
313           ;; Mode specific syntaxes.           ;; Mode specific syntaxes.
314           ,(cond ((c-major-mode-is 'objc-mode)           ,(cond ((c-major-mode-is 'objc-mode)
315                     ;; Let '@' be part of symbols in ObjC to cope with
316                     ;; its compiler directives as single keyword tokens.
317                     ;; This is then necessary since it's assumed that
318                     ;; every keyword is a single symbol.
319                   `(modify-syntax-entry ?@ "_" table))                   `(modify-syntax-entry ?@ "_" table))
320                  ((c-major-mode-is 'pike-mode)                  ((c-major-mode-is 'pike-mode)
321                   `(modify-syntax-entry ?@ "." table)))                   `(modify-syntax-entry ?@ "." table)))
# Line 328  so that all identifiers are recognized a Line 383  so that all identifiers are recognized a
383  keyword.  It's unspecified how far it matches.  Does not contain a \\|  keyword.  It's unspecified how far it matches.  Does not contain a \\|
384  operator at the top level."  operator at the top level."
385    t    (concat "[" c-alpha "_]")    t    (concat "[" c-alpha "_]")
386      objc (concat "[" c-alpha "@]")
387    pike (concat "[" c-alpha "_`]"))    pike (concat "[" c-alpha "_`]"))
388  (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))  (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))
389    
# Line 340  This is on the form that fits inside [ ] Line 396  This is on the form that fits inside [ ]
396    objc (concat c-alnum "_$@"))    objc (concat c-alnum "_$@"))
397    
398  (c-lang-defconst c-symbol-key  (c-lang-defconst c-symbol-key
399    "Regexp matching identifiers and keywords.  Assumed to match if    "Regexp matching identifiers and keywords (with submatch 0).  Assumed
400  `c-symbol-start' matches on the same position."  to match if `c-symbol-start' matches on the same position."
401    t    (concat (c-lang-const c-symbol-start)    t    (concat (c-lang-const c-symbol-start)
402                 "[" (c-lang-const c-symbol-chars) "]*")                 "[" (c-lang-const c-symbol-chars) "]*")
403    pike (concat    pike (concat
# Line 355  This is on the form that fits inside [ ] Line 411  This is on the form that fits inside [ ]
411    
412  (c-lang-defconst c-symbol-key-depth  (c-lang-defconst c-symbol-key-depth
413    ;; Number of regexp grouping parens in `c-symbol-key'.    ;; Number of regexp grouping parens in `c-symbol-key'.
414    t (c-regexp-opt-depth (c-lang-const c-symbol-key)))    t (regexp-opt-depth (c-lang-const c-symbol-key)))
415    
416  (c-lang-defconst c-nonsymbol-chars  (c-lang-defconst c-nonsymbol-chars
417    "This is the set of chars that can't be part of a symbol, i.e. the    "This is the set of chars that can't be part of a symbol, i.e. the
# Line 371  It's assumed to not contain any submatch Line 427  It's assumed to not contain any submatch
427    ;; `c-symbol-key'.    ;; `c-symbol-key'.
428    t (concat "[" (c-lang-const c-nonsymbol-chars) "]"))    t (concat "[" (c-lang-const c-nonsymbol-chars) "]"))
429    
430  (c-lang-defconst c-opt-identifier-concat-key  (c-lang-defconst c-identifier-ops
431    "Regexp matching the operators that join symbols to fully qualified    "The operators that make up fully qualified identifiers.  nil in
432  identifiers, or nil in languages that don't have such things.  Does  languages that don't have such things.  See `c-operators' for a
433  not contain a \\| operator at the top level."  description of the format.  Binary operators can concatenate symbols,
434    t    nil  e.g. \"::\" in \"A::B::C\".  Prefix operators can precede identifiers,
435    c++  "::"  e.g. \"~\" in \"~A::B\".  Other types of operators aren't supported.
436    
437    This value is by default merged into `c-operators'."
438      t    nil
439      c++  '((prefix "~" "??-" "compl")
440             (right-assoc "::")
441             (prefix "::"))
442    ;; Java has "." to concatenate identifiers but it's also used for    ;; Java has "." to concatenate identifiers but it's also used for
443    ;; normal indexing.  There's special code in the Java font lock    ;; normal indexing.  There's special code in the Java font lock
444    ;; rules to fontify qualified identifiers based on the standard    ;; rules to fontify qualified identifiers based on the standard
445    ;; naming conventions.  We still define "." here to make    ;; naming conventions.  We still define "." here to make
446    ;; `c-forward-name' move over as long names as possible which is    ;; `c-forward-name' move over as long names as possible which is
447    ;; necessary to e.g. handle throws clauses correctly.    ;; necessary to e.g. handle throws clauses correctly.
448    java "\\."    java '((left-assoc "."))
449    idl  "::"    idl  '((left-assoc "::")
450    pike "\\(::\\|\\.\\)")           (prefix "::"))
451      pike '((left-assoc "::")
452             (prefix "::")
453             (left-assoc ".")))
454    
455    (c-lang-defconst c-opt-identifier-concat-key
456      ;; Appendable adorned regexp matching the operators that join
457      ;; symbols to fully qualified identifiers, or nil in languages that
458      ;; don't have such things.
459      ;;
460      ;; This was a docstring constant in 5.30.  It still works but is now
461      ;; considered internal - change `c-identifier-ops' instead.
462      t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
463                                 '(left-assoc right-assoc)
464                                 t)))
465          (when ops
466            (c-make-keywords-re 'appendable ops))))
467  (c-lang-defvar c-opt-identifier-concat-key  (c-lang-defvar c-opt-identifier-concat-key
468    (c-lang-const c-opt-identifier-concat-key)    (c-lang-const c-opt-identifier-concat-key)
469    'dont-doc)    'dont-doc)
470    
471    (c-lang-defconst c-opt-identifier-concat-key-depth
472      ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
473      t (regexp-opt-depth (c-lang-const c-opt-identifier-concat-key)))
474    
475    (c-lang-defconst c-opt-identifier-prefix-key
476      ;; Appendable adorned regexp matching operators that might precede
477      ;; an identifier and that are part of the identifier in that case.
478      ;; nil in languages without such things.
479      t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
480                                 '(prefix)
481                                 t)))
482          (when ops
483            (c-make-keywords-re 'appendable ops))))
484    
485    (c-lang-defconst c-after-id-concat-ops
486      "Operators that can occur after a binary operator on `c-identifier-ops'
487    in identifiers.  nil in languages that don't have such things.
488    
489    Operators here should also have appropriate entries in `c-operators' -
490    it's not taken care of by default."
491      t    nil
492      ;; '~' for destructors in C++, '*' for member pointers.
493      c++  '("~" "*")
494      ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
495      ;; in import declarations.  (This will also match bogus things like
496      ;; "foo.*bar" but we don't bother.)
497      java '("*"))
498    
499  (c-lang-defconst c-opt-after-id-concat-key  (c-lang-defconst c-opt-after-id-concat-key
500    "Regexp that must match the token after `c-opt-identifier-concat-key'    ;; Regexp that must match the token after
501  for it to be considered an identifier concatenation operator (which    ;; `c-opt-identifier-concat-key' for it to be considered an
502  e.g. causes the preceding identifier to be fontified as a reference).    ;; identifier concatenation operator (which e.g. causes the
503  Assumed to be a string if `c-opt-identifier-concat-key' is."    ;; preceding identifier to be fontified as a reference).  Assumed to
504    t    (if (c-lang-const c-opt-identifier-concat-key)    ;; be a string if `c-opt-identifier-concat-key' is.
505             (c-lang-const c-symbol-start))    ;;
506    c++  (concat (c-lang-const c-symbol-start)    ;; This was a docstring constant in 5.30.  It still works but is now
507                 "\\|[~*]")    ;; considered internal - change `c-after-id-concat-ops' instead.
508    java (concat (c-lang-const c-symbol-start)    t (concat (c-lang-const c-symbol-start)
509                 "\\|\\*"))              (if (c-lang-const c-after-id-concat-ops)
510                    (concat "\\|" (c-make-keywords-re 'appendable
511                                    (c-lang-const c-after-id-concat-ops)))
512                  "")))
513    
514  (c-lang-defconst c-identifier-start  (c-lang-defconst c-identifier-start
515    "Regexp that matches the start of an \(optionally qualified)    "Regexp that matches the start of an (optionally qualified) identifier.
516  identifier.  It should also match all keywords.  It's unspecified how  It should also match all keywords.  It's unspecified how far it
517  far it matches."  matches."
518    t    (concat (c-lang-const c-symbol-start)    t (concat (c-lang-const c-symbol-start)
519                 (if (c-lang-const c-opt-identifier-concat-key)              (if (c-lang-const c-opt-identifier-prefix-key)
520                     (concat "\\|" (c-lang-const c-opt-identifier-concat-key))                  (concat "\\|"
521                   ""))                          (c-lang-const c-opt-identifier-prefix-key))
522    c++  (concat (c-lang-const c-identifier-start)                "")))
                "\\|"  
                "[~*][ \t\n\r\f\v]*" (c-lang-const c-symbol-start))  
   ;; Java does not allow a leading qualifier operator.  
   java (c-lang-const c-symbol-start))  
523  (c-lang-defvar c-identifier-start (c-lang-const c-identifier-start))  (c-lang-defvar c-identifier-start (c-lang-const c-identifier-start))
524    
525  (c-lang-defconst c-identifier-key  (c-lang-defconst c-identifier-key
526    "Regexp matching a fully qualified identifier, like \"A::B::c\" in    "Regexp matching a fully qualified identifier, like \"A::B::c\" in
527  C++.  It does not recognize the full range of syntactic whitespace  C++.  It does not recognize the full range of syntactic whitespace
528  between the tokens; `c-forward-name' has to be used for that."  between the tokens; `c-forward-name' has to be used for that.  It
529    t    (c-lang-const c-symbol-key)      ; Default to `c-symbol-key'.  should also not match identifiers containing parenthesis groupings,
530    ;; C++ allows a leading qualifier operator and a `~' before the last  e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
531    ;; symbol.  This regexp is more complex than strictly necessary to    ;; This regexp is more complex than strictly necessary to ensure
532    ;; ensure that it can be matched with a minimum of backtracking.    ;; that it can be matched with a minimum of backtracking.
533    c++  (concat    t (concat (if (c-lang-const c-opt-identifier-prefix-key)
534          "\\(" (c-lang-const c-opt-identifier-concat-key) "[ \t\n\r\f\v]*\\)?"                  (concat
535          (concat                   "\\("
536           "\\("                   (c-lang-const c-opt-identifier-prefix-key)
537           ;; The submatch below is depth of `c-opt-identifier-concat-key' + 3.                   (c-lang-const c-simple-ws) "*"
          "\\(" (c-lang-const c-symbol-key) "\\)"  
          (concat "\\("  
                  "[ \t\n\r\f\v]*"  
                  (c-lang-const c-opt-identifier-concat-key)  
                  "[ \t\n\r\f\v]*"  
                  ;; The submatch below is: `c-symbol-key-depth' +  
                  ;; 2 * depth of `c-opt-identifier-concat-key' + 5.  
                  "\\(" (c-lang-const c-symbol-key) "\\)"  
                  "\\)*")  
          (concat "\\("  
                  "[ \t\n\r\f\v]*"  
                  (c-lang-const c-opt-identifier-concat-key)  
                  "[ \t\n\r\f\v]*"  
                  "[~*]"  
                  "[ \t\n\r\f\v]*"  
                  ;; The submatch below is: 2 * `c-symbol-key-depth' +  
                  ;; 3 * depth of `c-opt-identifier-concat-key' + 7.  
                  "\\(" (c-lang-const c-symbol-key) "\\)"  
538                   "\\)?")                   "\\)?")
539           "\\|"                "")
540           "~[ \t\n\r\f\v]*"              "\\(" (c-lang-const c-symbol-key) "\\)"
541           ;; The submatch below is: 3 * `c-symbol-key-depth' +              (if (c-lang-const c-opt-identifier-concat-key)
542           ;; 3 * depth of `c-opt-identifier-concat-key' + 8.                  (concat
543           "\\(" (c-lang-const c-symbol-key) "\\)"                   "\\("
544           "\\)"))                   (c-lang-const c-simple-ws) "*"
545    ;; IDL and Pike allows a leading qualifier operator.                   (c-lang-const c-opt-identifier-concat-key)
546    (idl pike) (concat                   (c-lang-const c-simple-ws) "*"
547                "\\("                   (if (c-lang-const c-after-id-concat-ops)
548                (c-lang-const c-opt-identifier-concat-key)                       (concat
549                "[ \t\n\r\f\v]*"                        "\\("
550                "\\)?"                         (c-make-keywords-re 'appendable
551                ;; The submatch below is depth of                           (c-lang-const c-after-id-concat-ops))
552                ;; `c-opt-identifier-concat-key' + 2.                        (concat
553                "\\(" (c-lang-const c-symbol-key) "\\)"                         ;; For flexibility, consider the symbol match
554                (concat "\\("                         ;; optional if we've hit a
555                        "[ \t\n\r\f\v]*"                         ;; `c-after-id-concat-ops' operator.  This is
556                        (c-lang-const c-opt-identifier-concat-key)                         ;; also necessary to handle the "*" that can
557                        "[ \t\n\r\f\v]*"                         ;; end import declaration identifiers in Java.
558                        ;; The submatch below is: `c-symbol-key-depth' +                         "\\("
559                        ;; 2 * depth of `c-opt-identifier-concat-key' + 4.                         (c-lang-const c-simple-ws) "*"
560                           "\\(" (c-lang-const c-symbol-key) "\\)"
561                           "\\)?")
562                          "\\|"
563                        "\\(" (c-lang-const c-symbol-key) "\\)"                        "\\(" (c-lang-const c-symbol-key) "\\)"
564                        "\\)*"))                        "\\)")
565    ;; Java does not allow a leading qualifier operator.  If it ends                     (concat "\\(" (c-lang-const c-symbol-key) "\\)"))
566    ;; with ".*" (used in import declarations) we also consider that as                   "\\)*")
567    ;; part of the name.  ("*" is actually recognized in any position                "")))
   ;; except the first by this regexp, but we don't bother.)  
   java (concat "\\(" (c-lang-const c-symbol-key) "\\)" ; 1  
                (concat "\\("  
                        "[ \t\n\r\f\v]*"  
                        (c-lang-const c-opt-identifier-concat-key)  
                        "[ \t\n\r\f\v]*"  
                        (concat "\\("  
                                ;; The submatch below is `c-symbol-key-depth' +  
                                ;; depth of `c-opt-identifier-concat-key' + 4.  
                                "\\(" (c-lang-const c-symbol-key) "\\)"  
                                "\\|\\*\\)")  
                        "\\)*")))  
568  (c-lang-defvar c-identifier-key (c-lang-const c-identifier-key))  (c-lang-defvar c-identifier-key (c-lang-const c-identifier-key))
569    
570  (c-lang-defconst c-identifier-last-sym-match  (c-lang-defconst c-identifier-last-sym-match
571    "Used to identify the submatch in `c-identifier-key' that surrounds    ;; This was a docstring constant in 5.30 but it's no longer used.
572  the last symbol in the qualified identifier.  It's a list of submatch    ;; It's only kept to avoid breaking third party code.
573  numbers, of which the first that has a match is taken.  It's assumed    ;;
574  that at least one does when the regexp has matched."    ;; Used to identify the submatch in `c-identifier-key' that
575    t    '(0)    ;; surrounds the last symbol in the qualified identifier.  It's a
576    c++  (list (+ (* 3 (c-lang-const c-symbol-key-depth))    ;; list of submatch numbers, of which the first that has a match is
577                  (* 3 (c-regexp-opt-depth    ;; taken.  It's assumed that at least one does when the regexp has
578                        (c-lang-const c-opt-identifier-concat-key)))    ;; matched.
579                  8)    t nil)
580               (+ (* 2 (c-lang-const c-symbol-key-depth))  
581                  (* 3 (c-regexp-opt-depth  (c-lang-defconst c-string-escaped-newlines
582                        (c-lang-const c-opt-identifier-concat-key)))    "Set if the language support backslash escaped newlines inside string
583                  7)  literals."
584               (+ (c-lang-const c-symbol-key-depth)    t nil
585                  (* 2 (c-regexp-opt-depth    (c c++ objc pike) t)
586                        (c-lang-const c-opt-identifier-concat-key)))  (c-lang-defvar c-string-escaped-newlines
587                  5)    (c-lang-const c-string-escaped-newlines))
588               (+ (c-regexp-opt-depth  
589                   (c-lang-const c-opt-identifier-concat-key))  (c-lang-defconst c-multiline-string-start-char
590                  3))    "Set if the language supports multiline string literals without escaped
591    (idl pike) (list (+ (c-lang-const c-symbol-key-depth)  newlines.  If t, all string literals are multiline.  If a character,
592                        (* 2 (c-regexp-opt-depth  only literals where the open quote is immediately preceded by that
593                              (c-lang-const c-opt-identifier-concat-key)))  literal are multiline."
594                        4)    t    nil
595                     (+ (c-regexp-opt-depth    pike ?#)
596                         (c-lang-const c-opt-identifier-concat-key))  (c-lang-defvar c-multiline-string-start-char
597                        2))    (c-lang-const c-multiline-string-start-char))
   java (list (+ (c-lang-const c-symbol-key-depth)  
                 (c-regexp-opt-depth  
                  (c-lang-const c-opt-identifier-concat-key))  
                 4)  
              1))  
 (c-lang-defvar c-identifier-last-sym-match  
   (c-lang-const c-identifier-last-sym-match)  
   'dont-doc)  
598    
599  (c-lang-defconst c-opt-cpp-prefix  (c-lang-defconst c-opt-cpp-prefix
600    "Regexp matching the prefix of a cpp directive in the languages that    "Regexp matching the prefix of a cpp directive in the languages that
601  normally use that macro preprocessor.  Tested at bol or at boi.  normally use that macro preprocessor.  Tested at bol or at boi.
602  Assumed to not contain any submatches or \\| operators."  Assumed to not contain any submatches or \\| operators."
603      ;; TODO (ACM, 2005-04-01).  Amend the following to recognise escaped NLs;
604      ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
605    t "\\s *#\\s *"    t "\\s *#\\s *"
606    (java awk) nil)    (java awk) nil)
607  (c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix))  (c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix))
# Line 546  submatch surrounds the directive name." Line 618  submatch surrounds the directive name."
618                 "\\([" c-alnum "]+\\|!\\)"))                 "\\([" c-alnum "]+\\|!\\)"))
619  (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start))  (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start))
620    
621  (c-lang-defconst c-cpp-defined-fns  (c-lang-defconst c-cpp-message-directives
622    ;; Name of functions in cpp expressions that take an identifier as    "List of cpp directives (without the prefix) that are followed by a
623    ;; the argument.  string message."
624      t    (if (c-lang-const c-opt-cpp-prefix)
625               '("error"))
626      pike '("error" "warning"))
627    
628    (c-lang-defconst c-cpp-include-directives
629      "List of cpp directives (without the prefix) that are followed by a
630    file name in angle brackets or quotes."
631      t    (if (c-lang-const c-opt-cpp-prefix)
632               '("include"))
633      objc '("include" "import"))
634    
635    (c-lang-defconst c-opt-cpp-macro-define
636      "Cpp directive (without the prefix) that is followed by a macro
637    definition, or nil if the language doesn't have any."
638      t (if (c-lang-const c-opt-cpp-prefix)
639            "define"))
640    
641    (c-lang-defconst c-opt-cpp-macro-define-start
642      ;; Regexp matching everything up to the macro body of a cpp define,
643      ;; or the end of the logical line if there is none.  Set if
644      ;; c-opt-cpp-macro-define is.
645      t (if (c-lang-const c-opt-cpp-macro-define)
646            (concat (c-lang-const c-opt-cpp-prefix)
647                    (c-lang-const c-opt-cpp-macro-define)
648                    "[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?"
649                    "\\([ \t]\\|\\\\\n\\)*")))
650    (c-lang-defvar c-opt-cpp-macro-define-start
651      (c-lang-const c-opt-cpp-macro-define-start))
652    
653    (c-lang-defconst c-cpp-expr-directives
654      "List if cpp directives (without the prefix) that are followed by an
655    expression."
656      t (if (c-lang-const c-opt-cpp-prefix)
657            '("if" "elif")))
658    
659    (c-lang-defconst c-cpp-expr-functions
660      "List of functions in cpp expressions."
661    t    (if (c-lang-const c-opt-cpp-prefix)    t    (if (c-lang-const c-opt-cpp-prefix)
662             '("defined"))             '("defined"))
663    pike '("defined" "efun" "constant"))    pike '("defined" "efun" "constant"))
# Line 559  submatch surrounds the directive name." Line 668  submatch surrounds the directive name."
668    java (append (c-lang-const c-assignment-operators)    java (append (c-lang-const c-assignment-operators)
669                 '(">>>="))                 '(">>>="))
670    c++  (append (c-lang-const c-assignment-operators)    c++  (append (c-lang-const c-assignment-operators)
671                 '("and_eq" "or_eq" "xor_eq"))                 '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
672    idl  nil)    idl  nil)
673    
674  (c-lang-defconst c-operators  (c-lang-defconst c-operators
# Line 573  it.  The operator group types are: Line 682  it.  The operator group types are:
682    
683  'prefix         Unary prefix operators.  'prefix         Unary prefix operators.
684  'postfix        Unary postfix operators.  'postfix        Unary postfix operators.
685    'postfix-if-paren
686                    Unary postfix operators if and only if the chars have
687                    parenthesis syntax.
688  'left-assoc     Binary left associative operators (i.e. a+b+c means (a+b)+c).  'left-assoc     Binary left associative operators (i.e. a+b+c means (a+b)+c).
689  'right-assoc    Binary right associative operators (i.e. a=b=c means a=(b=c)).  'right-assoc    Binary right associative operators (i.e. a=b=c means a=(b=c)).
690  'right-assoc-sequence  'right-assoc-sequence
# Line 605  since CC Mode treats every identifier as Line 717  since CC Mode treats every identifier as
717                          ,@(when (c-major-mode-is '(c-mode c++-mode))                          ,@(when (c-major-mode-is '(c-mode c++-mode))
718                              '("%:%:" "??=??=")))))                              '("%:%:" "??=??=")))))
719    
720        ;; Primary.  Info duplicated in `c-opt-identifier-concat-key'        ;; Primary.
721        ;; and `c-identifier-key'.        ,@(c-lang-const c-identifier-ops)
722        ,@(cond ((c-major-mode-is 'c++-mode)        ,@(cond ((c-major-mode-is 'c++-mode)
723                 `((postfix-if-paren "<" ">") ; Templates.                 `((postfix-if-paren "<" ">"))) ; Templates.
                  (prefix "~" "??-" "compl")  
                  (right-assoc "::")  
                  (prefix "::")))  
724                ((c-major-mode-is 'pike-mode)                ((c-major-mode-is 'pike-mode)
725                 `((left-assoc "::")                 `((prefix "global" "predef")))
                  (prefix "::" "global" "predef")))  
726                ((c-major-mode-is 'java-mode)                ((c-major-mode-is 'java-mode)
727                 `(;; Not necessary since it's also in the postfix group below.                 `((prefix "super"))))
                  ;;(left-assoc ".")  
                  (prefix "super"))))  
728    
729        ;; Postfix.        ;; Postfix.
730        ,@(when (c-major-mode-is 'c++-mode)        ,@(when (c-major-mode-is 'c++-mode)
# Line 718  since CC Mode treats every identifier as Line 824  since CC Mode treats every identifier as
824    idl `(;; Preprocessor.    idl `(;; Preprocessor.
825          (prefix "#")          (prefix "#")
826          (left-assoc "##")          (left-assoc "##")
827          ;; Primary.  Info duplicated in `c-opt-identifier-concat-key'          ;; Primary.
828          ;; and `c-identifier-key'.          ,@(c-lang-const c-identifier-ops)
         (left-assoc "::")  
         (prefix "::")  
829          ;; Unary.          ;; Unary.
830          (prefix  "+" "-" "~")          (prefix  "+" "-" "~")
831          ;; Multiplicative.          ;; Multiplicative.
# Line 739  since CC Mode treats every identifier as Line 843  since CC Mode treats every identifier as
843    
844  (c-lang-defconst c-operator-list  (c-lang-defconst c-operator-list
845    ;; The operators as a flat list (without duplicates).    ;; The operators as a flat list (without duplicates).
846    t (delete-duplicates (mapcan (lambda (elem) (append (cdr elem) nil))    t (c-filter-ops (c-lang-const c-operators) t t))
                                (c-lang-const c-operators))  
                        :test 'string-equal))  
847    
848  (c-lang-defconst c-overloadable-operators  (c-lang-defconst c-overloadable-operators
849    "List of the operators that are overloadable, in their \"identifier form\"."    "List of the operators that are overloadable, in their \"identifier
850    form\".  See also `c-op-identitier-prefix'."
851    t    nil    t    nil
   ;; The preceding "operator" keyword is treated separately in C++.  
852    c++  '("new" "delete" ;; Can be followed by "[]" but we ignore that.    c++  '("new" "delete" ;; Can be followed by "[]" but we ignore that.
853           "+" "-" "*" "/" "%"           "+" "-" "*" "/" "%"
854           "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"           "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
# Line 768  since CC Mode treats every identifier as Line 870  since CC Mode treats every identifier as
870  (c-lang-defvar c-overloadable-operators-regexp  (c-lang-defvar c-overloadable-operators-regexp
871    (c-lang-const c-overloadable-operators-regexp))    (c-lang-const c-overloadable-operators-regexp))
872    
873    (c-lang-defconst c-opt-op-identitier-prefix
874      "Regexp matching the token before the ones in
875    `c-overloadable-operators' when operators are specified in their
876    \"identifier form\".  This typically matches \"operator\" in C++ where
877    operator functions are specified as e.g. \"operator +\".  It's nil in
878    languages without operator functions or where the complete operator
879    identifier is listed in `c-overloadable-operators'.
880    
881    This regexp is assumed to not match any non-operator identifier."
882      t   nil
883      c++ (c-make-keywords-re t '("operator")))
884    (c-lang-defvar c-opt-op-identitier-prefix
885      (c-lang-const c-opt-op-identitier-prefix))
886    
887  (c-lang-defconst c-other-op-syntax-tokens  (c-lang-defconst c-other-op-syntax-tokens
888    "List of the tokens made up of characters in the punctuation or    "List of the tokens made up of characters in the punctuation or
889  parenthesis syntax classes that have uses other than as expression  parenthesis syntax classes that have uses other than as expression
# Line 776  operators." Line 892  operators."
892    (c c++ pike) (append '("#" "##"       ; Used by cpp.    (c c++ pike) (append '("#" "##"       ; Used by cpp.
893                           "::" "...")                           "::" "...")
894                         (c-lang-const c-other-op-syntax-tokens))                         (c-lang-const c-other-op-syntax-tokens))
895    (c c++) (append '("<%" "%>" "<:" ":>" "%:" "%:%:" "*")    (c c++) (append '("*") (c-lang-const c-other-op-syntax-tokens))
896                    (c-lang-const c-other-op-syntax-tokens))    c++  (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
897    c++  (append '("&") (c-lang-const c-other-op-syntax-tokens))                 (c-lang-const c-other-op-syntax-tokens))
898    objc (append '("#" "##"               ; Used by cpp.    objc (append '("#" "##"               ; Used by cpp.
899                   "+" "-") (c-lang-const c-other-op-syntax-tokens))                   "+" "-") (c-lang-const c-other-op-syntax-tokens))
900    idl  (append '("#" "##")              ; Used by cpp.    idl  (append '("#" "##")              ; Used by cpp.
# Line 788  operators." Line 904  operators."
904                 (c-lang-const c-overloadable-operators))                 (c-lang-const c-overloadable-operators))
905    awk '("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))    awk '("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
906    
907    (c-lang-defconst c-all-op-syntax-tokens
908      ;; List of all tokens in the punctuation and parenthesis syntax
909      ;; classes.
910      t (delete-duplicates (append (c-lang-const c-other-op-syntax-tokens)
911                                   (c-lang-const c-operator-list))
912                           :test 'string-equal))
913    
914    (c-lang-defconst c-nonsymbol-token-char-list
915      ;; List containing all chars not in the word, symbol or
916      ;; syntactically irrelevant syntax classes, i.e. all punctuation,
917      ;; parenthesis and string delimiter chars.
918      t (c-with-syntax-table (c-lang-const c-mode-syntax-table)
919          ;; Only go through the chars in the printable ASCII range.  No
920          ;; language so far has 8-bit or widestring operators.
921          (let (list (char 32))
922            (while (< char 127)
923              (or (memq (char-syntax char) '(?w ?_ ?< ?> ?\ ))
924                  (setq list (cons (c-int-to-char char) list)))
925              (setq char (1+ char)))
926            list)))
927    
928  (c-lang-defconst c-nonsymbol-token-regexp  (c-lang-defconst c-nonsymbol-token-regexp
929    ;; Regexp matching all tokens in the punctuation and parenthesis    ;; Regexp matching all tokens in the punctuation and parenthesis
930    ;; syntax classes.  Note that this also matches ".", which can start    ;; syntax classes.  Note that this also matches ".", which can start
931    ;; a float.    ;; a float.
932    t (c-make-keywords-re nil    t (c-make-keywords-re nil
933        (c-with-syntax-table (c-lang-const c-mode-syntax-table)        (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
934          (mapcan (lambda (op)                      t
935                    (if (string-match "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'" op)                      "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
                       (list op)))  
                 (append (c-lang-const c-other-op-syntax-tokens)  
                         (c-lang-const c-operator-list))))))  
936  (c-lang-defvar c-nonsymbol-token-regexp  (c-lang-defvar c-nonsymbol-token-regexp
937    (c-lang-const c-nonsymbol-token-regexp))    (c-lang-const c-nonsymbol-token-regexp))
938    
# Line 819  operators." Line 953  operators."
953  (c-lang-defvar c-assignment-op-regexp  (c-lang-defvar c-assignment-op-regexp
954    (c-lang-const c-assignment-op-regexp))    (c-lang-const c-assignment-op-regexp))
955    
956    (c-lang-defconst c-<>-multichar-token-regexp
957      ;; Regexp matching all tokens containing "<" or ">" which are longer
958      ;; than one char.
959      t (c-make-keywords-re nil
960          (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
961                        t
962                        ".[<>]\\|[<>].")))
963    (c-lang-defvar c-<>-multichar-token-regexp
964      (c-lang-const c-<>-multichar-token-regexp))
965    
966  (c-lang-defconst c-<-op-cont-regexp  (c-lang-defconst c-<-op-cont-regexp
967    ;; Regexp matching the second and subsequent characters of all    ;; Regexp matching the second and subsequent characters of all
968    ;; multicharacter tokens that begin with "<".    ;; multicharacter tokens that begin with "<".
969    t (c-make-keywords-re nil    t (c-make-keywords-re nil
970        (mapcan (lambda (op)        (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
971                  (if (string-match "\\`<." op)                      t
972                      (list (substring op 1))))                      "\\`<."
973                (append (c-lang-const c-other-op-syntax-tokens)                      (lambda (op) (substring op 1)))))
                       (c-lang-const c-operator-list)))))  
974  (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))  (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
975    
976  (c-lang-defconst c->-op-cont-regexp  (c-lang-defconst c->-op-cont-regexp
977    ;; Regexp matching the second and subsequent characters of all    ;; Regexp matching the second and subsequent characters of all
978    ;; multicharacter tokens that begin with ">".    ;; multicharacter tokens that begin with ">".
979    t (c-make-keywords-re nil    t (c-make-keywords-re nil
980        (mapcan (lambda (op)        (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
981                  (if (string-match "\\`>." op)                      t
982                      (list (substring op 1))))                      "\\`>."
983                (append (c-lang-const c-other-op-syntax-tokens)                      (lambda (op) (substring op 1)))))
                       (c-lang-const c-operator-list)))))  
984  (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))  (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
985    
986  (c-lang-defconst c-stmt-delim-chars  (c-lang-defconst c-stmt-delim-chars
# Line 847  operators." Line 989  operators."
989    ;; begin with "^" to negate the set.  If ? : operators should be    ;; begin with "^" to negate the set.  If ? : operators should be
990    ;; detected then the string must end with "?:".    ;; detected then the string must end with "?:".
991    t    "^;{}?:"    t    "^;{}?:"
992    awk  "^;{}\n\r?:") ; The newline chars gets special treatment.    awk  "^;{}#\n\r?:") ; The newline chars gets special treatment.
993  (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars))  (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars))
994    
995  (c-lang-defconst c-stmt-delim-chars-with-comma  (c-lang-defconst c-stmt-delim-chars-with-comma
# Line 860  operators." Line 1002  operators."
1002    
1003  ;;; Syntactic whitespace.  ;;; Syntactic whitespace.
1004    
1005    (c-lang-defconst c-simple-ws
1006      "Regexp matching an ordinary whitespace character.
1007    Does not contain a \\| operator at the top level."
1008      ;; "\\s " is not enough since it doesn't match line breaks.
1009      t "\\(\\s \\|[\n\r]\\)")
1010    
1011    (c-lang-defconst c-simple-ws-depth
1012      ;; Number of regexp grouping parens in `c-simple-ws'.
1013      t (regexp-opt-depth (c-lang-const c-simple-ws)))
1014    
1015    (c-lang-defconst c-line-comment-starter
1016      "String that starts line comments, or nil if such don't exist.
1017    Line comments are always terminated by newlines.  At least one of
1018    `c-block-comment-starter' and this one is assumed to be set.
1019    
1020    Note that it's currently not enough to set this to support a new
1021    comment style.  Other stuff like the syntax table must also be set up
1022    properly."
1023      t    "//"
1024      awk  "#")
1025    (c-lang-defvar c-line-comment-starter (c-lang-const c-line-comment-starter))
1026    
1027    (c-lang-defconst c-block-comment-starter
1028      "String that starts block comments, or nil if such don't exist.
1029    Block comments are ended by `c-block-comment-ender', which is assumed
1030    to be set if this is.  At least one of `c-line-comment-starter' and
1031    this one is assumed to be set.
1032    
1033    Note that it's currently not enough to set this to support a new
1034    comment style.  Other stuff like the syntax table must also be set up
1035    properly."
1036      t    "/*"
1037      awk  nil)
1038    
1039    (c-lang-defconst c-block-comment-ender
1040      "String that ends block comments, or nil if such don't exist.
1041    
1042    Note that it's currently not enough to set this to support a new
1043    comment style.  Other stuff like the syntax table must also be set up
1044    properly."
1045      t    "*/"
1046      awk  nil)
1047    
1048  (c-lang-defconst c-comment-start-regexp  (c-lang-defconst c-comment-start-regexp
1049    ;; Regexp to match the start of any type of comment.    ;; Regexp to match the start of any type of comment.
1050    ;;    t (let ((re (c-make-keywords-re nil
1051    ;; TODO: Ought to use `c-comment-prefix-regexp' with some                  (list (c-lang-const c-line-comment-starter)
1052    ;; modifications instead of this.                        (c-lang-const c-block-comment-starter)))))
1053    t    "/[/*]"        (if (memq 'gen-comment-delim c-emacs-features)
1054    awk  "#")            (concat re "\\|\\s!")
1055            re)))
1056  (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp))  (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp))
1057    
1058    ;;;; Added by ACM, 2003/9/18.
1059    (c-lang-defconst c-block-comment-start-regexp
1060      ;; Regexp which matches the start of a block comment (if such exists in the
1061      ;; language)
1062      t (if (c-lang-const c-block-comment-starter)
1063            (regexp-quote (c-lang-const c-block-comment-starter))
1064          "\\<\\>"))
1065    (c-lang-defvar c-block-comment-start-regexp
1066      (c-lang-const c-block-comment-start-regexp))
1067    
1068  (c-lang-defconst c-literal-start-regexp  (c-lang-defconst c-literal-start-regexp
1069    ;; Regexp to match the start of comments and string literals.    ;; Regexp to match the start of comments and string literals.
1070    t (concat (c-lang-const c-comment-start-regexp)    t (concat (c-lang-const c-comment-start-regexp)
# Line 891  operators." Line 1087  operators."
1087  (c-lang-defconst comment-start  (c-lang-defconst comment-start
1088    "String that starts comments inserted with M-; etc.    "String that starts comments inserted with M-; etc.
1089  `comment-start' is initialized from this."  `comment-start' is initialized from this."
1090    t    "// "    ;; Default: Prefer line comments to block comments, and pad with a space.
1091    c    "/* "    t (concat (or (c-lang-const c-line-comment-starter)
1092    awk  "# ")                  (c-lang-const c-block-comment-starter))
1093                " ")
1094      ;; In C we still default to the block comment style since line
1095      ;; comments aren't entirely portable.
1096      c "/* ")
1097  (c-lang-defvar comment-start (c-lang-const comment-start)  (c-lang-defvar comment-start (c-lang-const comment-start)
1098    'dont-doc)    'dont-doc)
1099    
1100  (c-lang-defconst comment-end  (c-lang-defconst comment-end
1101    "String that ends comments inserted with M-; etc.    "String that ends comments inserted with M-; etc.
1102  `comment-end' is initialized from this."  `comment-end' is initialized from this."
1103    t    ""    ;; Default: Use block comment style if comment-start uses block
1104    c    " */")    ;; comments, and pad with a space in that case.
1105      t (if (string-match (concat "\\`\\("
1106                                  (c-lang-const c-block-comment-start-regexp)
1107                                  "\\)")
1108                          (c-lang-const comment-start))
1109            (concat " " (c-lang-const c-block-comment-ender))
1110          ""))
1111  (c-lang-defvar comment-end (c-lang-const comment-end)  (c-lang-defvar comment-end (c-lang-const comment-end)
1112    'dont-doc)    'dont-doc)
1113    
1114  (c-lang-defconst comment-start-skip  (c-lang-defconst comment-start-skip
1115    "Regexp to match the start of a comment plus everything up to its body.    "Regexp to match the start of a comment plus everything up to its body.
1116  `comment-start-skip' is initialized from this."  `comment-start-skip' is initialized from this."
1117    t    "/\\*+ *\\|//+ *"    ;; Default: Allow the last char of the comment starter(s) to be
1118    awk  "#+ *")    ;; repeated, then allow any amount of horizontal whitespace.
1119      t (concat "\\("
1120                (c-concat-separated
1121                 (mapcar (lambda (cs)
1122                           (when cs
1123                             (concat (regexp-quote cs) "+")))
1124                         (list (c-lang-const c-line-comment-starter)
1125                               (c-lang-const c-block-comment-starter)))
1126                 "\\|")
1127                "\\)\\s *"))
1128  (c-lang-defvar comment-start-skip (c-lang-const comment-start-skip)  (c-lang-defvar comment-start-skip (c-lang-const comment-start-skip)
1129    'dont-doc)    'dont-doc)
1130    
1131  (c-lang-defconst c-syntactic-ws-start  (c-lang-defconst c-syntactic-ws-start
1132    "Regexp matching any sequence that can start syntactic whitespace.    ;; Regexp matching any sequence that can start syntactic whitespace.
1133  The only uncertain case is '#' when there are cpp directives."    ;; The only uncertain case is '#' when there are cpp directives.
1134    t     "[ \n\t\r\v\f#]\\|/[/*]\\|\\\\[\n\r]"    t (concat "\\s \\|"
1135    awk   "[ \n\t\r\v\f#]\\|\\\\[\n\r]")              (c-make-keywords-re nil
1136  (c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start)                (append (list (c-lang-const c-line-comment-starter)
1137    'dont-doc)                              (c-lang-const c-block-comment-starter)
1138                                (when (c-lang-const c-opt-cpp-prefix)
1139                                  "#"))
1140                          '("\n" "\r")))
1141                "\\|\\\\[\n\r]"
1142                (when (memq 'gen-comment-delim c-emacs-features)
1143                  "\\|\\s!")))
1144    (c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start))
1145    
1146  (c-lang-defconst c-syntactic-ws-end  (c-lang-defconst c-syntactic-ws-end
1147    "Regexp matching any single character that might end syntactic whitespace."    ;; Regexp matching any single character that might end syntactic whitespace.
1148    t     "[ \n\t\r\v\f/]"    t (concat "\\s \\|"
1149    awk   "[ \n\t\r\v\f]")              (c-make-keywords-re nil
1150  (c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end)                (append (when (c-lang-const c-block-comment-ender)
1151    'dont-doc)                          (list
1152                             (string
1153                              (elt (c-lang-const c-block-comment-ender)
1154                                   (1- (length
1155                                        (c-lang-const c-block-comment-ender)))))))
1156                          '("\n" "\r")))
1157                (when (memq 'gen-comment-delim c-emacs-features)
1158                  "\\|\\s!")))
1159    (c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end))
1160    
1161    (c-lang-defconst c-unterminated-block-comment-regexp
1162      ;; Regexp matching an unterminated block comment that doesn't
1163      ;; contain line breaks, or nil in languages without block comments.
1164      ;; Does not contain a \| operator at the top level.
1165      t (when (c-lang-const c-block-comment-starter)
1166          (concat
1167           (regexp-quote (c-lang-const c-block-comment-starter))
1168           ;; It's messy to cook together a regexp that matches anything
1169           ;; but c-block-comment-ender.
1170           (let ((end (c-lang-const c-block-comment-ender)))
1171             (cond ((= (length end) 1)
1172                    (concat "[^" end "\n\r]*"))
1173                   ((= (length end) 2)
1174                    (concat "[^" (substring end 0 1) "\n\r]*"
1175                            "\\("
1176                            (regexp-quote (substring end 0 1)) "+"
1177                            "[^"
1178                            ;; The quoting rules inside char classes are silly. :P
1179                            (cond ((= (elt end 0) (elt end 1))
1180                                   (concat (substring end 0 1) "\n\r"))
1181                                  ((= (elt end 1) ?\])
1182                                   (concat (substring end 1 2) "\n\r"
1183                                           (substring end 0 1)))
1184                                  (t
1185                                   (concat (substring end 0 1) "\n\r"
1186                                           (substring end 1 2))))
1187                            "]"
1188                            "[^" (substring end 0 1) "\n\r]*"
1189                            "\\)*"))
1190                   (t
1191                    (error "Can't handle a block comment ender of length %s"
1192                           (length end))))))))
1193    
1194    (c-lang-defconst c-block-comment-regexp
1195      ;; Regexp matching a block comment that doesn't contain line breaks,
1196      ;; or nil in languages without block comments.  The reason we don't
1197      ;; allow line breaks is to avoid going very far and risk running out
1198      ;; of regexp stack; this regexp is intended to handle only short
1199      ;; comments that might be put in the middle of limited constructs
1200      ;; like declarations.  Does not contain a \| operator at the top
1201      ;; level.
1202      t (when (c-lang-const c-unterminated-block-comment-regexp)
1203          (concat
1204           (c-lang-const c-unterminated-block-comment-regexp)
1205           (let ((end (c-lang-const c-block-comment-ender)))
1206             (cond ((= (length end) 1)
1207                    (regexp-quote end))
1208                   ((= (length end) 2)
1209                    (concat (regexp-quote (substring end 0 1)) "+"
1210                            (regexp-quote (substring end 1 2))))
1211                   (t
1212                    (error "Can't handle a block comment ender of length %s"
1213                           (length end))))))))
1214    
1215  (c-lang-defconst c-nonwhite-syntactic-ws  (c-lang-defconst c-nonwhite-syntactic-ws
1216    ;; Regexp matching a piece of syntactic whitespace that isn't a    ;; Regexp matching a piece of syntactic whitespace that isn't a
1217    ;; sequence of simple whitespace characters.  As opposed to    ;; sequence of simple whitespace characters.  As opposed to
1218    ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp    ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
1219    ;; directives as syntactic whitespace.    ;; directives as syntactic whitespace.
1220    t (concat "/" (concat    t (c-concat-separated
1221                   "\\("       (list (when (c-lang-const c-line-comment-starter)
1222                   "/[^\n\r]*[\n\r]"      ; Line comment.               (concat (regexp-quote (c-lang-const c-line-comment-starter))
1223                   "\\|"                       "[^\n\r]*[\n\r]"))
1224                   ;; Block comment. We intentionally don't allow line             (c-lang-const c-block-comment-regexp)
1225                   ;; breaks in them to avoid going very far and risk             "\\\\[\n\r]"
1226                   ;; running out of regexp stack; this regexp is             (when (memq 'gen-comment-delim c-emacs-features)
1227                   ;; intended to handle only short comments that               "\\s!\\S!*\\s!"))
1228                   ;; might be put in the middle of limited constructs       "\\|"))
                  ;; like declarations.  
                  "\\*\\([^*\n\r]\\|\\*[^/\n\r]\\)*\\*/"  
                  "\\)")  
             "\\|"  
             "\\\\[\n\r]")               ; Line continuations.  
   awk ("#.*[\n\r]\\|\\\\[\n\r]"))  
1229    
1230  (c-lang-defconst c-syntactic-ws  (c-lang-defconst c-syntactic-ws
1231    ;; Regexp matching syntactic whitespace, including possibly the    ;; Regexp matching syntactic whitespace, including possibly the
1232    ;; empty string.  As opposed to `c-(forward|backward)-syntactic-ws',    ;; empty string.  As opposed to `c-(forward|backward)-syntactic-ws',
1233    ;; this doesn't regard cpp directives as syntactic whitespace.  Does    ;; this doesn't regard cpp directives as syntactic whitespace.  Does
1234    ;; not contain a \| operator at the top level.    ;; not contain a \| operator at the top level.
1235    t (concat "[ \t\n\r\f\v]*\\("    t (concat (c-lang-const c-simple-ws) "*"
1236              "\\(" (c-lang-const c-nonwhite-syntactic-ws) "\\)"              "\\("
1237              "[ \t\n\r\f\v]*\\)*"))              (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws) "\\)"
1238                        (c-lang-const c-simple-ws) "*")
1239                "\\)*"))
1240    
1241  (c-lang-defconst c-syntactic-ws-depth  (c-lang-defconst c-syntactic-ws-depth
1242    ;; Number of regexp grouping parens in `c-syntactic-ws'.    ;; Number of regexp grouping parens in `c-syntactic-ws'.
1243    t (c-regexp-opt-depth (c-lang-const c-syntactic-ws)))    t (regexp-opt-depth (c-lang-const c-syntactic-ws)))
1244    
1245  (c-lang-defconst c-nonempty-syntactic-ws  (c-lang-defconst c-nonempty-syntactic-ws
1246    ;; Regexp matching syntactic whitespace, which is at least one    ;; Regexp matching syntactic whitespace, which is at least one
1247    ;; character long.  As opposed to `c-(forward|backward)-syntactic-ws',    ;; character long.  As opposed to `c-(forward|backward)-syntactic-ws',
1248    ;; this doesn't regard cpp directives as syntactic whitespace.  Does    ;; this doesn't regard cpp directives as syntactic whitespace.  Does
1249    ;; not contain a \| operator at the top level.    ;; not contain a \| operator at the top level.
1250    t (concat "\\([ \t\n\r\f\v]\\|"    t (concat "\\("
1251                (c-lang-const c-simple-ws)
1252                "\\|"
1253              (c-lang-const c-nonwhite-syntactic-ws)              (c-lang-const c-nonwhite-syntactic-ws)
1254              "\\)+"))              "\\)+"))
1255    
1256  (c-lang-defconst c-nonempty-syntactic-ws-depth  (c-lang-defconst c-nonempty-syntactic-ws-depth
1257    ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.    ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
1258    t (c-regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws)))    t (regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws)))
1259    
1260  (c-lang-defconst c-single-line-syntactic-ws  (c-lang-defconst c-single-line-syntactic-ws
1261    ;; Regexp matching syntactic whitespace without any line breaks.  As    ;; Regexp matching syntactic whitespace without any line breaks.  As
1262    ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't    ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
1263    ;; regard cpp directives as syntactic whitespace.  Does not contain    ;; regard cpp directives as syntactic whitespace.  Does not contain
1264    ;; a \| operator at the top level.    ;; a \| operator at the top level.
1265    t (concat "[ \t]*\\("    t (if (c-lang-const c-block-comment-regexp)
1266              "/\\*\\([^*\n\r]\\|\\*[^/\n\r]\\)*\\*/" ; Block comment          (concat "\\s *\\("
1267              "[ \t]*\\)*")                  (c-lang-const c-block-comment-regexp)
1268    awk ("[ \t]*\\(#.*$\\)?"))                  "\\s *\\)*")
1269          "\\s *"))
1270    
1271  (c-lang-defconst c-single-line-syntactic-ws-depth  (c-lang-defconst c-single-line-syntactic-ws-depth
1272    ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.    ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
1273    t (c-regexp-opt-depth (c-lang-const c-single-line-syntactic-ws)))    t (regexp-opt-depth (c-lang-const c-single-line-syntactic-ws)))
1274    
1275  (c-lang-defvar c-syntactic-eol  (c-lang-defconst c-syntactic-eol
1276    ;; Regexp that matches when there is no syntactically significant    ;; Regexp that matches when there is no syntactically significant
1277    ;; text before eol.  Macros are regarded as syntactically    ;; text before eol.  Macros are regarded as syntactically
1278    ;; significant text here.    ;; significant text here.
1279    (concat (concat    t (concat (c-lang-const c-single-line-syntactic-ws)
1280             ;; Match horizontal whitespace and block comments that              ;; Match eol (possibly inside a block comment or preceded
1281             ;; don't contain newlines.              ;; by a line continuation backslash), or the beginning of a
1282             "\\(\\s \\|"              ;; line comment.  Note: This has to be modified for awk
1283             (concat "/\\*"              ;; where line comments start with '#'.
1284                     "\\([^*\n\r]\\|\\*[^/\n\r]\\)*"              "\\("
1285                     "\\*/")              (c-concat-separated
1286             "\\)*")               (list (when (c-lang-const c-line-comment-starter)
1287            (concat                       (regexp-quote (c-lang-const c-line-comment-starter)))
1288             ;; Match eol (possibly inside a block comment or preceded                     (when (c-lang-const c-unterminated-block-comment-regexp)
1289             ;; by a line continuation backslash), or the beginning of a                       (concat (c-lang-const c-unterminated-block-comment-regexp)
1290             ;; line comment.  Note: This has to be modified for awk                               "$"))
1291             ;; where line comments start with '#'.                     "\\\\$"
            "\\("  
            (concat "\\("  
                    "/\\*\\([^*\n\r]\\|\\*[^/\n\r]\\)*"  
                    "\\|"  
                    "\\\\"  
                    "\\)?"  
1292                     "$")                     "$")
1293             "\\|//\\)")))               "\\|")
1294                "\\)"))
1295    (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol))
1296    
1297    
1298    ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
1299    (c-lang-defconst c-at-vsemi-p-fn
1300      "Contains a function \"Is there a virtual semicolon at POS or point?\".
1301    Such a function takes one optional parameter, a buffer position (defaults to
1302    point), and returns NIL or t.  This variable contains NIL for languages which
1303    don't have EOL terminated statements. "
1304      t nil
1305      awk 'c-awk-at-vsemi-p)
1306    (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn))
1307    
1308    (c-lang-defconst c-vsemi-status-unknown-p-fn
1309      "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
1310    The (admittedly kludgey) purpose of such a function is to prevent an infinite
1311    recursion in c-beginning-of-statement-1 when point starts at a `while' token.
1312    The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
1313    even indirectly.  This variable contains NIL for languages which don't have
1314    EOL terminated statements."
1315      t nil
1316      awk 'c-awk-vsemi-status-unknown-p)
1317    (c-lang-defvar c-vsemi-status-unknown-p-fn
1318      (c-lang-const c-vsemi-status-unknown-p-fn))
1319    
1320    
1321  ;;; In-comment text handling.  ;;; In-comment text handling.
# Line 1137  not the type face." Line 1439  not the type face."
1439  (c-lang-defvar c-opt-type-component-key  (c-lang-defvar c-opt-type-component-key
1440    (c-lang-const c-opt-type-component-key))    (c-lang-const c-opt-type-component-key))
1441    
1442    (c-lang-defconst c-type-start-kwds
1443      ;; All keywords that can start a type (i.e. are either a type prefix
1444      ;; or a complete type).
1445      t (delete-duplicates (append (c-lang-const c-primitive-type-kwds)
1446                                   (c-lang-const c-type-prefix-kwds)
1447                                   (c-lang-const c-type-modifier-kwds))
1448                           :test 'string-equal))
1449    
1450  (c-lang-defconst c-class-decl-kwds  (c-lang-defconst c-class-decl-kwds
1451    "Keywords introducing declarations where the following block (if any)    "Keywords introducing declarations where the following block (if any)
1452  contains another declaration level that should be considered a class.  contains another declaration level that should be considered a class.
# Line 1187  will be handled." Line 1497  will be handled."
1497    
1498  (c-lang-defconst c-other-block-decl-kwds  (c-lang-defconst c-other-block-decl-kwds
1499    "Keywords where the following block (if any) contains another    "Keywords where the following block (if any) contains another
1500  declaration level that should not be considered a class.  declaration level that should not be considered a class.  For every
1501    keyword here, CC Mode will add a set of special syntactic symbols for
1502    those blocks.  E.g. if the keyword is \"foo\" then there will be
1503    `foo-open', `foo-close', and `infoo' symbols.
1504    
1505    The intention is that this category should be used for block
1506    constructs that aren't related to object orientation concepts like
1507    classes (which thus also include e.g. interfaces, templates,
1508    contracts, structs, etc).  The more pragmatic distinction is that
1509    while most want some indentation inside classes, it's fairly common
1510    that they don't want it in some of these constructs, so it should be
1511    simple to configure that differently from classes.  See also
1512    `c-class-decl-kwds'.
1513    
1514  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1515  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1516  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1517  will be handled."  will be handled."
1518    t   nil    t   nil
1519    c   '("extern")    (c objc) '("extern")
1520    c++ '("namespace" "extern")    c++ '("namespace" "extern")
1521    idl '("module"    idl '("module"
1522          ;; In CORBA CIDL:          ;; In CORBA CIDL:
# Line 1207  will be handled." Line 1529  will be handled."
1529  (c-lang-defvar c-other-decl-block-key (c-lang-const c-other-decl-block-key))  (c-lang-defvar c-other-decl-block-key (c-lang-const c-other-decl-block-key))
1530    
1531  (c-lang-defconst c-typedef-decl-kwds  (c-lang-defconst c-typedef-decl-kwds
1532    "Keywords introducing declarations where the identifiers are defined    "Keywords introducing declarations where the identifier(s) being
1533  to be types.  declared are types.
1534    
1535  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1536  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1537  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1538  will be handled."  will be handled."
1539    t    '("typedef")    ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1540    (java awk) nil)    ;; (since e.g. "Foo" is a type that's being defined in "class Foo
1541      ;; {...}").
1542      t    (append (c-lang-const c-class-decl-kwds)
1543                   (c-lang-const c-brace-list-decl-kwds))
1544      ;; Languages that have a "typedef" construct.
1545      (c c++ objc idl pike) (append (c-lang-const c-typedef-decl-kwds)
1546                                    '("typedef"))
1547      ;; Unlike most other languages, exception names are not handled as
1548      ;; types in IDL since they only can occur in "raises" specs.
1549      idl  (delete "exception" (append (c-lang-const c-typedef-decl-kwds) nil)))
1550    
1551  (c-lang-defconst c-typeless-decl-kwds  (c-lang-defconst c-typeless-decl-kwds
1552    "Keywords introducing declarations where the identifier (declarator)    "Keywords introducing declarations where the \(first) identifier
1553  list follows directly after the keyword, without any type.  \(declarator) follows directly after the keyword, without any type.
1554    
1555  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1556  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1557  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1558  will be handled."  will be handled."
1559    t    nil    ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
1560    ;; Unlike most other languages, exception names are not handled as    ;; (since e.g. "Foo" is the identifier being defined in "class Foo
1561    ;; types in IDL since they only can occur in "raises" specs.    ;; {...}").
1562    idl  '("exception" "factory" "finder" "native"    t    (append (c-lang-const c-class-decl-kwds)
1563           ;; In CORBA PSDL:                 (c-lang-const c-brace-list-decl-kwds))
1564           "key" "stores"    ;; Note: "manages" for CORBA CIDL clashes with its presence on
1565           ;; In CORBA CIDL:    ;; `c-type-list-kwds' for IDL.
1566           ;; Note that "manages" here clashes with its presence on    idl  (append (c-lang-const c-typeless-decl-kwds)
1567           ;; `c-type-list-kwds' for IDL.                 '("factory" "finder" "native"
1568           "executor" "facet" "manages" "segment")                   ;; In CORBA PSDL:
1569    pike '("constant"))                   "key" "stores"
1570                     ;; In CORBA CIDL:
1571                     "facet"))
1572      pike (append (c-lang-const c-class-decl-kwds)
1573                   '("constant")))
1574    
1575  (c-lang-defconst c-modifier-kwds  (c-lang-defconst c-modifier-kwds
1576    "Keywords that can prefix normal declarations of identifiers    "Keywords that can prefix normal declarations of identifiers
1577  \(and typically acts as flags).  Things like argument declarations  \(and typically act as flags).  Things like argument declarations
1578  inside function headers are also considered declarations in this  inside function headers are also considered declarations in this
1579  sense.  sense.
1580    
# Line 1270  will be handled." Line 1605  will be handled."
1605    "Keywords that can start or prefix any declaration level construct,    "Keywords that can start or prefix any declaration level construct,
1606  besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',  besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
1607  `c-other-block-decl-kwds', `c-typedef-decl-kwds',  `c-other-block-decl-kwds', `c-typedef-decl-kwds',
1608  `c-typeless-decl-kwds' and `c-modifier-kwds'.  In a declaration, these  `c-typeless-decl-kwds' and `c-modifier-kwds'.
 keywords are also recognized inside or after the identifiers that  
 makes up the type.  
1609    
1610  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',  If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
1611  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',  `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1612  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses  `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
1613  will be handled."  will be handled."
1614    t       nil    t       nil
   (c c++) '("__declspec")               ; MSVC extension.  
1615    objc    '("@class" "@end" "@defs")    objc    '("@class" "@end" "@defs")
1616    java    '("import" "package")    java    '("import" "package")
1617    pike    '("import" "inherit"))    pike    '("import" "inherit"))
1618    
1619    (c-lang-defconst c-decl-start-kwds
1620      "Keywords that always start declarations, wherever they occur.
1621    This can be used for declarations that aren't recognized by the normal
1622    combination of `c-decl-prefix-re' and `c-decl-start-re'."
1623      t    nil
1624      ;; Classes can be declared anywhere in a Pike expression.
1625      pike '("class"))
1626    
1627    (c-lang-defconst c-decl-hangon-kwds
1628      "Keywords that can occur anywhere in a declaration level construct.
1629    This is used for self-contained things that can be tacked on anywhere
1630    on a declaration and that should be ignored to be able to recognize it
1631    correctly.  Typical cases are compiler extensions like
1632    \"__attribute__\" or \"__declspec\":
1633    
1634        __declspec(noreturn) void foo();
1635        class __declspec(dllexport) classname {...};
1636        void foo() __attribute__((noreturn));
1637    
1638    Note that unrecognized plain symbols are skipped anyway if they occur
1639    before the type, so such things are not necessary to mention here.
1640    Mentioning them here is necessary only if they can occur in other
1641    places, or if they are followed by a construct that must be skipped
1642    over \(like the parens in the \"__attribute__\" and \"__declspec\"
1643    examples above).  In the last case, they alse need to be present on
1644    one of `c-type-list-kwds', `c-ref-list-kwds',
1645    `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
1646    `c-<>-type-kwds', or `c-<>-arglist-kwds'."
1647      ;; NB: These are currently not recognized in all parts of a
1648      ;; declaration.  Specifically, they aren't recognized in the middle
1649      ;; of multi-token types, inside declarators, and between the
1650      ;; identifier and the arglist paren of a function declaration.
1651      ;;
1652      ;; FIXME: This ought to be user customizable since compiler stuff
1653      ;; like this usually is wrapped in project specific macros.  (It'd
1654      ;; of course be even better if we could cope without knowing this.)
1655      t nil
1656      (c c++) '(;; GCC extension.
1657                "__attribute__"
1658                ;; MSVC extension.
1659                "__declspec"))
1660    
1661    (c-lang-defconst c-decl-hangon-key
1662      ;; Adorned regexp matching `c-decl-hangon-kwds'.
1663      t (c-make-keywords-re t (c-lang-const c-decl-hangon-kwds)))
1664    (c-lang-defvar c-decl-hangon-key (c-lang-const c-decl-hangon-key))
1665    
1666    (c-lang-defconst c-prefix-spec-kwds
1667      ;; All keywords that can occur in the preamble of a declaration.
1668      ;; They typically occur before the type, but they are also matched
1669      ;; after presumptive types since we often can't be sure that
1670      ;; something is a type or just some sort of macro in front of the
1671      ;; declaration.  They might be ambiguous with types or type
1672      ;; prefixes.
1673      t (delete-duplicates (append (c-lang-const c-class-decl-kwds)
1674                                   (c-lang-const c-brace-list-decl-kwds)
1675                                   (c-lang-const c-other-block-decl-kwds)
1676                                   (c-lang-const c-typedef-decl-kwds)
1677                                   (c-lang-const c-typeless-decl-kwds)
1678                                   (c-lang-const c-modifier-kwds)
1679                                   (c-lang-const c-other-decl-kwds)
1680                                   (c-lang-const c-decl-start-kwds)
1681                                   (c-lang-const c-decl-hangon-kwds))
1682                           :test 'string-equal))
1683    
1684    (c-lang-defconst c-prefix-spec-kwds-re
1685      ;; Adorned regexp of `c-prefix-spec-kwds'.
1686      t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))
1687    (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
1688    
1689  (c-lang-defconst c-specifier-key  (c-lang-defconst c-specifier-key
1690    ;; Adorned regexp matching keywords that can start a declaration but    ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that
1691    ;; not a type.    ;; aren't ambiguous with types or type prefixes.
1692    t (c-make-keywords-re t    t (c-make-keywords-re t
1693        (set-difference (append (c-lang-const c-class-decl-kwds)        (set-difference (c-lang-const c-prefix-spec-kwds)
1694                                (c-lang-const c-brace-list-decl-kwds)                        (c-lang-const c-type-start-kwds)
                               (c-lang-const c-other-block-decl-kwds)  
                               (c-lang-const c-typedef-decl-kwds)  
                               (c-lang-const c-typeless-decl-kwds)  
                               (c-lang-const c-modifier-kwds)  
                               (c-lang-const c-other-decl-kwds))  
                       (append (c-lang-const c-primitive-type-kwds)  
                               (c-lang-const c-type-prefix-kwds)  
                               (c-lang-const c-type-modifier-kwds))  
1695                        :test 'string-equal)))                        :test 'string-equal)))
1696  (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key))  (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key))
1697    
1698    (c-lang-defconst c-postfix-spec-kwds
1699      ;; Keywords that can occur after argument list of a function header
1700      ;; declaration, i.e. in the "K&R region".
1701      t (append (c-lang-const c-postfix-decl-spec-kwds)
1702                (c-lang-const c-decl-hangon-kwds)))
1703    
1704    (c-lang-defconst c-not-decl-init-keywords
1705      ;; Adorned regexp matching all keywords that can't appear at the
1706      ;; start of a declaration.
1707      t (c-make-keywords-re t
1708          (set-difference (c-lang-const c-keywords)
1709                          (append (c-lang-const c-type-start-kwds)
1710                                  (c-lang-const c-prefix-spec-kwds))
1711                          :test 'string-equal)))
1712    (c-lang-defvar c-not-decl-init-keywords
1713      (c-lang-const c-not-decl-init-keywords))
1714    
1715  (c-lang-defconst c-protection-kwds  (c-lang-defconst c-protection-kwds
1716    "Protection label keywords in classes."    "Access protection label keywords in classes."
1717    t    nil    t    nil
1718    c++  '("private" "protected" "public")    c++  '("private" "protected" "public")
1719    objc '("@private" "@protected" "@public"))    objc '("@private" "@protected" "@public"))
1720    
 (c-lang-defconst c-opt-access-key  
   ;; Regexp matching an access protection label in a class, or nil in  
   ;; languages that don't have such things.  
   t    (if (c-lang-const c-protection-kwds)  
            (c-make-keywords-re t (c-lang-const c-protection-kwds)))  
   c++  (concat "\\("  
                (c-make-keywords-re nil (c-lang-const c-protection-kwds))  
                "\\)[ \t\n\r\f\v]*:"))  
 (c-lang-defvar c-opt-access-key (c-lang-const c-opt-access-key))  
   
1721  (c-lang-defconst c-block-decls-with-vars  (c-lang-defconst c-block-decls-with-vars
1722    "Keywords introducing declarations that can contain a block which    "Keywords introducing declarations that can contain a block which
1723  might be followed by variable declarations, e.g. like \"foo\" in  might be followed by variable declarations, e.g. like \"foo\" in
# Line 1342  The keywords on list are assumed to also Line 1743  The keywords on list are assumed to also
1743  between the header and the body \(i.e. the \"K&R-region\") in  between the header and the body \(i.e. the \"K&R-region\") in
1744  declarations."  declarations."
1745    t    nil    t    nil
   (c c++) '("__attribute__")            ; GCC extension.  
1746    java '("extends" "implements" "throws")    java '("extends" "implements" "throws")
1747    idl  '("context" "getraises" "manages" "primarykey" "raises" "setraises"    idl  '("context" "getraises" "manages" "primarykey" "raises" "setraises"
1748           "supports"           "supports"
# Line 1366  reason to put keywords on this list if t Line 1766  reason to put keywords on this list if t
1766  There's also no reason to add keywords that prefixes a normal  There's also no reason to add keywords that prefixes a normal
1767  declaration consisting of a type followed by a declarator (list), so  declaration consisting of a type followed by a declarator (list), so
1768  the keywords on `c-modifier-kwds' should normally not be listed here  the keywords on `c-modifier-kwds' should normally not be listed here
1769  too.  either.
1770    
1771  Note: Use `c-typeless-decl-kwds' for keywords followed by a function  Note: Use `c-typeless-decl-kwds' for keywords followed by a function
1772  or variable identifier (that's being defined)."  or variable identifier (that's being defined)."
1773    t    '("struct" "union" "enum")    t    nil
   (c awk) nil  
1774    c++  '("operator")    c++  '("operator")
1775    objc (append '("@class" "@interface" "@implementation" "@protocol")    objc '("@class")
1776                 (c-lang-const c-type-list-kwds))    java '("import" "new" "extends" "implements" "throws")
1777    java '("class" "import" "interface" "new" "extends" "implements" "throws")    idl  '("manages" "native" "primarykey" "supports"
1778    idl  (append '("component" "eventtype" "home" "interface" "manages" "native"           ;; In CORBA PSDL:
1779                   "primarykey" "supports" "valuetype"           "as" "implements" "of" "scope")
1780                   ;; In CORBA PSDL:    pike '("inherit"))
                  "as" "implements" "of" "scope" "storagehome" "storagetype")  
                (c-lang-const c-type-list-kwds))  
   pike '("class" "enum" "inherit"))  
1781    
1782  (c-lang-defconst c-ref-list-kwds  (c-lang-defconst c-ref-list-kwds
1783    "Keywords that may be followed by a comma separated list of    "Keywords that may be followed by a comma separated list of
# Line 1414  special case when the list can contain o Line 1810  special case when the list can contain o
1810  (c-lang-defconst c-colon-type-list-re  (c-lang-defconst c-colon-type-list-re
1811    "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip    "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
1812  forward to the colon.  The end of the match is assumed to be directly  forward to the colon.  The end of the match is assumed to be directly
1813  after the colon, so the regexp should end with \":\" although that  after the colon, so the regexp should end with \":\".  Must be a
1814  isn't necessary.  Must be a regexp if `c-colon-type-list-kwds' isn't  regexp if `c-colon-type-list-kwds' isn't nil."
 nil."  
1815    t (if (c-lang-const c-colon-type-list-kwds)    t (if (c-lang-const c-colon-type-list-kwds)
1816          ;; Disallow various common punctuation chars that can't come          ;; Disallow various common punctuation chars that can't come
1817          ;; before the ":" that starts the inherit list after "class"          ;; before the ":" that starts the inherit list after "class"
# Line 1429  nil." Line 1824  nil."
1824    "Keywords that may be followed by a parenthesis expression that doesn't    "Keywords that may be followed by a parenthesis expression that doesn't
1825  contain type identifiers."  contain type identifiers."
1826    t       nil    t       nil
1827    (c c++) '("__declspec"))              ; MSVC extension.    (c c++) '(;; GCC extension.
1828                "__attribute__"
1829                ;; MSVC extension.
1830                "__declspec"))
1831    
1832  (c-lang-defconst c-paren-type-kwds  (c-lang-defconst c-paren-type-kwds
1833    "Keywords that may be followed by a parenthesis expression containing    "Keywords that may be followed by a parenthesis expression containing
# Line 1512  identifiers that follows the type in a n Line 1910  identifiers that follows the type in a n
1910    t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds)))    t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds)))
1911  (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key))  (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key))
1912    
1913    (c-lang-defconst c-block-stmt-kwds
1914      ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
1915      t (delete-duplicates (append (c-lang-const c-block-stmt-1-kwds)
1916                                   (c-lang-const c-block-stmt-2-kwds))
1917                           :test 'string-equal))
1918    
1919  (c-lang-defconst c-opt-block-stmt-key  (c-lang-defconst c-opt-block-stmt-key
1920    ;; Regexp matching the start of any statement that has a    ;; Regexp matching the start of any statement that has a
1921    ;; substatement (except a bare block).  Nil in languages that    ;; substatement (except a bare block).  Nil in languages that
# Line 1563  nevertheless contains a list separated w Line 1967  nevertheless contains a list separated w
1967  (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key))  (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key))
1968    
1969  (c-lang-defconst c-label-kwds  (c-lang-defconst c-label-kwds
1970    "Keywords introducing labels in blocks."    "Keywords introducing colon terminated labels in blocks."
1971    t '("case" "default")    t '("case" "default")
1972    awk nil)    awk nil)
1973    
1974    (c-lang-defconst c-label-kwds-regexp
1975      ;; Adorned regexp matching any keyword that introduces a label.
1976      t (c-make-keywords-re t (c-lang-const c-label-kwds)))
1977    (c-lang-defvar c-label-kwds-regexp (c-lang-const c-label-kwds-regexp))
1978    
1979  (c-lang-defconst c-before-label-kwds  (c-lang-defconst c-before-label-kwds
1980    "Keywords that might be followed by a label identifier."    "Keywords that might be followed by a label identifier."
1981    t    '("goto")    t    '("goto")
# Line 1575  nevertheless contains a list separated w Line 1984  nevertheless contains a list separated w
1984    idl  nil    idl  nil
1985    awk  nil)    awk  nil)
1986    
 (c-lang-defconst c-label-kwds-regexp  
   ;; Regexp matching any keyword that introduces a label.  
   t (c-make-keywords-re t (c-lang-const c-label-kwds)))  
 (c-lang-defvar c-label-kwds-regexp (c-lang-const c-label-kwds-regexp))  
   
1987  (c-lang-defconst c-constant-kwds  (c-lang-defconst c-constant-kwds
1988    "Keywords for constants."    "Keywords for constants."
1989    t       nil    t       nil
# Line 1602  nevertheless contains a list separated w Line 2006  nevertheless contains a list separated w
2006    ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.    ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
2007    t (delete-duplicates    t (delete-duplicates
2008       (append (c-lang-const c-primary-expr-kwds)       (append (c-lang-const c-primary-expr-kwds)
2009               (c-with-syntax-table (c-lang-const c-mode-syntax-table)               (c-filter-ops (c-lang-const c-operator-list)
2010                 (mapcan (lambda (op)                             t
2011                           (and (string-match "\\`\\(\\w\\|\\s_\\)+\\'" op)                             "\\`\\(\\w\\|\\s_\\)+\\'"))
                               (list op)))  
                        (c-lang-const c-operator-list))))  
2012       :test 'string-equal))       :test 'string-equal))
2013    
2014  (c-lang-defconst c-lambda-kwds  (c-lang-defconst c-lambda-kwds
# Line 1615  expressions." Line 2017  expressions."
2017    t    nil    t    nil
2018    pike '("lambda"))    pike '("lambda"))
2019    
 (c-lang-defconst c-opt-lambda-key  
   ;; Adorned regexp matching the start of lambda constructs, or nil in  
   ;; languages that don't have such things.  
   t (and (c-lang-const c-lambda-kwds)  
          (c-make-keywords-re t (c-lang-const c-lambda-kwds))))  
 (c-lang-defvar c-opt-lambda-key (c-lang-const c-opt-lambda-key))  
   
2020  (c-lang-defconst c-inexpr-block-kwds  (c-lang-defconst c-inexpr-block-kwds
2021    "Keywords that start constructs followed by statement blocks which can    "Keywords that start constructs followed by statement blocks which can
2022  be used in expressions \(the gcc extension for this in C and C++ is  be used in expressions \(the gcc extension for this in C and C++ is
2023  handled separately)."  handled separately by `c-recognize-paren-inexpr-blocks')."
2024    t    nil    t    nil
2025    pike '("catch" "gauge"))    pike '("catch" "gauge"))
2026    
 (c-lang-defconst c-opt-inexpr-block-key  
   ;; Regexp matching the start of in-expression statements, or nil in  
   ;; languages that don't have such things.  
   t    nil  
   pike (c-make-keywords-re t (c-lang-const c-inexpr-block-kwds)))  
 (c-lang-defvar c-opt-inexpr-block-key (c-lang-const c-opt-inexpr-block-key))  
   
2027  (c-lang-defconst c-inexpr-class-kwds  (c-lang-defconst c-inexpr-class-kwds
2028    "Keywords that can start classes inside expressions."    "Keywords that can start classes inside expressions."
2029    t    nil    t    nil
2030    java '("new")    java '("new")
2031    pike '("class"))    pike '("class"))
2032    
 (c-lang-defconst c-opt-inexpr-class-key  
   ;; Regexp matching the start of a class in an expression, or nil in  
   ;; languages that don't have such things.  
   t (and (c-lang-const c-inexpr-class-kwds)  
          (c-make-keywords-re t (c-lang-const c-inexpr-class-kwds))))  
 (c-lang-defvar c-opt-inexpr-class-key (c-lang-const c-opt-inexpr-class-key))  
   
2033  (c-lang-defconst c-inexpr-brace-list-kwds  (c-lang-defconst c-inexpr-brace-list-kwds
2034    "Keywords that can start brace list blocks inside expressions.    "Keywords that can start brace list blocks inside expressions.
2035  Note that Java specific rules are currently applied to tell this from  Note that Java specific rules are currently applied to tell this from
# Line 1665  Note that Java specific rules are curren Line 2046  Note that Java specific rules are curren
2046  (c-lang-defvar c-opt-inexpr-brace-list-key  (c-lang-defvar c-opt-inexpr-brace-list-key
2047    (c-lang-const c-opt-inexpr-brace-list-key))    (c-lang-const c-opt-inexpr-brace-list-key))
2048    
 (c-lang-defconst c-any-class-key  
   ;; Regexp matching the start of any class, both at top level and in  
   ;; expressions.  
   t (c-make-keywords-re t  
       (append (c-lang-const c-class-decl-kwds)  
               (c-lang-const c-inexpr-class-kwds))))  
 (c-lang-defvar c-any-class-key (c-lang-const c-any-class-key))  
   
2049  (c-lang-defconst c-decl-block-key  (c-lang-defconst c-decl-block-key
2050    ;; Regexp matching the start of any declaration-level block that    ;; Regexp matching keywords in any construct that contain another
2051    ;; contain another declaration level, i.e. that isn't a function    ;; declaration level, i.e. that isn't followed by a function block
2052    ;; block or brace list.    ;; or brace list.  When the first submatch matches, it's an
2053    t (c-make-keywords-re t    ;; unambiguous construct, otherwise it's an ambiguous match that
2054        (append (c-lang-const c-class-decl-kwds)    ;; might also be the return type of a function declaration.
2055                (c-lang-const c-other-block-decl-kwds)    t (let* ((decl-kwds (append (c-lang-const c-class-decl-kwds)
2056                (c-lang-const c-inexpr-class-kwds)))                                (c-lang-const c-other-block-decl-kwds)
2057    ;; In Pike modifiers might be followed by a block                                (c-lang-const c-inexpr-class-kwds)))
2058    ;; to apply to several declarations.             (unambiguous (set-difference decl-kwds
2059    pike (concat (c-lang-const c-decl-block-key)                                          (c-lang-const c-type-start-kwds)
2060                 "\\|"                                          :test 'string-equal))
2061                 "\\(" (c-make-keywords-re nil             (ambiguous (intersection decl-kwds
2062                         (c-lang-const c-modifier-kwds)) "\\)"                                      (c-lang-const c-type-start-kwds)
2063                 (c-lang-const c-syntactic-ws)                                      :test 'string-equal)))
2064                 "{"))        (if ambiguous
2065              (concat (c-make-keywords-re t unambiguous)
2066                      "\\|"
2067                      (c-make-keywords-re t ambiguous))
2068            (c-make-keywords-re t unambiguous))))
2069  (c-lang-defvar c-decl-block-key (c-lang-const c-decl-block-key))  (c-lang-defvar c-decl-block-key (c-lang-const c-decl-block-key))
2070    
2071  (c-lang-defconst c-bitfield-kwds  (c-lang-defconst c-bitfield-kwds
# Line 1794  Note that Java specific rules are curren Line 2171  Note that Java specific rules are curren
2171              alist (cdr alist))              alist (cdr alist))
2172        (setplist (intern kwd obarray)        (setplist (intern kwd obarray)
2173                  ;; Emacs has an odd bug that causes `mapcan' to fail                  ;; Emacs has an odd bug that causes `mapcan' to fail
2174                  ;; with unintelligible errors.  (XEmacs >= 20 works.)                  ;; with unintelligible errors.  (XEmacs works.)
2175                  ;;(mapcan (lambda (lang-const)                  ;;(mapcan (lambda (lang-const)
2176                  ;;            (list lang-const t))                  ;;            (list lang-const t))
2177                  ;;          lang-const-list)                  ;;          lang-const-list)
# Line 1804  Note that Java specific rules are curren Line 2181  Note that Java specific rules are curren
2181      obarray))      obarray))
2182    
2183  (c-lang-defconst c-regular-keywords-regexp  (c-lang-defconst c-regular-keywords-regexp
2184    ;; Adorned regexp matching all keywords that aren't types or    ;; Adorned regexp matching all keywords that should be fontified
2185    ;; constants.    ;; with the keywords face.  I.e. that aren't types or constants.
2186    t (c-make-keywords-re t    t (c-make-keywords-re t
2187        (set-difference (c-lang-const c-keywords)        (set-difference (c-lang-const c-keywords)
2188                        (append (c-lang-const c-primitive-type-kwds)                        (append (c-lang-const c-primitive-type-kwds)
# Line 1814  Note that Java specific rules are curren Line 2191  Note that Java specific rules are curren
2191  (c-lang-defvar c-regular-keywords-regexp  (c-lang-defvar c-regular-keywords-regexp
2192    (c-lang-const c-regular-keywords-regexp))    (c-lang-const c-regular-keywords-regexp))
2193    
 (c-lang-defconst c-not-decl-init-keywords  
   ;; Adorned regexp matching all keywords that can't appear at the  
   ;; start of a declaration.  
   t (c-make-keywords-re t  
       (set-difference (c-lang-const c-keywords)  
                       (append (c-lang-const c-primitive-type-kwds)  
                               (c-lang-const c-type-prefix-kwds)  
                               (c-lang-const c-type-modifier-kwds)  
                               (c-lang-const c-class-decl-kwds)  
                               (c-lang-const c-brace-list-decl-kwds)  
                               (c-lang-const c-other-block-decl-kwds)  
                               (c-lang-const c-typedef-decl-kwds)  
                               (c-lang-const c-typeless-decl-kwds)  
                               (c-lang-const c-modifier-kwds)  
                               (c-lang-const c-other-decl-kwds))  
                       :test 'string-equal)))  
 (c-lang-defvar c-not-decl-init-keywords  
   (c-lang-const c-not-decl-init-keywords))  
   
2194  (c-lang-defconst c-primary-expr-regexp  (c-lang-defconst c-primary-expr-regexp
2195    ;; Regexp matching the start of any primary expression, i.e. any    ;; Regexp matching the start of any primary expression, i.e. any
2196    ;; literal, symbol, prefix operator, and '('.  It doesn't need to    ;; literal, symbol, prefix operator, and '('.  It doesn't need to
# Line 1842  Note that Java specific rules are curren Line 2200  Note that Java specific rules are curren
2200    ;; be a match of e.g. an infix operator. (The case with ambiguous    ;; be a match of e.g. an infix operator. (The case with ambiguous
2201    ;; keyword operators isn't handled.)    ;; keyword operators isn't handled.)
2202    
2203    t (c-with-syntax-table (c-lang-const c-mode-syntax-table)    t (let* ((prefix-ops
2204        (let* ((prefix-ops              (c-filter-ops (c-lang-const c-operators)
2205                (mapcan (lambda (op)                            '(prefix)
2206                          ;; Filter out the special case prefix                            (lambda (op)
2207                          ;; operators that are close parens.                              ;; Filter out the special case prefix
2208                          (unless (string-match "\\s\)" op)                              ;; operators that are close parens.
2209                            (list op)))                              (not (string-match "\\s)" op)))))
2210                        (mapcan  
2211                         (lambda (opclass)             (nonkeyword-prefix-ops
2212                           (when (eq (car opclass) 'prefix)              (c-filter-ops prefix-ops
2213                             (append (cdr opclass) nil)))                            t
2214                         (c-lang-const c-operators))))                            "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
2215    
2216               (nonkeyword-prefix-ops             (in-or-postfix-ops
2217                (mapcan (lambda (op)              (c-filter-ops (c-lang-const c-operators)
2218                          (unless (string-match "\\`\\(\\w\\|\\s_\\)+\\'" op)                            '(postfix
2219                            (list op)))                              postfix-if-paren
2220                        prefix-ops))                              left-assoc
2221                                right-assoc
2222               (in-or-postfix-ops                              right-assoc-sequence)
2223                (mapcan (lambda (opclass)                            t))
2224                          (when (memq (car opclass)  
2225                                      '(postfix             (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops
2226                                        left-assoc                                                     in-or-postfix-ops
2227                                        right-assoc                                                     :test 'string-equal))
2228                                        right-assoc-sequence))             (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops
2229                            (append (cdr opclass) nil)))                                                 in-or-postfix-ops
2230                        (c-lang-const c-operators)))                                                 :test 'string-equal)))
2231    
2232               (unambiguous-prefix-ops (set-difference nonkeyword-prefix-ops        (concat
2233                                                       in-or-postfix-ops         "\\("
2234                                                       :test 'string-equal))         ;; Take out all symbol class operators from `prefix-ops' and make the
2235               (ambiguous-prefix-ops (intersection nonkeyword-prefix-ops         ;; first submatch from them together with `c-primary-expr-kwds'.
2236                                                   in-or-postfix-ops         (c-make-keywords-re t
2237                                                   :test 'string-equal)))           (append (c-lang-const c-primary-expr-kwds)
2238                     (set-difference prefix-ops nonkeyword-prefix-ops
2239          (concat                                   :test 'string-equal)))
2240           "\\("  
2241           ;; Take out all symbol class operators from `prefix-ops' and make the         "\\|"
2242           ;; first submatch from them together with `c-primary-expr-kwds'.         ;; Match all ambiguous operators.
2243           (c-make-keywords-re t         (c-make-keywords-re nil
2244             (append (c-lang-const c-primary-expr-kwds)           (intersection nonkeyword-prefix-ops in-or-postfix-ops
2245                     (set-difference prefix-ops nonkeyword-prefix-ops                         :test 'string-equal))
2246                                     :test 'string-equal)))         "\\)"
2247    
2248           "\\|"         "\\|"
2249           ;; Match all ambiguous operators.         ;; Now match all other symbols.
2250           (c-make-keywords-re nil         (c-lang-const c-symbol-start)
2251             (intersection nonkeyword-prefix-ops in-or-postfix-ops  
2252           "\\|"
2253           ;; The chars that can start integer and floating point
2254           ;; constants.
2255           "\\.?[0-9]"
2256    
2257           "\\|"
2258           ;; The nonambiguous operators from `prefix-ops'.
2259           (c-make-keywords-re nil
2260             (set-difference nonkeyword-prefix-ops in-or-postfix-ops
2261                           :test 'string-equal))                           :test 'string-equal))
          "\\)"  
   
          "\\|"  
          ;; Now match all other symbols.  
          (c-lang-const c-symbol-start)  
2262    
2263           "\\|"         "\\|"
2264           ;; The chars that can start integer and floating point         ;; Match string and character literals.
2265           ;; constants.         "\\s\""
2266           "\\.?[0-9]"         (if (memq 'gen-string-delim c-emacs-features)
2267               "\\|\\s|"
2268           "\\|"           ""))))
          ;; The nonambiguous operators from `prefix-ops'.  
          (c-make-keywords-re nil  
            (set-difference nonkeyword-prefix-ops in-or-postfix-ops  
                            :test 'string-equal))  
   
          "\\|"  
          ;; Match string and character literals.  
          "\\s\""  
          (if (memq 'gen-string-delim c-emacs-features)  
              "\\|\\s|"  
            "")))))  
2269  (c-lang-defvar c-primary-expr-regexp (c-lang-const c-primary-expr-regexp))  (c-lang-defvar c-primary-expr-regexp (c-lang-const c-primary-expr-regexp))
2270    
2271    
2272  ;;; Additional constants for parser-level constructs.  ;;; Additional constants for parser-level constructs.
2273    
2274  (c-lang-defconst c-decl-prefix-re  (c-lang-defconst c-decl-prefix-re
2275    "Regexp matching something that might precede a declaration or a cast,    "Regexp matching something that might precede a declaration, cast or
2276  such as the last token of a preceding statement or declaration.  It  label, such as the last token of a preceding statement or declaration.
2277  should not match bob, though.  It can't require a match longer than  This is used in the common situation where a declaration or cast
2278  one token.  The end of the token is taken to be at the end of the  doesn't start with any specific token that can be searched for.
2279  first submatch.  It must not include any following whitespace.  It's  
2280  undefined whether identifier syntax (see `c-identifier-syntax-table')  The regexp should not match bob; that is done implicitly.  It can't
2281  is in effect or not."  require a match longer than one token.  The end of the token is taken
2282    to be at the end of the first submatch, which is assumed to always
2283    match.  It's undefined whether identifier syntax (see
2284    `c-identifier-syntax-table') is in effect or not.  This regexp is
2285    assumed to be a superset of `c-label-prefix-re' if
2286    `c-recognize-colon-labels' is set.
2287    
2288    Besides this, `c-decl-start-kwds' is used to find declarations.
2289    
2290    Note: This variable together with `c-decl-start-re' and
2291    `c-decl-start-kwds' is only used to detect \"likely\"
2292    declaration/cast/label starts.  I.e. they might produce more matches
2293    but should not miss anything (or else it's necessary to use text
2294    properties - see the next note).  Wherever they match, the following
2295    construct is analyzed to see if it indeed is a declaration, cast or
2296    label.  That analysis is not cheap, so it's important that not too
2297    many false matches are triggered.
2298    
2299    Note: If a declaration/cast/label start can't be detected with this
2300    variable, it's necessary to use the `c-type' text property with the
2301    value `c-decl-end' on the last char of the last token preceding the
2302    declaration.  See the comment blurb at the start of cc-engine.el for
2303    more info."
2304    
2305    ;; We match a sequence of characters to skip over things like \"};\"    ;; We match a sequence of characters to skip over things like \"};\"
2306    ;; more quickly.  We match ")" in C for K&R region declarations, and    ;; more quickly.  We match ")" in C for K&R region declarations, and
2307    ;; in all languages except Java for when a cpp macro definition    ;; in all languages except Java for when a cpp macro definition
# Line 1937  is in effect or not." Line 2311  is in effect or not."
2311    ;; Match "<" in C++ to get the first argument in a template arglist.    ;; Match "<" in C++ to get the first argument in a template arglist.
2312    ;; In that case there's an additional check in `c-find-decl-spots'    ;; In that case there's an additional check in `c-find-decl-spots'
2313    ;; that it got open paren syntax.    ;; that it got open paren syntax.
2314    ;;    c++ "\\([\{\}\(\);,<]+\\)"
   ;; Also match a single ":" for protection labels.  We cheat a little  
   ;; and require a symbol immediately before to avoid false matches  
   ;; when starting directly on a single ":", which can be the start of  
   ;; the base class initializer list in a constructor.  
   c++ "\\([\{\}\(\);,<]+\\|\\(\\w\\|\\s_\\):\\)\\([^:]\\|\\'\\)"  
2315    ;; Additionally match the protection directives in Objective-C.    ;; Additionally match the protection directives in Objective-C.
2316    ;; Note that this doesn't cope with the longer directives, which we    ;; Note that this doesn't cope with the longer directives, which we
2317    ;; would have to match from start to end since they don't end with    ;; would have to match from start to end since they don't end with
# Line 1950  is in effect or not." Line 2319  is in effect or not."
2319    objc (concat "\\([\{\}\(\);,]+\\|"    objc (concat "\\([\{\}\(\);,]+\\|"
2320                 (c-make-keywords-re nil (c-lang-const c-protection-kwds))                 (c-make-keywords-re nil (c-lang-const c-protection-kwds))
2321                 "\\)")                 "\\)")
   ;; Match ":" for switch labels inside union declarations in IDL.  
   idl "\\([\{\}\(\);:,]+\\)\\([^:]\\|\\'\\)"  
2322    ;; Pike is like C but we also match "[" for multiple value    ;; Pike is like C but we also match "[" for multiple value
2323    ;; assignments and type casts.    ;; assignments and type casts.
2324    pike "\\([\{\}\(\)\[;,]+\\)")    pike "\\([\{\}\(\)\[;,]+\\)")
2325  (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re)  (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re)
2326    'dont-doc)    'dont-doc)
2327    
2328    (c-lang-defconst c-decl-start-re
2329      "Regexp matching the start of any declaration, cast or label.
2330    It's used on the token after the one `c-decl-prefix-re' matched.  This
2331    regexp should not try to match those constructs accurately as it's
2332    only used as a sieve to avoid spending more time checking other
2333    constructs."
2334      t (c-lang-const c-identifier-start))
2335    (c-lang-defvar c-decl-start-re (c-lang-const c-decl-start-re))
2336    
2337    (c-lang-defconst c-decl-prefix-or-start-re
2338      ;; Regexp matching something that might precede or start a
2339      ;; declaration, cast or label.
2340      ;;
2341      ;; If the first submatch matches, it's taken to match the end of a
2342      ;; token that might precede such a construct, e.g. ';', '}' or '{'.
2343      ;; It's built from `c-decl-prefix-re'.
2344      ;;
2345      ;; If the first submatch did not match, the match of the whole
2346      ;; regexp is taken to be at the first token in the declaration.
2347      ;; `c-decl-start-re' is not checked in this case.
2348      ;;
2349      ;; Design note: The reason the same regexp is used to match both
2350      ;; tokens that precede declarations and start them is to avoid an
2351      ;; extra regexp search from the previous declaration spot in
2352      ;; `c-find-decl-spots'.  Users of `c-find-decl-spots' also count on
2353      ;; that it finds all declaration/cast/label starts in approximately
2354      ;; linear order, so we can't do the searches in two separate passes.
2355      t (if (c-lang-const c-decl-start-kwds)
2356            (concat (c-lang-const c-decl-prefix-re)
2357                    "\\|"
2358                    (c-make-keywords-re t (c-lang-const c-decl-start-kwds)))
2359          (c-lang-const c-decl-prefix-re)))
2360    (c-lang-defvar c-decl-prefix-or-start-re
2361      (c-lang-const c-decl-prefix-or-start-re)
2362      'dont-doc)
2363    
2364  (c-lang-defconst c-cast-parens  (c-lang-defconst c-cast-parens
2365    ;; List containing the paren characters that can open a cast, or nil in    ;; List containing the paren characters that can open a cast, or nil in
2366    ;; languages without casts.    ;; languages without casts.
2367    t (c-with-syntax-table (c-lang-const c-mode-syntax-table)    t (c-filter-ops (c-lang-const c-operators)
2368        (mapcan (lambda (opclass)                    '(prefix)
2369                  (when (eq (car opclass) 'prefix)                    "\\`\\s\(\\'"
2370                    (mapcan (lambda (op)                    (lambda (op) (elt op 0))))
                             (when (string-match "\\`\\s\(\\'" op)  
                               (list (elt op 0))))  
                           (cdr opclass))))  
               (c-lang-const c-operators))))  
2371  (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens))  (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens))
2372    
2373    (c-lang-defconst c-block-prefix-disallowed-chars
2374      "List of syntactically relevant characters that never can occur before
2375    the open brace in any construct that contains a brace block, e.g. in
2376    the \"class Foo: public Bar\" part of:
2377    
2378        class Foo: public Bar {int x();} a, *b;
2379    
2380    If parens can occur, the chars inside those aren't filtered with this
2381    list.
2382    
2383    '<' and '>' should be disallowed even if angle bracket arglists can
2384    occur.  That since the search function needs to stop at them anyway to
2385    ensure they are given paren syntax.
2386    
2387    This is used to skip backward from the open brace to find the region
2388    in which to look for a construct like \"class\", \"enum\",
2389    \"namespace\" or whatever.  That skipping should be as tight as
2390    possible for good performance."
2391    
2392      ;; Default to all chars that only occurs in nonsymbol tokens outside
2393      ;; identifiers.
2394      t (set-difference
2395         (c-lang-const c-nonsymbol-token-char-list)
2396         (c-filter-ops (append (c-lang-const c-identifier-ops)
2397                               (list (cons nil
2398                                           (c-lang-const c-after-id-concat-ops))))
2399                       t
2400                       t
2401                       (lambda (op)
2402                         (let ((pos 0) res)
2403                           (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
2404                                                op pos)
2405                             (setq res (cons (aref op (match-beginning 1)) res)
2406                                   pos (match-end 0)))
2407                           res))))
2408    
2409      ;; Allow cpp operatios (where applicable).
2410      t (if (c-lang-const c-opt-cpp-prefix)
2411            (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2412                            '(?#))
2413          (c-lang-const c-block-prefix-disallowed-chars))
2414    
2415      ;; Allow ':' for inherit list starters.
2416      (c++ objc idl) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2417                                     '(?:))
2418    
2419      ;; Allow ',' for multiple inherits.
2420      (c++ java) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2421                                 '(?,))
2422    
2423      ;; Allow parentheses for anonymous inner classes in Java and class
2424      ;; initializer lists in Pike.
2425      (java pike) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2426                                  '(?\( ?\)))
2427    
2428      ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
2429      (c c++ objc) (set-difference (c-lang-const c-block-prefix-disallowed-chars)
2430                                   '(?\" ?')))
2431    
2432    (c-lang-defconst c-block-prefix-charset
2433      ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
2434      ;; for `c-syntactic-skip-backward'.
2435      t (c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars) t))
2436    (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset))
2437    
2438  (c-lang-defconst c-type-decl-prefix-key  (c-lang-defconst c-type-decl-prefix-key
2439    "Regexp matching the operators that might precede the identifier in a    "Regexp matching the declarator operators that might precede the
2440  declaration, e.g. the \"*\" in \"char *argv\".  This regexp should  identifier in a declaration, e.g. the \"*\" in \"char *argv\".  This
2441  match \"(\" if parentheses are valid in type declarations.  The end of  regexp should match \"(\" if parentheses are valid in declarators.
2442  the first submatch is taken as the end of the operator.  Identifier  The end of the first submatch is taken as the end of the operator.
2443  syntax is in effect when this is matched (see `c-identifier-syntax-table')."  Identifier syntax is in effect when this is matched \(see
2444    `c-identifier-syntax-table')."
2445    t (if (c-lang-const c-type-modifier-kwds)    t (if (c-lang-const c-type-modifier-kwds)
2446          (concat (c-regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>")          (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>")
2447        ;; Default to a regexp that never matches.        ;; Default to a regexp that never matches.
2448        "\\<\\>")        "\\<\\>")
2449      ;; Check that there's no "=" afterwards to avoid matching tokens
2450      ;; like "*=".
2451    (c objc) (concat "\\("    (c objc) (concat "\\("
2452                     "[*\(]"                     "[*\(]"
2453                     "\\|"                     "\\|"
# Line 2001  syntax is in effect when this is matched Line 2468  syntax is in effect when this is matched
2468                 (c-lang-const c-type-decl-prefix-key)                 (c-lang-const c-type-decl-prefix-key)
2469                 "\\)"                 "\\)"
2470                 "\\([^=]\\|$\\)")                 "\\([^=]\\|$\\)")
2471    pike "\\([*\(!~]\\)\\([^=]\\|$\\)")    pike "\\(\\*\\)\\([^=]\\|$\\)")
2472  (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key)  (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key)
2473    'dont-doc)    'dont-doc)
2474    
2475  (c-lang-defconst c-type-decl-suffix-key  (c-lang-defconst c-type-decl-suffix-key
2476    "Regexp matching the operators that might follow after the identifier    "Regexp matching the declarator operators that might follow after the
2477  in a declaration, e.g. the \"[\" in \"char argv[]\".  This regexp  identifier in a declaration, e.g. the \"[\" in \"char argv[]\".  This
2478  should match \")\" if parentheses are valid in type declarations.  If  regexp should match \")\" if parentheses are valid in declarators.  If
2479  it matches an open paren of some kind, the type declaration check  it matches an open paren of some kind, the type declaration check
2480  continues at the corresponding close paren, otherwise the end of the  continues at the corresponding close paren, otherwise the end of the
2481  first submatch is taken as the end of the operator.  Identifier syntax  first submatch is taken as the end of the operator.  Identifier syntax
# Line 2017  is in effect when this is matched (see ` Line 2484  is in effect when this is matched (see `
2484    ;; function argument list parenthesis.    ;; function argument list parenthesis.
2485    t    (if (c-lang-const c-type-modifier-kwds)    t    (if (c-lang-const c-type-modifier-kwds)
2486             (concat "\\(\(\\|"             (concat "\\(\(\\|"
2487                     (c-regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"                     (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"
2488                     "\\)")                     "\\)")
2489           "\\(\(\\)")           "\\(\(\\)")
2490    (c c++ objc) (concat    (c c++ objc) (concat
2491                  "\\("                  "\\("
2492                  "[\)\[\(]"                  "[\)\[\(]"
2493                  "\\|"                  (if (c-lang-const c-type-modifier-kwds)
2494                  ;; "throw" in `c-type-modifier-kwds' is followed by a                      (concat
2495                  ;; parenthesis list, but no extra measures are                       "\\|"
2496                  ;; necessary to handle that.                       ;; "throw" in `c-type-modifier-kwds' is followed
2497                  (c-regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"                       ;; by a parenthesis list, but no extra measures
2498                         ;; are necessary to handle that.
2499                         (regexp-opt (c-lang-const c-type-modifier-kwds) t)
2500                         "\\>")
2501                      "")
2502                  "\\)")                  "\\)")
2503    (java idl) "\\([\[\(]\\)")    (java idl) "\\([\[\(]\\)")
2504  (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)  (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
2505    'dont-doc)    'dont-doc)
2506    
2507  (c-lang-defconst c-after-suffixed-type-decl-key  (c-lang-defconst c-after-suffixed-type-decl-key
2508    "This regexp is matched after a type declaration expression where    "This regexp is matched after a declarator expression where
2509  `c-type-decl-suffix-key' has matched.  If it matches then the  `c-type-decl-suffix-key' has matched.  If it matches then the
2510  construct is taken as a declaration.  It's typically used to match the  construct is taken as a declaration.  It's typically used to match the
2511  beginning of a function body or whatever might occur after the  beginning of a function body or whatever might occur after the
# Line 2052  not \",\" or \";\"." Line 2523  not \",\" or \";\"."
2523    ;; could however produce false matches on code like "FOO(bar) x"    ;; could however produce false matches on code like "FOO(bar) x"
2524    ;; where FOO is a cpp macro, so it's better to leave it out and rely    ;; where FOO is a cpp macro, so it's better to leave it out and rely
2525    ;; on the other heuristics in that case.    ;; on the other heuristics in that case.
2526    t (if (c-lang-const c-postfix-decl-spec-kwds)    t (if (c-lang-const c-postfix-spec-kwds)
2527          ;; Add on the keywords in `c-postfix-decl-spec-kwds'.          ;; Add on the keywords in `c-postfix-spec-kwds'.
2528          (concat (c-lang-const c-after-suffixed-type-decl-key)          (concat (c-lang-const c-after-suffixed-type-decl-key)
2529                  "\\|"                  "\\|"
2530                  (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))                  (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
2531        (c-lang-const c-after-suffixed-type-decl-key))        (c-lang-const c-after-suffixed-type-decl-key))
2532    ;; Also match the colon that starts a base class initializer list in    ;; Also match the colon that starts a base class initializer list in
2533    ;; C++.  That can be confused with a function call before the colon    ;; C++.  That can be confused with a function call before the colon
# Line 2096  It's undefined whether identifier syntax Line 2567  It's undefined whether identifier syntax
2567  is in effect or not."  is in effect or not."
2568    t nil    t nil
2569    (c c++ objc pike) "\\(\\.\\.\\.\\)"    (c c++ objc pike) "\\(\\.\\.\\.\\)"
2570    java "\\(\\[[ \t\n\r\f\v]*\\]\\)")    java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)"))
2571  (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))  (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))
2572    
2573  (c-lang-defvar c-known-type-key  (c-lang-defvar c-known-type-key
# Line 2105  is in effect or not." Line 2576  is in effect or not."
2576    ;; submatch is the one that matches the type.  Note that this regexp    ;; submatch is the one that matches the type.  Note that this regexp
2577    ;; assumes that symbol constituents like '_' and '$' have word    ;; assumes that symbol constituents like '_' and '$' have word
2578    ;; syntax.    ;; syntax.
2579    (let ((extra-types (when (boundp (c-mode-symbol "font-lock-extra-types"))    (let* ((extra-types
2580                         (c-mode-var "font-lock-extra-types"))))            (when (boundp (c-mode-symbol "font-lock-extra-types"))
2581                (c-mode-var "font-lock-extra-types")))
2582             (regexp-strings
2583              (mapcan (lambda (re)
2584                        (when (string-match "[][.*+?^$\\]" re)
2585                          (list re)))
2586                      extra-types))
2587             (plain-strings
2588              (mapcan (lambda (re)
2589                        (unless (string-match "[][.*+?^$\\]" re)
2590                          (list re)))
2591                      extra-types)))
2592      (concat "\\<\\("      (concat "\\<\\("
2593              (c-make-keywords-re nil (c-lang-const c-primitive-type-kwds))              (c-concat-separated
2594              (if (consp extra-types)               (append (list (c-make-keywords-re nil
2595                  (concat "\\|" (mapconcat 'identity extra-types "\\|"))                               (append (c-lang-const c-primitive-type-kwds)
2596                "")                                       plain-strings)))
2597                         regexp-strings)
2598                 "\\|")
2599              "\\)\\>")))              "\\)\\>")))
2600    
2601  (c-lang-defconst c-special-brace-lists  (c-lang-defconst c-special-brace-lists
# Line 2163  Foo bar = gnu;" Line 2647  Foo bar = gnu;"
2647    c++ t)    c++ t)
2648  (c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))  (c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))
2649    
2650    (c-lang-defconst c-recognize-paren-inexpr-blocks
2651      "Non-nil to recognize gcc style in-expression blocks,
2652    i.e. compound statements surrounded by parentheses inside expressions."
2653      t nil
2654      (c c++) t)
2655    (c-lang-defvar c-recognize-paren-inexpr-blocks
2656      (c-lang-const c-recognize-paren-inexpr-blocks))
2657    
2658  (c-lang-defconst c-opt-<>-arglist-start  (c-lang-defconst c-opt-<>-arglist-start
2659    ;; Regexp matching the start of angle bracket arglists in languages    ;; Regexp matching the start of angle bracket arglists in languages
2660    ;; where `c-recognize-<>-arglists' is set.  Does not exclude    ;; where `c-recognize-<>-arglists' is set.  Does not exclude
# Line 2188  Foo bar = gnu;" Line 2680  Foo bar = gnu;"
2680  (c-lang-defvar c-opt-<>-arglist-start-in-paren  (c-lang-defvar c-opt-<>-arglist-start-in-paren
2681    (c-lang-const c-opt-<>-arglist-start-in-paren))    (c-lang-const c-opt-<>-arglist-start-in-paren))
2682    
 (c-lang-defconst c-label-key  
   "Regexp matching a normal label, i.e. a label that doesn't begin with  
 a keyword like switch labels.  It's only used at the beginning of a  
 statement."  
   t "\\<\\>"  
   (c c++ objc java pike) (concat "\\(" (c-lang-const c-symbol-key) "\\)"  
                                  "[ \t\n\r\f\v]*:\\([^:]\\|$\\)"))  
 (c-lang-defvar c-label-key (c-lang-const c-label-key)  
   'dont-doc)  
   
2683  (c-lang-defconst c-opt-postfix-decl-spec-key  (c-lang-defconst c-opt-postfix-decl-spec-key
2684    ;; Regexp matching the beginning of a declaration specifier in the    ;; Regexp matching the beginning of a declaration specifier in the
2685    ;; region between the header and the body of a declaration.    ;; region between the header and the body of a declaration.
2686    ;;    ;;
2687    ;; TODO: This is currently not used uniformly; c++-mode and    ;; TODO: This is currently not used uniformly; c++-mode and
2688    ;; java-mode each have their own ways of using it.    ;; java-mode each have their own ways of using it.
2689    t nil    t    nil
2690    c++ (concat ":?[ \t\n\r\f\v]*\\(virtual[ \t\n\r\f\v]+\\)?\\("    c++  (concat ":?"
2691                (c-make-keywords-re nil (c-lang-const c-protection-kwds))                 (c-lang-const c-simple-ws) "*"
2692                "\\)[ \t\n\r\f\v]+"                 "\\(virtual" (c-lang-const c-simple-ws) "+\\)?\\("
2693                "\\(" (c-lang-const c-symbol-key) "\\)")                 (c-make-keywords-re nil (c-lang-const c-protection-kwds))
2694    java (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))                 "\\)" (c-lang-const c-simple-ws) "+"
2695                   "\\(" (c-lang-const c-symbol-key) "\\)")
2696      java (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
2697  (c-lang-defvar c-opt-postfix-decl-spec-key  (c-lang-defvar c-opt-postfix-decl-spec-key
2698    (c-lang-const c-opt-postfix-decl-spec-key))    (c-lang-const c-opt-postfix-decl-spec-key))
2699    
2700    (c-lang-defconst c-recognize-colon-labels
2701      "Non-nil if generic labels ending with \":\" should be recognized.
2702    That includes labels in code and access keys in classes.  This does
2703    not apply to labels recognized by `c-label-kwds' and
2704    `c-opt-extra-label-key'."
2705      t nil
2706      (c c++ objc java pike) t)
2707    (c-lang-defvar c-recognize-colon-labels
2708      (c-lang-const c-recognize-colon-labels))
2709    
2710    (c-lang-defconst c-label-prefix-re
2711      "Regexp like `c-decl-prefix-re' that matches any token that can precede
2712    a generic colon label.  Not used if `c-recognize-colon-labels' is
2713    nil."
2714      t "\\([{};]+\\)")
2715    (c-lang-defvar c-label-prefix-re
2716      (c-lang-const c-label-prefix-re))
2717    
2718    (c-lang-defconst c-nonlabel-token-key
2719      "Regexp matching things that can't occur in generic colon labels,
2720    neither in a statement nor in a declaration context.  The regexp is
2721    tested at the beginning of every sexp in a suspected label,
2722    i.e. before \":\".  Only used if `c-recognize-colon-labels' is set."
2723      t (concat
2724         ;; Don't allow string literals.
2725         "[\"']\\|"
2726         ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
2727         (c-make-keywords-re t
2728           (set-difference (c-lang-const c-keywords)
2729                           (append (c-lang-const c-label-kwds)
2730                                   (c-lang-const c-protection-kwds))
2731                           :test 'string-equal)))
2732      ;; Also check for open parens in C++, to catch member init lists in
2733      ;; constructors.  We normally allow it so that macros with arguments
2734      ;; work in labels.
2735      c++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key)))
2736    (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
2737    
2738    (c-lang-defconst c-opt-extra-label-key
2739      "Optional regexp matching labels.
2740    Normally, labels are detected according to `c-nonlabel-token-key',
2741    `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'.  This regexp can
2742    be used if there are additional labels that aren't recognized that
2743    way."
2744      t    nil
2745      objc (c-make-keywords-re t (c-lang-const c-protection-kwds)))
2746    (c-lang-defvar c-opt-extra-label-key (c-lang-const c-opt-extra-label-key))
2747    
2748  (c-lang-defconst c-opt-friend-key  (c-lang-defconst c-opt-friend-key
2749    ;; Regexp describing friend declarations classes, or nil in    ;; Regexp describing friend declarations classes, or nil in
2750    ;; languages that don't have such things.    ;; languages that don't have such things.
2751    ;;    ;;
2752    ;; TODO: Ought to use `c-specifier-key' or similar, and the template    ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
2753    ;; skipping isn't done properly.  This will disappear soon.    ;; template skipping isn't done properly.  This will disappear soon.
2754    t nil    t    nil
2755    c++ "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")    c++  (concat "friend" (c-lang-const c-simple-ws) "+"
2756                   "\\|"
2757                   (concat "template"
2758                           (c-lang-const c-simple-ws) "*"
2759                           "<.+>"
2760                           (c-lang-const c-simple-ws) "*"
2761                           "friend"
2762                           (c-lang-const c-simple-ws) "+")))
2763  (c-lang-defvar c-opt-friend-key (c-lang-const c-opt-friend-key))  (c-lang-defvar c-opt-friend-key (c-lang-const c-opt-friend-key))
2764    
2765  (c-lang-defconst c-opt-method-key  (c-lang-defconst c-opt-method-key
2766    ;; Special regexp to match the start of Objective-C methods.  The    ;; Special regexp to match the start of Objective-C methods.  The
2767    ;; first submatch is assumed to end after the + or - key.    ;; first submatch is assumed to end after the + or - key.
2768    t nil    t    nil
2769    objc (concat    objc (concat
2770          ;; TODO: Ought to use a better method than anchoring on bol.          ;; TODO: Ought to use a better method than anchoring on bol.
2771          "^[ \t]*\\([+-]\\)[ \t\n\r\f\v]*"          "^\\s *"
2772          "\\(([^)]*)[ \t\n\r\f\v]*\\)?"  ; return type          "\\([+-]\\)"
2773            (c-lang-const c-simple-ws) "*"
2774            (concat "\\("                   ; Return type.
2775                    "([^\)]*)"
2776                    (c-lang-const c-simple-ws) "*"
2777                    "\\)?")
2778          "\\(" (c-lang-const c-symbol-key) "\\)"))          "\\(" (c-lang-const c-symbol-key) "\\)"))
2779  (c-lang-defvar c-opt-method-key (c-lang-const c-opt-method-key))  (c-lang-defvar c-opt-method-key (c-lang-const c-opt-method-key))
2780    
2781    (c-lang-defconst c-type-decl-end-used
2782      ;; Must be set in buffers where the `c-type' text property might be
2783      ;; used with the value `c-decl-end'.
2784      ;;
2785      ;; `c-decl-end' is used to mark the ends of labels and access keys
2786      ;; to make interactive refontification work better.
2787      t (or (c-lang-const c-recognize-colon-labels)
2788            (and (c-lang-const c-label-kwds) t))
2789      ;; `c-decl-end' is used to mark the end of the @-style directives in
2790      ;; Objective-C.
2791      objc t)
2792    (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used))
2793    
2794    
2795  ;;; Wrap up the `c-lang-defvar' system.  ;;; Wrap up the `c-lang-defvar' system.
2796    
# Line 2249  for the given mode. Line 2806  for the given mode.
2806  This function should be evaluated at compile time, so that the  This function should be evaluated at compile time, so that the
2807  function it returns is byte compiled with all the evaluated results  function it returns is byte compiled with all the evaluated results
2808  from the language constants.  Use the `c-init-language-vars' macro to  from the language constants.  Use the `c-init-language-vars' macro to
2809  accomplish that conveniently.  accomplish that conveniently."
   
 This function does not do any hidden buffer changes."  
2810    
2811    (if (and (not load-in-progress)    (if (and (not load-in-progress)
2812             (boundp 'byte-compile-dest-file)             (boundp 'byte-compile-dest-file)
# Line 2282  This function does not do any hidden buf Line 2837  This function does not do any hidden buf
2837                                                  (elt init 1))))                                                  (elt init 1))))
2838                                (cdr c-lang-variable-inits))))                                (cdr c-lang-variable-inits))))
2839    
2840                   (unless (get ',mode 'c-has-warned-lang-consts)                   ;; This diagnostic message isn't useful for end
2841                     (message ,(concat "%s compiled with CC Mode %s "                   ;; users, so it's disabled.
2842                                       "but loaded with %s - evaluating "                   ;;(unless (get ',mode 'c-has-warned-lang-consts)
2843                                       "language constants from source")                   ;;  (message ,(concat "%s compiled with CC Mode %s "
2844                              ',mode ,c-version c-version)                   ;;                    "but loaded with %s - evaluating "
2845                     (put ',mode 'c-has-warned-lang-consts t))                   ;;                    "language constants from source")
2846                     ;;           ',mode ,c-version c-version)
2847                     ;;  (put ',mode 'c-has-warned-lang-consts t))
2848    
2849                   (require 'cc-langs)                   (require 'cc-langs)
2850                   (let ((init (cdr c-lang-variable-inits)))                   (let ((init (cdr c-lang-variable-inits)))
# Line 2328  This function does not do any hidden buf Line 2885  This function does not do any hidden buf
2885    "Initialize all the language dependent variables for the given mode.    "Initialize all the language dependent variables for the given mode.
2886  This macro is expanded at compile time to a form tailored for the mode  This macro is expanded at compile time to a form tailored for the mode
2887  in question, so MODE must be a constant.  Therefore MODE is not  in question, so MODE must be a constant.  Therefore MODE is not
2888  evaluated and should not be quoted.  evaluated and should not be quoted."
   
 This macro does not do any hidden buffer changes."  
2889    `(funcall ,(c-make-init-lang-vars-fun mode)))    `(funcall ,(c-make-init-lang-vars-fun mode)))
2890    
2891    

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26