Some fixes to follow coding conventions.
[bpt/emacs.git] / lisp / progmodes / cc-langs.el
1 ;;; cc-langs.el --- language specific settings for CC Mode
2
3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc.
4
5 ;; Authors: 2000- Martin Stjernholm
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm
7 ;; 1992-1997 Barry A. Warsaw
8 ;; 1987 Dave Detlefs and Stewart Clamen
9 ;; 1985 Richard M. Stallman
10 ;; Maintainer: bug-cc-mode@gnu.org
11 ;; Created: 22-Apr-1997 (split from cc-mode.el)
12 ;; Version: See cc-mode.el
13 ;; Keywords: c languages oop
14
15 ;; This file is part of GNU Emacs.
16
17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; any later version.
21
22 ;; GNU Emacs is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
26
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with this program; see the file COPYING. If not, write to
29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 ;; Boston, MA 02111-1307, USA.
31
32 ;;; Commentary:
33
34 ;;; Code:
35
36 (eval-when-compile
37 (let ((load-path
38 (if (and (boundp 'byte-compile-dest-file)
39 (stringp byte-compile-dest-file))
40 (cons (file-name-directory byte-compile-dest-file) load-path)
41 load-path)))
42 (require 'cc-bytecomp)))
43
44 (cc-require 'cc-defs)
45 (cc-require 'cc-vars)
46
47 \f
48 (defvar c-buffer-is-cc-mode nil
49 "Non-nil for all buffers with a `major-mode' derived from CC Mode.
50 Otherwise, this variable is nil. I.e. this variable is non-nil for
51 `c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode',
52 `pike-mode', and any other non-CC Mode mode that calls
53 `c-initialize-cc-mode' (e.g. `awk-mode').")
54 (make-variable-buffer-local 'c-buffer-is-cc-mode)
55 (put 'c-buffer-is-cc-mode 'permanent-local t)
56
57 \f
58 ;; Regular expressions and other values which must be parameterized on
59 ;; a per-language basis.
60
61 ;; Regex describing a `symbol' in all languages. We cannot use just
62 ;; `word' syntax class since `_' cannot be in word class. Putting
63 ;; underscore in word class breaks forward word movement behavior that
64 ;; users are familiar with. Besides, this runs counter to Emacs
65 ;; convention.
66 ;;
67 ;; I suspect this definition isn't correct in light of Java's
68 ;; definition of a symbol as being Unicode. I know so little about
69 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to
70 ;; punt on this for now.
71 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*")
72
73 ;; HELPME: Many of the following keyword lists are more or less bogus
74 ;; for some languages (notably ObjC and IDL). The effects of the
75 ;; erroneous values in the language handling is miniscule since these
76 ;; constants are not used very much (yet, anyway) in the actual syntax
77 ;; detection code, but I'd still appreciate help to get them correct.
78
79 ;; Primitive type keywords.
80 (defconst c-C-primitive-type-kwds
81 "char\\|double\\|float\\|int\\|long\\|short\\|signed\\|unsigned\\|void")
82 (defconst c-C++-primitive-type-kwds c-C-primitive-type-kwds)
83 (defconst c-ObjC-primitive-type-kwds c-C-primitive-type-kwds)
84 (defconst c-Java-primitive-type-kwds
85 "boolean\\|byte\\|char\\|double\\|float\\|int\\|long\\|short\\|void")
86 (defconst c-IDL-primitive-type-kwds c-C-primitive-type-kwds)
87 (defconst c-Pike-primitive-type-kwds
88 (concat "constant\\|float\\|int\\|mapping\\|multiset\\|object\\|"
89 "program\\|string\\|void"))
90
91 ;; Declaration specifier keywords.
92 (defconst c-C-specifier-kwds
93 "auto\\|const\\|extern\\|register\\|static\\|volatile")
94 (defconst c-C++-specifier-kwds
95 (concat c-C-specifier-kwds "\\|friend\\|inline\\|virtual"))
96 (defconst c-ObjC-specifier-kwds c-C++-specifier-kwds)
97 (defconst c-Java-specifier-kwds
98 ;; Note: `const' is not used, but it's still a reserved keyword.
99 (concat "abstract\\|const\\|final\\|native\\|private\\|protected\\|"
100 "public\\|static\\|synchronized\\|transient\\|volatile"))
101 (defconst c-IDL-specifier-kwds c-C++-specifier-kwds)
102 (defconst c-Pike-specifier-kwds
103 (concat "final\\|inline\\|local\\|nomask\\|optional\\|private\\|"
104 "protected\\|static\\|variant"))
105
106 ;; Class/struct declaration keywords.
107 (defconst c-C-class-kwds "struct\\|union")
108 (defconst c-C++-class-kwds (concat c-C-class-kwds "\\|class"))
109 (defconst c-ObjC-class-kwds "interface\\|implementation")
110 (defconst c-Java-class-kwds "class\\|interface")
111 (defconst c-IDL-class-kwds
112 (concat c-C++-class-kwds "\\|interface\\|valuetype"))
113 (defconst c-Pike-class-kwds "class")
114
115 ;; Keywords introducing other declaration-level blocks.
116 (defconst c-C-extra-toplevel-kwds "extern")
117 (defconst c-C++-extra-toplevel-kwds
118 (concat c-C-extra-toplevel-kwds "\\|namespace"))
119 ;;(defconst c-ObjC-extra-toplevel-kwds nil)
120 ;;(defconst c-Java-extra-toplevel-kwds nil)
121 (defconst c-IDL-extra-toplevel-kwds "module")
122 ;;(defconst c-Pike-extra-toplevel-kwds nil)
123
124 ;; Keywords introducing other declaration-level constructs.
125 (defconst c-C-other-decl-kwds "enum\\|typedef")
126 (defconst c-C++-other-decl-kwds (concat c-C-other-decl-kwds "\\|template"))
127 ;;(defconst c-ObjC-other-decl-kwds nil)
128 (defconst c-Java-other-decl-kwds "import\\|package")
129 ;;(defconst c-IDL-other-decl-kwds nil)
130 (defconst c-Pike-other-decl-kwds "import\\|inherit")
131
132 ;; Keywords that occur in declaration-level constructs.
133 ;;(defconst c-C-decl-level-kwds nil)
134 ;;(defconst c-C++-decl-level-kwds nil)
135 ;;(defconst c-ObjC-decl-level-kwds nil)
136 (defconst c-Java-decl-level-kwds "extends\\|implements\\|throws")
137 ;;(defconst c-IDL-decl-level-kwds nil)
138 ;;(defconst c-Pike-decl-level-kwds nil)
139
140 ;; Protection label keywords in classes.
141 ;;(defconst c-C-protection-kwds nil)
142 (defconst c-C++-protection-kwds "private\\|protected\\|public")
143 (defconst c-ObjC-protection-kwds c-C++-protection-kwds)
144 ;;(defconst c-Java-protection-kwds nil)
145 ;;(defconst c-IDL-protection-kwds nil)
146 ;;(defconst c-Pike-protection-kwds nil)
147
148 ;; Statement keywords followed directly by a block.
149 (defconst c-C-block-stmt-1-kwds "do\\|else")
150 (defconst c-C++-block-stmt-1-kwds
151 (concat c-C-block-stmt-1-kwds "\\|asm\\|try"))
152 (defconst c-ObjC-block-stmt-1-kwds c-C++-block-stmt-1-kwds)
153 (defconst c-Java-block-stmt-1-kwds
154 (concat c-C-block-stmt-1-kwds "\\|finally\\|try"))
155 ;;(defconst c-IDL-block-stmt-1-kwds nil)
156 (defconst c-Pike-block-stmt-1-kwds c-C-block-stmt-1-kwds)
157
158 ;; Statement keywords followed by a paren sexp and then by a block.
159 (defconst c-C-block-stmt-2-kwds "for\\|if\\|switch\\|while")
160 (defconst c-C++-block-stmt-2-kwds (concat c-C-block-stmt-2-kwds "\\|catch"))
161 (defconst c-ObjC-block-stmt-2-kwds c-C++-block-stmt-2-kwds)
162 (defconst c-Java-block-stmt-2-kwds
163 (concat c-C++-block-stmt-2-kwds "\\|synchronized"))
164 ;;(defconst c-IDL-block-stmt-2-kwds nil)
165 (defconst c-Pike-block-stmt-2-kwds c-C-block-stmt-2-kwds)
166
167 ;; Statement keywords followed by an expression or nothing.
168 (defconst c-C-simple-stmt-kwds "break\\|continue\\|goto\\|return")
169 (defconst c-C++-simple-stmt-kwds c-C-simple-stmt-kwds)
170 (defconst c-ObjC-simple-stmt-kwds c-C-simple-stmt-kwds)
171 (defconst c-Java-simple-stmt-kwds
172 ;; Note: `goto' is not a valid statement, but the keyword is still reserved.
173 (concat c-C-simple-stmt-kwds "\\|throw"))
174 ;;(defconst c-IDL-simple-stmt-kwds nil)
175 (defconst c-Pike-simple-stmt-kwds "break\\|continue\\|return")
176
177 ;; Keywords introducing labels in blocks.
178 (defconst c-C-label-kwds "case\\|default")
179 (defconst c-C++-label-kwds c-C-label-kwds)
180 (defconst c-ObjC-label-kwds c-C-label-kwds)
181 (defconst c-Java-label-kwds c-C-label-kwds)
182 ;;(defconst c-IDL-label-kwds nil)
183 (defconst c-Pike-label-kwds c-C-label-kwds)
184
185 ;; Keywords that can occur anywhere in expressions.
186 (defconst c-C-expr-kwds "sizeof")
187 (defconst c-C++-expr-kwds
188 (concat c-C-expr-kwds "\\|delete\\|new\\|operator\\|this\\|throw"))
189 (defconst c-ObjC-expr-kwds c-C-expr-kwds)
190 (defconst c-Java-expr-kwds "instanceof\\|new\\|super\\|this")
191 ;;(defconst c-IDL-expr-kwds nil)
192 (defconst c-Pike-expr-kwds
193 (concat c-C-expr-kwds "\\|catch\\|class\\|gauge\\|lambda\\|predef"))
194
195 ;; All keywords.
196 (defconst c-C-keywords
197 (concat c-C-primitive-type-kwds "\\|" c-C-specifier-kwds
198 "\\|" c-C-class-kwds "\\|" c-C-extra-toplevel-kwds
199 "\\|" c-C-other-decl-kwds
200 ;; "\\|" c-C-decl-level-kwds "\\|" c-C-protection-kwds
201 "\\|" c-C-block-stmt-1-kwds "\\|" c-C-block-stmt-2-kwds
202 "\\|" c-C-simple-stmt-kwds "\\|" c-C-label-kwds
203 "\\|" c-C-expr-kwds))
204 (defconst c-C++-keywords
205 (concat c-C++-primitive-type-kwds "\\|" c-C++-specifier-kwds
206 "\\|" c-C++-class-kwds "\\|" c-C++-extra-toplevel-kwds
207 "\\|" c-C++-other-decl-kwds
208 ;; "\\|" c-C++-decl-level-kwds
209 "\\|" c-C++-protection-kwds
210 "\\|" c-C++-block-stmt-1-kwds "\\|" c-C++-block-stmt-2-kwds
211 "\\|" c-C++-simple-stmt-kwds "\\|" c-C++-label-kwds
212 "\\|" c-C++-expr-kwds))
213 (defconst c-ObjC-keywords
214 (concat c-ObjC-primitive-type-kwds "\\|" c-ObjC-specifier-kwds
215 "\\|" c-ObjC-class-kwds
216 ;; "\\|" c-ObjC-extra-toplevel-kwds
217 ;; "\\|" c-ObjC-other-decl-kwds "\\|" c-ObjC-decl-level-kwds
218 "\\|" c-ObjC-protection-kwds
219 "\\|" c-ObjC-block-stmt-1-kwds "\\|" c-ObjC-block-stmt-2-kwds
220 "\\|" c-ObjC-simple-stmt-kwds "\\|" c-ObjC-label-kwds
221 "\\|" c-ObjC-expr-kwds))
222 (defconst c-Java-keywords
223 (concat c-Java-primitive-type-kwds "\\|" c-Java-specifier-kwds
224 "\\|" c-Java-class-kwds
225 ;; "\\|" c-Java-extra-toplevel-kwds
226 "\\|" c-Java-other-decl-kwds "\\|" c-Java-decl-level-kwds
227 ;; "\\|" c-Java-protection-kwds
228 "\\|" c-Java-block-stmt-1-kwds "\\|" c-Java-block-stmt-2-kwds
229 "\\|" c-Java-simple-stmt-kwds "\\|" c-Java-label-kwds
230 "\\|" c-Java-expr-kwds))
231 (defconst c-IDL-keywords
232 (concat c-IDL-primitive-type-kwds "\\|" c-IDL-specifier-kwds
233 "\\|" c-IDL-class-kwds "\\|" c-IDL-extra-toplevel-kwds
234 ;; "\\|" c-IDL-other-decl-kwds "\\|" c-IDL-decl-level-kwds
235 ;; "\\|" c-IDL-protection-kwds
236 ;; "\\|" c-IDL-block-stmt-1-kwds "\\|" c-IDL-block-stmt-2-kwds
237 ;; "\\|" c-IDL-simple-stmt-kwds "\\|" c-IDL-label-kwds
238 ;; "\\|" c-IDL-expr-kwds)
239 ))
240 (defconst c-Pike-keywords
241 (concat c-Pike-primitive-type-kwds "\\|" c-Pike-specifier-kwds
242 "\\|" c-Pike-class-kwds
243 ;; "\\|" c-Pike-extra-toplevel-kwds
244 "\\|" c-Pike-other-decl-kwds
245 ;; "\\|" c-Pike-decl-level-kwds "\\|" c-Pike-protection-kwds
246 "\\|" c-Pike-block-stmt-1-kwds "\\|" c-Pike-block-stmt-2-kwds
247 "\\|" c-Pike-simple-stmt-kwds "\\|" c-Pike-label-kwds
248 "\\|" c-Pike-expr-kwds))
249
250 (defvar c-keywords nil)
251 (make-variable-buffer-local 'c-keywords)
252
253 ;; Keywords defining protection levels
254 (defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
255
256 ;; Regexps introducing class definitions.
257 (defconst c-C-class-key (c-paren-re c-C-class-kwds))
258 (defconst c-C++-class-key (c-paren-re c-C++-class-kwds))
259 (defconst c-IDL-class-key (c-paren-re c-IDL-class-kwds))
260 (defconst c-ObjC-class-key
261 (concat
262 "@\\(" c-ObjC-class-kwds "\\)\\s +"
263 c-symbol-key ;name of the class
264 "\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
265 "\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
266 ))
267 (defconst c-Java-class-key
268 (concat
269 "\\(" c-protection-key "\\s +\\)?"
270 "\\(" c-Java-class-kwds "\\)\\s +"
271 c-symbol-key ;name of the class
272 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
273 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
274 ))
275 (defconst c-Pike-class-key (c-paren-re c-Pike-class-kwds))
276
277 (defvar c-class-key c-C-class-key)
278 (make-variable-buffer-local 'c-class-key)
279
280 (defconst c-C-extra-toplevel-key (c-paren-re c-C-extra-toplevel-kwds))
281 (defconst c-C++-extra-toplevel-key (c-paren-re c-C++-extra-toplevel-kwds))
282 (defconst c-IDL-extra-toplevel-key (c-paren-re c-IDL-extra-toplevel-kwds))
283
284 (defvar c-extra-toplevel-key c-C-extra-toplevel-key)
285 (make-variable-buffer-local 'c-extra-toplevel-key)
286
287 ;; Keywords that can introduce bitfields in the languages that supports that.
288 (defconst c-C-bitfield-key "\\(char\\|int\\|long\\|signed\\|unsigned\\)")
289
290 (defvar c-bitfield-key nil)
291 (make-variable-buffer-local 'c-bitfield-key)
292
293 ;; regexp describing access protection clauses. language specific
294 (defvar c-access-key nil)
295 (make-variable-buffer-local 'c-access-key)
296 (defconst c-C++-access-key
297 (concat "\\<\\(" c-C++-protection-kwds "\\)\\>[ \t]*:"))
298 ;;(defconst c-IDL-access-key nil)
299 (defconst c-ObjC-access-key (concat "@" c-protection-key))
300 ;;(defconst c-Java-access-key nil)
301 ;;(defconst c-Pike-access-key nil)
302
303 ;; keywords introducing conditional blocks
304 (defconst c-C-conditional-key nil)
305 (defconst c-C++-conditional-key nil)
306 (defconst c-IDL-conditional-key nil)
307 (defconst c-ObjC-conditional-key nil)
308 (defconst c-Java-conditional-key nil)
309 (defconst c-Pike-conditional-key nil)
310
311 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
312 (exc-kws "\\|try\\|catch")
313 (thr-kws "\\|finally\\|synchronized")
314 (front "\\<\\(")
315 (back "\\)\\>[^_]"))
316 (setq c-C-conditional-key (concat front all-kws back)
317 c-C++-conditional-key (concat front all-kws exc-kws back)
318 ;; c-IDL-conditional-key is nil.
319 c-ObjC-conditional-key c-C-conditional-key
320 c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)
321 c-Pike-conditional-key (concat front all-kws "\\|foreach" back)))
322
323 (defvar c-conditional-key c-C-conditional-key)
324 (make-variable-buffer-local 'c-conditional-key)
325
326 ;; keywords describing method definition introductions
327 (defvar c-method-key nil)
328 (make-variable-buffer-local 'c-method-key)
329
330 (defconst c-ObjC-method-key
331 (concat
332 "^\\s *[+-]\\s *"
333 "\\(([^)]*)\\)?" ; return type
334 ;; \\s- in objc syntax table does not include \n
335 ;; since it is considered the end of //-comments.
336 "[ \t\n]*" c-symbol-key))
337
338 ;; comment starter definitions for various languages. language specific
339 (defconst c-C++-comment-start-regexp "/[/*]")
340 (defconst c-C-comment-start-regexp c-C++-comment-start-regexp)
341 (defconst c-IDL-comment-start-regexp c-C++-comment-start-regexp)
342 (defconst c-ObjC-comment-start-regexp c-C++-comment-start-regexp)
343 (defconst c-Pike-comment-start-regexp c-C++-comment-start-regexp)
344 ;; We need to match all 3 Java style comments
345 ;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
346 (defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
347 (defvar c-comment-start-regexp c-C++-comment-start-regexp)
348 (make-variable-buffer-local 'c-comment-start-regexp)
349
350 ;; Regexp describing a switch's case or default label for all languages
351 (defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
352 ;; Regexp describing any label.
353 (defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
354
355 ;; Regexp describing class inheritance declarations. TBD: this should
356 ;; be language specific, and only makes sense for C++
357 (defconst c-inher-key
358 (concat "\\(\\<static\\>\\s +\\)?"
359 c-C++-class-key "[ \t]+" c-symbol-key
360 "\\([ \t]*:[ \t]*\\)\\s *[^;]"))
361
362 ;; Regexp describing C++ base classes in a derived class definition.
363 ;; TBD: this should be language specific, and only makes sense for C++
364 (defvar c-baseclass-key
365 (concat
366 ":?[ \t]*\\(virtual[ \t]+\\)?\\("
367 c-protection-key "[ \t]+\\)" c-symbol-key))
368 (make-variable-buffer-local 'c-baseclass-key)
369
370 ;; Regexp describing friend declarations in C++ classes.
371 (defconst c-C++-friend-key
372 "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
373
374 ;; Regexp describing Java inheritance and throws clauses.
375 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
376
377 ;; Regexp describing the beginning of a Java top-level definition.
378 (defconst c-Java-defun-prompt-regexp
379 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()\7f=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*")
380
381 ;; Regexp to append to paragraph-start.
382 (defvar c-append-paragraph-start "$")
383 (make-variable-buffer-local 'c-append-paragraph-start)
384 (defconst c-Java-javadoc-paragraph-start
385 "\\(@[a-zA-Z]+\\>\\|$\\)")
386 (defconst c-Pike-pikedoc-paragraph-start
387 "\\(@[a-zA-Z]+\\>\\([^{]\\|$\\)\\|$\\)")
388
389 ;; Regexp to append to paragraph-separate.
390 (defvar c-append-paragraph-separate "$")
391 (make-variable-buffer-local 'c-append-paragraph-separate)
392 (defconst c-Pike-pikedoc-paragraph-separate c-Pike-pikedoc-paragraph-start)
393
394 ;; Regexp that starts lambda constructs.
395 (defvar c-lambda-key nil)
396 (make-variable-buffer-local 'c-lambda-key)
397 (defconst c-Pike-lambda-key "\\<lambda\\>")
398
399 ;; Regexp that are followed by a statement block in expressions.
400 (defvar c-inexpr-block-key nil)
401 (make-variable-buffer-local 'c-inexpr-block-key)
402 (defconst c-Pike-inexpr-block-key "\\<\\(catch\\|gauge\\)\\>")
403
404 ;; Regexp that may be followed by an anonymous class in expressions.
405 (defvar c-inexpr-class-key nil)
406 (make-variable-buffer-local 'c-inexpr-class-key)
407 (defconst c-Java-inexpr-class-key "\\<new\\>")
408 (defconst c-Pike-inexpr-class-key "\\<class\\>")
409
410 ;; List of open- and close-chars that makes up a pike-style brace
411 ;; list, ie for a `([ ])' list there should be a cons (?\[ . ?\]) in
412 ;; this list.
413 (defvar c-special-brace-lists nil)
414 (make-variable-buffer-local 'c-special-brace-lists)
415 (defconst c-Pike-special-brace-lists '((?{ . ?})
416 (?\[ . ?\])
417 (?< . ?>)))
418
419 \f
420 ;; Syntax tables.
421
422 (defun c-populate-syntax-table (table)
423 ;; Populate the syntax TABLE
424 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
425 (modify-syntax-entry ?_ "_" table)
426 (modify-syntax-entry ?\\ "\\" table)
427 (modify-syntax-entry ?+ "." table)
428 (modify-syntax-entry ?- "." table)
429 (modify-syntax-entry ?= "." table)
430 (modify-syntax-entry ?% "." table)
431 (modify-syntax-entry ?< "." table)
432 (modify-syntax-entry ?> "." table)
433 (modify-syntax-entry ?& "." table)
434 (modify-syntax-entry ?| "." table)
435 (modify-syntax-entry ?\' "\"" table)
436 ;; Set up block and line oriented comments. The new C standard
437 ;; mandates both comment styles even in C, so since all languages
438 ;; now require dual comments, we make this the default.
439 (cond
440 ;; XEmacs 19 & 20
441 ((memq '8-bit c-emacs-features)
442 (modify-syntax-entry ?/ ". 1456" table)
443 (modify-syntax-entry ?* ". 23" table))
444 ;; Emacs 19 & 20
445 ((memq '1-bit c-emacs-features)
446 (modify-syntax-entry ?/ ". 124b" table)
447 (modify-syntax-entry ?* ". 23" table))
448 ;; incompatible
449 (t (error "CC Mode is incompatible with this version of Emacs"))
450 )
451 (modify-syntax-entry ?\n "> b" table)
452 ;; Give CR the same syntax as newline, for selective-display
453 (modify-syntax-entry ?\^m "> b" table))
454
455 ;;;###autoload
456 (defvar c-mode-syntax-table nil
457 "Syntax table used in c-mode buffers.")
458 (if c-mode-syntax-table
459 ()
460 (setq c-mode-syntax-table (make-syntax-table))
461 (c-populate-syntax-table c-mode-syntax-table))
462
463 ;;;###autoload
464 (defvar c++-mode-syntax-table nil
465 "Syntax table used in c++-mode buffers.")
466 (if c++-mode-syntax-table
467 ()
468 (setq c++-mode-syntax-table (make-syntax-table))
469 (c-populate-syntax-table c++-mode-syntax-table)
470 ;; TBD: does it make sense for colon to be symbol class in C++?
471 ;; I'm not so sure, since c-label-key is busted on lines like:
472 ;; Foo::bar( i );
473 ;; maybe c-label-key should be fixed instead of commenting this out,
474 ;; but it also bothers me that this only seems appropriate for C++
475 ;; and not C.
476 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
477 )
478
479 (defvar c++-template-syntax-table nil
480 "A variant of `c++-mode-syntax-table' that defines `<' and `>' as
481 parenthesis characters. Used temporarily when template argument lists
482 are parsed.")
483 (if c++-template-syntax-table
484 ()
485 (setq c++-template-syntax-table
486 (copy-syntax-table c++-mode-syntax-table))
487 (modify-syntax-entry ?< "(>" c++-template-syntax-table)
488 (modify-syntax-entry ?> ")<" c++-template-syntax-table))
489
490 ;;;###autoload
491 (defvar objc-mode-syntax-table nil
492 "Syntax table used in objc-mode buffers.")
493 (if objc-mode-syntax-table
494 ()
495 (setq objc-mode-syntax-table (make-syntax-table))
496 (c-populate-syntax-table objc-mode-syntax-table)
497 ;; add extra Objective-C only syntax
498 (modify-syntax-entry ?@ "_" objc-mode-syntax-table))
499
500 ;;;###autoload
501 (defvar java-mode-syntax-table nil
502 "Syntax table used in java-mode buffers.")
503 (if java-mode-syntax-table
504 ()
505 (setq java-mode-syntax-table (make-syntax-table))
506 (c-populate-syntax-table java-mode-syntax-table))
507
508 ;;;###autoload
509 (defvar idl-mode-syntax-table nil
510 "Syntax table used in idl-mode buffers.")
511 (if idl-mode-syntax-table
512 nil
513 (setq idl-mode-syntax-table (make-syntax-table))
514 (c-populate-syntax-table idl-mode-syntax-table))
515
516 ;;;###autoload
517 (defvar pike-mode-syntax-table nil
518 "Syntax table used in pike-mode buffers.")
519 (if pike-mode-syntax-table
520 ()
521 (setq pike-mode-syntax-table (make-syntax-table))
522 (c-populate-syntax-table pike-mode-syntax-table)
523 (modify-syntax-entry ?@ "." pike-mode-syntax-table))
524
525 \f
526 ;; internal state variables
527
528 ;; Internal state of hungry delete key feature
529 (defvar c-hungry-delete-key nil)
530 (make-variable-buffer-local 'c-hungry-delete-key)
531
532 ;; Internal state of auto newline feature.
533 (defvar c-auto-newline nil)
534 (make-variable-buffer-local 'c-auto-newline)
535
536 ;; Internal auto-newline/hungry-delete designation string for mode line.
537 (defvar c-auto-hungry-string nil)
538 (make-variable-buffer-local 'c-auto-hungry-string)
539
540 ;; Non-nil means K&R style argument declarations are valid.
541 (defvar c-recognize-knr-p t)
542 (make-variable-buffer-local 'c-recognize-knr-p)
543
544 \f
545 (cc-provide 'cc-langs)
546
547 ;;; cc-langs.el ends here