Mercurial > emacs
annotate lisp/progmodes/cc-langs.el @ 41359:5042a5269efd
(calc-info): Don't perform voodoo, just (info "Calc").
author | Colin Walters <walters@gnu.org> |
---|---|
date | Thu, 22 Nov 2001 06:03:24 +0000 |
parents | 7a94f1c588c4 |
children | 7a3ac6c387fe |
rev | line source |
---|---|
36920 | 1 ;;; cc-langs.el --- language specific settings for CC Mode |
18720 | 2 |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 4 |
30402
cc4564c9cd55
(c-append-paragraph-start): New variable used by
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5 ;; Authors: 2000- Martin Stjernholm |
cc4564c9cd55
(c-append-paragraph-start): New variable used by
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
24282 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20141 | 12 ;; Version: See cc-mode.el |
18720 | 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 | |
36920 | 28 ;; along with this program; see the file COPYING. If not, write to |
29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18720 | 30 ;; Boston, MA 02111-1307, USA. |
31 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
34 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
35 |
26817 | 36 (eval-when-compile |
37 (let ((load-path | |
36920 | 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) | |
26817 | 41 load-path))) |
36920 | 42 (require 'cc-bytecomp))) |
26817 | 43 |
36920 | 44 (cc-require 'cc-defs) |
45 (cc-require 'cc-vars) | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
46 |
18720 | 47 |
26817 | 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) | |
18772 | 56 |
26817 | 57 |
18720 | 58 ;; Regular expressions and other values which must be parameterized on |
59 ;; a per-language basis. | |
60 | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
61 ;; Regex describing a `symbol' in all languages. We cannot use just |
18720 | 62 ;; `word' syntax class since `_' cannot be in word class. Putting |
63 ;; underscore in word class breaks forward word movement behavior that | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
64 ;; users are familiar with. Besides, this runs counter to Emacs |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
65 ;; convention. |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
66 ;; |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
67 ;; I suspect this definition isn't correct in light of Java's |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
68 ;; definition of a symbol as being Unicode. I know so little about |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
69 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
70 ;; punt on this for now. |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
71 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*") |
18720 | 72 |
36920 | 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) | |
18720 | 166 |
36920 | 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)) | |
18720 | 260 (defconst c-ObjC-class-key |
261 (concat | |
36920 | 262 "@\\(" c-ObjC-class-kwds "\\)\\s +" |
18720 | 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 +\\)?" | |
36920 | 270 "\\(" c-Java-class-kwds "\\)\\s +" |
18720 | 271 c-symbol-key ;name of the class |
24282 | 272 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass |
18720 | 273 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list |
274 )) | |
36920 | 275 (defconst c-Pike-class-key (c-paren-re c-Pike-class-kwds)) |
24282 | 276 |
18720 | 277 (defvar c-class-key c-C-class-key) |
278 (make-variable-buffer-local 'c-class-key) | |
279 | |
36920 | 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 | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
284 (defvar c-extra-toplevel-key c-C-extra-toplevel-key) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
285 (make-variable-buffer-local 'c-extra-toplevel-key) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
286 |
26817 | 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 | |
18720 | 293 ;; regexp describing access protection clauses. language specific |
294 (defvar c-access-key nil) | |
295 (make-variable-buffer-local 'c-access-key) | |
36920 | 296 (defconst c-C++-access-key |
297 (concat "\\<\\(" c-C++-protection-kwds "\\)\\>[ \t]*:")) | |
298 ;;(defconst c-IDL-access-key nil) | |
18720 | 299 (defconst c-ObjC-access-key (concat "@" c-protection-key)) |
36920 | 300 ;;(defconst c-Java-access-key nil) |
301 ;;(defconst c-Pike-access-key nil) | |
18720 | 302 |
303 ;; keywords introducing conditional blocks | |
304 (defconst c-C-conditional-key nil) | |
305 (defconst c-C++-conditional-key nil) | |
26817 | 306 (defconst c-IDL-conditional-key nil) |
307 (defconst c-ObjC-conditional-key nil) | |
18720 | 308 (defconst c-Java-conditional-key nil) |
24282 | 309 (defconst c-Pike-conditional-key nil) |
18720 | 310 |
311 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch") | |
312 (exc-kws "\\|try\\|catch") | |
313 (thr-kws "\\|finally\\|synchronized") | |
36920 | 314 (front "\\<\\(") |
315 (back "\\)\\>[^_]")) | |
18720 | 316 (setq c-C-conditional-key (concat front all-kws back) |
317 c-C++-conditional-key (concat front all-kws exc-kws back) | |
26817 | 318 ;; c-IDL-conditional-key is nil. |
319 c-ObjC-conditional-key c-C-conditional-key | |
24282 | 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))) | |
18720 | 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 "/[/*]") | |
26817 | 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) | |
18720 | 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 "/\\(/\\|[*][*]?\\)") | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
347 (defvar c-comment-start-regexp c-C++-comment-start-regexp) |
18720 | 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:;.,{}()=]*\\|\\([_$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 | |
36920 | 381 ;; Regexp to append to paragraph-start. |
30402
cc4564c9cd55
(c-append-paragraph-start): New variable used by
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
382 (defvar c-append-paragraph-start "$") |
cc4564c9cd55
(c-append-paragraph-start): New variable used by
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
383 (make-variable-buffer-local 'c-append-paragraph-start) |
21108
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
384 (defconst c-Java-javadoc-paragraph-start |
36920 | 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) | |
21108
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
393 |
24282 | 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\\>") | |
30402
cc4564c9cd55
(c-append-paragraph-start): New variable used by
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
408 (defconst c-Pike-inexpr-class-key "\\<class\\>") |
24282 | 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 | |
18720 | 419 |
36920 | 420 ;; Syntax tables. |
18720 | 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) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
435 (modify-syntax-entry ?\' "\"" table) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
436 ;; Set up block and line oriented comments. The new C standard |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
437 ;; mandates both comment styles even in C, so since all languages |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
438 ;; now require dual comments, we make this the default. |
18720 | 439 (cond |
440 ;; XEmacs 19 & 20 | |
441 ((memq '8-bit c-emacs-features) | |
442 (modify-syntax-entry ?/ ". 1456" table) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
443 (modify-syntax-entry ?* ". 23" table)) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
444 ;; Emacs 19 & 20 |
18720 | 445 ((memq '1-bit c-emacs-features) |
446 (modify-syntax-entry ?/ ". 124b" table) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
447 (modify-syntax-entry ?* ". 23" table)) |
18720 | 448 ;; incompatible |
449 (t (error "CC Mode is incompatible with this version of Emacs")) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
450 ) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
451 (modify-syntax-entry ?\n "> b" table) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
452 ;; Give CR the same syntax as newline, for selective-display |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
453 (modify-syntax-entry ?\^m "> b" table)) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
454 |
18720 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
461 (c-populate-syntax-table c-mode-syntax-table)) |
18720 | 462 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
463 ;;;###autoload |
18720 | 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 | |
26817 | 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 | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
490 ;;;###autoload |
18720 | 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) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
497 ;; add extra Objective-C only syntax |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
498 (modify-syntax-entry ?@ "_" objc-mode-syntax-table)) |
18720 | 499 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
500 ;;;###autoload |
18720 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
506 (c-populate-syntax-table java-mode-syntax-table)) |
18720 | 507 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
508 ;;;###autoload |
19250 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
514 (c-populate-syntax-table idl-mode-syntax-table)) |
19250 | 515 |
24282 | 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 | |
36920 | 525 |
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) | |
24282 | 531 |
36920 | 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) | |
19250 | 543 |
544 | |
36920 | 545 (cc-provide 'cc-langs) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
546 |
18720 | 547 ;;; cc-langs.el ends here |