Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/cbm/cbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 (Modular — Python-superset systems language; .mojo / .🔥)
CBM_LANG_COUNT
} CBMLanguage;

Expand Down
3 changes: 3 additions & 0 deletions internal/cbm/grammar_mojo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Each grammar compiled as separate unit (conflicting static symbols).
#include "vendored/grammars/mojo/parser.c"
#include "vendored/grammars/mojo/scanner.c"
19 changes: 19 additions & 0 deletions internal/cbm/lang_specs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -205,6 +206,18 @@ static const char *py_var_types[] = {"assignment", "augmented_assignment", NULL}
static const char *py_throw_types[] = {"raise_statement", NULL};
static const char *py_decorator_types[] = {"decorator", NULL};

// ==================== MOJO ====================
// Mojo (Modular) is a Python superset; the lsh/tree-sitter-mojo grammar is
// forked from tree-sitter-python, so every node type mirrors Python exactly
// EXCEPT the class array — Mojo's "struct"/"class" both parse as
// class_definition, but "trait" and the "__extension" form get their own
// nodes. So the spec reuses the py_* arrays and overrides only the class
// types. ("fn"/"def" both parse as function_definition; compile-time
// "alias NAME = value" has no dedicated node and is recovered as an
// `assignment`, so it falls under py_var_types like ordinary `var` fields.)
static const char *mojo_class_types[] = {"class_definition", "trait_definition",
"extension_definition", NULL};

// ==================== JAVASCRIPT ====================
static const char *js_func_types[] = {"function_declaration", "generator_function_declaration",
"function_expression", "arrow_function",
Expand Down Expand Up @@ -2039,6 +2052,12 @@ static const CBMLangSpec lang_specs[CBM_LANG_COUNT] = {
empty_types, empty_types, NULL, empty_types, NULL, NULL, tree_sitter_cfml,
NULL},

// CBM_LANG_MOJO (Python-derived; reuses py_* arrays, only class types differ)
[CBM_LANG_MOJO] = {CBM_LANG_MOJO, py_func_types, mojo_class_types, empty_types, py_module_types,
py_call_types, py_import_types, py_import_from_types, py_branch_types,
py_var_types, py_var_types, py_throw_types, NULL, py_decorator_types,
py_env_funcs, py_env_members, tree_sitter_mojo, NULL},

// CBM_LANG_GLEAM
[CBM_LANG_GLEAM] = {CBM_LANG_GLEAM, gleam_func_types, gleam_class_types, gleam_field_types,
gleam_module_types, gleam_call_types, gleam_import_types, empty_types,
Expand Down
1 change: 1 addition & 0 deletions internal/cbm/vendored/grammars/MANIFEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Re-vendoring from upstream must re-apply these.
| matlab | 15 | acristoffers/tree-sitter-matlab | `c2390a59016f` | VERIFIED-BOTH | ✅ |
| mermaid | 14 | monaqa/tree-sitter-mermaid | `90ae195b3193` | VERIFIED-BOTH | ✅ |
| meson | 15 | tree-sitter-grammars/tree-sitter-meson | `c84f3540624b` | VERIFIED-BOTH | ✅ |
| mojo | 15 | lsh/tree-sitter-mojo | `33193a99afe6` | VENDORED | ✅ |
| nasm | 14 | naclsn/tree-sitter-nasm | `d1b3638d017f` | VERIFIED-BOTH | ✅ |
| nickel | 15 | nickel-lang/tree-sitter-nickel | `b5b6cc3bc7b9` | VERIFIED-BOTH | ✅ |
| nix | 13 | nix-community/tree-sitter-nix | `eabf96807ea4` | VERIFIED-BOTH | ✅ |
Expand Down
21 changes: 21 additions & 0 deletions internal/cbm/vendored/grammars/mojo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Max Brunsfeld

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading