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

Function grammar_for

codegraph-kernel/src/langs.rs:50–108  ·  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.4's src/ (#3212), the sources the vendored wasm is
75 // built from (table identity by construction; see grammars.ts),
76 // compiled in build.rs with the same scanner patch.
77 "swift" => {
78 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_swift) }.into())
79 }
80 // R7b: fwcd main@d6af96d (#3410), vendored C compiled in build.rs
81 // (no crate carries it).
82 "kotlin" => {
83 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_kotlin) }.into())
84 }
85 // R7b batch 4: crate =1.2.0, sha-identical to the r-lib v1.2.0 tag
86 // the vendored wasm was built from (r checklist §Grammar prep).
87 "r" => Some(tree_sitter_r::LANGUAGE.into()),
88 // R7b batch 4: v0.4.1 vendored C compiled in build.rs (revision not
89 // on crates.io — the wasm is the v0.4.1 tag, table-identical).
90 "lua" => {
91 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_lua) }.into())
92 }
93 // R7b batch 4: crate =1.2.0, sha-identical to the v1.2.0 tag the
94 // vendored wasm was built from (lua-luau checklist §Grammar prep).
95 "luau" => Some(tree_sitter_luau::LANGUAGE.into()),
96 // R7b batch 4: vendored C compiled in build.rs, now the v0.26.2
97 // release (#1823), kept byte-identical with the vendored wasm.
98 "scala" => {
99 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_scala) }.into())
100 }
101 // UserNobody14 0038280 vendored C compiled in build.rs, the sources
102 // the vendored wasm is built from (#3270).
103 "dart" => {
104 Some(unsafe { tree_sitter_language::LanguageFn::from_raw(tree_sitter_dart) }.into())
105 }
106 _ => None,
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