Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the quivers library are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).

## [0.14.1] - 2026-07-01

### Fixed

- **v0.11.0 -> v0.14.0 grammar migration hop.** The `CHAIN` in `src/quivers/cli/migrations/__init__.py` now includes `"v0.14.0"`, with the accompanying hop module `v0_11_0_to_v0_14_0.py` and a matching entry in `MIGRATORS` and `COVERAGE`. `qvr migrate --from v0.11.0 --to v0.14.0` composes cleanly; `qvr migrate --check` reports `added_rules: family_call_arg, list_arg` and `uncovered_removed: []` for the pair. The hop is byte-identity: v0.14.0 adds two productions (`family_call_arg`, `list_arg`) to the `_draw_arg` choice as strict grammar extensions, so every source that parses under v0.11.0 also parses under v0.14.0. The `grammars/qvr/vcs/parsers/v0.14.0/` tree-sitter parser snapshot and the panproto VCS object store under `grammars/qvr/vcs/.panproto/` are rebuilt via `python grammars/qvr/vcs/build_schemas.py --reset` and `python grammars/qvr/vcs/build_parsers.py`.

## [0.14.0] - 2026-06-30

### Added
Expand Down
15 changes: 8 additions & 7 deletions grammars/qvr/vcs/.panproto/logs/HEAD
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{"old_id":[80,52,28,145,9,13,70,212,22,181,103,52,28,14,11,39,175,221,51,74,66,78,119,17,4,41,128,239,46,143,169,98],"new_id":[119,44,179,139,157,52,145,150,151,134,15,189,88,114,231,29,82,212,185,140,62,207,75,48,1,167,23,45,141,135,111,158],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322433,"message":"commit: qvr grammar at v0.3.0"}
{"old_id":[119,44,179,139,157,52,145,150,151,134,15,189,88,114,231,29,82,212,185,140,62,207,75,48,1,167,23,45,141,135,111,158],"new_id":[252,28,154,191,193,167,133,235,207,17,194,65,151,118,197,141,237,231,69,104,5,193,215,217,251,98,158,33,65,95,211,238],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.4.0"}
{"old_id":[252,28,154,191,193,167,133,235,207,17,194,65,151,118,197,141,237,231,69,104,5,193,215,217,251,98,158,33,65,95,211,238],"new_id":[174,167,90,49,153,49,250,40,214,102,203,33,170,153,172,149,46,171,140,189,174,85,16,170,4,201,220,1,12,186,224,176],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.5.0"}
{"old_id":[174,167,90,49,153,49,250,40,214,102,203,33,170,153,172,149,46,171,140,189,174,85,16,170,4,201,220,1,12,186,224,176],"new_id":[48,153,25,12,224,217,52,173,16,50,208,170,19,220,22,196,155,251,251,67,31,71,14,237,138,94,88,134,112,155,3,246],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.6.0"}
{"old_id":[48,153,25,12,224,217,52,173,16,50,208,170,19,220,22,196,155,251,251,67,31,71,14,237,138,94,88,134,112,155,3,246],"new_id":[140,164,20,211,1,142,49,168,167,37,175,32,68,55,203,6,57,0,44,126,249,169,71,17,147,87,247,135,1,51,207,11],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.7.0"}
{"old_id":[140,164,20,211,1,142,49,168,167,37,175,32,68,55,203,6,57,0,44,126,249,169,71,17,147,87,247,135,1,51,207,11],"new_id":[192,122,146,9,146,79,135,152,21,76,145,53,100,142,209,95,107,142,203,24,26,156,107,54,206,179,166,5,190,162,62,113],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.9.0"}
{"old_id":[192,122,146,9,146,79,135,152,21,76,145,53,100,142,209,95,107,142,203,24,26,156,107,54,206,179,166,5,190,162,62,113],"new_id":[13,67,197,192,1,108,138,76,41,205,26,83,168,49,21,226,65,63,228,107,237,184,107,0,30,63,16,26,41,62,224,140],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.11.0"}
{"old_id":[179,49,38,17,240,96,62,99,164,0,255,172,96,118,13,183,18,180,113,97,71,188,56,7,193,206,239,176,78,102,226,21],"new_id":[36,155,136,38,221,81,91,44,4,232,217,208,108,69,117,83,205,14,206,176,173,4,194,203,91,239,136,20,208,42,220,46],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.3.0"}
{"old_id":[36,155,136,38,221,81,91,44,4,232,217,208,108,69,117,83,205,14,206,176,173,4,194,203,91,239,136,20,208,42,220,46],"new_id":[195,37,110,44,21,27,181,132,82,81,122,211,239,181,108,31,175,175,235,198,173,227,98,7,70,176,209,96,4,245,128,12],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.4.0"}
{"old_id":[195,37,110,44,21,27,181,132,82,81,122,211,239,181,108,31,175,175,235,198,173,227,98,7,70,176,209,96,4,245,128,12],"new_id":[87,255,29,80,41,203,190,169,99,171,22,137,200,120,230,90,113,107,82,244,202,148,76,79,148,189,164,77,132,255,193,84],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.5.0"}
{"old_id":[87,255,29,80,41,203,190,169,99,171,22,137,200,120,230,90,113,107,82,244,202,148,76,79,148,189,164,77,132,255,193,84],"new_id":[123,116,127,50,242,4,161,222,107,21,135,179,236,11,179,67,250,243,135,200,5,103,248,107,78,127,224,25,39,247,171,9],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.6.0"}
{"old_id":[123,116,127,50,242,4,161,222,107,21,135,179,236,11,179,67,250,243,135,200,5,103,248,107,78,127,224,25,39,247,171,9],"new_id":[62,20,116,43,239,116,33,124,72,247,75,53,49,102,253,144,77,62,201,135,46,29,89,188,229,24,91,211,195,118,122,56],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.7.0"}
{"old_id":[62,20,116,43,239,116,33,124,72,247,75,53,49,102,253,144,77,62,201,135,46,29,89,188,229,24,91,211,195,118,122,56],"new_id":[113,179,14,161,186,251,75,109,120,149,84,81,114,223,133,26,221,15,24,15,128,45,247,218,191,0,255,81,92,49,30,39],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.9.0"}
{"old_id":[113,179,14,161,186,251,75,109,120,149,84,81,114,223,133,26,221,15,24,15,128,45,247,218,191,0,255,81,92,49,30,39],"new_id":[179,212,148,249,169,134,88,155,202,39,222,113,119,181,74,83,220,244,40,208,215,47,182,46,191,203,93,31,40,248,225,68],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.11.0"}
{"old_id":[179,212,148,249,169,134,88,155,202,39,222,113,119,181,74,83,220,244,40,208,215,47,182,46,191,203,93,31,40,248,225,68],"new_id":[155,124,108,121,116,173,223,4,152,54,134,1,48,26,202,124,235,146,134,148,255,6,49,8,6,233,42,106,123,15,234,235],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.14.0"}
15 changes: 8 additions & 7 deletions grammars/qvr/vcs/.panproto/logs/refs/heads/main
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{"old_id":[80,52,28,145,9,13,70,212,22,181,103,52,28,14,11,39,175,221,51,74,66,78,119,17,4,41,128,239,46,143,169,98],"new_id":[119,44,179,139,157,52,145,150,151,134,15,189,88,114,231,29,82,212,185,140,62,207,75,48,1,167,23,45,141,135,111,158],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322433,"message":"commit: qvr grammar at v0.3.0"}
{"old_id":[119,44,179,139,157,52,145,150,151,134,15,189,88,114,231,29,82,212,185,140,62,207,75,48,1,167,23,45,141,135,111,158],"new_id":[252,28,154,191,193,167,133,235,207,17,194,65,151,118,197,141,237,231,69,104,5,193,215,217,251,98,158,33,65,95,211,238],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.4.0"}
{"old_id":[252,28,154,191,193,167,133,235,207,17,194,65,151,118,197,141,237,231,69,104,5,193,215,217,251,98,158,33,65,95,211,238],"new_id":[174,167,90,49,153,49,250,40,214,102,203,33,170,153,172,149,46,171,140,189,174,85,16,170,4,201,220,1,12,186,224,176],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.5.0"}
{"old_id":[174,167,90,49,153,49,250,40,214,102,203,33,170,153,172,149,46,171,140,189,174,85,16,170,4,201,220,1,12,186,224,176],"new_id":[48,153,25,12,224,217,52,173,16,50,208,170,19,220,22,196,155,251,251,67,31,71,14,237,138,94,88,134,112,155,3,246],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.6.0"}
{"old_id":[48,153,25,12,224,217,52,173,16,50,208,170,19,220,22,196,155,251,251,67,31,71,14,237,138,94,88,134,112,155,3,246],"new_id":[140,164,20,211,1,142,49,168,167,37,175,32,68,55,203,6,57,0,44,126,249,169,71,17,147,87,247,135,1,51,207,11],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.7.0"}
{"old_id":[140,164,20,211,1,142,49,168,167,37,175,32,68,55,203,6,57,0,44,126,249,169,71,17,147,87,247,135,1,51,207,11],"new_id":[192,122,146,9,146,79,135,152,21,76,145,53,100,142,209,95,107,142,203,24,26,156,107,54,206,179,166,5,190,162,62,113],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.9.0"}
{"old_id":[192,122,146,9,146,79,135,152,21,76,145,53,100,142,209,95,107,142,203,24,26,156,107,54,206,179,166,5,190,162,62,113],"new_id":[13,67,197,192,1,108,138,76,41,205,26,83,168,49,21,226,65,63,228,107,237,184,107,0,30,63,16,26,41,62,224,140],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1779322434,"message":"commit: qvr grammar at v0.11.0"}
{"old_id":[179,49,38,17,240,96,62,99,164,0,255,172,96,118,13,183,18,180,113,97,71,188,56,7,193,206,239,176,78,102,226,21],"new_id":[36,155,136,38,221,81,91,44,4,232,217,208,108,69,117,83,205,14,206,176,173,4,194,203,91,239,136,20,208,42,220,46],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.3.0"}
{"old_id":[36,155,136,38,221,81,91,44,4,232,217,208,108,69,117,83,205,14,206,176,173,4,194,203,91,239,136,20,208,42,220,46],"new_id":[195,37,110,44,21,27,181,132,82,81,122,211,239,181,108,31,175,175,235,198,173,227,98,7,70,176,209,96,4,245,128,12],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.4.0"}
{"old_id":[195,37,110,44,21,27,181,132,82,81,122,211,239,181,108,31,175,175,235,198,173,227,98,7,70,176,209,96,4,245,128,12],"new_id":[87,255,29,80,41,203,190,169,99,171,22,137,200,120,230,90,113,107,82,244,202,148,76,79,148,189,164,77,132,255,193,84],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.5.0"}
{"old_id":[87,255,29,80,41,203,190,169,99,171,22,137,200,120,230,90,113,107,82,244,202,148,76,79,148,189,164,77,132,255,193,84],"new_id":[123,116,127,50,242,4,161,222,107,21,135,179,236,11,179,67,250,243,135,200,5,103,248,107,78,127,224,25,39,247,171,9],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.6.0"}
{"old_id":[123,116,127,50,242,4,161,222,107,21,135,179,236,11,179,67,250,243,135,200,5,103,248,107,78,127,224,25,39,247,171,9],"new_id":[62,20,116,43,239,116,33,124,72,247,75,53,49,102,253,144,77,62,201,135,46,29,89,188,229,24,91,211,195,118,122,56],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.7.0"}
{"old_id":[62,20,116,43,239,116,33,124,72,247,75,53,49,102,253,144,77,62,201,135,46,29,89,188,229,24,91,211,195,118,122,56],"new_id":[113,179,14,161,186,251,75,109,120,149,84,81,114,223,133,26,221,15,24,15,128,45,247,218,191,0,255,81,92,49,30,39],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.9.0"}
{"old_id":[113,179,14,161,186,251,75,109,120,149,84,81,114,223,133,26,221,15,24,15,128,45,247,218,191,0,255,81,92,49,30,39],"new_id":[179,212,148,249,169,134,88,155,202,39,222,113,119,181,74,83,220,244,40,208,215,47,182,46,191,203,93,31,40,248,225,68],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.11.0"}
{"old_id":[179,212,148,249,169,134,88,155,202,39,222,113,119,181,74,83,220,244,40,208,215,47,182,46,191,203,93,31,40,248,225,68],"new_id":[155,124,108,121,116,173,223,4,152,54,134,1,48,26,202,124,235,146,134,148,255,6,49,8,6,233,42,106,123,15,234,235],"author":"qvr-grammar-vcs <vcs@quivers>","timestamp":1782934349,"message":"commit: qvr grammar at v0.14.0"}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/heads/main
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0d43c5c0016c8a4c29cd1a53a83115e2413fe46bedb86b001e3f101a293ee08c
9b7c6c7974addf0498368601301aca7ceb928694ff06310806e92a6a7b0feaeb
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.11.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0d43c5c0016c8a4c29cd1a53a83115e2413fe46bedb86b001e3f101a293ee08c
b3d494f9a986589bca27de7177b54a53dcf428d0d72fb62ebfcb5d1f28f8e144
1 change: 1 addition & 0 deletions grammars/qvr/vcs/.panproto/refs/tags/v0.14.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9b7c6c7974addf0498368601301aca7ceb928694ff06310806e92a6a7b0feaeb
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.2.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50341c91090d46d416b567341c0e0b27afdd334a424e7711042980ef2e8fa962
b3312611f0603e63a400ffac60760db712b4716147bc3807c1ceefb04e66e215
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.3.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
772cb38b9d34919697860fbd5872e71d52d4b98c3ecf4b3001a7172d8d876f9e
249b8826dd515b2c04e8d9d06c457553cd0eceb0ad04c2cb5bef8814d02adc2e
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.4.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fc1c9abfc1a785ebcf11c2419776c58dede7456805c1d7d9fb629e21415fd3ee
c3256e2c151bb58452517ad3efb56c1fafafebc6ade3620746b0d16004f5800c
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.5.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aea75a319931fa28d666cb21aa99ac952eab8cbdae5510aa04c9dc010cbae0b0
57ff1d5029cbbea963ab1689c878e65a716b52f4ca944c4f94bda44d84ffc154
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.6.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3099190ce0d934ad1032d0aa13dc16c49bfbfb431f470eed8a5e5886709b03f6
7b747f32f204a1de6b1587b3ec0bb343faf387c80567f86b4e7fe01927f7ab09
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.7.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8ca414d3018e31a8a725af204437cb0639002c7ef9a947119357f7870133cf0b
3e14742bef74217c48f74b353166fd904d3ec9872e1d59bce5185bd3c3767a38
2 changes: 1 addition & 1 deletion grammars/qvr/vcs/.panproto/refs/tags/v0.9.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c07a9209924f8798154c9135648ed15f6b8ecb181a9c6b36ceb3a605bea23e71
71b30ea1bafb4b6d7895545172df851add0f180f802df7dabf00ff515c311e27
Binary file modified grammars/qvr/vcs/parsers/HEAD/qvr.dylib
Binary file not shown.
109 changes: 94 additions & 15 deletions grammars/qvr/vcs/parsers/HEAD/source/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* external scanner; tree-sitter-python style).
* 2. ``KEYWORD NAME[(params)] : SIG [options] [body]`` is the
* single declaration header shape.
* 3. ``composition NAME at LEVEL`` replaces algebra /
* 3. ``composition NAME as LEVEL`` replaces algebra /
* semigroupoid / bilinear_form / composition_rule.
* 4. ``morphism NAME : DOM -> COD [role=...]`` replaces latent /
* observed / kernel / embed / discretize.
Expand Down Expand Up @@ -69,6 +69,11 @@ module.exports = grammar({

conflicts: $ => [
[$._let_atom, $.let_index],
/* ``Real 64 [low=0.0]`` vs ``Real 64`` followed by a parent
* rule's option_block (e.g. morphism_decl). GLR enumerates
* both attachments and picks the one whose parent rule
* accepts the parse. */
[$.continuous_constructor],
],

rules: {
Expand Down Expand Up @@ -136,13 +141,16 @@ module.exports = grammar({
optional(field('docs', $.doc_comment_group)),
'composition',
field('name', $.identifier),
optional(seq('at', field('level', $.composition_level))),
optional(seq( $._newline,
$._indent,
repeat1(choice($.composition_rule_entry, $._newline)),
$._dedent,
)),
$._newline,
optional(seq('as', field('level', $.composition_level))),
choice(
seq(
$._newline,
$._indent,
repeat1(choice($.composition_rule_entry, $._newline)),
$._dedent,
),
$._newline,
),
),

composition_level: $ => choice(
Expand Down Expand Up @@ -372,6 +380,7 @@ module.exports = grammar({

_deduction_body_entry: $ => choice(
$.deduction_atoms,
$.deduction_binders,
$.deduction_rule,
$.deduction_lexicon,
$.deduction_lexicon_from_file,
Expand All @@ -383,13 +392,27 @@ module.exports = grammar({
$._newline,
),

// ``binders`` declares constructors whose first argument is
// a bound variable. The compiler treats binder applications
// specially: the variable position is alpha-renamed to a
// fresh canonical symbol per term construction so the chart
// identifies alpha-equivalent terms, and pattern-matching on
// a binder's bound variable correctly threads the renaming
// through the rule's bindings.
deduction_binders: $ => seq(
'binders',
field('binders', commaSep1($.identifier)),
$._newline,
),

deduction_rule: $ => seq(
'rule',
field('name', $.identifier),
':',
field('premises', commaSep1($._object_expr)),
choice('|-', '⊢'),
field('conclusion', $._object_expr),
optional(field('pragma', $.lexicon_pragma)),
$._newline,
),

Expand All @@ -406,10 +429,22 @@ module.exports = grammar({
field('category', $._lexicon_category),
'=',
field('lf', $._let_arith),
optional(field('options', $.option_block)),
optional(field('pragma', $.lexicon_pragma)),
$._newline,
),

// Inline pragma form used as a trailing attribute on lexicon
// entries. Distinct from ``pragma_outer`` only in that it does
// not terminate with a newline (the enclosing lexicon_entry
// owns the trailing newline). ``#`` opens the comment / pragma
// family, so no let-arith expression can extend past the lf
// into this position; the surface is unambiguous.
lexicon_pragma: $ => seq(
'#[',
field('entries', commaSep1($.pragma_entry)),
']',
),

_lexicon_category: $ => choice(
'*',
$.enum_set_literal,
Expand Down Expand Up @@ -567,12 +602,15 @@ module.exports = grammar({
bracketedList($, '(', field('sig_args', $.identifier), ')'),
)),
optional(field('options', $.option_block)),
optional(seq( $._newline,
$._indent,
repeat1(choice($._encoder_body_entry, $._newline)),
$._dedent,
)),
$._newline,
choice(
seq(
$._newline,
$._indent,
repeat1(choice($._encoder_body_entry, $._newline)),
$._dedent,
),
$._newline,
),
),

_encoder_body_entry: $ => choice(
Expand Down Expand Up @@ -816,6 +854,7 @@ module.exports = grammar({
$.observe_step,
$.marginalize_step,
$.let_step,
$.score_step,
),

sample_step: $ => seq(
Expand Down Expand Up @@ -862,6 +901,18 @@ module.exports = grammar({
$._newline,
),

// Score / factor step: ``score NAME = EXPR``. The value of
// ``EXPR`` is added to the program's ``log_joint`` (the
// deduction analog of an ``observe`` whose log-density comes
// from a chart goal weight or any other tensor expression).
score_step: $ => seq(
'score',
field('name', $.identifier),
'=',
field('value', $._let_arith),
$._newline,
),

return_step: $ => seq(
'return',
field('return', $._return_pattern),
Expand All @@ -870,10 +921,33 @@ module.exports = grammar({

_draw_arg: $ => choice(
$.bracket_index_arg,
$.family_call_arg,
$.list_arg,
$.identifier,
$.signed_number,
),

// Distribution-call expression at a draw-arg position, e.g.
// `Mixture([0.3, 0.7], [PointMass(0), Poisson(rate)])`. The
// compiler recurses into `args` to build the inner distribution
// before passing it to the outer family's builder. See the
// measure-algebra design note for the operator vocabulary.
family_call_arg: $ => prec(2, seq(
field('family', $.identifier),
'(',
optional(field('args', commaSep1($._draw_arg))),
')',
)),

// List-of-draw-args, e.g. `[0.3, 0.7]` for mixture weights or
// `[PointMass(0), Poisson(rate)]` for mixture components. Mirrors
// the let-expression list literal but at the draw-arg position.
list_arg: $ => seq(
'[',
optional(commaSep1($._draw_arg)),
']',
),

bracket_index_arg: $ => prec(1, seq(
field('name', $.identifier),
'[',
Expand Down Expand Up @@ -1014,6 +1088,7 @@ module.exports = grammar({
'Diagonal',
)),
repeat1(field('args', $._object_constructor_arg)),
optional(field('options', $.option_block)),
)),

/* Constructor positional arguments are space-separated (Haskell-
Expand Down Expand Up @@ -1389,6 +1464,10 @@ function commaSep1(rule) {
return seq(rule, repeat(seq(',', rule)));
}

function commaSep(rule) {
return optional(commaSep1(rule));
}

/* Bracketed comma-separated list with two forms:
*
* Inline: ``[ a, b, c ]`` -- single line, no newlines.
Expand Down
Loading
Loading