Skip to content

feat(treesitter): add native C runtime and 18-grammar compilation bridge - #143

Merged
HarshK97 merged 6 commits into
mainfrom
feat/native-treesitter-c-runtime
Sep 6, 2026
Merged

feat(treesitter): add native C runtime and 18-grammar compilation bridge#143
HarshK97 merged 6 commits into
mainfrom
feat/native-treesitter-c-runtime

Conversation

@HarshK97

@HarshK97 HarshK97 commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Problem

  1. As much as I loved gotreesitter, when Parsing is your bottleneck instead of your algorithm, then it's a problem. Pure Go parsing was dominating runtime on larger files and eating up too much memory.

What Changed

  • Added a native C99 flat-buffer bridge (native/bridge/src/bridge.c, native/bridge/include/bridge.h) that parses source code and traverses the Tree-sitter CST directly in C, returning a contiguous flat array to Go in a single call.
  • Added native/bridge/build_grammars.go to fetch, configure, and compile Tree-sitter core and all 18 supported grammars in parallel into a single static libdiffmantic_grammars.a.
  • Added native/bridge/src/registry.c to map language identifiers to their native grammar entry points.
  • Added native/bridge/grammars.json to lock upstream Tree-sitter and grammar releases to explicit tags.
  • Configured Renovate (.github/renovate.json5) with a regex manager to track upstream grammar releases, replacing Dependabot.
  • Added grammar compilation caching in .github/workflows/ci.yml and added the grammars-native target to Makefile.

- Vendor modern Tree-sitter C runtime header and Go build tool (build_grammars.go)
- Support parallel static compilation of 18 native grammars into libdiffmantic_grammars.a
- Add Renovate configuration and GitHub Actions caching for native grammars
- Replace Dependabot with Renovate for automated grammar version bumps
golangci-lint fmt walks ./... on the filesystem regardless of .gitignore.
The grammars-native build step clones vendored grammar repos into
native/bridge/grammars/ before the fmt step runs, so their Go example
files were getting caught and failing the format diff check.

Add --exclude-dirs native/bridge/grammars to skip those cloned files.
@HarshK97
HarshK97 force-pushed the feat/native-treesitter-c-runtime branch 3 times, most recently from c2d6d04 to f3fc744 Compare September 6, 2026 13:59
In golangci-lint v2, linters and formatters have separate exclusion
blocks. Added linters.exclusions.paths and formatters.exclusions.paths
to skip native/bridge/grammars, which is populated at build time by
cloning vendored grammar repos and is not tracked by git.
@HarshK97
HarshK97 force-pushed the feat/native-treesitter-c-runtime branch from f3fc744 to 7629e4a Compare September 6, 2026 14:04
@HarshK97
HarshK97 merged commit d76cfe4 into main Sep 6, 2026
16 checks passed
@HarshK97
HarshK97 deleted the feat/native-treesitter-c-runtime branch September 6, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant