#include "lang_specs.h" #include "cbm.h" // CBMLanguage, CBM_LANG_* #include "tree_sitter/api.h" // TSLanguage // -- Extern declarations for tree-sitter grammar functions -- // These symbols are defined in the grammar C code compiled by Go tree-sitter modules. extern const TSLanguage *tree_sitter_go(void); extern const TSLanguage *tree_sitter_python(void); extern const TSLanguage *tree_sitter_javascript(void); extern const TSLanguage *tree_sitter_typescript(void); extern const TSLanguage *tree_sitter_tsx(void); extern const TSLanguage *tree_sitter_rust(void); extern const TSLanguage *tree_sitter_java(void); extern const TSLanguage *tree_sitter_cpp(void); extern const TSLanguage *tree_sitter_c_sharp(void); extern const TSLanguage *tree_sitter_php_only(void); extern const TSLanguage *tree_sitter_lua(void); extern const TSLanguage *tree_sitter_scala(void); extern const TSLanguage *tree_sitter_kotlin(void); extern const TSLanguage *tree_sitter_ruby(void); extern const TSLanguage *tree_sitter_c(void); extern const TSLanguage *tree_sitter_bash(void); extern const TSLanguage *tree_sitter_zig(void); extern const TSLanguage *tree_sitter_elixir(void); extern const TSLanguage *tree_sitter_haskell(void); extern const TSLanguage *tree_sitter_ocaml(void); extern const TSLanguage *tree_sitter_objc(void); extern const TSLanguage *tree_sitter_swift(void); extern const TSLanguage *tree_sitter_dart(void); extern const TSLanguage *tree_sitter_perl(void); extern const TSLanguage *tree_sitter_groovy(void); extern const TSLanguage *tree_sitter_erlang(void); extern const TSLanguage *tree_sitter_r(void); extern const TSLanguage *tree_sitter_html(void); extern const TSLanguage *tree_sitter_css(void); extern const TSLanguage *tree_sitter_scss(void); extern const TSLanguage *tree_sitter_yaml(void); extern const TSLanguage *tree_sitter_toml(void); extern const TSLanguage *tree_sitter_hcl(void); extern const TSLanguage *tree_sitter_sql(void); extern const TSLanguage *tree_sitter_dockerfile(void); // New languages (v0.5 expansion) extern const TSLanguage *tree_sitter_clojure(void); extern const TSLanguage *tree_sitter_fsharp(void); extern const TSLanguage *tree_sitter_julia(void); extern const TSLanguage *tree_sitter_vim(void); extern const TSLanguage *tree_sitter_nix(void); extern const TSLanguage *tree_sitter_commonlisp(void); extern const TSLanguage *tree_sitter_elm(void); extern const TSLanguage *tree_sitter_fortran(void); extern const TSLanguage *tree_sitter_cuda(void); extern const TSLanguage *tree_sitter_COBOL(void); extern const TSLanguage *tree_sitter_verilog(void); extern const TSLanguage *tree_sitter_elisp(void); extern const TSLanguage *tree_sitter_json(void); extern const TSLanguage *tree_sitter_xml(void); extern const TSLanguage *tree_sitter_markdown(void); extern const TSLanguage *tree_sitter_make(void); extern const TSLanguage *tree_sitter_cmake(void); extern const TSLanguage *tree_sitter_proto(void); extern const TSLanguage *tree_sitter_graphql(void); extern const TSLanguage *tree_sitter_vue(void); extern const TSLanguage *tree_sitter_svelte(void); extern const TSLanguage *tree_sitter_meson(void); extern const TSLanguage *tree_sitter_glsl(void); extern const TSLanguage *tree_sitter_ini(void); // Scientific/math languages extern const TSLanguage *tree_sitter_matlab(void); extern const TSLanguage *tree_sitter_lean(void); extern const TSLanguage *tree_sitter_form(void); extern const TSLanguage *tree_sitter_magma(void); extern const TSLanguage *tree_sitter_wolfram(void); // New languages extern const TSLanguage *tree_sitter_solidity(void); extern const TSLanguage *tree_sitter_typst(void); extern const TSLanguage *tree_sitter_gdscript(void); extern const TSLanguage *tree_sitter_gleam(void); extern const TSLanguage *tree_sitter_powershell(void); extern const TSLanguage *tree_sitter_pascal(void); extern const TSLanguage *tree_sitter_d(void); extern const TSLanguage *tree_sitter_scheme(void); extern const TSLanguage *tree_sitter_fennel(void); extern const TSLanguage *tree_sitter_fish(void); extern const TSLanguage *tree_sitter_awk(void); extern const TSLanguage *tree_sitter_zsh(void); extern const TSLanguage *tree_sitter_tcl(void); extern const TSLanguage *tree_sitter_ada(void); extern const TSLanguage *tree_sitter_agda(void); extern const TSLanguage *tree_sitter_racket(void); extern const TSLanguage *tree_sitter_odin(void); extern const TSLanguage *tree_sitter_rescript(void); extern const TSLanguage *tree_sitter_purescript(void); extern const TSLanguage *tree_sitter_nickel(void); extern const TSLanguage *tree_sitter_crystal(void); extern const TSLanguage *tree_sitter_teal(void); extern const TSLanguage *tree_sitter_hare(void); extern const TSLanguage *tree_sitter_pony(void); extern const TSLanguage *tree_sitter_luau(void); extern const TSLanguage *tree_sitter_qmljs(void); extern const TSLanguage *tree_sitter_cfscript(void); extern const TSLanguage *tree_sitter_cfml(void); extern const TSLanguage *tree_sitter_janet_simple(void); extern const TSLanguage *tree_sitter_sway(void); extern const TSLanguage *tree_sitter_nasm(void); extern const TSLanguage *tree_sitter_asm(void); extern const TSLanguage *tree_sitter_astro(void); extern const TSLanguage *tree_sitter_blade(void); extern const TSLanguage *tree_sitter_just(void); extern const TSLanguage *tree_sitter_gotmpl(void); extern const TSLanguage *tree_sitter_templ(void); extern const TSLanguage *tree_sitter_liquid(void); extern const TSLanguage *tree_sitter_jinja2(void); extern const TSLanguage *tree_sitter_prisma(void); extern const TSLanguage *tree_sitter_hyprlang(void); extern const TSLanguage *tree_sitter_dotenv(void); extern const TSLanguage *tree_sitter_diff(void); extern const TSLanguage *tree_sitter_wgsl(void); extern const TSLanguage *tree_sitter_kdl(void); extern const TSLanguage *tree_sitter_json5(void); extern const TSLanguage *tree_sitter_jsonnet(void); extern const TSLanguage *tree_sitter_ron(void); extern const TSLanguage *tree_sitter_thrift(void); extern const TSLanguage *tree_sitter_capnp(void); extern const TSLanguage *tree_sitter_properties(void); extern const TSLanguage *tree_sitter_ssh_config(void); extern const TSLanguage *tree_sitter_bibtex(void); extern const TSLanguage *tree_sitter_starlark(void); extern const TSLanguage *tree_sitter_bicep(void); extern const TSLanguage *tree_sitter_csv(void); extern const TSLanguage *tree_sitter_requirements(void); extern const TSLanguage *tree_sitter_hlsl(void); extern const TSLanguage *tree_sitter_vhdl(void); extern const TSLanguage *tree_sitter_systemverilog(void); extern const TSLanguage *tree_sitter_devicetree(void); extern const TSLanguage *tree_sitter_linkerscript(void); extern const TSLanguage *tree_sitter_gn(void); extern const TSLanguage *tree_sitter_kconfig(void); extern const TSLanguage *tree_sitter_bitbake(void); extern const TSLanguage *tree_sitter_smali(void); extern const TSLanguage *tree_sitter_tablegen(void); extern const TSLanguage *tree_sitter_ispc(void); extern const TSLanguage *tree_sitter_cairo(void); extern const TSLanguage *tree_sitter_move(void); extern const TSLanguage *tree_sitter_squirrel(void); extern const TSLanguage *tree_sitter_func(void); extern const TSLanguage *tree_sitter_regex(void); extern const TSLanguage *tree_sitter_jsdoc(void); extern const TSLanguage *tree_sitter_rst(void); extern const TSLanguage *tree_sitter_beancount(void); extern const TSLanguage *tree_sitter_mermaid(void); extern const TSLanguage *tree_sitter_puppet(void); extern const TSLanguage *tree_sitter_po(void); extern const TSLanguage *tree_sitter_gitattributes(void); extern const TSLanguage *tree_sitter_gitignore(void); extern const TSLanguage *tree_sitter_slang(void); extern const TSLanguage *tree_sitter_llvm(void); extern const TSLanguage *tree_sitter_smithy(void); extern const TSLanguage *tree_sitter_wit(void); extern const TSLanguage *tree_sitter_tlaplus(void); extern const TSLanguage *tree_sitter_pkl(void); extern const TSLanguage *tree_sitter_gomod(void); 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}; // ==================== GO ==================== static const char *go_func_types[] = {"function_declaration", "method_declaration", "method_elem", "func_literal", NULL}; static const char *go_class_types[] = {"type_spec", "type_alias", "type_declaration", NULL}; static const char *go_field_types[] = {"field_declaration", NULL}; static const char *go_module_types[] = {"source_file", NULL}; static const char *go_call_types[] = {"call_expression", NULL}; static const char *go_import_types[] = {"import_declaration", "import", NULL}; static const char *go_branch_types[] = {"if_statement", "for_statement", "expression_switch_statement", "type_switch_statement", "select_statement", "expression_case", "type_case", "communication_case", "default_case", "defer_statement", "go_statement", NULL}; static const char *go_var_types[] = {"var_declaration", "const_declaration", NULL}; static const char *go_assign_types[] = {"assignment_statement", "short_var_declaration", NULL}; // ==================== PYTHON ==================== static const char *py_func_types[] = {"function_definition", NULL}; static const char *py_class_types[] = {"class_definition", NULL}; static const char *py_module_types[] = {"module", NULL}; static const char *py_call_types[] = {"call", "with_statement", NULL}; static const char *py_import_types[] = {"import_statement", "import", NULL}; static const char *py_import_from_types[] = {"import_from_statement", NULL}; static const char *py_branch_types[] = { "if_statement", "for_statement", "while_statement", "try_statement", "except_clause", "with_statement", "elif_clause", NULL}; 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}; // ==================== JAVASCRIPT ==================== static const char *js_func_types[] = {"function_declaration", "generator_function_declaration", "function_expression", "arrow_function", "method_definition", NULL}; static const char *js_class_types[] = {"class_declaration", "class", NULL}; static const char *js_module_types[] = {"program", NULL}; static const char *js_call_types[] = {"call_expression", "new_expression", NULL}; static const char *js_import_types[] = {"import_statement", "lexical_declaration", "export_statement", "import", "extends", "require", NULL}; static const char *js_branch_types[] = {"if_statement", "for_statement", "for_in_statement", "while_statement", "switch_statement", "switch_case", "switch_default", "try_statement", "catch_clause", "do_statement", NULL}; static const char *js_var_types[] = {"lexical_declaration", "variable_declaration", NULL}; static const char *js_throw_types[] = {"throw_statement", NULL}; // ==================== TYPESCRIPT ==================== static const char *ts_func_types[] = {"function_declaration", "generator_function_declaration", "function_expression", "arrow_function", "method_definition", "function_signature", NULL}; static const char *ts_class_types[] = {"class_declaration", "class", "abstract_class_declaration", "enum_declaration", "interface_declaration", "type_alias_declaration", "internal_module", NULL}; static const char *ts_decorator_types[] = {"decorator", NULL}; // ==================== QML (Qt) ==================== // QMLJS grammar is a TypeScript superset plus declarative ui_* nodes, so the // JS/TS function, call, branch, variable and module arrays are reused as-is. static const char *qml_class_types[] = {"class_declaration", "class", "abstract_class_declaration", "enum_declaration", "interface_declaration", "ui_inline_component", NULL}; static const char *qml_field_types[] = {"ui_property", "ui_signal", "public_field_definition", NULL}; static const char *qml_import_types[] = {"import_statement", "import", "ui_import", NULL}; // ==================== CFScript (CFML .cfc script dialect) ==================== // JS-like grammar: components contain function/method declarations. Reuses the // JS call/branch/var/module arrays. static const char *cfscript_func_types[] = {"function_declaration", "function_expression", "arrow_function", "method_definition", NULL}; static const char *cfscript_field_types[] = {"property_declaration", NULL}; static const char *cfscript_import_types[] = {"import_statement", "import", NULL}; // ==================== CFML (tag dialect — .cfm templates) ==================== // Tag-based grammar (HTML-derived). Embedded functions appear as // function_declaration/function_expression. Tag nodes // (cf_function_tag) carry their name in a cf_attribute rather than a `name` // field, so the definition walker mints them via extract_cfml_function_tag and // compute_func_qn names them via compute_cfml_func_qn — but cf_function_tag is // listed here too so push_boundary_scopes pushes a SCOPE_FUNC and in-body calls // source to the enclosing cffunction rather than the Module. static const char *cfml_func_types[] = {"cf_function_tag", "function_declaration", "function_expression", NULL}; static const char *cfml_call_types[] = {"call_expression", NULL}; static const char *cfml_branch_types[] = { "cf_if_tag", "cf_elseif_tag", "cf_else_tag", "if_statement", "for_statement", "while_statement", "switch_statement", NULL}; static const char *cfml_module_types[] = {"program", "component_file", NULL}; // ==================== RUST ==================== static const char *rust_func_types[] = {"function_item", "function_signature_item", "closure_expression", NULL}; static const char *rust_class_types[] = {"struct_item", "enum_item", "union_item", "trait_item", "type_item", "impl_item", NULL}; static const char *rust_field_types[] = {"field_declaration", NULL}; static const char *rust_module_types[] = {"source_file", "mod_item", NULL}; static const char *rust_call_types[] = {"call_expression", "macro_invocation", NULL}; static const char *rust_import_types[] = {"use_declaration", "extern_crate_declaration", NULL}; static const char *rust_import_from_types[] = {"use_declaration", NULL}; static const char *rust_branch_types[] = {"if_expression", "for_expression", "while_expression", "loop_expression", "match_expression", "match_arm", NULL}; static const char *rust_var_types[] = {"static_item", "const_item", NULL}; static const char *rust_assign_types[] = {"assignment_expression", "compound_assignment_expr", NULL}; static const char *rust_decorator_types[] = {"attribute_item", NULL}; // ==================== JAVA ==================== static const char *java_func_types[] = {"method_declaration", "constructor_declaration", "lambda_expression", NULL}; static const char *java_class_types[] = {"class_declaration", "interface_declaration", "enum_declaration", "annotation_type_declaration", "record_declaration", "module_declaration", "package_declaration", NULL}; static const char *java_field_types[] = {"field_declaration", NULL}; static const char *java_module_types[] = {"program", NULL}; static const char *java_call_types[] = {"method_invocation", "object_creation_expression", NULL}; static const char *java_import_types[] = {"import_declaration", "extends", "import", NULL}; static const char *java_branch_types[] = { "if_statement", "for_statement", "enhanced_for_statement", "while_statement", "switch_expression", "switch_block_statement_group", "try_statement", "catch_clause", NULL}; static const char *java_var_types[] = {"field_declaration", "local_variable_declaration", NULL}; static const char *java_assign_types[] = {"assignment_expression", NULL}; static const char *java_throw_types[] = {"throw_statement", NULL}; static const char *java_decorator_types[] = {"marker_annotation", "annotation", NULL}; // ==================== C++ ==================== static const char *cpp_func_types[] = {"function_definition", "declaration", "field_declaration", "template_declaration", "lambda_expression", NULL}; static const char *cpp_class_types[] = {"class_specifier", "struct_specifier", "union_specifier", "enum_specifier", "type_definition", NULL}; static const char *cpp_field_types[] = {"field_declaration", NULL}; static const char *cpp_module_types[] = {"translation_unit", "namespace_definition", "linkage_specification", "declaration", NULL}; static const char *cpp_call_types[] = { "call_expression", "field_expression", "subscript_expression", "new_expression", "delete_expression", "binary_expression", "unary_expression", "update_expression", NULL}; static const char *cpp_import_types[] = {"preproc_include", "template_function", "declaration", NULL}; static const char *cpp_branch_types[] = {"if_statement", "for_statement", "for_range_loop", "while_statement", "switch_statement", "case_statement", "try_statement", "catch_clause", NULL}; static const char *cpp_var_types[] = {"declaration", NULL}; static const char *cpp_assign_types[] = {"assignment_expression", NULL}; static const char *cpp_throw_types[] = {"throw_statement", NULL}; // ==================== C# ==================== static const char *cs_func_types[] = {"destructor_declaration", "local_function_statement", "function_pointer_type", "constructor_declaration", "anonymous_method_expression", "lambda_expression", "method_declaration", NULL}; static const char *cs_class_types[] = {"class_declaration", "struct_declaration", "enum_declaration", "interface_declaration", "record_declaration", "type_declaration", NULL}; static const char *cs_module_types[] = {"compilation_unit", NULL}; static const char *cs_call_types[] = {"invocation_expression", "object_creation_expression", NULL}; static const char *cs_import_types[] = {"using_directive", "namespace_use_declaration", "using_statement", "namespace_declaration", NULL}; static const char *cs_branch_types[] = {"if_statement", "for_statement", "foreach_statement", "while_statement", "switch_statement", "case_switch_label", "try_statement", "catch_clause", NULL}; static const char *cs_var_types[] = {"field_declaration", "local_declaration_statement", NULL}; static const char *cs_field_types[] = {"field_declaration", "property_declaration", NULL}; /* tree-sitter-c-sharp models `x++`/`++x` as postfix_/prefix_unary_expression * (there is no `update_expression` node — that is a JS/TS kind), so a static * field bump like `_count++` must list those node kinds to emit a WRITES. */ static const char *cs_assign_types[] = {"assignment_expression", "postfix_unary_expression", "prefix_unary_expression", NULL}; static const char *cs_throw_types[] = {"throw_statement", "throw_expression", NULL}; static const char *cs_decorator_types[] = {"attribute", NULL}; // ==================== PHP ==================== static const char *php_func_types[] = {"function_static_declaration", "anonymous_function", "function_definition", "arrow_function", "method_declaration", NULL}; static const char *php_class_types[] = {"trait_declaration", "enum_declaration", "interface_declaration", "class_declaration", NULL}; static const char *php_import_types[] = {"extends", "include", "namespace_use_declaration", "require", "use_declaration", NULL}; static const char *php_module_types[] = {"program", NULL}; static const char *php_call_types[] = { "member_call_expression", "scoped_call_expression", "function_call_expression", "object_creation_expression", "nullsafe_member_call_expression", NULL}; static const char *php_branch_types[] = {"if_statement", "for_statement", "foreach_statement", "while_statement", "switch_statement", "case_statement", "try_statement", "catch_clause", NULL}; static const char *php_var_types[] = {"expression_statement", NULL}; static const char *php_assign_types[] = {"assignment_expression", NULL}; static const char *php_throw_types[] = {"throw_expression", NULL}; static const char *php_decorator_types[] = {"attribute_group", NULL}; // ==================== LUA ==================== static const char *lua_func_types[] = {"function_declaration", "function_definition", NULL}; static const char *lua_module_types[] = {"chunk", NULL}; static const char *lua_call_types[] = {"function_call", NULL}; static const char *lua_import_types[] = {"function_call", NULL}; static const char *lua_branch_types[] = {"if_statement", "for_statement", "for_in_statement", "while_statement", "repeat_statement", NULL}; static const char *lua_var_types[] = {"variable_declaration", NULL}; static const char *lua_assign_types[] = {"assignment_statement", NULL}; // ==================== SCALA ==================== static const char *scala_func_types[] = {"function_definition", "function_declaration", "lambda_expression", NULL}; static const char *scala_class_types[] = {"class_definition", "object_definition", "trait_definition", "enum_definition", "type_definition", NULL}; static const char *scala_module_types[] = {"compilation_unit", NULL}; static const char *scala_call_types[] = {"call_expression", "generic_function", "field_expression", "infix_expression", "instance_expression", NULL}; static const char *scala_import_types[] = {"import_declaration", "extends", "import", "using_directive", NULL}; static const char *scala_branch_types[] = { "if_expression", "for_expression", "while_expression", "match_expression", "case_clause", "try_expression", "catch_clause", NULL}; static const char *scala_var_types[] = {"val_definition", "var_definition", "val_declaration", "var_declaration", NULL}; static const char *scala_assign_types[] = {"assignment_expression", NULL}; static const char *scala_throw_types[] = {"throw_expression", NULL}; static const char *scala_decorator_types[] = {"annotation", NULL}; // ==================== KOTLIN ==================== static const char *kotlin_func_types[] = {"function_declaration", "secondary_constructor", "anonymous_function", NULL}; static const char *kotlin_class_types[] = {"class_declaration", "object_declaration", "companion_object", "type_alias", NULL}; static const char *kotlin_module_types[] = {"source_file", NULL}; static const char *kotlin_call_types[] = {"call_expression", "navigation_expression", NULL}; static const char *kotlin_import_types[] = {"import", NULL}; static const char *kotlin_branch_types[] = { "if_expression", "for_statement", "while_statement", "when_expression", "when_entry", "try_expression", "catch_block", NULL}; static const char *kotlin_var_types[] = {"property_declaration", NULL}; static const char *kotlin_assign_types[] = {"assignment", "directly_assignable_expression", NULL}; static const char *kotlin_throw_types[] = {"throw_expression", NULL}; static const char *kotlin_decorator_types[] = {"annotation", NULL}; // ==================== RUBY ==================== static const char *ruby_func_types[] = {"method", "singleton_method", NULL}; static const char *ruby_class_types[] = {"class", "module", NULL}; static const char *ruby_module_types[] = {"program", NULL}; static const char *ruby_call_types[] = {"call", "command_call", NULL}; static const char *ruby_import_types[] = {"call", NULL}; static const char *ruby_branch_types[] = {"if", "unless", "while", "until", "for", "case", "when", "rescue", "elsif", NULL}; static const char *ruby_var_types[] = {"assignment", NULL}; static const char *ruby_assign_types[] = {"assignment", "operator_assignment", NULL}; // ==================== C ==================== static const char *c_func_types[] = {"function_definition", NULL}; static const char *c_class_types[] = {"struct_specifier", "enum_specifier", "union_specifier", "type_definition", NULL}; static const char *c_field_types[] = {"field_declaration", NULL}; static const char *c_module_types[] = {"translation_unit", NULL}; static const char *c_call_types[] = {"call_expression", NULL}; static const char *c_import_types[] = {"preproc_include", NULL}; static const char *c_branch_types[] = {"if_statement", "for_statement", "while_statement", "do_statement", "switch_statement", "case_statement", NULL}; static const char *c_var_types[] = {"declaration", NULL}; static const char *c_assign_types[] = {"assignment_expression", NULL}; // ==================== BASH ==================== static const char *bash_func_types[] = {"function_definition", NULL}; static const char *bash_module_types[] = {"program", NULL}; static const char *bash_call_types[] = {"command", NULL}; static const char *bash_import_types[] = {"command", NULL}; static const char *bash_branch_types[] = {"if_statement", "while_statement", "for_statement", "case_statement", "elif_clause", NULL}; static const char *bash_var_types[] = {"variable_assignment", NULL}; // ==================== ZIG ==================== static const char *zig_func_types[] = {"function_declaration", "test_declaration", "function_signature", NULL}; static const char *zig_class_types[] = {"struct_declaration", "enum_declaration", "union_declaration", NULL}; static const char *zig_field_types[] = {"container_field", NULL}; static const char *zig_module_types[] = {"source_file", NULL}; static const char *zig_call_types[] = {"call_expression", "builtin_function", NULL}; static const char *zig_import_types[] = {"builtin_function", NULL}; static const char *zig_branch_types[] = {"if_statement", "for_statement", "while_statement", "switch_expression", NULL}; static const char *zig_var_types[] = {"variable_declaration", NULL}; static const char *zig_assign_types[] = {"assignment_expression", NULL}; // ==================== ELIXIR ==================== static const char *elixir_func_types[] = {"call", "anonymous_function", NULL}; static const char *elixir_module_types[] = {"source", NULL}; static const char *elixir_call_types[] = {"call", "dot", "binary_operator", NULL}; static const char *elixir_import_types[] = {"call", NULL}; static const char *elixir_branch_types[] = {"call", NULL}; static const char *elixir_var_types[] = {"binary_operator", NULL}; // ==================== HASKELL ==================== /* "bind" = a nullary value binding (`foo = 1`); has a `name` field like `function`. * `signature` (type annotations) is suppressed in cbm_resolve_func_name so it never doubles. */ static const char *haskell_func_types[] = {"function", "signature", "bind", NULL}; static const char *haskell_class_types[] = {"class", "data_type", "newtype", NULL}; static const char *haskell_module_types[] = {"haskell", NULL}; static const char *haskell_call_types[] = {"infix", "apply", NULL}; static const char *haskell_import_types[] = {"import", "instance", NULL}; static const char *haskell_branch_types[] = {"match", "guards", "if", "case", "do", "boolean", NULL}; static const char *haskell_var_types[] = {"function", NULL}; // ==================== OCAML ==================== static const char *ocaml_func_types[] = {"value_definition", "constructor_declaration", "method_definition", NULL}; static const char *ocaml_class_types[] = {"type_definition", "class_definition", "module_definition", "exception_definition", "record_declaration", NULL}; static const char *ocaml_module_types[] = {"compilation_unit", NULL}; static const char *ocaml_call_types[] = {"application_expression", "infix_expression", "method_invocation", "module_application", "new_expression", NULL}; static const char *ocaml_import_types[] = {"open_module", "include", NULL}; static const char *ocaml_branch_types[] = {"match_expression", "if_expression", "match_case", NULL}; static const char *ocaml_var_types[] = {"value_definition", NULL}; // ==================== OBJECTIVE-C ==================== static const char *objc_func_types[] = {"function_definition", "method_definition", "method_declaration", NULL}; static const char *objc_class_types[] = {"class_interface", "class_implementation", "protocol_declaration", "class_declaration", "enum_specifier", "struct_declaration", "struct_specifier", "type_definition", "union_specifier", NULL}; static const char *objc_field_types[] = {"property_declaration", NULL}; static const char *objc_module_types[] = {"translation_unit", NULL}; static const char *objc_call_types[] = {"call_expression", "message_expression", NULL}; static const char *objc_import_types[] = {"preproc_import", "preproc_include", NULL}; static const char *objc_branch_types[] = {"if_statement", "for_statement", "while_statement", "switch_statement", NULL}; static const char *objc_var_types[] = {"declaration", NULL}; static const char *objc_assign_types[] = {"assignment_expression", NULL}; // ==================== SWIFT ==================== static const char *swift_func_types[] = {"function_declaration", "macro_declaration", NULL}; static const char *swift_class_types[] = {"class_declaration", "protocol_declaration", "struct_declaration", "enum_declaration", NULL}; static const char *swift_field_types[] = {"property_declaration", NULL}; static const char *swift_module_types[] = {"source_file", NULL}; static const char *swift_call_types[] = {"call_expression", "constructor_expression", "macro_invocation", "navigation_expression", NULL}; static const char *swift_import_types[] = {"import_declaration", "import", NULL}; static const char *swift_branch_types[] = {"if_statement", "guard_statement", "for_statement", "while_statement", "switch_statement", NULL}; static const char *swift_var_types[] = {"property_declaration", NULL}; static const char *swift_assign_types[] = {"assignment", NULL}; static const char *swift_throw_types[] = {"throw_statement", NULL}; static const char *swift_decorator_types[] = {"attribute", NULL}; // ==================== DART ==================== static const char *dart_func_types[] = {"function_signature", "method_signature", "lambda_expression", NULL}; static const char *dart_class_types[] = {"class_definition", "enum_declaration", "mixin_declaration", "type_alias", NULL}; static const char *dart_field_types[] = {"declaration", NULL}; static const char *dart_module_types[] = {"program", NULL}; static const char *dart_call_types[] = {"selector", "new_expression", NULL}; static const char *dart_import_types[] = {"import_or_export", "extends", "import", NULL}; static const char *dart_branch_types[] = {"if_statement", "for_statement", "while_statement", "switch_statement", NULL}; static const char *dart_var_types[] = {"declaration", NULL}; static const char *dart_assign_types[] = {"assignment_expression", NULL}; static const char *dart_throw_types[] = {"throw_expression", NULL}; static const char *dart_decorator_types[] = {"annotation", NULL}; // ==================== PERL ==================== static const char *perl_func_types[] = {"subroutine_declaration_statement", NULL}; static const char *perl_module_types[] = {"source_file", NULL}; static const char *perl_call_types[] = {"ambiguous_function_call_expression", "function_call_expression", "func1op_call_expression", "method_call_expression", NULL}; static const char *perl_import_types[] = {"use_statement", "require_statement", "require", NULL}; static const char *perl_branch_types[] = {"if_statement", "unless_statement", "for_statement", "foreach_statement", "while_statement", NULL}; static const char *perl_var_types[] = {"variable_declaration", "expression_statement", NULL}; static const char *perl_assign_types[] = {"assignment_expression", NULL}; // ==================== GROOVY ==================== static const char *groovy_func_types[] = {"function_definition", "function_declaration", NULL}; static const char *groovy_class_types[] = {"class_definition", NULL}; static const char *groovy_module_types[] = {"source_file", NULL}; static const char *groovy_call_types[] = {"function_call", "juxt_function_call", NULL}; static const char *groovy_import_types[] = {"groovy_import", "extends", "import", NULL}; static const char *groovy_branch_types[] = {"if_statement", "for_statement", "while_statement", "switch_statement", NULL}; static const char *groovy_var_types[] = {"declaration", NULL}; static const char *groovy_assign_types[] = {"assignment", NULL}; static const char *groovy_throw_types[] = {"throw_statement", NULL}; static const char *groovy_decorator_types[] = {"annotation", NULL}; // ==================== ERLANG ==================== static const char *erlang_func_types[] = {"function_clause", NULL}; static const char *erlang_class_types[] = {"type_alias", NULL}; static const char *erlang_module_types[] = {"source_file", NULL}; static const char *erlang_call_types[] = {"call", NULL}; static const char *erlang_import_types[] = {"module_attribute", "import", "include", NULL}; static const char *erlang_branch_types[] = {"if_expression", "case_expression", "receive_expression", NULL}; static const char *erlang_var_types[] = {"pp_define", "record_decl", NULL}; static const char *erlang_assign_types[] = {"match_expression", NULL}; static const char *erlang_throw_types[] = {"call", NULL}; // ==================== R ==================== static const char *r_func_types[] = {"function_definition", NULL}; static const char *r_module_types[] = {"program", NULL}; static const char *r_call_types[] = {"call", NULL}; static const char *r_import_types[] = {"call", NULL}; static const char *r_branch_types[] = {"if_statement", "for_statement", "while_statement", NULL}; static const char *r_var_types[] = {"binary_operator", NULL}; // ==================== HTML ==================== static const char *html_module_types[] = {"document", NULL}; // ==================== CSS ==================== static const char *css_call_types[] = {"call_expression", NULL}; static const char *css_module_types[] = {"stylesheet", NULL}; static const char *css_import_types[] = {"import_statement", NULL}; // ==================== SCSS ==================== static const char *scss_func_types[] = {"mixin_statement", "function_statement", NULL}; static const char *scss_module_types[] = {"stylesheet", NULL}; static const char *scss_call_types[] = {"call_expression", "include_statement", NULL}; static const char *scss_import_types[] = {"import_statement", "use_statement", "include_statement", NULL}; static const char *scss_branch_types[] = {"if_statement", NULL}; static const char *scss_var_types[] = {"declaration", NULL}; // ==================== YAML ==================== static const char *yaml_module_types[] = {"stream", NULL}; static const char *yaml_var_types[] = {"block_mapping_pair", NULL}; // ==================== TOML ==================== static const char *toml_module_types[] = {"document", NULL}; static const char *toml_class_types[] = {"table", "table_array_element", NULL}; static const char *toml_var_types[] = {"pair", NULL}; // ==================== HCL ==================== static const char *hcl_class_types[] = {"block", NULL}; static const char *hcl_module_types[] = {"config_file", NULL}; static const char *hcl_call_types[] = {"function_call", NULL}; static const char *hcl_var_types[] = {"attribute", NULL}; // ==================== SQL ==================== static const char *sql_func_types[] = {"create_function", "function_declaration", NULL}; static const char *sql_field_types[] = {"column_definition", NULL}; static const char *sql_class_types[] = {"custom_type", NULL}; static const char *sql_module_types[] = {"program", NULL}; static const char *sql_call_types[] = {"function_call", "invocation", "command", NULL}; static const char *sql_branch_types[] = {"if_statement", "case_expression", NULL}; static const char *sql_var_types[] = {"create_table", "create_view", NULL}; // ==================== DOCKERFILE ==================== static const char *dockerfile_module_types[] = {"source_file", NULL}; static const char *dockerfile_var_types[] = {"env_instruction", "arg_instruction", NULL}; // ==================== ENV ACCESS ==================== static const char *go_env_funcs[] = {"os.Getenv", "os.LookupEnv", NULL}; static const char *py_env_funcs[] = {"os.getenv", "os.environ.get", NULL}; static const char *py_env_members[] = {"os.environ", NULL}; static const char *js_env_members[] = {"process.env", NULL}; static const char *ts_env_members[] = {"process.env", NULL}; static const char *rust_env_funcs[] = {"env::var", "std::env::var", NULL}; static const char *java_env_funcs[] = {"System.getenv", "System.getProperty", NULL}; static const char *cpp_env_funcs[] = {"getenv", "std::getenv", NULL}; static const char *cs_env_funcs[] = {"Environment.GetEnvironmentVariable", NULL}; static const char *php_env_funcs[] = {"getenv", "env", NULL}; static const char *lua_env_funcs[] = {"os.getenv", NULL}; static const char *scala_env_funcs[] = {"sys.env", "System.getenv", "System.getProperty", NULL}; static const char *kotlin_env_funcs[] = {"System.getenv", "System.getProperty", NULL}; static const char *ruby_env_members[] = {"ENV", NULL}; static const char *c_env_funcs[] = {"getenv", NULL}; static const char *zig_env_funcs[] = {"std.os.getenv", NULL}; static const char *elixir_env_funcs[] = {"System.get_env", NULL}; static const char *haskell_env_funcs[] = {"lookupEnv", "getEnv", NULL}; static const char *ocaml_env_funcs[] = {"Sys.getenv", NULL}; static const char *r_env_funcs[] = {"Sys.getenv", NULL}; static const char *perl_env_funcs[] = {"$ENV", NULL}; // ==================== CLOJURE ==================== /* Clojure def-forms (defn/def/...) are `list_lit` nodes; gating the actual * def-vs-call distinction happens in cbm_resolve_func_name (returns NULL for a * non-def list_lit such as a call), so non-def lists never push a SCOPE_FUNC. */ static const char *clojure_func_types[] = {"list_lit", NULL}; static const char *clojure_module_types[] = {"source", NULL}; static const char *clojure_call_types[] = {"list_lit", NULL}; // ==================== F# ==================== /* Top-level `let f () = ...` parses to function_or_value_defn (module-level * value_declaration is aliased to declaration_expression, which wraps it). The * name lives on a function_declaration_left/value_declaration_left child — see * the CBM_LANG_FSHARP branch in cbm_resolve_func_name. */ static const char *fsharp_func_types[] = {"function_declaration", "value_declaration", "function_or_value_defn", NULL}; static const char *fsharp_class_types[] = {"type_definition", "exception_definition", NULL}; static const char *fsharp_module_types[] = {"file", NULL}; static const char *fsharp_call_types[] = {"application_expression", "dot_expression", NULL}; static const char *fsharp_import_types[] = {"import_decl", "open_expression", "instance", NULL}; static const char *fsharp_branch_types[] = {"if_expression", "for_expression", "while_expression", "match_expression", "elif_expression", NULL}; static const char *fsharp_var_types[] = {"value_declaration", NULL}; // ==================== JULIA ==================== /* `assignment` covers Julia short-form `f(x) = body` (the grammar parses it as an * assignment with a call_expression LHS, not a short_function_definition). The * resolver names it only when the LHS is a call, so plain `x = 5` is not a def. */ static const char *julia_func_types[] = {"function_definition", "short_function_definition", "assignment", NULL}; static const char *julia_class_types[] = {"struct_definition", "abstract_definition", "primitive_definition", NULL}; static const char *julia_module_types[] = {"source_file", NULL}; static const char *julia_call_types[] = {"call_expression", "broadcast_call_expression", NULL}; static const char *julia_import_types[] = {"import_statement", "using_statement", "export_statement", "import", NULL}; static const char *julia_branch_types[] = {"if_statement", "for_statement", "while_statement", "try_statement", NULL}; static const char *julia_var_types[] = {"const_statement", "assignment", NULL}; static const char *julia_assign_types[] = {"assignment", "compound_assignment_expression", NULL}; static const char *julia_throw_types[] = {"throw_statement", NULL}; // ==================== VIM SCRIPT ==================== static const char *vim_func_types[] = {"function_definition", "function_declaration", "lambda_expression", NULL}; static const char *vim_import_types[] = {"include", NULL}; static const char *vim_module_types[] = {"script_file", NULL}; static const char *vim_call_types[] = {"call_expression", "call", "command", NULL}; static const char *vim_branch_types[] = {"if_statement", "for_statement", "while_statement", "try_statement", NULL}; static const char *vim_var_types[] = {"let_statement", NULL}; // ==================== NIX ==================== static const char *nix_func_types[] = {"function_expression", NULL}; static const char *nix_module_types[] = {"source_expression", NULL}; static const char *nix_call_types[] = {"apply_expression", NULL}; static const char *nix_branch_types[] = {"if_expression", NULL}; static const char *nix_var_types[] = {"binding", NULL}; // ==================== COMMON LISP ==================== static const char *commonlisp_func_types[] = {"defun", NULL}; static const char *commonlisp_import_types[] = {"with_clause", NULL}; static const char *commonlisp_module_types[] = {"source", NULL}; static const char *commonlisp_call_types[] = {"list_lit", NULL}; // ==================== ELM ==================== static const char *elm_func_types[] = {"value_declaration", "function_declaration", NULL}; static const char *elm_class_types[] = {"type_declaration", "type_alias_declaration", "module_declaration", NULL}; static const char *elm_module_types[] = {"file", NULL}; static const char *elm_call_types[] = {"function_call", "function_call_expr", NULL}; static const char *elm_import_types[] = {"import", NULL}; static const char *elm_branch_types[] = {"case_of_expr", "if_else_expr", NULL}; // ==================== FORTRAN ==================== /* subroutine/function wrap an inner *_statement that carries the `name` field; * function_statement was already present, subroutine_statement was missing. */ static const char *fortran_func_types[] = {"function", "subroutine", "function_statement", "subroutine_statement", NULL}; static const char *fortran_class_types[] = {"derived_type_definition", "enum_statement", NULL}; static const char *fortran_module_types[] = {"translation_unit", NULL}; static const char *fortran_call_types[] = {"call_expression", "keyword_argument", "call", NULL}; static const char *fortran_import_types[] = {"use_statement", "include_statement", "extends", "import", "import_statement", "include", "open_statement", "preproc_include", NULL}; static const char *fortran_branch_types[] = {"if_statement", "do_loop_statement", "where_statement", "select_case_statement", NULL}; static const char *fortran_var_types[] = {"variable_declaration", NULL}; static const char *fortran_assign_types[] = {"assignment_statement", NULL}; // ==================== CUDA ==================== // CUDA extends C++, reuse cpp types (same grammar family) // ==================== COBOL ==================== static const char *cobol_func_types[] = {"program_definition", NULL}; static const char *cobol_import_types[] = {"open_statement", "use_statement", "with_clause", NULL}; static const char *cobol_module_types[] = {"source_file", NULL}; static const char *cobol_call_types[] = {"call_statement", NULL}; static const char *cobol_branch_types[] = {"if_statement", "evaluate_statement", "perform_statement", NULL}; static const char *cobol_var_types[] = {"data_description_entry", NULL}; // ==================== VERILOG ==================== static const char *verilog_func_types[] = {"function_declaration", "task_declaration", "function_body_declaration", "function_statement", NULL}; static const char *verilog_class_types[] = {"module_declaration", "class_declaration", "interface_declaration", "package_declaration", "type_declaration", NULL}; static const char *verilog_import_types[] = {"extends", "import", "package_import_declaration", NULL}; static const char *verilog_module_types[] = {"source_file", NULL}; static const char *verilog_call_types[] = {"system_tf_call", "subroutine_call", "function_subroutine_call", "method_call", NULL}; static const char *verilog_branch_types[] = {"conditional_statement", "case_statement", "loop_statement", NULL}; static const char *verilog_var_types[] = {"net_declaration", "data_declaration", NULL}; static const char *verilog_assign_types[] = {"blocking_assignment", "nonblocking_assignment", NULL}; // ==================== EMACS LISP ==================== static const char *elisp_func_types[] = {"function_definition", "macro_definition", NULL}; static const char *elisp_module_types[] = {"source_file", NULL}; static const char *elisp_call_types[] = {"list", NULL}; // ==================== JSON ==================== static const char *json_module_types[] = {"document", NULL}; static const char *json_var_types[] = {"pair", NULL}; // ==================== XML ==================== static const char *xml_module_types[] = {"document", NULL}; static const char *xml_class_types[] = {"element", NULL}; // ==================== MARKDOWN ==================== static const char *markdown_module_types[] = {"document", NULL}; static const char *markdown_class_types[] = {"atx_heading", "setext_heading", NULL}; // ==================== MAKEFILE ==================== static const char *makefile_func_types[] = {"rule", "recipe", NULL}; static const char *makefile_module_types[] = {"makefile", NULL}; static const char *makefile_call_types[] = {"function_call", "call", "shell_function", NULL}; static const char *makefile_import_types[] = {"include_directive", "include", NULL}; static const char *makefile_var_types[] = {"variable_assignment", NULL}; // ==================== CMAKE ==================== static const char *cmake_func_types[] = {"function_def", "macro_def", NULL}; static const char *cmake_module_types[] = {"source_file", NULL}; static const char *cmake_call_types[] = {"normal_command", NULL}; // ==================== PROTOBUF ==================== static const char *protobuf_class_types[] = {"message", "enum", "service", NULL}; static const char *protobuf_func_types[] = {"rpc", NULL}; static const char *protobuf_module_types[] = {"source_file", NULL}; static const char *protobuf_field_types[] = {"field", "map_field", "oneof_field", NULL}; static const char *protobuf_import_types[] = {"import", NULL}; // ==================== GRAPHQL ==================== static const char *graphql_class_types[] = { "object_type_definition", "input_object_type_definition", "enum_type_definition", "interface_type_definition", "union_type_definition", "scalar_type_definition", "type_definition", NULL}; static const char *graphql_module_types[] = {"document", NULL}; static const char *graphql_field_types[] = {"field_definition", "input_value_definition", NULL}; // ==================== Embedded sub-languages ==================== // Host grammars (Svelte/Vue/HTML/Astro) treat