Skip to content

[swift/main] Provide literal pattern for convertible regexes #709

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
merged 2 commits into from
Jan 9, 2024

Conversation

natecook1000
Copy link
Member

This adds an (SPI) API for converting a Regex instance to a regex literal when possible, whether the regex starts as a literal, a run-time-constructed regex, or using the RegexBuilder syntax. The _literalPattern is round-trippable, so a regex created from a _literalPattern will have that same _literalPattern, but it could be different from the original pattern used to create a regex.

This adds another confirmation test, as part of the parse testing. When a parsing test is expected to succeed, and contains supported syntax, this checks that a round-tripped literal pattern maintains its identity.

Cherry pick of #670.

This adds an (SPI) API for converting a `Regex` instance to a regex
literal when possible, whether the regex starts as a literal, a
run-time-constructed regex, or using the RegexBuilder syntax.
The `_literalPattern` is round-trippable, so a regex created from
a `_literalPattern` will have that same `_literalPattern`, but it
could be different from the original pattern used to create a regex.

This adds another confirmation test, as part of the parse testing.
When a parsing test is expected to succeed, and contains supported
syntax, this checks that a round-tripped literal pattern maintains
its identity.
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000
Copy link
Member Author

@swift-ci Please test Windows platform

@natecook1000 natecook1000 merged commit 157c224 into swift/main Jan 9, 2024
@natecook1000 natecook1000 deleted the swiftmain_literal_pattern branch January 9, 2024 21:57
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.

1 participant