Updated highlighting...
This commit is contained in:
parent
fc7946133e
commit
5083f3f594
@ -4,6 +4,6 @@ set -xe
|
||||
|
||||
clang -g -ansi -Weverything -o xighlight xighlight.c
|
||||
gcc -g -ansi -Wall -Wextra -Wpedantic -o xighlight xighlight.c
|
||||
cat xighlight.c | valgrind --show-leak-kinds=all --leak-check=full ./xighlight
|
||||
cat xighlight.c | valgrind --show-leak-kinds=all --leak-check=full --track-origins=yes ./xighlight
|
||||
|
||||
exit
|
||||
|
22
xighlight.c
22
xighlight.c
@ -24,7 +24,6 @@ int main (void) {
|
||||
int multiline_comment = 0;
|
||||
int character = 0;
|
||||
int string = 0;
|
||||
int bracket = 0;
|
||||
int operator = 0;
|
||||
int keyword = 0;
|
||||
int digit = 0;
|
||||
@ -32,7 +31,7 @@ int main (void) {
|
||||
int lowercase = 0;
|
||||
int underscore = 0;
|
||||
|
||||
char separator [29] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n";
|
||||
char * separator = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
|
||||
|
||||
char * c_keywords [32] = {
|
||||
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
|
||||
@ -41,23 +40,22 @@ int main (void) {
|
||||
"char", "short", "int", "long", "signed", "unsigned", "float", "double"
|
||||
};
|
||||
|
||||
syntax_define (& whitespace, 1, 0, " \t\r\n", "", '\0', COLOUR_WHITE, EFFECT_NORMAL);
|
||||
syntax_define (& preprocessor, 0, 0, "#", "\n", '\\', COLOUR_RED, EFFECT_BOLD);
|
||||
syntax_define (& line_comment, 0, 0, "//", "\n", '\0', COLOUR_GREY, EFFECT_BOLD);
|
||||
syntax_define (& multiline_comment, 0, 0, "/*", "*/", '\0', COLOUR_GREY, EFFECT_BOLD);
|
||||
syntax_define (& character, 0, 0, "'", "'", '\\', COLOUR_PINK, EFFECT_BOLD);
|
||||
syntax_define (& string, 0, 0, "\"", "\"", '\\', COLOUR_RED, EFFECT_BOLD);
|
||||
syntax_define (& bracket, 1, 0, "()[]{}", "", '\0', COLOUR_GREEN, EFFECT_BOLD);
|
||||
syntax_define (& operator, 1, 0, ".,:;<=>+-*/%!&~^?|", "", '\0', COLOUR_BLUE, EFFECT_BOLD);
|
||||
syntax_define (& whitespace, 1, 0, " \t\r\n", "", '\0', COLOUR_WHITE, EFFECT_NORMAL);
|
||||
syntax_define (& preprocessor, 0, 0, "#", "\n", '\\', COLOUR_PINK, EFFECT_BOLD);
|
||||
syntax_define (& line_comment, 0, 0, "//", "\n", '\0', COLOUR_GREY, EFFECT_BOLD);
|
||||
syntax_define (& multiline_comment, 0, 0, "/*", "*/", '\0', COLOUR_GREY, EFFECT_BOLD);
|
||||
syntax_define (& character, 0, 0, "'", "'", '\\', COLOUR_RED, EFFECT_NORMAL);
|
||||
syntax_define (& string, 0, 0, "\"", "\"", '\\', COLOUR_RED, EFFECT_BOLD);
|
||||
syntax_define (& operator, 1, 0, ".,:;<=>+-*/%!&~^?|()[]{}", "", '\0', COLOUR_CYAN, EFFECT_NORMAL);
|
||||
|
||||
for (word = 0; word != 32; ++word) {
|
||||
syntax_define (& keyword, 0, 1, c_keywords [word], separator, '\0', COLOUR_YELLOW, EFFECT_BOLD);
|
||||
syntax_define (& keyword, 0, 1, c_keywords [word], separator, '\0', COLOUR_BLUE, EFFECT_BOLD);
|
||||
}
|
||||
|
||||
syntax_define (& digit, 1, 1, "0123456789", separator, '\0', COLOUR_CYAN, EFFECT_BOLD);
|
||||
syntax_define (& uppercase, 1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separator, '\0', COLOUR_PINK, EFFECT_ITALIC);
|
||||
syntax_define (& lowercase, 1, 1, "abcdefghijklmnopqrstuvwxyz", separator, '\0', COLOUR_WHITE, EFFECT_ITALIC);
|
||||
syntax_define (& underscore, 0, 1, "_", separator, '\0', COLOUR_YELLOW, EFFECT_ITALIC);
|
||||
syntax_define (& underscore, 0, 1, "_", separator, '\0', COLOUR_PINK, EFFECT_BOLD);
|
||||
|
||||
buffer = record ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user