c_type_re =
/\b(auto|c(har|onst)|double|e(num|xtern)|float|int|long|register\
|s(hort|igned|t(atic|ruct))|typedef|un(ion|signed)|vo(id|latile))\b/;
state CHighlight extends Highlight
{
BEGIN {
if (verbose_highlighting)
verbose_re = /(->|<=|>=|==|!=|\&\&|\|\||!)/;
else
verbose_re = 0;
}
verbose_re {
match = $0;
if (strcmp (match, "->") == 0)
str = "rightarrow";
else if (strcmp (match, "<=") == 0)
str = "le";
else if (strcmp (match, ">=") == 0)
str = "ge";
else if (strcmp (match, "==") == 0)
str = "equiv";
else if (strcmp (match, "&&") == 0)
str = "land";
else if (strcmp (match, "||") == 0)
str = "lor";
else if (strcmp (match, "!") == 0)
str = "lnot";
else if (strcmp (match, "!=") == 0)
str = "ne";
else
str = 0;
if (!str || !language_symbol (str))
language_print ($0);
}
}
state CHighlightEntry extends CHighlight
{
BEGIN {
if (highlight_entry_nesting++ == 0)
header ();
}
END {
if (--highlight_entry_nesting == 0)
trailer ();
}
}
state c extends CHighlightEntry
{
BEGIN {
type_re = c_type_re;
}
/\/\*/ {
comment_face (true);
language_print ($0);
call (c_comment);
comment_face (false);
}
/\/\// {
comment_face (true);
language_print ($0);
call (eat_one_line);
comment_face (false);
}
/\"/ {
string_face (true);
language_print ($0);
call (c_string);
string_face (false);
}
/^#/ {
language_print ($0);
call (c_ppline);
}
/'.'|'\\\\.'/ {
string_face (true);
language_print ($0);
string_face (false);
}
/\b(break|continue|d(efault|o)|else|for|if|return|s(izeof|witch)|while)\b/ {
keyword_face (true);
language_print ($0);
keyword_face (false);
}
c_type_re {
type_face (true);
language_print ($0);
type_face (false);
}
/^([ \t]*)([a-zA-Z0-9_]+)(:)/ {
language_print ($1);
reference_face (true);
language_print ($2);
reference_face (false);
language_print ($3);
}
/\<(goto|case)\>([ \t]+)(-?[A-Za-z_0-9]+)?/ {
keyword_face (true);
language_print ($1);
keyword_face (false);
language_print ($2);
if (length ($3) > 0)
{
reference_face (true);
language_print ($3);
reference_face (false);
}
}
/^([a-zA-Z_][a-zA-Z_0-9]*)([ \t]*\()/ {
function_name_face (true);
language_print ($1);
function_name_face (false);
language_print ($2);
}
/^([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, type_re);
language_print (middle_garbage);
function_name_face (true);
language_print (function_name);
function_name_face (false);
language_print (tail_garbage);
}
}