Skip to content

Constrain the deferred declaration path to a dotted name#2

Merged
yavorpanayotov merged 1 commit into
masterfrom
deferred-path-grammar
Jun 12, 2026
Merged

Constrain the deferred declaration path to a dotted name#2
yavorpanayotov merged 1 commit into
masterfrom
deferred-path-grammar

Conversation

@yavorpanayotov

Copy link
Copy Markdown
Collaborator

Sibling change to juxt/allium-tools#39 (issue juxt/allium-tools#24): the deferred declaration path is now a dotted name with an optional use-alias qualifier and an optional quoted location hint, mirroring the reference parser.

What changes

deferred_declaration previously read its path as $._expression, so calls (deferred Foo("x")), comparisons, and parenthesised forms parsed as deferred paths, and the qualified form billing/InvoiceWorkflow parsed as a division expression. It now reads:

deferred_declaration: ($) =>
  seq("deferred", field("path", $.deferred_path), optional(field("hint", $.string_literal))),

deferred_path: ($) =>
  seq($.identifier, optional(seq("/", $.identifier)), repeat(seq(".", $.identifier))),

The quoted location hint (deferred Foo.bar "detailed/foo.allium") is part of the grammar per the decision on juxt/allium-tools#24, exposed as the hint field.

Known divergence from the reference parser: allium-tools requires the path and hint to sit on one line (its line guards prevent a dangling . or / from absorbing the next declaration's keyword); newlines are extras in this grammar, so that constraint is not enforced here.

Node shape change: a dotted path is now (deferred_path (identifier) (identifier)) instead of (member_expression ...). The bundled highlight queries don't reference deferred paths, so no query changes are needed. (Noticed in passing: deferred, open, contract, and invariant are absent from the @keyword list in highlights.scm — pre-existing, left for a separate change.)

Verification

  • npx tree-sitter generate is clean; generated src/ committed per repo convention.
  • npx tree-sitter test: 98/98 corpus parses pass — the dotted-path expectation updated to the new shape, plus new cases for the qualified path, the quoted hint, and an :error test for an expression-shaped path.
  • Smoke-parsed the documented forms from the v3 language reference (dotted + -- see: comment, qualified, quoted hint) — all produce the expected trees.

🤖 Generated with Claude Code

deferred_declaration read its path as $._expression, so calls,
comparisons, and parenthesised forms parsed as deferred paths, and the
qualified form billing/InvoiceWorkflow parsed as division. The
reference parser constrained the path in juxt/allium-tools#24
(juxt/allium-tools#39); this mirrors that grammar:

  deferred_path: identifier ('/' identifier)? ('.' identifier)*

with an optional trailing string_literal location hint
(`deferred Foo.bar "detailed/foo.allium"`), now part of the grammar
on both sides.

Known divergence from the reference parser: the path and hint are
required to sit on one line there, which this grammar does not
enforce (newlines are extras).

Corpus: dotted-path expectation updated to the new node shape; new
cases for the qualified path, the quoted hint, and an :error test for
an expression-shaped path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yavorpanayotov yavorpanayotov merged commit ed17704 into master Jun 12, 2026
@yavorpanayotov yavorpanayotov deleted the deferred-path-grammar branch June 12, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant