Skip to content

More precise grammar for conditional translation#196

Merged
stefnotch merged 4 commits into
mainfrom
restrict-conditional-translation
Jul 12, 2026
Merged

More precise grammar for conditional translation#196
stefnotch merged 4 commits into
mainfrom
restrict-conditional-translation

Conversation

@stefnotch

@stefnotch stefnotch commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Conditional translation in the spec and in the implementations does not fully match up. Time to fix this.

Narrower grammar for @if

#191 (comment)

Both in wesl-rs and wgsl-analyzer, the current grammar of @if has been causing implementation woes. To address this with the smallest spec change, I opted to separate "attributes" and "translate-time attributes". Translate-time attributes are @if(...), @elif(...) and @else. They are parsed exactly as such, thus being unambiguous. This change does not reject any existing WESL programs.

@else in the spec

#117

Both wesl-js and wesl-rs support @elif and @else. This adds them to the spec

Compared to #164 , I did not yet update the name to "condition attributes". I wanted to keep the diff easy to review for this PR.

@stefnotch stefnotch requested review from k2d222 and mighdoll and removed request for mighdoll June 26, 2026 12:33
@stefnotch stefnotch requested a review from mighdoll June 28, 2026 21:41
Comment thread ConditionalTranslation.md Outdated
Comment thread ConditionalTranslation.md Outdated

@mighdoll mighdoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, editorial suggestions here.

Comment thread ConditionalTranslation.md Outdated
Comment thread ConditionalTranslation.md Outdated
@stefnotch stefnotch requested a review from mighdoll July 12, 2026 05:03
@stefnotch stefnotch merged commit e803d5a into main Jul 12, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in specs and docs Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants