mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
Parse-item identity dominates parse-table construction. `ParseItem`'s `Hash`, `Eq`, and `Ord` walk the entire production on every call, comparing per-step precedence, aliases, and field names. These are stored as strings for named precedences and for every alias and field. Precompute, once per table build, two dense `u32` ids for every `(production, dot)` slot by ranking the whole slot universe with the item-content comparator, now extracted as `ItemContent`. Equal-content slots are adjacent after sorting and the id increments only at content boundaries, so comparing the `cmp` id reproduces the structural order exactly (both an ordering and an equality). A second id, `eq_with_syms`, refines `cmp` by the preceding symbols, which enter equality only for items with `has_preceding_inherited_fields`. `ParseItem` now carries its production's key slice, and `Hash`/`Eq`/`Ord` become integer ops. On the current string-based production storage this is performance-neutral in isolation (the up-front ranking pays back the per-comparison savings). It is the foundation for the following change to a pooled, integer-keyed production representation, which makes both the ranking and the item comparisons cheaper integer work. |
||
|---|---|---|
| .cargo | ||
| .github | ||
| .zed | ||
| crates | ||
| docs | ||
| lib | ||
| test/fixtures | ||
| .dockerignore | ||
| .editorconfig | ||
| .envrc | ||
| .gitattributes | ||
| .gitignore | ||
| .taplo.toml | ||
| build.zig | ||
| build.zig.zon | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CMakeLists.txt | ||
| CONTRIBUTING.md | ||
| Dockerfile | ||
| flake.lock | ||
| flake.nix | ||
| FUNDING.json | ||
| LICENSE | ||
| Makefile | ||
| Package.swift | ||
| README.md | ||
tree-sitter
Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited. Tree-sitter aims to be:
- General enough to parse any programming language
- Fast enough to parse on every keystroke in a text editor
- Robust enough to provide useful results even in the presence of syntax errors
- Dependency-free so that the runtime library (which is written in pure C) can be embedded in any application