This commit is contained in:
anon
2023-09-01 00:15:22 +02:00
parent ee1b599871
commit d743b4a4c8
5 changed files with 131 additions and 87 deletions

View File

@ -174,20 +174,18 @@ int new_char_tokens(const char * str,
token_t * new_keyword_token(const char * const word,
hl_group_t * const g) {
//char * new_word = strdup(word);
//size_t word_length = strlen(word);
//char * new_word = (char*)malloc(word_length + 4 + 1);
size_t word_length = strlen(word);
char * new_word = (char*)malloc(word_length + 4 + 1);
//memcpy(new_word, "\\<", 2);
//memcpy(new_word + 2, word, word_length);
//strcpy(new_word + 2 + word_length, "\\>");
memcpy(new_word, "\\<", 2);
memcpy(new_word + 2, word, word_length);
strcpy(new_word + 2 + word_length, "\\>");
token_t * mt = (token_t*)malloc(sizeof(token_t));
mt->hl = g;
mt->t = KEYWORD;
//mt->syntax = regex_compile(new_word);
mt->syntax = regex_compile(word);
mt->syntax = regex_compile(new_word);
append_token(mt);

View File

@ -12,10 +12,12 @@ const char * preprocessor_keywords[] = {
NULL
};
new_char_tokens("+-&|.()[]{}", operator_hl);
new_keyword_tokens(c_keywords, control_hl);
new_keyword_tokens(preprocessor_keywords, special_hl);
new_region_token("/\\*", "\\*/", comment_hl);
new_region_token("//", "\\n", comment_hl);
new_region_token("\"", "\"", string_literal_hl);
new_region_token("<", ">", string_literal_hl);
//new_char_tokens("+-&|.()[]{}", operator_hl);
//new_keyword_tokens(c_keywords, control_hl);
//new_keyword_tokens(preprocessor_keywords, special_hl);
//new_region_token("/\\*", "\\*/", comment_hl);
//new_region_token("//", "\\n", comment_hl);
//new_region_token("\"", "\"", string_literal_hl);
//new_region_token("<", ">", string_literal_hl);
//new_keyword_token("keyword", special_hl);
new_keyword_token("while", operator_hl);