-
Notifications
You must be signed in to change notification settings - Fork 49
[Integration] main (50ec05d) -> swift/main #225
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…exComponentBuilder`. (swiftlang#200) We've decided to use `RegexComponent` for the protocol, and use `RegexComponentBuilder` for the builder type since we want the user to import a module named `RegexBuilder` to get the DSL.
Replace free functions such as `oneOrMore` with types such as `OneOrMore`. This hides overloads of free functions as initializers within those types. It also makes the DSL consistent with SwiftUI. - `oneOrMore` -> `OneOrMore` - `zeroOrMore` -> `ZeroOrMore` - `optionally` -> `Optionally` - `repeating` -> `Repeat` - `choiceOf` -> `ChoiceOf` - `capture` -> `Capture` - `tryCapture` -> `TryCapture` Note: The reason we didn't realize this was possible (e.g. in swiftlang#126) was because we were narrowly focused on including the subpattern type in the quantifier/combinator's generic parameter, i.e. `OneOrMore<Component: RegexComponent>`, which made it impossible to deduce each type's `typealias Match` from `Component`. Now we have an unconstrained generic parameter (e.g. `OneOrMore<Match>`) which gives us the full flexibility to hide `Match` deduction rules in initializers' type signatures.
DSL free functions -> types
Transition from the old name `buildBlock(combining:into:)` to the [newly proposed](https://forums.swift.org/t/pitch-buildpartialblock-for-result-builders/55561) `buildPartialBlock(first:)` and `buildPartialBlock(accumulated:next:)`. Requires DEVELOPMENT-SNAPSHOT-2022-03-09 or later.
This is something we should've done earlier, as we've been referring to this type as `MatchResult` the whole time. The only reason I named it `RegexMatch` was because the (now deleted) VM had a lower-level type named `MatchResult`.
Rename `RegexMatch` to `MatchResult`.
Adopt `buildPartialBlock`.
- Add a new pitch for the regex builder DSL. - Update the strongly typed regex captures pitch to the latest design.
Fix protocol definition in DSL pitch.
Fix typo and `ChoiceOf` initializer in DSL pitch.
Given that the `Regex` type pitch is going to include the `Regex.Match` type, we add the extension that contains `subscript(_: Reference)` to the DSL pitch. Also fix the `Reference` code example.
Add `Regex.Match.subscript(_: Reference)` to DSL pitch.
- Require creating an branch from a commit on main instead of merging from main, as main is moving constantly. - Require creating a dummy PR in apple/swift before we have full CI in this repo.
Clarify integration process.
Rename Alternation to OrderedChoice, scrap groupTransform and capturing from group in favor of a capture node.
…ng-processing into merge-from-pr218
Merge from swift/main to pick up swiftlang#218
- Rename the `Match` associatedtype in `RegexComponent` to `Output`. - Rename `MatchResult` to `Regex.Match`. The new names have been pitched as part of the [regex type](https://forums.swift.org/t/pitch-regex-type-and-overview/56029) and the [regex builder DSL](https://forums.swift.org/t/pitch-regex-builder-dsl/56007).
`AnyRegexOutput` is a collection type that represents a type-erased regex output with two use cases: - When a `Regex` is initialized from a string, e.g. `Regex("(a)|(b)|c")`, it has type `Regex<AnyRegexOutput>`. One can iterate over the output to access output elements (the whole match followed by any captures). - When working with an existing code base that uses dynamic `Regex` creation from strings, one can type-erase the match result of a strongly typed regex, e.g. `Regex<(Substring, Substring, Substring)>.Match`, and use it as a drop in replacement for the dynamic regex match. This has been pitched as part of the [regex type](https://forums.swift.org/t/pitch-regex-type-and-overview/56029). --- Example: ```swift let regex = try! Regex(#"([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s+;\s+(\w+).*"#) let line = """ A6F0..A6F1 ; Extend # Mn [2] BAMUM COMBINING MARK KOQNDON..BAMUM \ COMBINING MARK TUKWENTIS """ let match = line.firstMatch(of: regex)! let output = match.output // `AnyRegexOutput` output.0 // => (the entire match) output[0].bounds // => (the bounds of the entire match) output[0].substring // => (the entire match) output[1].substring // => "A6F0" output[2].substring // => "A6F1" output[3].substring // => "Extend" ```
Supports conversion from `AnyRegexOutput` to a user-specified type.
…utput Add `AnyRegexOutput.as(_:)`.
@swift-ci please test |
milseman
approved these changes
Mar 21, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
rxwei
added a commit
to rxwei/swift
that referenced
this pull request
Mar 21, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.