xarbon/language/c.h

32 lines
1.7 KiB
C
Raw Normal View History

2024-09-28 13:33:22 -04:00
static void highlight_c (void) {
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
char * keywords [] = {
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
"do", "while", "for", "continue", "switch", "case", "default", "break",
"enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof",
"char", "short", "int", "long", "signed", "unsigned", "float", "double"
};
int word;
syntax_define (false, false, "/*", "*/", '\0', (int) 0xff777777, 0);
syntax_define (false, false, "/**", "*/", '\0', (int) 0xff775555, 0);
syntax_define (false, false, "//", "\n", '\0', (int) 0xff777777, 0);
syntax_define (false, false, "#", "\n", '\\', (int) 0xff3377aa, 0);
syntax_define (false, false, "'", "'", '\\', (int) 0xff7733cc, 0);
syntax_define (false, false, "\"", "\"", '\\', (int) 0xffcc3377, 0);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
syntax_define (false, true, keywords [word], separators, '\0', (int) 0xff33ccee, 0);
}
syntax_define (true, false, "()[]{}", "", '\0', (int) 0xffee5533, 0);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', (int) 0xffeeaa33, 0);
syntax_define (true, true, "0123456789", separators, '\0', (int) 0xffee33aa, 0);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', (int) 0xffcccccc, 0);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', (int) 0xffeeeeee, 0);
syntax_define (true, true, "_", separators, '\0', (int) 0xffaaaaaa, 0);
}