Issue #485: Decide: how a dsl block names a grammar that comes from a package

Open and answer this issue on GitHub.

language, blocked · opened 2026-10-06 · updated 2026-10-07 · 5 comments

Moved from docs/open-decisions.md, which is being retired: open questions for the owner are now issues labelled decision.

What the feature is. A dsl NAME { … } eod block hands its text to a grammar, which parses it while the program is built. A grammar can come from a package: a database driver brings the SQL grammar (ADR-299 D1, Part II 10.5).

Today. ADR-299 D1 says dsl sqlite { … } eod names the grammar of the sqlite package. That works there because the package and the grammar have the same name. Nothing says what a program writes when they differ, for example a package nikaia_sql with a grammar mysql, or a package with two grammars. Part I 9.2 says a name from a package is reached through the package’s name, but the qualified spelling does not parse (probed on 0.0.541):

error: Expected `from` or `{` here, but found `:`.
 4 |     let q = dsl nikaia_sql::mysql {

(An earlier version of Part II 10.5 wrote use nikaia_sql and then dsl mysql; the page now uses sqlite, so the example no longer shows the problem, but the rule is still missing.)

Why it is the owner’s. It is the spelling every program with a DSL from a package writes.

Options

  1. dsl package::grammar, as every other name from a package is written.
  2. A package’s grammar is named bare, and the package’s name is its grammar’s name where it has one.
  3. use brings the grammar’s name in, the one exception to 9.2.

Recommendation: 1. It is 9.2’s rule without an exception, and dsl sqlite can remain the short form when package and grammar share a name. Costs if wrong: option 1 wrong means a longer line; option 3 wrong means the exception 9.2 was written to avoid.

To build after the decision: the parser accepts the chosen spelling; ADR-299 D1 and Part II 10.5 state it; a test with a package whose grammar has a different name.

Comments

keywan-ghadami, 2026-10-06

Decided (owner): option 1, and no short form

What was checked first: the qualified spelling still does not parse today (error: Expected \from` or `{` here, but found `:` at dsl nikaia_sql::mysql {`).

Options presented:

Rule: ADR-299 D20, Part II 10.5, NK1228.

To build

  1. Parser:
    • dsl takes a path, NAME (:: NAME)*, before the optional build-time arguments, -> T and {.
    • Remove the from-or-{ expectation’s wording for ::.
  2. Resolution:
    • A single name resolves to a grammar the program declares.
    • package::Grammar resolves to a pub grammar of a used package.
    • A single name that is a package is NK1228, with a help listing that package’s pub grammars (dsl sqlite::Sql).
  3. Tests:
    • A local grammar Json used as dsl Json { … } eod still works.
    • A path package with pub grammar Sql used as dsl pkg::Sql { … } eod works.
    • dsl pkg { … } eod is NK1228, naming pkg::Sql.
    • A package with two grammars: each reachable by its own path.
  4. Corpus:
    • examples/fortunes.nika’s dsl postgres becomes dsl postgres::Sql.
    • Update the sources in crates/nikaia/tests/refusals.rs and stored_views.rs that write dsl postgres.

Generated by Claude Code

keywan-ghadami, 2026-10-06

Taking the build (session 01DGERcXMpRWbGxPuAFEzp6E).


Generated by Claude Code

keywan-ghadami, 2026-10-06

Built as far as today’s compiler goes: 0.0.582 (ff43698)

What can’t be built yet, and why:

A question for the specification (decision, not mine)

Part III’s inline-assembly example (30-nikaia-tooling.md, block #13) writes:

use std::backend::x86
…
    dsl x86 { … } eod

Under D20, x86 is a module there, so the block is now NK1228. tests/specification/EXPECTED.txt records exactly that change. The example was not rewritten with the sqlite ones.

What is the x86 grammar’s name? dsl x86::Asm, for example. Once a name is chosen the page needs that one line, and the baseline goes back to its old refusal.

I’m leaving the issue open for pub grammar’s half and this question. It stays ready for the first part, which is waiting on ADR-296 D25 being built.


Generated by Claude Code

keywan-ghadami, 2026-10-06

Decided (owner): dsl x86::Asm.

Part III’s inline-assembly example now writes dsl x86::Asm { … } eod, and ADR-296’s sentence follows (0.0.594). The block in tests/specification/EXPECTED.txt is back to its old refusal, without NK1228.

What remains is build work: a package’s pub grammar (ADR-296 D25), resolution to it, the help listing a package’s grammars, and the two-grammar test. Back to ready.


Generated by Claude Code

keywan-ghadami, 2026-10-07

Set to blocked on #520. Everything left here (resolution to a package’s pub grammar, the help listing its grammars, the two-grammar test) needs pub grammar, which is decided (ADR-296 D25) and not built. It had no issue of its own until now, so #520 is it. That also makes #485’s remaining steps its step 4.


Generated by Claude Code

Back to Open Issues