Tree-sitter, a fast incremental code parsing generator, has significantly improved the R developer experience through an R grammar file created by Davis Vaughan. This grammar powers a growing ecosystem of tools including: Air (code formatter in Rust), Jarl (linter/fixer), Ark (R kernel for Positron IDE enabling autocompletion and hover help), improved GitHub code search for R, the {treesitter} R package for programmatic code analysis, ast-grep via {astgrepr} and {flir} for code refactoring, {muttest} for mutation testing, and difftastic for structural code diffing. The post explains what code parsing and parse trees are, demonstrates both base R parsing and Tree-sitter parsing of the same code snippet, and outlines why Rust CLIs built on Tree-sitter are often more practical than R packages for certain use cases.
Table of contents
Code parsing: what is Tree-sitter?Browsing code interactively: Positron IDE, GitHubSearching/browsing codeFormatting and linting: Air, JarlMore toolsConclusion: more to come?Sort: