From 44b4d81cd1ba49a035e66699416639b46723c872 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 01:31:16 -0300 Subject: library: a dependent package names its languages: `.languages = "rust"` (or a list) replaces the `.grammars` tier with the languages named and what each needs, the manifest's new `needs` field (markdown brings markdown_inline; no other grammar needs one: a fence's language is coloured when it is in the build), so a browser reader builds one module per language; a name the manifest does not have, or `.grammars` beside `.languages`, ends the configure with exit 1 and the names it has (Zig only logs an option it cannot read in a dependency and builds on with exit 0); build.zig exports `grammar_manifest` for a consumer's build script to loop over at configure time; build/core.zig treeSitter takes a set (`GrammarSet`, `tierSet`) and syntax.zig knows the set by the queries the build gave (`@hasDecl(ts_queries, ...)`), not by the tier; test/consumer loops over the manifest (`each-language`, 26/26: each language alone is in its build, linked by its symbol, and no other is), `test` runs rust and markdown of it and a configure with `klingon` that fails saying so Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/syntax.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'core/syntax.zig') diff --git a/core/syntax.zig b/core/syntax.zig index 00ee497f..1bb8fb52 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -37,11 +37,10 @@ const Spec = struct { capture_styles: [256]u8 = undefined, }; +/// A grammar is in the build when the build gave its queries (build/core.zig +/// `treeSitter`): a tier's set, or the languages a package named. fn grammarSelected(comptime g: grammar_manifest.Grammar) bool { - return switch (g.tier) { - .minimal => minimal_grammars, - .full => full_grammars, - }; + return @hasDecl(ts_queries, g.name ++ "_highlights"); } fn specCount() comptime_int { -- cgit v1.3