Compare commits
No commits in common. "5ccd6dd2ab79cab09cff1942a4cf077ef2835f41" and "324a78ae1e0832d1662ba20811fcaf5a0c1508ed" have entirely different histories.
5ccd6dd2ab
...
324a78ae1e
|
@ -15,42 +15,6 @@ source "$HELPERS_DIR/print-routines.sh"
|
||||||
# Build Tree Sitter
|
# 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() {
|
build_tree_sitter() {
|
||||||
BIN_NAME="custom_4coder"
|
BIN_NAME="custom_4coder"
|
||||||
|
|
||||||
|
@ -68,17 +32,23 @@ build_tree_sitter() {
|
||||||
|
|
||||||
TEMP_OUT_DIR=$BUILD_TEMP_DIR/tree-sitter
|
TEMP_OUT_DIR=$BUILD_TEMP_DIR/tree-sitter
|
||||||
mkdir -p $TEMP_OUT_DIR
|
mkdir -p $TEMP_OUT_DIR
|
||||||
rm $TEMP_OUT_DIR/*.o
|
|
||||||
rm "$BUILD_TEMP_DIR/tree-sitter.a"
|
|
||||||
|
|
||||||
# Build tree-sitter.lib/.a
|
# Build tree-sitter.lib/.a
|
||||||
print_step "Building tree-sitter lib"
|
print_step "Building tree-sitter lib"
|
||||||
clang $CLANG_OPTS "${INCLUDES[@]}" "$CUSTOM_ROOT/lib/src/lib.c" -o $TEMP_OUT_DIR/tree-sitter.o
|
clang $CLANG_OPTS "${INCLUDES[@]}" "$CUSTOM_ROOT/lib/src/lib.c" -o $TEMP_OUT_DIR/tree-sitter.o
|
||||||
print_success "Complete"
|
print_success "Complete"
|
||||||
|
|
||||||
build_tree_sitter_language "cpp" "C++"
|
# Lang: C++ (This needs to be two calls to clang so that you can specify the obj file names)
|
||||||
build_tree_sitter_language "jai" "Jai"
|
print_step "Building tree-sitter C++ Language Lib"
|
||||||
build_tree_sitter_language "bash" "Bash"
|
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"
|
||||||
|
|
||||||
# Link tree-sitter lib and parser obj files into a static library to link into main custom dll
|
# 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"
|
print_step "Linking tree-sitter static library"
|
||||||
|
|
|
@ -155,7 +155,7 @@ api_type_match(API_Type *a, API_Type *b){
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case APITypeKind_Enum:
|
case APITypeKind_Enum:
|
||||||
{
|
{
|
||||||
if (a->enum_type.val_count == b->enum_type.val_count &&
|
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;
|
}break;
|
||||||
|
|
||||||
case APITypeKind_Typedef:
|
case APITypeKind_Typedef:
|
||||||
{
|
{
|
||||||
if (string_match(a->typedef_type.name, b->typedef_type.name) &&
|
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
|
function void
|
||||||
generate_api_master_list(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
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));
|
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||||
|
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
call != 0;
|
||||||
call = call->next){
|
call = call->next){
|
||||||
|
@ -240,9 +240,9 @@ generate_api_master_list(Arena *scratch, API_Definition *api, API_Generation_Fla
|
||||||
|
|
||||||
function void
|
function void
|
||||||
generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
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));
|
fprintf(out, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||||
|
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
call != 0;
|
||||||
call = call->next){
|
call = call->next){
|
||||||
|
@ -269,9 +269,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
||||||
}
|
}
|
||||||
fprintf(out, ")\n");
|
fprintf(out, ")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
call != 0;
|
||||||
call = call->next){
|
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, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
fprintf(out, "struct API_VTable_%.*s{\n", string_expand(api->name));
|
fprintf(out, "struct API_VTable_%.*s{\n", string_expand(api->name));
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
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, "};\n");
|
||||||
|
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
fprintf(out, "#if defined(STATIC_LINK_API)\n");
|
fprintf(out, "#if defined(STATIC_LINK_API)\n");
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
call != 0;
|
||||||
|
@ -357,9 +357,9 @@ generate_header(Arena *scratch, API_Definition *api, API_Generation_Flag flags,
|
||||||
|
|
||||||
function void
|
function void
|
||||||
generate_cpp(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
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, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||||
|
|
||||||
fprintf(out, "function void\n");
|
fprintf(out, "function void\n");
|
||||||
fprintf(out, "%.*s_api_fill_vtable(API_VTable_%.*s *vtable){\n",
|
fprintf(out, "%.*s_api_fill_vtable(API_VTable_%.*s *vtable){\n",
|
||||||
string_expand(api->name),
|
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, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
fprintf(out, "#if defined(DYNAMIC_LINK_API)\n");
|
fprintf(out, "#if defined(DYNAMIC_LINK_API)\n");
|
||||||
fprintf(out, "function void\n");
|
fprintf(out, "function void\n");
|
||||||
fprintf(out, "%.*s_api_read_vtable(API_VTable_%.*s *vtable){\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
|
function void
|
||||||
generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag flags, FILE *out, String_Const_u8 generated_by){
|
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, "/* Generated by \"%.*s\" */\n\n", string_expand(generated_by));
|
||||||
|
|
||||||
fprintf(out, "function API_Definition*\n");
|
fprintf(out, "function API_Definition*\n");
|
||||||
fprintf(out, "%.*s_api_construct(Arena *arena){\n",
|
fprintf(out, "%.*s_api_construct(Arena *arena){\n",
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
fprintf(out, " API_Definition *result = begin_api(arena, \"%.*s\");\n",
|
fprintf(out, " API_Definition *result = begin_api(arena, \"%.*s\");\n",
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
|
|
||||||
for (API_Call *call = api->first_call;
|
for (API_Call *call = api->first_call;
|
||||||
call != 0;
|
call != 0;
|
||||||
call = call->next){
|
call = call->next){
|
||||||
|
@ -414,7 +414,7 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
||||||
"string_u8_litexpr(\"\"));\n",
|
"string_u8_litexpr(\"\"));\n",
|
||||||
string_expand(call->name),
|
string_expand(call->name),
|
||||||
string_expand(call->return_type));
|
string_expand(call->return_type));
|
||||||
|
|
||||||
if (call->params.count == 0){
|
if (call->params.count == 0){
|
||||||
fprintf(out, " (void)call;\n");
|
fprintf(out, " (void)call;\n");
|
||||||
}
|
}
|
||||||
|
@ -427,10 +427,10 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
||||||
string_expand(param->name));
|
string_expand(param->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, " }\n");
|
fprintf(out, " }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, " return(result);\n");
|
fprintf(out, " return(result);\n");
|
||||||
fprintf(out, "}\n");
|
fprintf(out, "}\n");
|
||||||
}
|
}
|
||||||
|
@ -440,15 +440,15 @@ generate_constructor(Arena *scratch, API_Definition *api, API_Generation_Flag fl
|
||||||
function b32
|
function b32
|
||||||
api_definition_generate_api_includes(Arena *arena, API_Definition *api, Generated_Group group, API_Generation_Flag flags, String_Const_u8 generated_by){
|
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
|
// NOTE(allen): Arrange output files
|
||||||
|
|
||||||
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
||||||
path_to_self = string_remove_last_folder(path_to_self);
|
path_to_self = string_remove_last_folder(path_to_self);
|
||||||
|
|
||||||
String_Const_u8 fname_ml = {};
|
String_Const_u8 fname_ml = {};
|
||||||
String_Const_u8 fname_h = {};
|
String_Const_u8 fname_h = {};
|
||||||
String_Const_u8 fname_cpp = {};
|
String_Const_u8 fname_cpp = {};
|
||||||
String_Const_u8 fname_con = {};
|
String_Const_u8 fname_con = {};
|
||||||
|
|
||||||
String_Const_u8 root = {};
|
String_Const_u8 root = {};
|
||||||
switch (group){
|
switch (group){
|
||||||
case GeneratedGroup_Core:
|
case GeneratedGroup_Core:
|
||||||
|
@ -460,69 +460,67 @@ api_definition_generate_api_includes(Arena *arena, API_Definition *api, Generate
|
||||||
root = string_u8_litexpr("custom/generated/");
|
root = string_u8_litexpr("custom/generated/");
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fname_ml = push_u8_stringf(arena, "%.*s%.*s%.*s_api_master_list.h",
|
fname_ml = push_u8_stringf(arena, "%.*s%.*s%.*s_api_master_list.h",
|
||||||
string_expand(path_to_self),
|
string_expand(path_to_self),
|
||||||
string_expand(root),
|
string_expand(root),
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
|
|
||||||
fname_h = push_u8_stringf(arena, "%.*s%.*s%.*s_api.h",
|
fname_h = push_u8_stringf(arena, "%.*s%.*s%.*s_api.h",
|
||||||
string_expand(path_to_self),
|
string_expand(path_to_self),
|
||||||
string_expand(root),
|
string_expand(root),
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
|
|
||||||
fname_cpp = push_u8_stringf(arena, "%.*s%.*s%.*s_api.cpp",
|
fname_cpp = push_u8_stringf(arena, "%.*s%.*s%.*s_api.cpp",
|
||||||
string_expand(path_to_self),
|
string_expand(path_to_self),
|
||||||
string_expand(root),
|
string_expand(root),
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
|
|
||||||
fname_con = push_u8_stringf(arena, "%.*s%.*s%.*s_api_constructor.cpp",
|
fname_con = push_u8_stringf(arena, "%.*s%.*s%.*s_api_constructor.cpp",
|
||||||
string_expand(path_to_self),
|
string_expand(path_to_self),
|
||||||
string_expand(root),
|
string_expand(root),
|
||||||
string_expand(api->name));
|
string_expand(api->name));
|
||||||
|
|
||||||
FILE *out_file_ml = fopen((char*)fname_ml.str, "wb");
|
FILE *out_file_ml = fopen((char*)fname_ml.str, "wb");
|
||||||
if (out_file_ml == 0){
|
if (out_file_ml == 0){
|
||||||
printf("could not open output file: '%s'\n", fname_ml.str);
|
printf("could not open output file: '%s'\n", fname_ml.str);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *out_file_h = fopen((char*)fname_h.str, "wb");
|
FILE *out_file_h = fopen((char*)fname_h.str, "wb");
|
||||||
if (out_file_h == 0){
|
if (out_file_h == 0){
|
||||||
printf("could not open output file: '%s'\n", fname_h.str);
|
printf("could not open output file: '%s'\n", fname_h.str);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *out_file_cpp = fopen((char*)fname_cpp.str, "wb");
|
FILE *out_file_cpp = fopen((char*)fname_cpp.str, "wb");
|
||||||
if (out_file_cpp == 0){
|
if (out_file_cpp == 0){
|
||||||
printf("could not open output file: '%s'\n", fname_cpp.str);
|
printf("could not open output file: '%s'\n", fname_cpp.str);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *out_file_con = fopen((char*)fname_con.str, "wb");
|
FILE *out_file_con = fopen((char*)fname_con.str, "wb");
|
||||||
if (out_file_cpp == 0){
|
if (out_file_cpp == 0){
|
||||||
printf("could not open output file: '%s'\n", fname_con.str);
|
printf("could not open output file: '%s'\n", fname_con.str);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("%s:1:\n", fname_ml.str);
|
printf("%s:1:\n", fname_ml.str);
|
||||||
printf("%s:1:\n", fname_h.str);
|
printf("%s:1:\n", fname_h.str);
|
||||||
printf("%s:1:\n", fname_cpp.str);
|
printf("%s:1:\n", fname_cpp.str);
|
||||||
printf("%s:1:\n", fname_con.str);
|
printf("%s:1:\n", fname_con.str);
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// NOTE(allen): Generate output
|
// NOTE(allen): Generate output
|
||||||
|
|
||||||
generate_api_master_list(arena, api, flags, out_file_ml, generated_by);
|
generate_api_master_list(arena, api, flags, out_file_ml, generated_by);
|
||||||
generate_header(arena, api, flags, out_file_h, generated_by);
|
generate_header(arena, api, flags, out_file_h, generated_by);
|
||||||
generate_cpp(arena, api, flags, out_file_cpp, generated_by);
|
generate_cpp(arena, api, flags, out_file_cpp, generated_by);
|
||||||
generate_constructor(arena, api, flags, out_file_con, generated_by);
|
generate_constructor(arena, api, flags, out_file_con, generated_by);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
fclose(out_file_ml);
|
fclose(out_file_ml);
|
||||||
fclose(out_file_h);
|
fclose(out_file_h);
|
||||||
fclose(out_file_cpp);
|
fclose(out_file_cpp);
|
||||||
|
@ -589,7 +587,7 @@ api_definition_check(Arena *arena, API_Definition *correct, API_Definition *remo
|
||||||
b32 report_missing = HasFlag(flags, APICheck_ReportMissingAPI);
|
b32 report_missing = HasFlag(flags, APICheck_ReportMissingAPI);
|
||||||
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
||||||
b32 report_mismatch = HasFlag(flags, APICheck_ReportMismatchAPI);
|
b32 report_mismatch = HasFlag(flags, APICheck_ReportMismatchAPI);
|
||||||
|
|
||||||
b32 iterate_correct = (report_missing || report_mismatch);
|
b32 iterate_correct = (report_missing || report_mismatch);
|
||||||
if (iterate_correct){
|
if (iterate_correct){
|
||||||
for (API_Call *call = correct->first_call;
|
for (API_Call *call = correct->first_call;
|
||||||
|
@ -607,7 +605,7 @@ api_definition_check(Arena *arena, API_Definition *correct, API_Definition *remo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 iterate_remote = (report_extra);
|
b32 iterate_remote = (report_extra);
|
||||||
if (iterate_remote){
|
if (iterate_remote){
|
||||||
for (API_Call *call = remote->first_call;
|
for (API_Call *call = remote->first_call;
|
||||||
|
@ -627,7 +625,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){
|
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_missing = HasFlag(flags, APICheck_ReportMissingAPI);
|
||||||
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
b32 report_extra = HasFlag(flags, APICheck_ReportExtraAPI);
|
||||||
|
|
||||||
b32 iterate_correct = (report_missing);
|
b32 iterate_correct = (report_missing);
|
||||||
if (iterate_correct){
|
if (iterate_correct){
|
||||||
for (API_Definition *api = correct->first;
|
for (API_Definition *api = correct->first;
|
||||||
|
@ -640,7 +638,7 @@ api_list_check(Arena *arena, API_Definition_List *correct, API_Definition_List *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 iterate_remote = (report_extra);
|
b32 iterate_remote = (report_extra);
|
||||||
if (iterate_remote){
|
if (iterate_remote){
|
||||||
for (API_Definition *api = remote->first;
|
for (API_Definition *api = remote->first;
|
||||||
|
@ -654,7 +652,7 @@ api_list_check(Arena *arena, API_Definition_List *correct, API_Definition_List *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (API_Definition *api = correct->first;
|
for (API_Definition *api = correct->first;
|
||||||
api != 0;
|
api != 0;
|
||||||
api = api->next){
|
api = api->next){
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct Event_Code_List{
|
||||||
Event_Code *first;
|
Event_Code *first;
|
||||||
Event_Code *last;
|
Event_Code *last;
|
||||||
i32 count;
|
i32 count;
|
||||||
|
|
||||||
String_Const_u8 code_prefix;
|
String_Const_u8 code_prefix;
|
||||||
String_Const_u8 name_table;
|
String_Const_u8 name_table;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ function void
|
||||||
generate_codes(Arena *scratch, Event_Code_List *list, FILE *out){
|
generate_codes(Arena *scratch, Event_Code_List *list, FILE *out){
|
||||||
String_Const_u8 code_prefix = list->code_prefix;
|
String_Const_u8 code_prefix = list->code_prefix;
|
||||||
String_Const_u8 name_table = list->name_table;
|
String_Const_u8 name_table = list->name_table;
|
||||||
|
|
||||||
fprintf(out, "enum{\n");
|
fprintf(out, "enum{\n");
|
||||||
i32 counter = 1;
|
i32 counter = 1;
|
||||||
for (Event_Code *code = list->first;
|
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, " %.*s_COUNT = %d,\n", string_expand(code_prefix), counter);
|
||||||
fprintf(out, "};\n");
|
fprintf(out, "};\n");
|
||||||
|
|
||||||
fprintf(out, "global char* %.*s[%.*s_COUNT] = {\n",
|
fprintf(out, "global char* %.*s[%.*s_COUNT] = {\n",
|
||||||
string_expand(name_table), string_expand(code_prefix));
|
string_expand(name_table), string_expand(code_prefix));
|
||||||
fprintf(out, " \"None\",\n");
|
fprintf(out, " \"None\",\n");
|
||||||
|
@ -70,7 +70,7 @@ function Event_Code*
|
||||||
add_code(Arena *arena, Event_Code_List *list, String_Const_u8 name){
|
add_code(Arena *arena, Event_Code_List *list, String_Const_u8 name){
|
||||||
Event_Code *code = push_array(arena, Event_Code, 1);
|
Event_Code *code = push_array(arena, Event_Code, 1);
|
||||||
sll_queue_push(list->first, list->last, code);
|
sll_queue_push(list->first, list->last, code);
|
||||||
list->count += 1;
|
list->count;
|
||||||
code->name = push_string_copy(arena, name);
|
code->name = push_string_copy(arena, name);
|
||||||
return(code);
|
return(code);
|
||||||
}
|
}
|
||||||
|
@ -171,30 +171,30 @@ make_core_list(Arena *arena){
|
||||||
int
|
int
|
||||||
main(void){
|
main(void){
|
||||||
Arena arena = make_arena_malloc();
|
Arena arena = make_arena_malloc();
|
||||||
|
|
||||||
Event_Code_List key_list = make_key_list(&arena);
|
Event_Code_List key_list = make_key_list(&arena);
|
||||||
Event_Code_List mouse_list = make_mouse_list(&arena);
|
Event_Code_List mouse_list = make_mouse_list(&arena);
|
||||||
Event_Code_List core_list = make_core_list(&arena);
|
Event_Code_List core_list = make_core_list(&arena);
|
||||||
|
|
||||||
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
String_Const_u8 path_to_self = string_u8_litexpr(__FILE__);
|
||||||
path_to_self = string_remove_last_folder(path_to_self);
|
path_to_self = string_remove_last_folder(path_to_self);
|
||||||
String_Const_u8 file_name =
|
String_Const_u8 file_name =
|
||||||
push_u8_stringf(&arena, "%.*scustom/generated/4coder_event_codes.h",
|
push_u8_stringf(&arena, "%.*scustom/generated/4coder_event_codes.h",
|
||||||
string_expand(path_to_self));
|
string_expand(path_to_self));
|
||||||
|
|
||||||
FILE *out = fopen((char*)file_name.str, "wb");
|
FILE *out = fopen((char*)file_name.str, "wb");
|
||||||
if (out == 0){
|
if (out == 0){
|
||||||
printf("could not open output file '%s'\n", file_name.str);
|
printf("could not open output file '%s'\n", file_name.str);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, "/* Generated by: " __FILE__ );
|
fprintf(out, "/* Generated by: " __FILE__ );
|
||||||
fprintf(out, " */\n" );
|
fprintf(out, " */\n" );
|
||||||
|
|
||||||
generate_codes(&arena, &key_list, out);
|
generate_codes(&arena, &key_list, out);
|
||||||
generate_codes(&arena, &mouse_list, out);
|
generate_codes(&arena, &mouse_list, out);
|
||||||
generate_codes(&arena, &core_list, out);
|
generate_codes(&arena, &core_list, out);
|
||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,9 @@
|
||||||
enum Tree_Sitter_Language_Query_Kind
|
enum Tree_Sitter_Language_Query_Kind
|
||||||
{
|
{
|
||||||
Tree_Sitter_Language_Query_Highlights,
|
Tree_Sitter_Language_Query_Highlights,
|
||||||
Tree_Sitter_Language_Query_Tags,
|
Tree_Sitter_Language_Query_Functions,
|
||||||
|
Tree_Sitter_Language_Query_Types,
|
||||||
|
|
||||||
Tree_Sitter_Language_Query_Count,
|
Tree_Sitter_Language_Query_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,6 +38,10 @@ struct Tree_Sitter_Languages
|
||||||
|
|
||||||
global Tree_Sitter_Languages 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_data_id);
|
||||||
CUSTOM_ID(attachment, buffer_tree_sitter_parse_task_id);
|
CUSTOM_ID(attachment, buffer_tree_sitter_parse_task_id);
|
||||||
|
@ -63,9 +69,6 @@ struct Tree_Sitter_Code_Index_Nest_List
|
||||||
Tree_Sitter_Code_Index_Nest_Node* last;
|
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_code_indexing = true;
|
||||||
b8 use_tree_sitter_token_coloring = true;
|
b8 use_tree_sitter_token_coloring = true;
|
||||||
function void tree_sitter_code_index_update_tick(Application_Links *app);
|
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"
|
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 > /dev/null
|
pushd $dst
|
||||||
g++ -I"$CUSTOM_ROOT" $opts $full_target -o one_time
|
g++ -I"$CUSTOM_ROOT" $opts $full_target -o one_time
|
||||||
popd > /dev/null
|
popd
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
/* 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
|
|
|
@ -1,211 +0,0 @@
|
||||||
/* 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
|
|
|
@ -1,298 +0,0 @@
|
||||||
/* 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,7 +12,6 @@ patterns = {
|
||||||
};
|
};
|
||||||
blacklist_patterns = {
|
blacklist_patterns = {
|
||||||
".*",
|
".*",
|
||||||
"non-source",
|
|
||||||
};
|
};
|
||||||
load_paths_base = {
|
load_paths_base = {
|
||||||
{ ".", .relative = true, .recursive = true, },
|
{ ".", .relative = true, .recursive = true, },
|
||||||
|
|
Loading…
Reference in New Issue