Issue #520: Build ADR-296 D25: pub grammar - a package offers its grammar’s entries

Open and answer this issue on GitHub.

blocked · opened 2026-10-07 · updated 2026-10-07 · 1 comment

Split out of #485, which waits on it. There was no issue for it.

What is decided (ADR-296 D25). pub belongs to the grammar. pub grammar G offers every entry rule of G to other packages, the way a pub enum offers its variants. A rule is never pub on its own: pub rule is refused, and the message names both words. No entry is distinguished.

Today. The parser refuses pub grammar with decided and not built (parser/mod.rs, around line 2398). So no package can offer a grammar, and dsl pkg::Sql { … } eod (ADR-299 D20, #485) has nothing to resolve to.

To build

  1. Parser: accept pub grammar, and refuse pub rule with both words named (if that is not done already).
  2. Ledger: a pub grammar’s entries are recorded as the package’s entries (G::rule, as a grammar call is keyed, ADR-296 D24), with their signatures. So a consumer resolves pkg::G::rule(…), and a dsl pkg::G { … }.
  3. Lowering: the package’s crate exports the grammar’s entry functions, and a consumer’s call reaches them.
  4. #485’s remaining steps: dsl pkg::G resolves to the pub grammar. NK1228’s help lists the package’s pub grammars. A package with two grammars has each reachable by its own path.

Tests: a path package declares pub grammar Num { entry rule n -> i64 = … }, and a consumer calls pkg::Num::n("42") and prints 42. A non-pub grammar is NK1110 (private). pub rule is refused.

Comments

keywan-ghadami, 2026-10-07

Steps 1-3 built in 0.0.618 (67a67a4).

Left:

  1. A par_fold entry across packages, which needs parse_…_pieces and the parallelism. The ledger does not say an entry is a fold, so such a call would be lowered as a sequential parse and refused by rustc. It needs a column, or the dependency’s units.
  2. Step 4, dsl lib::G { … }: a dsl block over a grammar is not lowered at all yet, its own or a package’s. That is #518, so it waits there.

Generated by Claude Code

Back to Open Issues