MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / grammar_for

Function grammar_for

codegraph-kernel/src/langs.rs:50–107  ·  view source on GitHub ↗
(language: &str)

Source from the content-addressed store, hash-verified

48];
49
50pub fn grammar_for(language: &str) -> Option<Language> {
51 match language {
52 "typescript" => Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()),
53 "tsx" => Some(tree_sitter_typescript::LANGUAGE_TSX.into()),
54 "javascript" | "jsx" => Some(tree_sitter_javascript::LANGUAGE.into()),
55 "java" => Some(tree_sitter_java::LANGUAGE.into()),
56 "python" => Some(tree_sitter_python::LANGUAGE.into()),
57 "go" => Some(tree_sitter_go::LANGUAGE.into()),
58 // `.metal`/`.cu`/`.cuh` map to language 'cpp' at detectLanguage, so the
59 // dialects ride this grammar too (their blanking pre-passes stay
60 // TS-side — the route point applies preParse before the kernel call).
61 "c" => Some(tree_sitter_c::LANGUAGE.into()),
62 "cpp" => Some(tree_sitter_cpp::LANGUAGE.into()),
63 // R7b: v0.24.2, sha-matched with the vendored wasm (grammars.ts).
64 "rust" => Some(tree_sitter_rust::LANGUAGE.into()),
65 // R7b: 0.23.5, table-identical to the vendored ABI-15 wasm (#717;
66 // verified against the crates.io tarball — csharp checklist header).
67 "csharp" => Some(tree_sitter_c_sharp::LANGUAGE.into()),
68 // R7b: v0.23.1, sha-matched with the vendored wasm (grammars.ts).
69 // Content bump only — the tag's parser.c is still ABI 14.
70 "ruby" => Some(tree_sitter_ruby::LANGUAGE.into()),
71 // R7b: v0.24.2, the full HTML-interleaving variant — LANGUAGE_PHP,
72 // NEVER LANGUAGE_PHP_ONLY (which errors on leading HTML).
73 "php" => Some(tree_sitter_php::LANGUAGE_PHP.into()),
74 // R7b: crate 0.7.3's src/, the sources the vendored wasm is built
75 // from (table identity by construction; see grammars.ts), compiled in
76 // build.rs with the scanner's `try!` fix (`1ULL << FAKE_TRY_BANG`).
77 "swift" => {
78 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_swift) }.into())
79 }
80 // R7b: fwcd 0.3.8, vendored C compiled in build.rs (crate unusable).
81 "kotlin" => {
82 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_kotlin) }.into())
83 }
84 // R7b batch 4: crate =1.2.0, sha-identical to the r-lib v1.2.0 tag
85 // the vendored wasm was built from (r checklist §Grammar prep).
86 "r" => Some(tree_sitter_r::LANGUAGE.into()),
87 // R7b batch 4: v0.4.1 vendored C compiled in build.rs (revision not
88 // on crates.io — the wasm is the v0.4.1 tag, table-identical).
89 "lua" => {
90 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_lua) }.into())
91 }
92 // R7b batch 4: crate =1.2.0, sha-identical to the v1.2.0 tag the
93 // vendored wasm was built from (lua-luau checklist §Grammar prep).
94 "luau" => Some(tree_sitter_luau::LANGUAGE.into()),
95 // R7b batch 4: vendored C compiled in build.rs, now the v0.26.2
96 // release (#1823), kept byte-identical with the vendored wasm.
97 "scala" => {
98 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_scala) }.into())
99 }
100 // R7b batch 4: UserNobody14 d4d8f3e vendored C compiled in build.rs
101 // (same commit as the byte-copied tree-sitter-wasms 0.1.13 artifact).
102 "dart" => {
103 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_dart) }.into())
104 }
105 _ => None,
106 }
107}

Callers 15

extractFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85
grammar_infoFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85

Calls

no outgoing calls