/** * Name: csharp * Description: C# programming language * Author: Adam Milazzo (http://www.adammil.net) */ cpp_type_re = /* Types. (build-re '(abstract bool byte char class const decimal delegate double enum event explicit extern float implicit int interface internal long object operator out override params private protected public readonly ref sbyte sealed short static string struct uint ulong ushort virtual void volatile)) */ /\b(abstract|b(ool|yte)|c(har|lass|onst)|d(e(cimal|legate)|ouble)|\ e(num|vent|x(plicit|tern))|\ float|i(mplicit|nt(|er(face|nal)))|long|o(bject|perator|ut|verride)|\ p(arams|r(ivate|otected)|ublic)|re(adonly|f)|\ s(byte|ealed|hort|t(atic|r(ing|uct)))|u(int|long|short)|v(irtual|o(id|latile)))\b/; /* * We inherit the C# state from the C state. This gives us all the * defaults, etc. All we have to do here is to overwrite things that * are not implemented, or are broken. */ state csharp extends c { BEGIN { /* See `c.st' for the comments on this one. */ type_re = cpp_type_re; } /* Doc comments */ /\/\/\// { comment_face(true); bold(true); language_print($0); call(eat_one_line); bold(false); comment_face(false); } /* One line comments. */ /\/\// { comment_face (true); language_print ($0); call (eat_one_line); comment_face (false); } /* Verbatim strings */ /\@\"[^"]+\"/ { string_face(true); language_print($0); string_face(false); } /* Keywords; those missing from C, but not types, goto, or case (build-re '(asm catch delete new operator overload this throw try)) */ /\b(as|base|c(atch|hecked)|f(alse|i(nally|xed)|oreach)|get|is|lock|\ n(amespace|ew|ull)|set|t(h(is|row)|r(ue|y)|ypeof)|u(n(checked|safe)|sing)|yield)\b/ { keyword_face (true); language_print ($0); keyword_face (false); } /* Types. */ cpp_type_re { type_face (true); language_print ($0); type_face (false); } /* Remove false labels. */ /[a-zA-Z0-9_]+::/ { language_print ($0); } /* Labels. Emacs accepts also bare numbers. */ /^([ \t]*)([a-zA-Z0-9_]+)(:)/ { language_print ($1); reference_face (true); language_print ($2); reference_face (false); language_print ($3); } /* * Function definitions, but only if you code with the one and only * usable indentation style (GNU). */ /^([a-zA-Z_][a-zA-Z_0-9:~]*)([ \t]*\()/ { function_name_face (true); language_print ($1); function_name_face (false); language_print ($2); } /* Function definitions and prototypes for other (loser) coding styles. */ /^([A-Za-z][a-zA-Z0-9_\&\* ]+)([ \*])([a-zA-Z_][a-zA-Z_0-9:~]*)([ \t]*\()/ { garbage = $1; middle_garbage = $2; function_name = $3; tail_garbage = $4; highlight_types (garbage, cpp_type_re); language_print (middle_garbage); function_name_face (true); language_print (function_name); function_name_face (false); language_print (tail_garbage); } } /* Local variables: mode: c End: */