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