Skip to content

`tree-sitter-bynk`

The tree-sitter grammar for Bynk. It is the source of truth for structural tooling — syntax highlighting (the playground’s live editor, and any editor that speaks tree-sitter). The static documentation site highlights its code blocks separately, via Expressive Code / Shiki from the editor’s TextMate grammar.

PathWhat it is
grammar.jsThe grammar definition — the file you edit.
src/parser.c, src/scanner.cGenerated parser plus a hand-written external scanner (for --- … --- doc blocks).
src/grammar.json, src/node-types.jsonGenerated grammar metadata.
queries/highlights.scmHighlight queries (the highlight groups).
queries/injections.scmLanguage-injection queries (currently none).
test/corpus/Versioned parse-tree test cases.

The generated files in src/ are committed. The book’s grammar reference is generated from src/grammar.json.

With the tree-sitter CLI:

Terminal window
npm install # once
npm run build # tree-sitter generate → regenerates src/
npm test # tree-sitter test → runs the corpus

After editing grammar.js, run npm run build to regenerate the parser, then npm test to check it against the corpus. A corpus case is a named section: the source, a --- separator, and the expected S-expression parse tree.

highlights.scm maps grammar nodes to standard highlight groups — @keyword (and @keyword.declaration, .import, .modifier, .operator), @type, @type.builtin, @string, @number, @comment, @function, @variable, @operator, @punctuation.*, and more. These groups drive the editor (VS Code via vscode-bynk) and the playground’s wasm tree-sitter highlighter, so interactive highlighting stays correct as the grammar evolves. The static documentation site highlights ```bynk blocks separately, via Expressive Code / Shiki from the editor’s TextMate grammar, so it is not driven by these tree-sitter highlight groups.

grammar.js is regenerated to src/ via tree-sitter generate; commit the generated files together with the grammar change so downstream consumers (the editors and the playground’s highlighter) stay consistent.