From: Emil Date: Mon, 28 Aug 2023 19:03:03 +0000 (-0600) Subject: Relocate syntax/ X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=18b6128e606a53043d1cecf680a54386d7b7da5c;p=public-libhl.git Relocate syntax/ --- diff --git a/Makefile b/Makefile index 544c1af..816bb8c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ TARGET:=hl CFLAGS:=-std=c99 -CPPFLAGS:=-Isyntax -Iinclude -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 +CPPFLAGS:=-Iinclude -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 DEBUG=1 diff --git a/include/syntax/c.h b/include/syntax/c.h new file mode 100644 index 0000000..271ee5c --- /dev/null +++ b/include/syntax/c.h @@ -0,0 +1,21 @@ +const char * c_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", + NULL +}; + +const char * preprocessor_keywords[] = { + "#include", "#pragma", "#define", "#undef", "#ifdef", "#ifndef", "#elifdef", "#elifndef", + "#if", "#elif", "#else", "#endif", "#embed", "#line", "#error", "#warning", + 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); diff --git a/source/main.c b/source/main.c index 2b6ad6a..7ba4529 100644 --- a/source/main.c +++ b/source/main.c @@ -40,7 +40,7 @@ int main(int argc, // Highlight init terminal_hl_init(); // - #include "c.h" + #include "syntax/c.h" // render_string(buffer, "cterm"); diff --git a/syntax/c.h b/syntax/c.h deleted file mode 100644 index 271ee5c..0000000 --- a/syntax/c.h +++ /dev/null @@ -1,21 +0,0 @@ -const char * c_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", - NULL -}; - -const char * preprocessor_keywords[] = { - "#include", "#pragma", "#define", "#undef", "#ifdef", "#ifndef", "#elifdef", "#elifndef", - "#if", "#elif", "#else", "#endif", "#embed", "#line", "#error", "#warning", - 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);