odvcencio/gotreesitter: Pure Go tree-sitter runtime
GoTreeSitter: Pure Go Tree-Sitter Runtime Achieves 90x Faster Incremental Parsing
Breaking News: Developers now have a pure Go tree-sitter runtime that eliminates CGo dependencies and delivers 90x faster incremental parsing than the standard CGo binding. This revolutionary approach makes tree-sitter parsing accessible across all Go targets, including WASM and embedded systems.
The Problem with CGo Dependencies
Every existing Go tree-sitter binding requires CGo, creating significant pain points:
- Cross-compilation breaks on WASI, ARM64, and Windows without MSYS2
- CI pipelines need C toolchains in every build image
go installfails for users without GCC- Race detector and fuzzing tools work poorly across CGo boundaries
Pure Go Solution
gotreesitter is pure Go—simply go get github.com/odvcencio/gotreesitter and build on any target, any platform. The implementation uses the same parse-table format as tree-sitter, so existing grammars work without recompilation.
Performance Breakthrough
The incremental hot path reuses subtrees aggressively—a single-byte edit reparses in microseconds while the CGo binding pays full C-runtime and call overhead. The no-edit fast path exits on a single nil-check: zero allocations, single-digit nanoseconds.
Benchmark Summary:
- Full parse: 1,330 μs vs 2,058 μs (1.5x faster)
- Incremental (single-byte edit): 1.38 μs vs 124 μs (90x faster)
- Incremental (no-op reparse): 8.6 ns vs 121 μs (14,000x faster)
Complete Language Support
205 grammars ship in the registry, with:
- 204 full grammars parsing without errors
- 1 partial (
norg) requiring external scanner - 195 DFA-based implementations
- 9 token_source hand-written bridges
Languages include Go, Python, JavaScript, Rust, Java, C/C++, TypeScript, HTML, CSS, and many more.
Feature-Rich Implementation
The runtime includes:
- Parser with GLR support for ambiguous grammars
- Incremental reuse with cursor-based subtree reuse
- Arena allocator with slab-based node allocation
- DFA lexer with hand-written bridges where needed
- External scanner VM for language-specific scanning
- Query engine with S-expression pattern matching
- Highlighter for syntax highlighting
- Tagger for symbol definition/reference extraction
Production-Ready
As of February 2026, all shipped highlight and tags queries compile successfully. The test suite includes smoke tests, correctness snapshots, highlight validation, query tests, parser tests, and fuzzing for robustness.
Getting Started
go
import (
“fmt”
“github.com/odvcencio/gotreesitter”
“github.com/odvcencio/gotreesitter/grammars”
)
func main() {
src := []byte(package main func main() {})
lang := grammars.GoLanguage()
parser := gotreesitter.NewParser(lang)
tree := parser.Parse(src)
fmt.Println(tree.RootNode())
}
Why This Matters
This pure Go implementation democratizes tree-sitter parsing across the Go ecosystem. Developers can now use advanced syntax analysis in WebAssembly applications, embedded systems, and cross-platform tools without the complexity and limitations of CGo.
The performance gains—especially in incremental parsing scenarios common in editors and language servers—make gotreesitter not just a drop-in replacement but a significant upgrade over existing solutions.
Ready to transform your Go parsing capabilities? Install gotreesitter today and experience the future of tree-sitter in pure Go.
Tags: #Go #TreeSitter #Parsing #Performance #WASM #Editor #LanguageServer #OpenSource #GoLang #SyntaxHighlighting #IncrementalParsing #CrossPlatform
Viral Phrases: “90x faster incremental parsing,” “pure Go tree-sitter runtime,” “eliminates CGo dependencies,” “14,000x faster no-op reparse,” “democratizes syntax analysis,” “revolutionary performance breakthrough,” “game-changing Go implementation,” “future of tree-sitter in pure Go,” “cross-platform parsing revolution,” “WASM-ready syntax analysis”
,



Leave a Reply
Want to join the discussion?Feel free to contribute!