Commit graph

6536 commits

Author SHA1 Message Date
Will Lillis f430449ab9 fix(rust): address manual-readme lint
Some checks failed
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 16s
CI / check-wasm-stdlib (push) Failing after 15s
CI / checks (push) Has been cancelled
Cargo automatically resolves this, so the `Cargo.toml` entries are
redundant.
2026-09-04 14:48:46 -04:00
Will Lillis 068db86ca9 fix(rust): address new assert-is-empty nightly lint
The resulting code is arguably uglier, but there is a strong argument
for the improved message when the assert trips.
2026-09-04 14:48:46 -04:00
cui fliter ee0c20b1f5
fix(cli)!: fix query test capture range matching across lines (#5917)
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 14s
CI / build (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 15s
Signed-off-by: cuishuang <imcusg@gmail.com>
BREAKING CHANGE: changes the signature of `assert_expected_captures`, which is exposed publicly when tree-sitter-cli is consumed as a library.
2026-09-03 23:25:21 -04:00
dependabot[bot] 702ba49a6a build(deps): bump @humanfs/node in /crates/cli/eslint
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 15s
Bumps [@humanfs/node](https://github.com/humanwhocodes/humanfs/tree/HEAD/packages/node) from 0.16.7 to 0.16.8.
- [Release notes](https://github.com/humanwhocodes/humanfs/releases)
- [Changelog](https://github.com/humanwhocodes/humanfs/blob/main/packages/node/CHANGELOG.md)
- [Commits](https://github.com/humanwhocodes/humanfs/commits/node-v0.16.8/packages/node)

---
updated-dependencies:
- dependency-name: "@humanfs/node"
  dependency-version: 0.16.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 16:35:52 +02:00
dependabot[bot] b9c5eb2b73 build(deps): bump @humanfs/node in /lib/binding_web
Bumps [@humanfs/node](https://github.com/humanwhocodes/humanfs/tree/HEAD/packages/node) from 0.16.7 to 0.16.8.
- [Release notes](https://github.com/humanwhocodes/humanfs/releases)
- [Changelog](https://github.com/humanwhocodes/humanfs/blob/main/packages/node/CHANGELOG.md)
- [Commits](https://github.com/humanwhocodes/humanfs/commits/node-v0.16.8/packages/node)

---
updated-dependencies:
- dependency-name: "@humanfs/node"
  dependency-version: 0.16.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 16:35:42 +02:00
Yudai Takada 351bd71e52
fix(lib): decode UTF-16 surrogate pairs with input endianness (#5912)
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 15s
Problem: Parsing UTF-16BE source containing supplementary-plane characters, such as `let emoji = "😀"`, decoded the emoji as two isolated surrogates on little-endian hosts, causing incorrect lexer lookahead and potentially shifted token boundaries.

Soluton: Fix the trailing surrogate byte-order conversion in both UTF-16LE and UTF-16BE decoders and adds a regression test for U+1F600.
2026-09-03 08:21:08 +02:00
dependabot[bot] c206ad1e6a build(deps): bump the npm group across 1 directory with 3 updates
Some checks failed
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 16s
CI / check-wasm-stdlib (push) Failing after 15s
CI / checks (push) Has been cancelled
Bumps the npm group with 3 updates in the /lib/binding_web directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `@types/node` from 26.2.0 to 26.4.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.9.0 to 10.9.1
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.9.0...v10.9.1)

Updates `typescript-eslint` from 8.67.0 to 8.68.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.68.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.4.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
- dependency-name: eslint
  dependency-version: 10.9.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: typescript-eslint
  dependency-version: 8.68.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-31 23:52:08 +02:00
dependabot[bot] 51da0190f5 ci: bump vmactions/omnios-vm from 1.3.4 to 1.3.6 in the actions group
Bumps the actions group with 1 update: [vmactions/omnios-vm](https://github.com/vmactions/omnios-vm).


Updates `vmactions/omnios-vm` from 1.3.4 to 1.3.6
- [Release notes](https://github.com/vmactions/omnios-vm/releases)
- [Commits](https://github.com/vmactions/omnios-vm/compare/v1.3.4...v1.3.6)

---
updated-dependencies:
- dependency-name: vmactions/omnios-vm
  dependency-version: 1.3.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-31 23:51:47 +02:00
Amaan Qureshi e5cbeb74eb nix: fix the flake
Some checks failed
CI / checks (push) Waiting to run
CI / build (push) Failing after 16s
CI / sanitize (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 14s
Deploy Docs / deploy-docs (push) Has been cancelled
Check Wasm Exports / check-wasm-exports (push) Has been cancelled
2026-08-30 17:33:12 -04:00
Amaan Qureshi ea9ddbe190 docs: replace mdbook-admonish with mdBook admonitions 2026-08-30 17:33:12 -04:00
Will Lillis aa1b924997 fix(generate): defer token rewrites until lexical expansion
In a future feature, `RulePool` nodes can be shared between lexical and
syntax roots. No grammars generated by grammar.js/grammra.json are affected
by this issue, as they lead to a tree pool rather than a DAG.

With a DAG `RulePool` representation, however, rewriting tokens during
extraction can destroy a token body before lexical expansion consumes
it and can renumber shared syntax nodes more than once.

Record terminal rewrites while inspecting the original pool, expand tokens
and separators first, then commit the rewrites and renumber each reachable
syntax node once. Resolve grammar metadata against the pending rewrites
before mutating the pool.
2026-08-30 14:23:29 -04:00
Will Lillis 1b64a459ff perf(generate): flatten Choices directly into the children tail 2026-08-30 14:23:29 -04:00
Will Lillis 1e070eb28e perf(generate): build Seq and Repeat child ranges without temporaries
`try_seq` reserves a `Seq`'s child range up front and fills slots as
recursion produces each member. The `Repeat` arm builds
`Choice(repeat(x), blank)` directly, skipping the `choice` helper.

Slightly faster and less memory used.
2026-08-30 14:23:29 -04:00
Christian Clason 91e875ad7b chore: start working on v0.28 2026-08-30 19:50:28 +02:00
Arne Bertrand 6070dbfefd
fix(nix): remove Dockerfile reference from flake (#5892)
Fixup for https://github.com/tree-sitter/tree-sitter/pull/5872.
2026-08-30 16:49:12 +00:00
Christian Clason f52e78cb9f build(deps): cargo update
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 16s
CI / check-wasm-stdlib (push) Failing after 15s
2026-08-30 09:29:09 +02:00
Will Lillis 49dbf70ebd fix(rust): ensure C returned pointers are non-null in
`Node::grammar_name` and `Node::kind`
2026-08-30 02:58:20 -04:00
Will Lillis 9540ea3b10 fix(lib): reject an old_tree from a different language 2026-08-30 02:58:20 -04:00
Will Lillis 3e7be91c46 fix(rust): reject out-of-range node kind ids
`node_kind_is_named`, `node_kind_is_visible` and `node_kind_is_supertype`
forwarded their `u16` straight to `ts_language_symbol_type`, which indexes
`symbol_metadata` unchecked. Bound the id by `node_kind_count()`.
2026-08-30 02:58:20 -04:00
Will Lillis f47170927d fix(lib): bounds-check symbol and state ids in language lookups
`ts_language_next_state` indexed the parse table with the caller's `state`
and `symbol` without validating either, and `ts_language_subtypes` read
`symbol_metadata` before checking `supertype` was in range.
2026-08-30 02:58:20 -04:00
Will Lillis 5ddf71b9f4 fix(rust)!: expose QueryMatch::captures as a method
The field handed out a slice whose lifetime outlived the streaming-iterator
loan it came from. An accessor reborrowing through `&self` bounds it correctly.

BREAKING CHANGE: In the rust bindings, replace `m.captures` with `m.captures()`.
2026-08-30 02:58:20 -04:00
cuishuang efa0dd9a36 fix(cli): correct zero-based positions for --edits
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 16s
CI / check-wasm-stdlib (push) Failing after 15s
Signed-off-by: cuishuang <imcusg@gmail.com>
2026-08-29 21:06:30 -04:00
Christian Clason 16d5e9d227 ci(checks): add lint-toml step using taplo
Some checks failed
CI / checks (push) Waiting to run
CI / sanitize (push) Failing after 14s
CI / build (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 14s
Deploy Docs / deploy-docs (push) Has been cancelled
2026-08-29 11:10:37 +02:00
Will Lillis 3ac04a64f7 docs: add taplo instructions 2026-08-29 11:10:37 +02:00
Will Lillis d9cb739430 fix(toml): drop align_entries = true from .taplo.toml
This key was being applied inconsistently depending on nesting level.
2026-08-29 11:10:37 +02:00
Will Lillis 7a2dd61a7c fix(xtask): preserve format padding when updating Cargo.toml files 2026-08-29 11:10:37 +02:00
Christian Clason a520ad0fc3 chore: remove .dockerignore
Fixup for #5872, which missed the hidden file.
2026-08-29 10:30:35 +02:00
Christian Clason da219f40f8 chore: remove Zed editor config
Problem: Editor-specific settings should not be part of the global
repository. (Only config files that control standard tooling in order to
enforce, e.g., formatting policies are appropriate to commit -- and only
if covered by CI.)

Solution: Drop the Zed config files from the repo.
2026-08-29 10:30:35 +02:00
Christian Clason 664e9a6786 build(deps)!: bump wasi-sdk to v34
Some checks failed
CI / checks (push) Waiting to run
Deploy Docs / deploy-docs (push) Waiting to run
CI / sanitize (push) Failing after 15s
CI / build (push) Failing after 15s
CI / check-wasm-stdlib (push) Failing after 14s
Check Bindgen Output / check-bindgen (push) Has been cancelled
Check Wasm Exports / check-wasm-exports (push) Has been cancelled
Breaking change: LLVM 23 replaces `wasm32-wasi` target with
`wasm32-wasip1`, requiring updating the flags used by
`tree-sitter build --wasm`.
2026-08-27 10:35:19 +02:00
Christian Clason fcef970e81 build(deps): bump wasmtime-c-api to v48.0.1 2026-08-27 09:37:57 +02:00
Kyuhwan Lee 8933cb7b40 docs(web): add WASM version compatibility section
Add documentation about version compatibility requirements between
web-tree-sitter parser ABIs for WASM file generation.

This helps users understand why Language.load() might fail when using
pre-built WASM files from third-party packages that were built with
incompatible tree-sitter-cli versions.

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
2026-08-25 17:34:56 -04:00
Will Lillis 82639170a7 docs: specify Emscripten version constraints for web binding builds 2026-08-25 17:34:37 -04:00
dependabot[bot] 129d8cd141 build(deps): bump eslint
Bumps the npm group with 1 update in the /lib/binding_web directory: [eslint](https://github.com/eslint/eslint).


Updates `eslint` from 10.8.1 to 10.9.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.8.1...v10.9.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 10.9.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-25 09:59:01 +02:00
dependabot[bot] f3a9521894 build(deps): bump cc from 1.4.3 to 1.4.4 in the cargo group
Bumps the cargo group with 1 update: [cc](https://github.com/rust-lang/cc-rs).


Updates `cc` from 1.4.3 to 1.4.4
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.4.3...cc-v1.4.4)

---
updated-dependencies:
- dependency-name: cc
  dependency-version: 1.4.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-25 09:58:43 +02:00
Peter Stenger 0be5f898ad fix(web): map Node-only specifiers to false via browser field
Browser bundlers (esbuild, webpack, vite, rollup) statically discover the
`await import("fs/promises")` and `await import("module")` calls in the
shipped ESM bundle and try to resolve them, even though both sit in
Node-only branches that never execute in a browser.

Adding a top-level `browser` field tells bundlers to substitute empty
stubs for these specifiers when targeting the browser. The runtime gates
(`globalThis.process?.versions.node` and `ENVIRONMENT_IS_NODE`) already
prevent the stubs from ever being invoked.

Fixes #5545.
2026-08-25 00:27:50 -04:00
katrinafyi ac17c8d003 playground: set default LANGUAGE_BASE_URL to "." to fix subfolder hosting
Previously with the empty string base URL, the playground would not work when hosted at a subfolder of the domain. This is because playground.js has this code:

      const url = `${LANGUAGE_BASE_URL}/tree-sitter-${newLanguageName}.wasm`;

With an empty string, it would look for wasm at the root of the website and 404.

Github code search shows that this is an issue which lots of people have run into, and everyone has to work around it: https://github.com/search?q=%2FLANGUAGE_BASE_URL+%3D+%22%22%2F+-language%3AHTML&type=code

Related to https://www.github.com/tree-sitter/tree-sitter/issues/5230
2026-08-24 19:41:26 -04:00
Will Lillis c6c137a329 fix(generate): avoid mutating inherited reserved sets
Copy the base grammar's reserved set map before adding or replacing sets
in a derived grammar.
2026-08-23 17:08:31 -04:00
Will Lillis 1cb91662a5 fix(generate): validate symbol-only grammar fields
Require `word`, `conflicts`, `inline`, and `supertypes` callbacks
to return named grammar symbols instead of silently accepting values
that produce undefined names.

Restrict `precedences` lists to named rules and precedence names, and
preserve the existing handling of undefined and duplicate `inline`
rules.
2026-08-23 17:08:31 -04:00
Mike Arndt 7ca101cb7e fix(cli): align grammar DSL declarations with runtime
Model grammar() as returning the evaluated grammar beneath a `grammar`
property, with callbacks replaced by their normalized values and
runtime-initialized fields represented as required properties.

Correct the evaluated rule types for named precedences and regular
expression flags. Narrow symbol-only callbacks such as `conflicts`,
`inline`, `supertypes`, and `word`, and expose the inherited values
passed to `extras` and `reserved` callbacks.

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
2026-08-23 17:08:31 -04:00
Will Lillis dad7d0bd88 generate: use a single buffer for the string pool's backing store
This representation slightly lowers walltime and allocations, but also
makes `StrPool` `Send`.
2026-08-23 14:15:16 -04:00
Will Lillis f9dcb005cd fix(generate)!: use node identities in node-types bookkeeping
Some node-types bookkeeping still used the type name without its named
status. This caused anonymous nodes to inherit extra metadata from named
nodes with the same text, and could create false supertype cycles when a
named supertype and anonymous alias shared a name.

Key extra metadata and supertype dependencies by the complete
(type, named) identity.

Reject named aliases that collide with a canonical supertype. Such an
identity cannot be represented as both a concrete node and an abstract
supertype in node-types.json, and previously caused generation to panic.

All output entries now come from the map keyed by (type, named), so no
two entries can reach the final sort with the same identity. Remove the
unreachable root and extra tie-breakers and the now-redundant deduplication.

BREAKING CHANGE: Alters a public error enum for the generate crate.
2026-08-23 13:40:32 -04:00
Will Lillis 78267a0a96 fix(generate): merge anonymous token aliases in node-types.json
When an anonymous token alias and an anonymous syntax-node alias have
the same name, node-types.json emits two entries with the same type and
named status. For example,

```
alias($._node, "same")
```
and

```
alias("!", "same")
```

produce separate anonymous "same" entries. Add anonymous tokens to
the node-type map instead. When a token shares an identity with a
structured node, retain its possible children and fields but mark
them as optional because the token appearance is a leaf.
2026-08-23 13:40:32 -04:00
Will Lillis 00beb27f83 fix(generate): distinguish named and anonymous node types
A node-types entry is identified by both its type name and its `named`
value. The generator only keyed accumulated entries by name, so aliases
like

    alias($._node, $.same)
    alias($._node, "same")

were incorrectly merged into one entry. Whichever alias was processed
first determined the entry's `named` value, and the structures of two
distinct node types could be combined.

Key accumulated entries by `NodeTypeRef` so named and anonymous nodes
with the same type name remain separate.
2026-08-23 13:40:32 -04:00
Will Lillis 7bd12334c4 fix(generate): include aliased supertypes in node-types.json
Aliasing a supertype makes the aliased occurrence appear as a regular
node in the syntax tree. For example,

```
alias($.expression, $.expression_target)
```

can produce:

```
(expression_target (identifier))
```

Previously, node-types generation skipped the source supertype entirely.
It could reference `expression_target` as a field or child type without
emitting a corresponding top-level entry for it.

Continue emitting the canonical `expression` entry with its `subtypes`,
but pass aliased appearances through regular node generation so their
children and fields are recorded and merged normally.
2026-08-23 13:40:32 -04:00
Will Lillis 54a46eb49b fix(rust): remove must_use attribute from Tree::changed_ranges
`ExactSizeIterator` implements `std::iter::Iterator`, which is already
`must_use`.
2026-08-23 09:45:42 +02:00
Christian Clason 2452dc7a71 chore: remove Dockerfile
Problem: The committed Dockerfile is not used by the standard tooling in
this repo and therefore bitrots freely, which increases maintenance
burden on the (non-Docker-using) maintainers.

Solution: Drop the Dockerfile from the repo.
2026-08-23 00:35:12 -04:00
Amaan Qureshi 74b7d0c951 feat!: add an eof function
This commit adds an `eof()` function for grammars, which is easier to
use than the NUL byte directly. It compiles down to a constraint that
the enclosing production can only reduce at end of input, not to a
shiftable token.

BREAKING CHANGE: Public error types for `tree-sitter-generate` were modified.

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
2026-08-21 20:02:58 -04:00
Will Lillis baad4174e5 fix(generate)!: hold IoError inside GenerateError::GrammarPath 2026-08-20 22:11:42 -04:00
Will Lillis cde84508ac fix(generate)!: error when nonexistent _file_ path is passed to
`generate_parser_in_directory`.
2026-08-20 22:11:42 -04:00
Max Brunsfeld 43623ec9bf
Upgrade to latest wasmtime, improve robustness and perf of wasm-based parsing (#5847)
* build(deps): upgrade wasmtime C API to 48.0.0

Upgrade the Rust and Zig Wasmtime dependencies and enable reference values with the null GC collector.

Wasmtime 48 requires a newer Rust toolchain, whose Clippy version identifies three item helpers that can be const. Mark them const so the workspace continues to pass Clippy with warnings denied.

* feat(benchmark): support Wasm grammars

* perf(wasm): cache language function handles

* fix(wasm): improve validation and failure cleanup

Bounds-check dylink metadata parsing, require exact import and export names, and restore memory and function-table allocation offsets when language loading fails.

* fix(wasm): copy the complete supertype map
2026-08-20 21:02:11 +00:00