Add Mojo language wiring

Signed-off-by: Anand Aiyer <aaiyer@gmail.com>
This commit is contained in:
Anand Aiyer committed 2026-07-08 00:05:19 +05:30
1 parent 5554f8a46a
commit 222e97a076
7 files changed
+41

No files matched your search

+1
View File
@@ -170,6 +170,7 @@ typedef enum {
CBM_LANG_QML, // Qt QML (Qt Modeling Language — declarative UI + embedded JS)
CBM_LANG_CFSCRIPT, // CFML script dialect (.cfc components — Lucee/ColdFusion)
CBM_LANG_CFML, // CFML tag dialect (.cfm templates — Lucee/ColdFusion)
CBM_LANG_MOJO, // Mojo
CBM_LANG_COUNT
} CBMLanguage;
+22
View File
@@ -164,6 +164,7 @@ extern const TSLanguage *tree_sitter_apex(void);
extern const TSLanguage *tree_sitter_soql(void);
extern const TSLanguage *tree_sitter_sosl(void);
extern const TSLanguage *tree_sitter_pine(void);
extern const TSLanguage *tree_sitter_mojo(void);
// -- Empty sentinel --
static const char *empty_types[] = {NULL};
@@ -1596,6 +1597,21 @@ static const char *pine_var_types[] = {"variable_definition_statement",
static const char *pine_branch_types[] = {"if_statement", "switch_statement", "for_statement",
"for_in_statement", "while_statement", NULL};
static const char *pine_assign_types[] = {"reassignment_statement", NULL};
static const char *mojo_func_types[] = {"function_definition", NULL};
static const char *mojo_class_types[] = {"class_definition", "trait_definition", NULL};
static const char *mojo_module_types[] = {"module", NULL};
static const char *mojo_call_types[] = {"call", NULL};
static const char *mojo_import_types[] = {"import_statement", "import_from_statement",
"future_import_statement", NULL};
static const char *mojo_branch_types[] = {"if_statement",
"match_statement",
"for_statement",
"while_statement",
"try_statement",
"with_statement",
NULL};
static const char *mojo_var_types[] = {"assignment", NULL};
static const char *mojo_assign_types[] = {"assignment", "augmented_assignment", NULL};
// ==================== SPEC TABLE ====================
static const CBMLangSpec lang_specs[CBM_LANG_COUNT] = {
@@ -2571,6 +2587,12 @@ static const CBMLangSpec lang_specs[CBM_LANG_COUNT] = {
pine_branch_types, pine_var_types, pine_assign_types, empty_types, NULL,
empty_types, NULL, NULL, tree_sitter_pine, NULL},
// CBM_LANG_MOJO
[CBM_LANG_MOJO] = {CBM_LANG_MOJO, mojo_func_types, mojo_class_types, empty_types,
mojo_module_types, mojo_call_types, mojo_import_types, mojo_import_types,
mojo_branch_types, mojo_var_types, mojo_assign_types, empty_types, NULL,
empty_types, NULL, NULL, tree_sitter_mojo, NULL},
};
_Static_assert(sizeof(lang_specs) / sizeof(lang_specs[0]) == CBM_LANG_COUNT,
+4
View File
@@ -187,6 +187,9 @@ static const ext_entry_t EXT_TABLE[] = {
/* Meson */
{".meson", CBM_LANG_MESON},
/* Mojo */
{".mojo", CBM_LANG_MOJO},
/* Nix */
{".nix", CBM_LANG_NIX},
@@ -835,6 +838,7 @@ static const char *LANG_NAMES[CBM_LANG_COUNT] = {
[CBM_LANG_APEX] = "Apex",
[CBM_LANG_SOQL] = "SOQL",
[CBM_LANG_SOSL] = "SOSL",
[CBM_LANG_MOJO] = "Mojo",
};
+1
View File
@@ -118,6 +118,7 @@ static const lang_name_entry_t LANG_NAME_TABLE[] = {
{"glsl", CBM_LANG_GLSL},
{"ini", CBM_LANG_INI},
{"matlab", CBM_LANG_MATLAB},
{"mojo", CBM_LANG_MOJO},
{"lean", CBM_LANG_LEAN},
{"form", CBM_LANG_FORM},
{"magma", CBM_LANG_MAGMA},
+1
View File
@@ -151,6 +151,7 @@ static const LabelGolden LABEL_GOLDENS[] = {
{"func", "Function:1,Module:1"},
{"lean", "Function:2,Module:1"},
{"move", "Function:1,Module:1"},
{"mojo", "Class:1,Function:1,Method:1,Module:1"},
{"smali", "Class:1,Function:1,Module:1"},
{"systemverilog", "Class:1,Function:1,Module:1"},
{"verilog", "Class:1,Module:1"},
+6
View File
@@ -196,6 +196,12 @@ const GrammarCase CBM_GRAMMAR_CASES[] = {
"module 0x1::m {\n public fun foo() {}\n}\n",
1,
{"foo", NULL}},
{"mojo",
CBM_LANG_MOJO,
"a.mojo",
"fn foo() -> Int:\n return 1\n\nstruct A:\n fn bar(self) -> Int:\n return foo()\n",
2,
{"foo", "A", NULL}},
{"smali",
CBM_LANG_SMALI,
"A.smali",
+6
View File
@@ -956,6 +956,11 @@ TEST(lang_ext_move) {
PASS();
}
TEST(lang_ext_mojo) {
ASSERT_EQ(cbm_language_for_extension(".mojo"), CBM_LANG_MOJO);
PASS();
}
TEST(lang_ext_squirrel) {
ASSERT_EQ(cbm_language_for_extension(".nut"), CBM_LANG_SQUIRREL);
PASS();
@@ -1271,6 +1276,7 @@ SUITE(language) {
RUN_TEST(lang_ext_ispc);
RUN_TEST(lang_ext_cairo);
RUN_TEST(lang_ext_move);
RUN_TEST(lang_ext_mojo);
RUN_TEST(lang_ext_squirrel);
RUN_TEST(lang_ext_func);
RUN_TEST(lang_ext_rst);