Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'oneof' in syntax-directed operations #637

Merged
merged 5 commits into from
Mar 26, 2025
Merged

Conversation

szuend
Copy link
Contributor

@szuend szuend commented Mar 10, 2025

In the source map spec we have the use-case of declaring an SDO over a lexical production (for VLQ decoding).

This PR adds the missing implementation.

@nicolo-ribaudo nicolo-ribaudo requested a review from bakkot March 11, 2025 10:36
test/errors.js Outdated
<h1>Static Semantics: Example</h1>
<dl class='header'></dl>
<emu-grammar>
Foo :: one of \`a\`
Copy link
Member

Choose a reason for hiding this comment

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

This should read

Suggested change
Foo :: one of \`a\`
Foo :: \`a\`

We should prohibit "one of" with only one alternative.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the test to Foo :: one of `a` `b` instead. Allowing Foo :: `a` should probably be done in a separate PR since it requires changing rhsMatches to compare different kinds of productions. Also disallowing Foo :: one of `a` should probably be done in the linter in a separate PR.

@jmdyck
Copy link
Contributor

jmdyck commented Mar 11, 2025

Note that the current spec does have examples of an SDO being defined on a "one of" production, but they're all in the 'inline' form, rather than the emu-grammar+emu-alg form:

- The TRV of <emu-grammar>DecimalDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`</emu-grammar> is ...
- The TRV of <emu-grammar>HexDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` `a` `b` `c` `d` `e` `f` `A` `B` `C` `D` `E` `F`</emu-grammar> is ...
- The TRV of <emu-grammar>SingleEscapeCharacter :: one of `'` `"` `\` `b` `f` `n` `r` `t` `v`</emu-grammar> is ...

@szuend
Copy link
Contributor Author

szuend commented Mar 17, 2025

Anything missing to get this landed?

@bakkot bakkot merged commit d2d4ace into tc39:main Mar 26, 2025
2 checks passed
@bakkot
Copy link
Contributor

bakkot commented Mar 26, 2025

Published in 21.1.0, sorry for the delay.

@szuend szuend deleted the fix-one-of-sdo branch March 27, 2025 06:59
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.

5 participants