Skip to content

Aiur grammar: statement sequencing t; rest#475

Merged
arthurpaulino merged 1 commit into
mainfrom
ap/aiur-grammar-unit
Jul 8, 2026
Merged

Aiur grammar: statement sequencing t; rest#475
arthurpaulino merged 1 commit into
mainfrom
ap/aiur-grammar-unit

Conversation

@arthurpaulino

Copy link
Copy Markdown
Member

Add syntax:0 aiur_trm "; " (aiur_trm)?f(x); rest elaborates to
let _ = f(x); rest (wildcard let, value discarded); trailing f(x);
closes the block with (). Unit-returning calls sit in statement
position without the let _ = boilerplate.

The sequencing rule is the grammar's only prec-0 rule; positions where
an expression can end right before a ; are bumped to prec 1 so it
can't leak into expression operands: let right-hand sides, +/-
right operands, return, array elements/replicate. Without the binop
guard, let x = a - 1; rest reparses as a - (1; rest) — caught only
at ix codegen scope-check (unboundGlobal), not by lake build,
since elaboration builds Source.Term without checking. All other
argument positions are bounded by closing tokens and can't precede a
;. Since prec-51 positions accept every leading form, default rule
prec ≥ 51 and the :1 annotations exclude only the sequencing rule.

Rewrite all 113 let _ = call(...); sites in Ix/IxVM and the 3
let _ = store(...) sites in Tests/Aiur to the new form, and drop the
4 redundant explicit () continuations after trailing assert_eq!
(an omitted continuation already elaborates to unit). Generated kernel
is byte-identical after lake exe ix codegen (identical IR by
construction — no FFT shift), and lake test -- aiur-cross passes
with the new syntax exercised.

@arthurpaulino arthurpaulino force-pushed the ap/aiur-grammar-unit branch 2 times, most recently from 7b0af4d to 49bca62 Compare July 8, 2026 11:07
@arthurpaulino arthurpaulino marked this pull request as ready for review July 8, 2026 11:07
Add `syntax:0 aiur_trm "; " (aiur_trm)?` — `f(x); rest` elaborates to
`let _ = f(x); rest` (wildcard let, value discarded); trailing `f(x);`
closes the block with `()`. Unit-returning calls sit in statement
position without the `let _ =` boilerplate.

The sequencing rule is the grammar's only prec-0 rule; positions where
an expression can end right before a `;` are bumped to prec 1 so it
can't leak into expression operands: `let` right-hand sides, `+`/`-`
right operands, `return`, array elements/replicate. Without the binop
guard, `let x = a - 1; rest` reparses as `a - (1; rest)` — caught only
at `ix codegen` scope-check (`unboundGlobal`), not by `lake build`,
since elaboration builds Source.Term without checking. All other
argument positions are bounded by closing tokens and can't precede a
`;`. Since prec-51 positions accept every leading form, default rule
prec ≥ 51 and the :1 annotations exclude only the sequencing rule.

Rewrite all 113 `let _ = call(...);` sites in Ix/IxVM and the 3
`let _ = store(...)` sites in Tests/Aiur to the new form, and drop the
4 redundant explicit `()` continuations after trailing `assert_eq!`
(an omitted continuation already elaborates to unit). Generated kernel
is byte-identical after `lake exe ix codegen` (identical IR by
construction — no FFT shift), and `lake test -- aiur-cross` passes
with the new syntax exercised.
@arthurpaulino arthurpaulino force-pushed the ap/aiur-grammar-unit branch from 49bca62 to 38f0ee7 Compare July 8, 2026 12:37
@arthurpaulino arthurpaulino merged commit e8dbdb4 into main Jul 8, 2026
15 of 16 checks passed
@arthurpaulino arthurpaulino deleted the ap/aiur-grammar-unit branch July 8, 2026 13:27
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.

2 participants