tree-sitter-<lang> crates. Grammars change over time and need periodic updates — both for bug fixes
and to keep up with new syntax.
Kotlin is not tree-sitter-backed — it uses an ANTLR grammar. To regenerate the Kotlin parser,
see Add a new language → Adding an ANTLR-backed language and
cargo xtask antlr generate kotlin, not the tree-sitter flow below.Currently pinned tree-sitter grammars
Each grammar is inline-pinned in its owningcrates/mehen-<lang>/Cargo.toml — the analyzer crate
is the single source of truth. xtask never pins a grammar itself; the kind-enum generator reaches
each grammar through the analyzer crate’s __grammar_language() accessor (a path dependency), so the
codegen and the runtime parser always link the exact same revision. Bumping the pin in the analyzer’s
Cargo.toml is therefore enough — there is no second [workspace.dependencies] line to keep in sync.
PowerShell is tree-sitter-backed but has no generated
grammar.rs and is not an xtask
codegen target. mehen-powershell matches node kinds by their string names against
tree_sitter_pwsh::LANGUAGE at runtime, so bumping tree-sitter-pwsh needs no kind-enum
regeneration — only C and Go do.grammar.rs and need no kind-enum regeneration.
(Kotlin and Java are ANTLR-backed — see the note above; SQL uses sqruff and Markdown uses
pulldown-cmark.)
Update process
1
Bump the pin
Update the single inline pin in the owning
crates/mehen-<lang>/Cargo.toml:xtask picks up the new revision automatically through the mehen-<lang> path dependency, so
there is no separate xtask/Cargo.toml or [workspace.dependencies] line to bump.2
Regenerate kind enums
grammar.rs (C and Go) from the pinned grammar’s
node-kind table. CI runs cargo xtask tree-sitter check-generated to ensure pinned-grammar
bumps without a regenerate are caught at PR time. (PowerShell has no grammar.rs, so bumping
tree-sitter-pwsh skips this step.)3
Fix breakage
New node kinds may appear (and need handling), and existing node kinds may be renamed or
restructured. Update analyzer code accordingly.
4
Run validation
5
Open a PR
Commit the updated
Cargo.toml, Cargo.lock, and any regenerated grammar.rs files.Automation
Dependabot raises grammar bump PRs automatically. Theregenerate-grammars workflow detects those
PRs (branch name contains tree-sitter) and runs cargo xtask tree-sitter generate --all plus the
test suite, then commits the regenerated files back to the PR branch. Reviewers should still verify
analyzer code still handles any renamed kinds.