Skip to content

[5.7] Cherry-pick some syntax tweaks #493

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

Merged

Conversation

hamishknight
Copy link
Contributor

Cherry pick of #432, #487, and #484.

  • Allow the use of unbounded quotes \Q..., and no-op matching option syntax (?).
  • Allow the scoped unsetting of extended syntax e.g (?-x:...), as long as it does not span multiple lines. Additionally, ensure that unscoped unsetting of extended syntax via (?^) is banned.
  • Fix a crash on \o.

PCRE and ICU both support quoted sequences that
don't have a terminating `\E`. Update the parsing
to allow this.

Additionally, allow empty quoted sequences outside
of custom character classes, which is consistent
with ICU.

Finally, don't allow quoted sequences to span
multiple lines in extended syntax literals.
This is accepted by PCRE, and forms an empty
option change sequence. We probably ought to warn
on it though as it's a no-op.
This was caused by the fact that we'd walk into
`expectUnicodeScalar` if we saw `\o`, but we only
want to parse `\o{`. Instead, change it to be a `lex..`
method, and bail if we don't lex a scalar.
This shouldn't include e.g `namedCapturesOnly`.
This should always be set in a multi-line literal,
with extended syntax potentially being set and
unset as we parse.
Relax the ban on unsetting extended syntax in a
multi-line literal such that it does not apply to
a scoped unset e.g `(?-x:...)`, as long as it does
not span multiple lines.

This commit also bans the use of `(?^)` in a
multi-line literal, unless it is scoped and does
not span multiple lines. Instead, `(?^x)` must be
written, as PCRE defines `(?^)` to be equivalent to
`(?-imnsx)`.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight added the r5.7 5.7 Release Cherry Picks label Jun 17, 2022
@hamishknight hamishknight merged commit 9807fcd into swiftlang:swift/release/5.7 Jun 17, 2022
@hamishknight hamishknight deleted the syntax-tweaks-5.7 branch June 17, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r5.7 5.7 Release Cherry Picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants