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

Function grammar_for

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

Source from the content-addressed store, hash-verified

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

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
extractFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85
extractFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected