3 * Description: Objective-C programming language.
4 * Author: Markku Rossi <mtr@iki.fi> with help of Emacs' `font-lock.el'.
9 (build-re '(auto extern register static typedef struct union enum
10 signed unsigned short long int char float double void volatile
11 const id oneway in out inout bycopy byref))
13 /\b(auto|by(copy|ref)|c(har|onst)|double|e(num|xtern)|float\
14 |i(d|n(|out|t))|long|o(neway|ut)|register|s(hort|igned|t(atic|ruct))\
15 |typedef|un(ion|signed)|vo(id|latile))\b/;
18 state objc_method_line extends CHighlight
20 /* Argument declarations after the method.
21 $1 $2 $3 $4 $5 $6 $7 */
22 /([ \t]*)([A-Za-z_][A-Za-z_0-9]*)?(:[ \t]*)(\(([^)\n]+)\))?([ \t]*)([A-Za-z_][A-Za-z_0-9]*)/ {
27 function_name_face (true);
29 function_name_face (false);
45 variable_name_face (true);
47 variable_name_face (false);
56 /* This is *not* inherited from CHighlight. */
57 state objc_method_continuation_line
59 /* Method names and arguments on lines following the function declaration.
60 $1 $2 $3 $4 $5 $6 $7 */
61 /^([ \t]*)([A-Za-z_][A-Za-z_0-9]*)?(:[ \t]*)(\(([^)\n]+)\))?([ \t]*)\
62 ([A-Za-z_][A-Za-z_0-9]*)/ {
67 function_name_face (true);
69 function_name_face (false);
85 variable_name_face (true);
87 variable_name_face (false);
89 /* Highlight all remaining arguments on this line. */
90 call (objc_method_line);
94 * If the previous one didn't match, we'r done with this method
102 /* This is *not* inherited from CHighlight. */
103 state objc_compiler_directive_line
105 /([ \t:<(,]*)([A-Za-z_][A-Za-z_0-9]*)/ {
108 function_name_face (true);
110 function_name_face (false);
114 * If the previous one didn't match, we'r done with this directive.
115 * Yes, that should match an empty string.
123 * We inherit the Objective-C state from the C state. This gives us
124 * all the defaults, etc. All we have to do here is to overwrite
125 * things that are not implemented, or are broken.
130 /* See `c.st' for the comments on this one. */
131 type_re = objc_type_re;
134 /* One line comments. */
139 comment_face (false);
142 /* Compiler directives. */
143 /(@)([A-Za-z][A-Za-z0-9]*)\>/ {
144 /* Leading garbage. */
150 keyword_face (false);
152 /* And all the remaining stuff on this line. */
153 call (objc_compiler_directive_line);
156 /* Keywords. Basicly what's missing from C *but* not goto or case.
157 (build-re '(self super _cmd id Class SEL IMP BOOL YES NO nil Nil))
159 /\b(BOOL|Class|IMP|N(O|il)|SEL|YES|_cmd|id|nil|s(elf|uper))\b/ {
162 keyword_face (false);
172 /* Method names. First, on the same line as the function declaration.
173 $1 $2 $3 $4 $5 $6 $7 */
174 /(^[+-][ \t]*)(PRIVATE)?([ \t]*)(\(([^)\n]+)\))?([ \t]*)([A-Za-z_]\
189 language_print ("(");
193 language_print (")");
198 function_name_face (true);
200 function_name_face (false);
202 /* Highlight arguments from the same line. */
203 call (objc_method_line);
206 * Method names and arguments on lines following the function declaration.
208 call (objc_method_continuation_line);
212 * Labels and case tags. These must remain as a sole statement on a line,
213 * otherwise we detect selectors. Emacs accepts also bare numbers.
215 /^([ \t]*)([a-zA-Z0-9_]+)(:[ \t]*)$/ {
218 reference_face (true);
220 reference_face (false);