Compare commits
7 Commits
324a78ae1e
...
5ccd6dd2ab
Author | SHA1 | Date |
---|---|---|
|
5ccd6dd2ab | |
|
58374ba625 | |
|
67e0420eb1 | |
|
336a98f701 | |
|
c5a462993d | |
|
60e850b2ff | |
|
877527e918 |
|
@ -15,6 +15,42 @@ source "$HELPERS_DIR/print-routines.sh"
|
|||
# Build Tree Sitter
|
||||
# =============================================================================
|
||||
|
||||
build_tree_sitter_language() {
|
||||
LANG_DIR=$1
|
||||
LANG_NAME=$2
|
||||
|
||||
PARSER_SRC="${CUSTOM_ROOT}/lang/$LANG_DIR/parser.c"
|
||||
PARSER_OUT="$TEMP_OUT_DIR/${LANG_DIR}_parser.o"
|
||||
|
||||
SCANNER_SRC="${CUSTOM_ROOT}/lang/$LANG_DIR/scanner.cc"
|
||||
SCANNER_OUT="$TEMP_OUT_DIR/${LANG_DIR}_scanner.o"
|
||||
|
||||
print_step "Building tree-sitter $LANG_NAME Language Lib ($LANG_DIR)"
|
||||
BUILT_ANYTHING=0
|
||||
|
||||
if [ -f $PARSER_SRC ]; then
|
||||
echo " Building Parser..."
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "$PARSER_SRC" -o "$PARSER_OUT"
|
||||
if [ $? == 0 ]; then
|
||||
BUILT_ANYTHING=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f $SCANNER_SRC ]; then
|
||||
echo " Building Scanner..."
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "$SCANNER_SRC" -o "$SCANNER_OUT"
|
||||
if [ $? == 0 ]; then
|
||||
BUILT_ANYTHING=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $BUILT_ANYTHING == 1 ]; then
|
||||
print_success "Complete"
|
||||
else
|
||||
print_warning "Failed to build anything."
|
||||
fi
|
||||
}
|
||||
|
||||
build_tree_sitter() {
|
||||
BIN_NAME="custom_4coder"
|
||||
|
||||
|
@ -32,23 +68,17 @@ build_tree_sitter() {
|
|||
|
||||
TEMP_OUT_DIR=$BUILD_TEMP_DIR/tree-sitter
|
||||
mkdir -p $TEMP_OUT_DIR
|
||||
rm $TEMP_OUT_DIR/*.o
|
||||
rm "$BUILD_TEMP_DIR/tree-sitter.a"
|
||||
|
||||
# Build tree-sitter.lib/.a
|
||||
print_step "Building tree-sitter lib"
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "$CUSTOM_ROOT/lib/src/lib.c" -o $TEMP_OUT_DIR/tree-sitter.o
|
||||
print_success "Complete"
|
||||
|
||||
# Lang: C++ (This needs to be two calls to clang so that you can specify the obj file names)
|
||||
print_step "Building tree-sitter C++ Language Lib"
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "${CUSTOM_ROOT}/lang/cpp/parser.c" -o $TEMP_OUT_DIR/cpp_parser.o
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "${CUSTOM_ROOT}/lang/cpp/scanner.cc" -o $TEMP_OUT_DIR/cpp_scanner.o
|
||||
print_success "Complete"
|
||||
|
||||
# Lang: Jai
|
||||
print_step "Building tree-sitter Jai Language Lib"
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "${CUSTOM_ROOT}/lang/jai/parser.c" -o $TEMP_OUT_DIR/jai_parser.o
|
||||
clang $CLANG_OPTS "${INCLUDES[@]}" "${CUSTOM_ROOT}/lang/jai/scanner.cc" -o $TEMP_OUT_DIR/jai_scanner.o
|
||||
print_success "Complete"
|
||||
build_tree_sitter_language "cpp" "C++"
|
||||
build_tree_sitter_language "jai" "Jai"
|
||||
build_tree_sitter_language "bash" "Bash"
|
||||
|
||||
# Link tree-sitter lib and parser obj files into a static library to link into main custom dll
|
||||
print_step "Linking tree-sitter static library"
|
||||
|
|
|
@ -155,7 +155,7 @@ api_type_match(API_Type *a, API_Type *b){
|
|||
result = true;
|
||||
}
|
||||
}break;
|
||||
|
||||
|
||||
case APITypeKind_Enum:
|
||||
{
|
||||
if (a->enum_type.val_count == b->enum_type.val_count &&
|
||||
|
@ -172,7 +172,7 @@ api_type_match(API_Type *a, API_Type *b){
|
|||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
|
||||
case APITypeKind_Typedef:
|
||||
{
|
||||
if (string_match(a->typedef_type.name, b->typedef_type.name) &&
|
||||
|
@ -209,9 +209,9 @@ api_get_callable_name(Arena *arena, String_Const_u8 api_name, String_Const_u8 na
|
|||
|
||||
function void
|
||||
generate_api_master_list(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
||||
|
||||
|
||||
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||
|
||||
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
call = call->next){
|
||||
|
@ -240,9 +240,9 @@ generate_api_master_list(Arena *scratch, API_Definition *api, API_Generation_Fla
|
|||
|
||||
function void
|
||||
generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
||||
|
||||
|
||||
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||
|
||||
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
call = call->next){
|
||||
|
@ -269,9 +269,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
|||
}
|
||||
fprintf(out, ")\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(out, "\n");
|
||||
|
||||
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
call = call->next){
|
||||
|
@ -296,9 +296,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
|||
}
|
||||
fprintf(out, ");\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(out, "\n");
|
||||
|
||||
|
||||
fprintf(out, "struct API_VTable_%.*s{\n", string_expand(api->name));
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
|
@ -311,9 +311,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
|||
fprintf(out, ";\n");
|
||||
}
|
||||
fprintf(out, "};\n");
|
||||
|
||||
|
||||
fprintf(out, "\n");
|
||||
|
||||
|
||||
fprintf(out, "#if defined(STATIC_LINK_API)\n");
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
|
@ -357,9 +357,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
|||
|
||||
function void
|
||||
generate_cpp(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
||||
|
||||
|
||||
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||
|
||||
|
||||
fprintf(out, "function void\n");
|
||||
fprintf(out, "%.*s_api_fill_vtable(API_VTable_%.*s *vtable){\n",
|
||||
string_expand(api->name),
|
||||
|
@ -374,7 +374,7 @@ generate_cpp(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FIL
|
|||
}
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
|
||||
|
||||
fprintf(out, "#if defined(DYNAMIC_LINK_API)\n");
|
||||
fprintf(out, "function void\n");
|
||||
fprintf(out, "%.*s_api_read_vtable(API_VTable_%.*s *vtable){\n",
|
||||
|
@ -395,15 +395,15 @@ generate_cpp(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FIL
|
|||
|
||||
function void
|
||||
generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
||||
|
||||
|
||||
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||
|
||||
|
||||
fprintf(out, "function API_Definition*\n");
|
||||
fprintf(out, "%.*s_api_construct(Arena *arena){\n",
|
||||
string_expand(api->name));
|
||||
fprintf(out, " API_Definition *result = begin_api(arena, \"%.*s\");\n",
|
||||
string_expand(api->name));
|
||||
|
||||
|
||||
for (API_Call *call = api->first_call;
|
||||
call != 0;
|
||||
call = call->next){
|
||||
|
@ -414,7 +414,7 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
|||
"string_u8_litexpr(\"\"));\n",
|
||||
string_expand(call->name),
|
||||
string_expand(call->return_type));
|
||||
|
||||
|
||||
if (call->params.count == 0){
|
||||
fprintf(out, " (void)call;\n");
|
||||
}
|
||||
|
@ -427,10 +427,10 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
|||
string_expand(param->name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fprintf(out, " }\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(out, " return(result);\n");
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
@ -440,15 +440,15 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
|||
function b32
|
||||
api_definition_generate_api_includes(Arena *arena, API_Definition *api, Generated_Group group, API_Generation_Flag flags, String_Const_u8 generated_by){
|
||||
// NOTE(allen): Arrange output files
|
||||
|
||||
|
||||
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
||||
path_to_self = string_remove_last_folder(path_to_self);
|
||||
|
||||
|
||||
String_Const_u8 fname_ml = {};
|
||||
String_Const_u8 fname_h = {};
|
||||
String_Const_u8 fname_cpp = {};
|
||||
String_Const_u8 fname_con = {};
|
||||
|
||||
|
||||
String_Const_u8 root = {};
|
||||
switch (group){
|
||||
case GeneratedGroup_Core:
|
||||
|
@ -460,67 +460,69 @@ api_definition_generate_api_includes(Arena *arena, API_Definition *api, Generate
|
|||
root = string_u8_litexpr("custom/generated/");
|
||||
}break;
|
||||
}
|
||||
|
||||
|
||||
fname_ml = push_u8_stringf(arena, "%.*s%.*s%.*s_api_master_list.h",
|
||||
string_expand(path_to_self),
|
||||
string_expand(root),
|
||||
string_expand(api->name));
|
||||
|
||||
|
||||
fname_h = push_u8_stringf(arena, "%.*s%.*s%.*s_api.h",
|
||||
string_expand(path_to_self),
|
||||
string_expand(root),
|
||||
string_expand(api->name));
|
||||
|
||||
|
||||
fname_cpp = push_u8_stringf(arena, "%.*s%.*s%.*s_api.cpp",
|
||||
string_expand(path_to_self),
|
||||
string_expand(root),
|
||||
string_expand(api->name));
|
||||
|
||||
|
||||
fname_con = push_u8_stringf(arena, "%.*s%.*s%.*s_api_constructor.cpp",
|
||||
string_expand(path_to_self),
|
||||
string_expand(root),
|
||||
string_expand(api->name));
|
||||
|
||||
|
||||
FILE *out_file_ml = fopen((char*)fname_ml.str, "wb");
|
||||
if (out_file_ml == 0){
|
||||
printf("could not open output file: '%s'\n", fname_ml.str);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
FILE *out_file_h = fopen((char*)fname_h.str, "wb");
|
||||
if (out_file_h == 0){
|
||||
printf("could not open output file: '%s'\n", fname_h.str);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
FILE *out_file_cpp = fopen((char*)fname_cpp.str, "wb");
|
||||
if (out_file_cpp == 0){
|
||||
printf("could not open output file: '%s'\n", fname_cpp.str);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
FILE *out_file_con = fopen((char*)fname_con.str, "wb");
|
||||
if (out_file_cpp == 0){
|
||||
printf("could not open output file: '%s'\n", fname_con.str);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
printf("%s:1:\n", fname_ml.str);
|
||||
printf("%s:1:\n", fname_h.str);
|
||||
printf("%s:1:\n", fname_cpp.str);
|
||||
printf("%s:1:\n", fname_con.str);
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
// NOTE(allen): Generate output
|
||||
|
||||
|
||||
generate_api_master_list(arena, api, flags, out_file_ml, generated_by);
|
||||
generate_header(arena, api, flags, out_file_h, generated_by);
|
||||
generate_cpp(arena, api, flags, out_file_cpp, generated_by);
|
||||
generate_constructor(arena, api, flags, out_file_con, generated_by);
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
fclose(out_file_ml);
|
||||
fclose(out_file_h);
|
||||
fclose(out_file_cpp);
|
||||
|
@ -587,7 +589,7 @@ api_definition_check(Arena *arena, API_Definition *correct, API_Definition *remo
|
|||
b32 report_missing = HasFlag(flags, APICheck_ReportMissingAPI);
|
||||
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
||||
b32 report_mismatch = HasFlag(flags, APICheck_ReportMismatchAPI);
|
||||
|
||||
|
||||
b32 iterate_correct = (report_missing || report_mismatch);
|
||||
if (iterate_correct){
|
||||
for (API_Call *call = correct->first_call;
|
||||
|
@ -605,7 +607,7 @@ api_definition_check(Arena *arena, API_Definition *correct, API_Definition *remo
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
b32 iterate_remote = (report_extra);
|
||||
if (iterate_remote){
|
||||
for (API_Call *call = remote->first_call;
|
||||
|
@ -625,7 +627,7 @@ function void
|
|||
api_list_check(Arena *arena, API_Definition_List *correct, API_Definition_List *remote, API_Check_Flag flags, List_String_Const_u8 *error_list){
|
||||
b32 report_missing = HasFlag(flags, APICheck_ReportMissingAPI);
|
||||
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
||||
|
||||
|
||||
b32 iterate_correct = (report_missing);
|
||||
if (iterate_correct){
|
||||
for (API_Definition *api = correct->first;
|
||||
|
@ -638,7 +640,7 @@ api_list_check(Arena *arena, API_Definition_List *correct, API_Definition_List *
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
b32 iterate_remote = (report_extra);
|
||||
if (iterate_remote){
|
||||
for (API_Definition *api = remote->first;
|
||||
|
@ -652,7 +654,7 @@ api_list_check(Arena *arena, API_Definition_List *correct, API_Definition_List *
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (API_Definition *api = correct->first;
|
||||
api != 0;
|
||||
api = api->next){
|
||||
|
|
|
@ -28,7 +28,7 @@ struct Event_Code_List{
|
|||
Event_Code *first;
|
||||
Event_Code *last;
|
||||
i32 count;
|
||||
|
||||
|
||||
String_Const_u8 code_prefix;
|
||||
String_Const_u8 name_table;
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ function void
|
|||
generate_codes(Arena *scratch, Event_Code_List *list, FILE *out){
|
||||
String_Const_u8 code_prefix = list->code_prefix;
|
||||
String_Const_u8 name_table = list->name_table;
|
||||
|
||||
|
||||
fprintf(out, "enum{\n");
|
||||
i32 counter = 1;
|
||||
for (Event_Code *code = list->first;
|
||||
|
@ -51,7 +51,7 @@ generate_codes(Arena *scratch, Event_Code_List *list, FILE *out){
|
|||
}
|
||||
fprintf(out, " %.*s_COUNT = %d,\n", string_expand(code_prefix), counter);
|
||||
fprintf(out, "};\n");
|
||||
|
||||
|
||||
fprintf(out, "global char* %.*s[%.*s_COUNT] = {\n",
|
||||
string_expand(name_table), string_expand(code_prefix));
|
||||
fprintf(out, " \"None\",\n");
|
||||
|
@ -70,7 +70,7 @@ function Event_Code*
|
|||
add_code(Arena *arena, Event_Code_List *list, String_Const_u8 name){
|
||||
Event_Code *code = push_array(arena, Event_Code, 1);
|
||||
sll_queue_push(list->first, list->last, code);
|
||||
list->count;
|
||||
list->count += 1;
|
||||
code->name = push_string_copy(arena, name);
|
||||
return(code);
|
||||
}
|
||||
|
@ -171,30 +171,30 @@ make_core_list(Arena *arena){
|
|||
int
|
||||
main(void){
|
||||
Arena arena = make_arena_malloc();
|
||||
|
||||
|
||||
Event_Code_List key_list = make_key_list(&arena);
|
||||
Event_Code_List mouse_list = make_mouse_list(&arena);
|
||||
Event_Code_List core_list = make_core_list(&arena);
|
||||
|
||||
|
||||
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
||||
path_to_self = string_remove_last_folder(path_to_self);
|
||||
String_Const_u8 file_name =
|
||||
push_u8_stringf(&arena, "%.*scustom/generated/4coder_event_codes.h",
|
||||
string_expand(path_to_self));
|
||||
|
||||
|
||||
FILE *out = fopen((char*)file_name.str, "wb");
|
||||
if (out == 0){
|
||||
printf("could not open output file '%s'\n", file_name.str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
fprintf(out, "/* Generated by: " __FILE__ );
|
||||
fprintf(out, " */\n" );
|
||||
|
||||
|
||||
generate_codes(&arena, &key_list, out);
|
||||
generate_codes(&arena, &mouse_list, out);
|
||||
generate_codes(&arena, &core_list, out);
|
||||
|
||||
|
||||
fclose(out);
|
||||
return(0);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -8,9 +8,7 @@
|
|||
enum Tree_Sitter_Language_Query_Kind
|
||||
{
|
||||
Tree_Sitter_Language_Query_Highlights,
|
||||
Tree_Sitter_Language_Query_Functions,
|
||||
Tree_Sitter_Language_Query_Types,
|
||||
|
||||
Tree_Sitter_Language_Query_Tags,
|
||||
Tree_Sitter_Language_Query_Count,
|
||||
};
|
||||
|
||||
|
@ -38,10 +36,6 @@ struct Tree_Sitter_Languages
|
|||
|
||||
global Tree_Sitter_Languages tree_sitter_languages;
|
||||
|
||||
extern "C" {
|
||||
TSLanguage *tree_sitter_cpp();
|
||||
TSLanguage *tree_sitter_jai();
|
||||
}
|
||||
|
||||
CUSTOM_ID(attachment, buffer_tree_sitter_data_id);
|
||||
CUSTOM_ID(attachment, buffer_tree_sitter_parse_task_id);
|
||||
|
@ -69,6 +63,9 @@ struct Tree_Sitter_Code_Index_Nest_List
|
|||
Tree_Sitter_Code_Index_Nest_Node* last;
|
||||
};
|
||||
|
||||
function TSQuery* tree_sitter_query_new(Application_Links* app, TSLanguage* language, String_Const_u8 query_string);
|
||||
function void tree_sitter_register_language(String_Const_u8 ext, TSLanguage* language, Tree_Sitter_Language_Queries queries);
|
||||
|
||||
b8 use_tree_sitter_code_indexing = true;
|
||||
b8 use_tree_sitter_token_coloring = true;
|
||||
function void tree_sitter_code_index_update_tick(Application_Links *app);
|
||||
|
|
|
@ -35,8 +35,8 @@ debug=-g
|
|||
|
||||
opts="-Wno-macro-redefined -Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-missing-declarations -Wno-logical-op-parentheses -g -DOS_LINUX=1 -DOS_WINDOWS=0 -DOS_MAC=0"
|
||||
|
||||
pushd $dst
|
||||
pushd $dst > /dev/null
|
||||
g++ -I"$CUSTOM_ROOT" $opts $full_target -o one_time
|
||||
popd
|
||||
popd > /dev/null
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/* date = July 11th 2025 6:02 pm */
|
||||
|
||||
#ifndef TREE_SITTER_BASH_H
|
||||
#define TREE_SITTER_BASH_H
|
||||
|
||||
// Source: https://github.com/tree-sitter/tree-sitter-bash/blob/master/queries/highlights.scm
|
||||
String_Const_u8 TS_BASH_HIGHLIGHT_QUERY = string_u8_litexpr(R"DONE(
|
||||
[
|
||||
(string)
|
||||
(raw_string)
|
||||
(heredoc_body)
|
||||
(heredoc_start)
|
||||
] @string
|
||||
|
||||
(command_name) @function.call
|
||||
|
||||
(variable_name) @property
|
||||
|
||||
[
|
||||
"case"
|
||||
"do"
|
||||
"done"
|
||||
"elif"
|
||||
"else"
|
||||
"esac"
|
||||
"export"
|
||||
"fi"
|
||||
"for"
|
||||
"function"
|
||||
"if"
|
||||
"in"
|
||||
"select"
|
||||
"then"
|
||||
"unset"
|
||||
"until"
|
||||
"while"
|
||||
] @keyword
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(function_definition name: (word) @function)
|
||||
|
||||
(file_descriptor) @number
|
||||
|
||||
[
|
||||
(command_substitution)
|
||||
(process_substitution)
|
||||
(expansion)
|
||||
] @embedded
|
||||
|
||||
[
|
||||
"$"
|
||||
"&&"
|
||||
">"
|
||||
">>"
|
||||
"<"
|
||||
"|"
|
||||
] @operator
|
||||
|
||||
(
|
||||
(command (_) @constant)
|
||||
(#match? @constant "^-")
|
||||
)
|
||||
|
||||
)DONE");
|
||||
|
||||
extern "C" {
|
||||
TSLanguage* tree_sitter_bash();
|
||||
}
|
||||
|
||||
void
|
||||
tree_sitter_register_bash(Application_Links* app)
|
||||
{
|
||||
TSLanguage* language = tree_sitter_bash();
|
||||
Tree_Sitter_Language_Queries queries = {};
|
||||
queries.ptr[Tree_Sitter_Language_Query_Highlights] = tree_sitter_query_new(app, language, TS_BASH_HIGHLIGHT_QUERY);
|
||||
tree_sitter_register_language(SCu8("sh"), language, queries);
|
||||
}
|
||||
|
||||
#endif //TREE_SITTER_BASH_H
|
|
@ -0,0 +1,211 @@
|
|||
/* date = July 11th 2025 6:04 pm */
|
||||
|
||||
#ifndef TREE_SITTER_CPP_H
|
||||
#define TREE_SITTER_CPP_H
|
||||
|
||||
// Source: https://github.com/tree-sitter/tree-sitter-cpp/blob/master/queries/tags.scm
|
||||
String_Const_u8 TS_CPP_TAGS_QUERY_SCM = string_u8_litexpr(R"DONE(
|
||||
(struct_specifier name: (type_identifier) @name body:(_)) @definition.class
|
||||
|
||||
(declaration type: (union_specifier name: (type_identifier) @name)) @definition.class
|
||||
|
||||
(function_declarator declarator: (identifier) @name) @definition.function
|
||||
|
||||
(function_declarator declarator: (field_identifier) @name) @definition.function
|
||||
|
||||
(function_declarator declarator: (qualified_identifier scope: (namespace_identifier) @local.scope name: (identifier) @name)) @definition.method
|
||||
|
||||
(type_definition declarator: (type_identifier) @name) @definition.type
|
||||
|
||||
(enum_specifier name: (type_identifier) @name) @definition.type
|
||||
|
||||
(class_specifier name: (type_identifier) @name) @definition.class
|
||||
|
||||
(_ "{" @scope_begin "}" @scope_end )
|
||||
(_ "(" @scope_begin ")" @scope_end )
|
||||
(_ "[" @scope_begin "]" @scope_end )
|
||||
|
||||
)DONE");
|
||||
|
||||
// Source: https://github.com/tree-sitter/tree-sitter-cpp/blob/master/queries/highlights.scm
|
||||
String_Const_u8 TS_CPP_HIGHLIGHT_QUERY_SCM = string_u8_litexpr(R"DONE(
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
|
||||
|
||||
"break" @keyword
|
||||
"case" @keyword
|
||||
"const" @keyword
|
||||
"continue" @keyword
|
||||
"default" @keyword
|
||||
"do" @keyword
|
||||
"else" @keyword
|
||||
"enum" @keyword
|
||||
"extern" @keyword
|
||||
"for" @keyword
|
||||
"if" @keyword
|
||||
"inline" @keyword
|
||||
"return" @keyword
|
||||
"sizeof" @keyword
|
||||
"static" @keyword
|
||||
"struct" @keyword
|
||||
"switch" @keyword
|
||||
"typedef" @keyword
|
||||
"union" @keyword
|
||||
"volatile" @keyword
|
||||
"while" @keyword
|
||||
|
||||
"#define" @keyword
|
||||
"#elif" @keyword
|
||||
"#else" @keyword
|
||||
"#endif" @keyword
|
||||
"#if" @keyword
|
||||
"#ifdef" @keyword
|
||||
"#ifndef" @keyword
|
||||
"#include" @keyword
|
||||
(preproc_directive) @keyword
|
||||
|
||||
"--" @operator
|
||||
"-" @operator
|
||||
"-=" @operator
|
||||
"->" @operator
|
||||
"=" @operator
|
||||
"!=" @operator
|
||||
"*" @operator
|
||||
"&" @operator
|
||||
"&&" @operator
|
||||
"+" @operator
|
||||
"++" @operator
|
||||
"+=" @operator
|
||||
"<" @operator
|
||||
"==" @operator
|
||||
">" @operator
|
||||
"||" @operator
|
||||
|
||||
"." @delimiter
|
||||
";" @delimiter
|
||||
|
||||
(string_literal) @string
|
||||
(system_lib_string) @string
|
||||
|
||||
(null) @constant
|
||||
(number_literal) @number
|
||||
(char_literal) @number
|
||||
|
||||
(field_identifier) @property
|
||||
(statement_identifier) @label
|
||||
(type_identifier) @type
|
||||
(primitive_type) @type
|
||||
(sized_type_specifier) @type
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function))
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
(preproc_function_def
|
||||
name: (identifier) @function.special)
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Functions
|
||||
|
||||
(call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(template_function
|
||||
name: (identifier) @function)
|
||||
|
||||
(template_method
|
||||
name: (field_identifier) @function)
|
||||
|
||||
(template_function
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_declarator
|
||||
declarator: (qualified_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(function_declarator
|
||||
declarator: (field_identifier) @function)
|
||||
|
||||
; Types
|
||||
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(auto) @type
|
||||
|
||||
; Constants
|
||||
|
||||
(this) @variable.builtin
|
||||
(null "nullptr" @constant)
|
||||
|
||||
; Modules
|
||||
(module_name
|
||||
(identifier) @module)
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"catch"
|
||||
"class"
|
||||
"co_await"
|
||||
"co_return"
|
||||
"co_yield"
|
||||
"constexpr"
|
||||
"constinit"
|
||||
"consteval"
|
||||
"delete"
|
||||
"explicit"
|
||||
"final"
|
||||
"friend"
|
||||
"mutable"
|
||||
"namespace"
|
||||
"noexcept"
|
||||
"new"
|
||||
"override"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"template"
|
||||
"throw"
|
||||
"try"
|
||||
"typename"
|
||||
"using"
|
||||
"concept"
|
||||
"requires"
|
||||
"virtual"
|
||||
"import"
|
||||
"export"
|
||||
"module"
|
||||
] @keyword
|
||||
|
||||
; Strings
|
||||
|
||||
(raw_string_literal) @string
|
||||
)DONE");
|
||||
|
||||
extern "C" {
|
||||
TSLanguage *tree_sitter_cpp();
|
||||
}
|
||||
|
||||
void
|
||||
tree_sitter_register_cpp(Application_Links* app)
|
||||
{
|
||||
TSLanguage* language = tree_sitter_cpp();
|
||||
Tree_Sitter_Language_Queries queries = {};
|
||||
queries.ptr[Tree_Sitter_Language_Query_Highlights] = tree_sitter_query_new(app, language, TS_CPP_HIGHLIGHT_QUERY_SCM);
|
||||
queries.ptr[Tree_Sitter_Language_Query_Tags] = tree_sitter_query_new(app, language, TS_CPP_TAGS_QUERY_SCM);
|
||||
tree_sitter_register_language(SCu8("c"), language, queries);
|
||||
tree_sitter_register_language(SCu8("cpp"), language, queries);
|
||||
tree_sitter_register_language(SCu8("h"), language, queries);
|
||||
tree_sitter_register_language(SCu8("hpp"), language, queries);
|
||||
tree_sitter_register_language(SCu8("cc"), language, queries);
|
||||
}
|
||||
|
||||
#endif //TREE_SITTER_CPP_H
|
|
@ -0,0 +1,298 @@
|
|||
/* date = July 11th 2025 6:03 pm */
|
||||
|
||||
#ifndef TREE_SITTER_JAI_H
|
||||
#define TREE_SITTER_JAI_H
|
||||
|
||||
String_Const_u8 TS_JAI_TAGS_QUERY = string_u8_litexpr(R"DONE(
|
||||
|
||||
(procedure_declaration
|
||||
name: (identifier) @definition.function
|
||||
)
|
||||
|
||||
(struct_declaration
|
||||
name: (identifier) @definition.type
|
||||
)
|
||||
|
||||
(enum_declaration
|
||||
name: (identifier) @definition.type
|
||||
)
|
||||
|
||||
)DONE");
|
||||
|
||||
// NOTE(PS): source: https://github.com/St0wy/tree-sitter-jai/blob/main/queries/highlights.scm
|
||||
String_Const_u8 TS_JAI_HIGHLIGHT_QUERY = string_u8_litexpr(R"DONE(
|
||||
; Includes
|
||||
|
||||
[
|
||||
(import)
|
||||
(load)
|
||||
] @include
|
||||
|
||||
; Keywords
|
||||
[
|
||||
; from modules/Jai_Lexer
|
||||
"if"
|
||||
"xx"
|
||||
|
||||
"ifx"
|
||||
"for"
|
||||
|
||||
"then"
|
||||
"else"
|
||||
"null"
|
||||
"case"
|
||||
"enum"
|
||||
"true"
|
||||
"cast"
|
||||
|
||||
"while"
|
||||
"break"
|
||||
"using"
|
||||
"defer"
|
||||
"false"
|
||||
"union"
|
||||
|
||||
"return"
|
||||
"struct"
|
||||
"inline"
|
||||
"remove"
|
||||
|
||||
; "size_of"
|
||||
"type_of"
|
||||
; "code_of"
|
||||
; "context"
|
||||
|
||||
"continue"
|
||||
"operator"
|
||||
|
||||
; "type_info"
|
||||
"no_inline"
|
||||
"interface"
|
||||
|
||||
"enum_flags"
|
||||
|
||||
; "is_constant"
|
||||
|
||||
"push_context"
|
||||
|
||||
; "initializer_of"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"return"
|
||||
] @keyword.return
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"case"
|
||||
"break"
|
||||
] @keyword.conditional
|
||||
|
||||
((if_expression
|
||||
[
|
||||
"then"
|
||||
"ifx"
|
||||
"else"
|
||||
] @keyword.conditional.ternary)
|
||||
(#set! "priority" 105))
|
||||
|
||||
; Repeats
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
"continue"
|
||||
] @keyword.repeat
|
||||
|
||||
; Variables
|
||||
|
||||
; (identifier) @variable
|
||||
name: (identifier) @variable
|
||||
argument: (identifier) @variable
|
||||
named_argument: (identifier) @variable
|
||||
(member_expression (identifier) @variable)
|
||||
(parenthesized_expression (identifier) @variable)
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#any-of? @variable.builtin "context"))
|
||||
|
||||
; Namespaces
|
||||
|
||||
(import (identifier) @namespace)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter (identifier) @parameter ":" "="? (identifier)? @constant)
|
||||
|
||||
; (call_expression argument: (identifier) @parameter "=")
|
||||
|
||||
; Functions
|
||||
|
||||
; (procedure_declaration (identifier) @function (procedure (block)))
|
||||
(procedure_declaration (identifier) @function (block))
|
||||
|
||||
(call_expression function: (identifier) @function.call)
|
||||
|
||||
; Types
|
||||
|
||||
type: (types) @type
|
||||
type: (identifier) @type
|
||||
((types) @type)
|
||||
|
||||
modifier: (identifier) @keyword
|
||||
keyword: (identifier) @keyword
|
||||
|
||||
((types (identifier) @type.builtin)
|
||||
(#any-of? @type.builtin
|
||||
"bool" "int" "string"
|
||||
"s8" "s16" "s32" "s64"
|
||||
"u8" "u16" "u32" "u64"
|
||||
"Type" "Any"))
|
||||
|
||||
(struct_declaration (identifier) @type ":" ":")
|
||||
|
||||
(enum_declaration (identifier) @type ":" ":")
|
||||
|
||||
; (const_declaration (identifier) @type ":" ":" [(array_type) (pointer_type)])
|
||||
|
||||
; ; I don't like this
|
||||
; ((identifier) @type
|
||||
; (#lua-match? @type "^[A-Z][a-zA-Z0-9]*$")
|
||||
; (#not-has-parent? @type parameter procedure_declaration call_expression))
|
||||
|
||||
; Fields
|
||||
|
||||
(member_expression "." (identifier) @field)
|
||||
|
||||
(assignment_statement (identifier) @field "="?)
|
||||
(update_statement (identifier) @field)
|
||||
|
||||
; Constants
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")
|
||||
(#not-has-parent? @constant type parameter))
|
||||
|
||||
(member_expression . "." (identifier) @constant)
|
||||
|
||||
(enum_declaration "{" (identifier) @constant)
|
||||
|
||||
; Literals
|
||||
|
||||
(integer) @number
|
||||
(float) @number
|
||||
|
||||
(string) @string
|
||||
|
||||
;(character) @character
|
||||
|
||||
(string (escape_sequence) @string.escape)
|
||||
|
||||
(boolean) @boolean
|
||||
|
||||
[
|
||||
(uninitialized)
|
||||
(null)
|
||||
] @constant.builtin
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
":"
|
||||
"="
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
">"
|
||||
">="
|
||||
"<"
|
||||
"<="
|
||||
"=="
|
||||
"!="
|
||||
"|"
|
||||
"~"
|
||||
"&"
|
||||
"&~"
|
||||
"<<"
|
||||
">>"
|
||||
"<<<"
|
||||
">>>"
|
||||
"||"
|
||||
"&&"
|
||||
"!"
|
||||
".."
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"<<="
|
||||
">>="
|
||||
"<<<="
|
||||
">>>="
|
||||
"||="
|
||||
"&&="
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
|
||||
[ "{" "}" ] @punctuation.bracket
|
||||
|
||||
[ "(" ")" ] @punctuation.bracket
|
||||
|
||||
[ "[" "]" ] @punctuation.bracket
|
||||
|
||||
[
|
||||
"`"
|
||||
"->"
|
||||
"."
|
||||
","
|
||||
":"
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Comments
|
||||
|
||||
[
|
||||
(block_comment)
|
||||
(comment)
|
||||
] @comment @spell
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
||||
(block_comment) @comment
|
||||
|
||||
directive: ("#") @keyword ; #if
|
||||
type: ("type_of") @type
|
||||
|
||||
(compiler_directive) @keyword
|
||||
(heredoc_start) @none
|
||||
(heredoc_end) @none
|
||||
(heredoc_body) @string
|
||||
(note) @string
|
||||
|
||||
)DONE");
|
||||
|
||||
extern "C" {
|
||||
TSLanguage *tree_sitter_jai();
|
||||
}
|
||||
|
||||
void
|
||||
tree_sitter_register_jai (Application_Links* app)
|
||||
{
|
||||
TSLanguage* language = tree_sitter_jai();
|
||||
Tree_Sitter_Language_Queries queries = {};
|
||||
queries.ptr[Tree_Sitter_Language_Query_Highlights] = tree_sitter_query_new(app, language, TS_JAI_HIGHLIGHT_QUERY);
|
||||
queries.ptr[Tree_Sitter_Language_Query_Tags] = tree_sitter_query_new(app, language, TS_JAI_TAGS_QUERY);
|
||||
tree_sitter_register_language(SCu8("jai"), language, queries);
|
||||
}
|
||||
|
||||
#endif //TREE_SITTER_JAI_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -12,6 +12,7 @@ patterns = {
|
|||
};
|
||||
blacklist_patterns = {
|
||||
".*",
|
||||
"non-source",
|
||||
};
|
||||
load_paths_base = {
|
||||
{ ".", .relative = true, .recursive = true, },
|
||||
|
|
Loading…
Reference in New Issue