Skip to content

gotreesitter v0.59.0

Latest

Choose a tag to compare

@github-actions github-actions released this 01 Dec 19:56
· 27 commits to main since this release
8c3ce04

Highlights

  • All 206 of 206 built-in grammars now parse by default through ccore, the
    C-faithful parser core (up from 34 in v0.58.0, covering 50/50 top-50, 100/100
    top-100, and 30/30 Tier 1 grammars), with 206/206 incremental reuse,
    141/206 included-range parsing, 163/206 error-tree incremental reuse,
    and 11/206 native ambiguity forest parsing.
  • Runtime, query, and Swift throughput improved across multiple passes: core
    optimizations cut Go full-parse latency by 16.13% (#1860), 13.79%
    (#1906), and 29.23% (#1907) and single-byte incremental edit latency by
    27.27% (#1906) and 7.18% (#1907); routing public queries and highlighters
    through internal/query cut latency by 4.04× geomean and Highlight
    allocations by 6,145× (92,172 → 15, #1863); Swift 0.7.4 on ccore cut a
    27 KB SplitArgumentTests.swift parse from 4.95 s (HasError=true) on
    v0.58.0 to 3.7 ms (HasError=false) and an ~824-file Swift repo from
    6m 00s to 1.09 s (#1859, #1877, #1915).
  • Retired the frozen compact scheduler (#1858, deleting 165,918 lines across
    594 files including 172 root Go files) and moved 20 upstream-blocked grammars
    to canonical in-repo Go DSL ownership built by grammargen
    (internal/tablebuild, #1911–#1914), bringing owned grammars to 24.

Upgrade notes

  • Certified default trees across all 206 grammars: Trees for the 172 newly
    certified grammars can change where v0.58.0's legacy engine differed from
    the C tree-sitter runtime, particularly on syntax errors and included
    ranges; they now match C. Registry helpers (LangEntry.Parse, ParseContext,
    ParseStrict, grammars.ParseFile, ParseFilePooled,
    LangEntry.NewHighlighter, and ParseIncrementalWithTokenSource with
    registered factories) also route through ccore by default, including C, C++,
    Java, and Authzed via the table-v1 scan provider (#1730, #1787). To keep
    the legacy engine for one parser, call parser.SetAdmissionCandidateRoute(false)
    (takes effect on the next parse; ClearAdmissionCandidateRoute() restores the
    default).
  • Go grammar and GoExternalScanner: Go now ships tables built from
    upstream tree-sitter-go (2346a3ab: 1,442 states, 214 symbols) via
    internal/tablebuild and parses through ccore by default (#1816).
    GoExternalScanner is no longer registered for the default Go blob and serves
    only the frozen artifact in internal/frozengo.
  • Swift 0.7.4 grammar and highlight query: Swift is pinned to
    alex-pinkus/tree-sitter-swift 0.7.4 (171fa3bc: 11,522 states, 567 symbols,
    222 tokens) and parses through ccore by default (#1859). The 0.7.4 grammar
    adds unsafe expressions, copy, and fixed-size array types ([3 of Int]),
    allows spaces or tabs before closing /# in multiline regex literals, drops
    the "nil" token (update custom queries to use (nil_literal)), reports
    parse errors on incomplete inputs like let x = and let x = 1 + to match
    C, and serializes C's 4-byte scanner checkpoint instead of the old 9-byte
    format. The bundled highlight query is now upstream's queries/highlights.scm,
    which renames captures such as @function → @function.call /
    @function.method, @property → @variable.member, @string.regex →
    @string.regexp, and adds @boolean, @keyword.conditional,
    @keyword.repeat, @keyword.return, @keyword.import, and
    @keyword.modifier.
  • Nginx scanner checkpoint format: Nginx scanner serialization changed from
    the old 2-byte format to match pinned C; callers that persisted Nginx scanner
    snapshots must reparse source to regenerate them (#1837).
  • Query match order, captures, work budgets, and SetValues: Public
    Query, QueryCursor, and Highlighter now execute through internal/query
    (#1863): queries return each contiguous sibling
    run, emit matches in completion order, drop matches whose captures are covered
    by longer matches, and apply explicit work budgets to the whole cursor run on
    eligible trees. QueryMatch.SetValues now returns the last #set! directive
    for a key when set more than once instead of the first (#1764).
  • Parse stops, work limits, and changed ranges: On certified routes, early
    parse stops (deadline, cancellation, progress callback stop, memory budget,
    hard memory ceiling, conversion depth, or SetParseWorkLimits iteration/node
    limits) now return an empty stopped ERROR tree (HasError() == true,
    ParseStoppedEarly() == true, original ParseStopReason()) instead of
    falling back to the legacy engine (#1877). DiffChangedRanges on legacy-engine
    trees now reports only the span between unchanged leading and trailing
    children instead of the full parent (#1812); ParseIncremental and
    Tree.ChangedRanges documentation now notes that certified core trees share
    no *Node with their old tree and carry no recorded edits on the new tree.
  • Compact scheduler retirement: internal/parsercorephase0/, the
    "candidate" ledger route, compact-scheduler build tags
    (gts_parsercorephase0), and 59 deprecated compact-scheduler diagnostic and
    table-analysis symbols are removed (#1858). Non-deprecated admission switch
    APIs and counters remain as fail-closed stubs until v1.0.
  • Planned API removals for v1.0: The following APIs remain available in
    v0.59.0 (served or bridged on ccore) and are scheduled for removal in v1.0
    (see docs/roadmap.md):
    SetGLRTrace (use SetLogger / SetProgressCallback), SetAmbiguityProfile
    (moving to internal/diag), ParseForestExperimental (forest parsing stays
    internal to ccore), ParseWorkLimits.StackDepthLimit (use memory,
    iteration, or node limits), and GOT_PARSE_PROGRESS (replaced by
    Parser.SetProgressCallback).

Added

  • Add internal/query, a pure-Go tree-sitter query compiler,
    parse-table pattern analyzer, and zero-alloc ccore.NodeReader cursor, wired
    behind public Query, QueryCursor, and Highlighter (#1856, #1863).
  • Add Parser.SetProgressCallback on both ccore and legacy routes, reporting
    byte offset and error state and returning the cancelled parse result when the
    callback stops the parse (#1840).
  • Serve parse stops, SetParseWorkLimits (iteration and node limits),
    SetLogger, and observers directly on ccore for certified grammars (#1827,
    #1877).
  • Add certified included-range parsing (Ranges, now 141/206 grammars),
    error-tree incremental reuse (ErrReuse, now 163/206 grammars), native
    ambiguity forest parsing (Forest, 11/206 grammars), table-v1 scan
    providers for registry token-source routes (authzed, c, cpp, java),
    and the opt-in single-line length-changing leaf shortcut
    (ShortcutTokenStableLength / Parser.SetLengthShortcut, #1730, #1739,
    #1747, #1758, #1820, #1823, #1910).
  • Add internal/tablebuild, a pure-Go tree-sitter table
    generator (prepared grammar, LR(1) construction, state merging, and lexer
    tables), and move 20 upstream-blocked grammars to canonical Go DSL ownership
    alongside Go and Swift (#1772, #1773, #1777, #1778, #1782, #1790,
    #1816, #1859, #1911, #1912, #1913, #1914).
  • Add the CI-checked 206-grammar status dashboard (cmd/grammardashboard,
    docs/grammar-dashboard.md), the 79/79 C recovery parity ratchet
    (TestParityRecoveryBoard), route reachability goldens
    (roottest/admission/testdata/route_reachability.golden), ts2go blob
    freshness checks, and perfcounterledger -stale (#1785, #1792, #1814,
    #1857).
  • Add grep.CompilePattern per-grammar snippet contexts (e.g. Go wraps patterns
    in package p; func f() { $$ } so call patterns such as fmt.Println($X)
    match calls; grammars without a context parse the bare pattern as before,
    #1816).
  • Add opt-in ECMAScript constructor call facts, declaration header ranges,
    heritage expressions and ranges, source ranges for Python and ECMAScript
    import items, and local named export items for JavaScript and TypeScript
    (#1712, #1713, #1741, #1742, 865c658e).

Changed

  • Serve the remaining 172 built-in grammars through ccore by default,
    bringing certified coverage from 34 to 206 of 206 (50/50 top-50, 100/100
    top-100, 30/30 Tier 1; 206/206 parser_parse served by core; 118/118 external
    scanners registered and bound). Newly certified grammars by pull request:
    • TSX #1689;
    • Ada, Bass, Common Lisp, Emacs Lisp (elisp), Embedded Template, Faust, and HTML #1714;
    • EditorConfig, Haxe, Janet, Odin, Pkl, and QL #1716;
    • Chatito, CUE, DTD, Meson, and Puppet #1720;
    • Cylc, Kconfig, Org, and TableGen #1723;
    • Bash, HCL, Lua, and OCaml #1727;
    • Java #1766, JavaScript #1770, C++ and Less #1774, YAML #1775, C# #1776, PHP #1779, Fortran and Markdown #1783, Dart #1786, and Go #1816;
    • Julia, Nix, PowerShell, SCSS, SQL, and XML #1828;
    • Scala #1835, CMake, Haskell, Svelte, and Vue #1836, Nginx and Nim #1837, GLSL, Jinja2, LLVM IR, and Verilog #1839, Git Rebase, Prisma, Scheme, and Twig #1850, MATLAB #1851, Gleam and Racket #1852, Perl #1854, and Swift #1859;
    • D, GDScript, Gitignore, Luau, and Starlark #1862;
    • CUDA, HLSL, VHDL, and WGSL #1869;
    • Angular, Astro, Crystal, PureScript, and Regex #1879, Bicep and CSV #1880, AWK, Comment, Elm, JSDoc, and Markdown Inline #1886, Doxygen #1894, JSON5 #1898, and Facility #1903;
    • Apex, Assembly (asm), Authzed, BrightScript, Circom, Corn, CPON, EDS, and EEx #1861;
    • Elsa, Enforce, FIDL, Forth, Gitattributes, Hare, and Hyprlang #1865;
    • Ledger, Linker Script, Mermaid, Pascal, PEM, Prolog, PromQL, and Rego #1872;
    • Smithy, SPARQL, Thrift, Tmux, Turtle, V, Vimdoc, and WAT #1867;
    • Agda, Arduino, Djot, Just, KDL, Mojo, Norg, and RON #1891;
    • Beancount, BitBake, Blade, Caddy, Cairo, Cooklang, and Dhall #1873;
    • Fennel, FIRRTL, Foam, Godot Resource, and Hack #1874;
    • Move, Nushell, and ReScript #1882;
    • Tcl, Teal, Templ, TLA+, Typst, Wolfram, and Yuck #1878;
    • Ninja #1908 and Pug #1909;
    • Owned Go DSL cohorts: HEEx, HTTP, Liquid, and Robot #1911; Fish, F#, Hurl, and jq #1912; COBOL, Disassembly, Earthfile, Jsonnet, Nickel, and reStructuredText (rst) #1913; DOT, GN, Properties, Requirements, Squirrel, and Uxntal #1914.
  • Route C registry helpers (LangEntry.Parse, ParseContext, ParseStrict,
    grammars.ParseFile, ParseFilePooled, LangEntry.NewHighlighter, and
    ParseIncrementalWithTokenSource with the registered factory) through ccore
    using the table-v1 scan provider, and count declined registry requests with
    their reason in the route counters (#1787).
  • Expand Ranges (to 141/206 grammars) and ErrReuse (to 163/206 grammars)
    across top-50 and long-tail grammars, including Haskell, JSON, TSX, Java, C#,
    PHP, Bash, Python, Ruby, YAML, GDScript, TypeScript, Swift, D, and C (#1842,
    #1868, #1870, #1871, #1875, #1876, #1881, #1883, #1884, #1887,
    #1889, #1890, #1892, #1896, #1897, #1899, #1901, #1902, #1904).
  • Retire the compact scheduler (internal/parsercorephase0/), removing 165,918
    lines across 594 files (172 root Go files; rootBudget tightened from 621 to
    449), and relocate 29 admission and parse test files to roottest/ (#1762,
    #1763, #1858).
  • Optimize internal/ccore memory layout, table lookup, lexing, and incremental
    reuse across four passes: shrink stack nodes from 224 B to 48 B with flat
    tables and inline single-head reductions (#1860), grow publish stacks on demand
    and use allocation-log mark clearing in findMultiWalk (#1900), specialize
    prepared action/goto lookups and in-place repeat reductions (#1906), and add
    bounded 768 KiB flat parse tables with pre-decoded ActionEntry fast kinds
    (#1907); also reduce view-edit conversion and summary-walk overhead (#1765,
    #1767, b1334ed9).
  • Upgrade Swift to alex-pinkus/tree-sitter-swift 0.7.4 (171fa3bc) with
    upstream queries/highlights.scm, bump F# to b576ecf7ced0, ship yaml-core
    tables for YAML, and build Go from upstream tree-sitter-go (2346a3ab) with
    internal/tablebuild (#1769, #1775, #1816, #1859).
  • Split CI into a light PR tier and a heavy nightly/release tier
    (ci [tier: heavy]) with split matrix guard, build, and vet jobs (#1771,
    #1802, #1826).

Fixed

  • Accept trailing non-ASCII Unicode whitespace skipped by the grammar and extend
    root spans to the end of parsed input (#1885, closes #1866).
  • Narrow DiffChangedRanges on legacy-engine trees to the span between
    unchanged leading and trailing children (pasting a 42-byte function into a
    20 KB Go file dropped from 20,346 bytes reported to 91 bytes) and use ccore
    for public syntax changed ranges (#1744, #1812).
  • Make QueryMatch.SetValues last-wins for repeated #set! keys, compile
    quote-led query groups as siblings, return every alternation match in C order,
    decode escaped \? punctuation tokens in the core query adapter, and route
    ranged queries on materialized core trees through internal/query (#1734,
    #1753, #1764, #1882).
  • Keep table flattening in bounds, align missing-token placement in excluded
    ranges, honor end tokens and adjacent boundaries in included ranges, and
    preserve lookahead on ordinary EOF reductions in repairNoLookaheadLexModes
    (#1888, #1895, #1903).
  • Accept complete final Go type, var, and const declarations without a
    trailing newline through the grammar file APIs (#1855).
  • Keep a bare & as JSX text in both TSX and JavaScript scanners (#1709,
    #1797).
  • Align Go external scanner ports with pinned C and eliminate hangs, crashes,
    and state or race defects across the fleet (including COBOL, Disassembly,
    Earthfile, Jsonnet, Nickel, reStructuredText, Fish, F#, Hurl, jq, Pug,
    Properties, ReScript, Nginx, Nim, Scala, PHP, SQL, C++, C#, Less, D, and
    earlier scanner waves; #1715, #1717, #1725, #1728, #1729,
    #1731, #1746, #1750, #1756, #1757, #1835, #1837,
    #1882, #1909, #1912, #1913).
  • Fix ts2go end-of-input lexer edges and NUL token names, preserve lexer
    metadata when incremental reuse sidecars grow, count bytes in shared lexer
    cursor columns, exclude impossible patterns from inferred tag queries, and
    keep selected trailing trivia in deferred result roots (#1710, #1740,
    #1748, #1751, #1785, #1793).

Evidence

  • Certification records and route reachability at candidate base b7d45f4e5:
    testdata/ccore_certificates.json (206/206 built-in grammars certified),
    roottest/admission/testdata/route_reachability.golden (206/206 parser_parse
    served by core; 4,162 core / 884 legacy / 310 skip across 26 entry points),
    and docs/grammar-dashboard.md (cmd/grammardashboard -check enforced in CI).
  • Raw graduation gate logs, 200,000-call scandiff runs, and 20-seed paired
    benchstat archives are published on the
    evidence release,
    including the public query/highlighter routing benchmark
    (query-public-routing-bench-e1e99b870.tar.gz)
    and the internal/ccore optimization passes (#1860, #1906, #1907).
  • Recovery parity is ratcheted in CI at 79 of 79 matching trees and
    79 of 79 HasError agreement with the C reference runtime (TestParityRecoveryBoard,
    #1857); knownCOracleDifferences dropped from 20 to 9.
  • The exact candidate ci [tier: heavy] run and randomized release benchmark
    receipt are recorded with the release receipt at publication time.