feat(kernel): R7a C/C++ walker — dual-lang ccpp module, preParse hoist, 7 new blanks, c/cpp default-routed (#1346)
Parity: 0 diffs on redis/git/fmt/protobuf/ALS sweeps; full-init dumps byte-identical on all five + linux at kernel scale (10.4M dump lines, same sha256 both arms). Linux 2c/6GB envelope: kernel-arm 19.1min vs wasm-arm 22.9min (parse 356s vs 435s) on a much richer graph (the new blanks recover error-swallowed code: git 2x nodes, linux kernel/+mm/ 3x). Deferral guard corrected by measurement (C/C++ error incidence 9-42%; --max-deferral flag); defer-reuse memo kills the 3x re-blank/re-parse cost deferred files paid. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
44561b6aad
commit
2d72891b59
@@ -1,3 +1,5 @@
|
||||
target/
|
||||
# Cross-compile scratch dirs (e.g. target-linux for the cg1212 envelope runs)
|
||||
target-*/
|
||||
prebuilds/
|
||||
*.node
|
||||
|
||||
Generated
+22
@@ -52,6 +52,8 @@ dependencies = [
|
||||
"regex",
|
||||
"sha2",
|
||||
"tree-sitter",
|
||||
"tree-sitter-c",
|
||||
"tree-sitter-cpp",
|
||||
"tree-sitter-go",
|
||||
"tree-sitter-java",
|
||||
"tree-sitter-javascript",
|
||||
@@ -482,6 +484,26 @@ dependencies = [
|
||||
"tree-sitter-language",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-c"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9b2eb57a55fed6b00812912e730b7a275cf4fe98bfd6a5d76263d4438371728"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter-language",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-cpp"
|
||||
version = "0.23.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df2196ea9d47b4ab4a31b9297eaa5a5d19a0b121dceb9f118f6790ad0ab94743"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter-language",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-go"
|
||||
version = "0.23.4"
|
||||
|
||||
@@ -25,6 +25,11 @@ tree-sitter-javascript = "0.25"
|
||||
tree-sitter-java = "0.23"
|
||||
tree-sitter-python = "0.23"
|
||||
tree-sitter-go = "0.23"
|
||||
# Pinned exact: the vendored wasm (src/extraction/wasm/) was built from these
|
||||
# tags' checked-in parser.c, sha-matched against these registry tarballs
|
||||
# (R7a prep, #1345). A patch bump here without re-vendoring breaks the match.
|
||||
tree-sitter-c = "=0.24.2"
|
||||
tree-sitter-cpp = "=0.23.4"
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = "2"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@ use tree_sitter::Language;
|
||||
|
||||
/// Languages this kernel binary can extract (reported by contractInfo;
|
||||
/// TS-side routing policy decides what actually routes).
|
||||
pub const LANGUAGES: [&str; 7] =
|
||||
["typescript", "tsx", "javascript", "jsx", "java", "python", "go"];
|
||||
pub const LANGUAGES: [&str; 9] =
|
||||
["typescript", "tsx", "javascript", "jsx", "java", "python", "go", "c", "cpp"];
|
||||
|
||||
pub fn grammar_for(language: &str) -> Option<Language> {
|
||||
match language {
|
||||
@@ -26,6 +26,11 @@ pub fn grammar_for(language: &str) -> Option<Language> {
|
||||
"java" => Some(tree_sitter_java::LANGUAGE.into()),
|
||||
"python" => Some(tree_sitter_python::LANGUAGE.into()),
|
||||
"go" => Some(tree_sitter_go::LANGUAGE.into()),
|
||||
// `.metal`/`.cu`/`.cuh` map to language 'cpp' at detectLanguage, so the
|
||||
// dialects ride this grammar too (their blanking pre-passes stay
|
||||
// TS-side — the route point applies preParse before the kernel call).
|
||||
"c" => Some(tree_sitter_c::LANGUAGE.into()),
|
||||
"cpp" => Some(tree_sitter_cpp::LANGUAGE.into()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#![deny(clippy::all)]
|
||||
|
||||
mod buffers;
|
||||
mod ccpp;
|
||||
mod docstring;
|
||||
mod ids;
|
||||
mod go;
|
||||
@@ -103,6 +104,7 @@ pub fn extract_file(file_path: String, content: String, language: String) -> Res
|
||||
"java" => java::extract(&file_path, &content).map_err(Error::from_reason)?,
|
||||
"python" => python::extract(&file_path, &content).map_err(Error::from_reason)?,
|
||||
"go" => go::extract(&file_path, &content).map_err(Error::from_reason)?,
|
||||
"c" | "cpp" => ccpp::extract(&file_path, &content, &language).map_err(Error::from_reason)?,
|
||||
_ => tsjs::extract(&file_path, &content, &language).map_err(Error::from_reason)?,
|
||||
};
|
||||
Ok(ExtractBuffers {
|
||||
|
||||
Reference in New Issue
Block a user