Skip to content

[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 27 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cd3ad6d
Rename `RegexProtocol` to `RegexComponent` and `RegexBuilder` to `Reg…
rxwei Mar 8, 2022
f2ed846
DSL free functions -> types
rxwei Mar 10, 2022
85c7d90
Merge pull request #203 from rxwei/dsl-functions-to-types
rxwei Mar 11, 2022
a9509fc
Adopt `buildPartialBlock`.
rxwei Mar 11, 2022
8f48032
Rename `RegexMatch` to `MatchResult`.
rxwei Mar 11, 2022
74ea98d
Merge pull request #205 from rxwei/regexmatch
rxwei Mar 14, 2022
167e4d2
Merge pull request #204 from rxwei/buildpartialblock
rxwei Mar 14, 2022
69d23a8
Add regex builder DSL pitch and update captures pitch (#201)
rxwei Mar 16, 2022
a91b951
DSL pitch fixes (#209)
rxwei Mar 17, 2022
58efb77
Fix protocol definition in DSL pitch.
rxwei Mar 17, 2022
0241228
Merge pull request #210 from rxwei/dsl-pitch-fix-protocol
rxwei Mar 17, 2022
f848f58
Fix typo and `ChoiceOf` initializer in DSL pitch.
rxwei Mar 17, 2022
0f9f0a4
Merge pull request #211 from rxwei/dsl-pitch-fix-typo
rxwei Mar 17, 2022
0db0ce6
Add `Regex.Match.subscript(_: Reference)` to DSL pitch.
rxwei Mar 17, 2022
b68a030
Merge pull request #212 from rxwei/dsl-pitch-matchresult
rxwei Mar 17, 2022
0f07c42
Clarify integration process.
rxwei Mar 18, 2022
20a6471
Add regex type and overview pitch (#216)
milseman Mar 18, 2022
d65fa08
Merge pull request #215 from rxwei/clarify-integration-process
rxwei Mar 18, 2022
89e18aa
Cleanup DSLTree a little (#206)
milseman Mar 20, 2022
f4cc29b
Merge branch 'swift/main' of github.com:apple/swift-experimental-stri…
rxwei Mar 21, 2022
279847c
Merge pull request #220 from rxwei/merge-from-pr218
rxwei Mar 21, 2022
ed92d3b
Rename `Match` and `MatchResult` to `Output` and `Regex.Match`.
rxwei Mar 21, 2022
b5dd0ef
Replace `DynamicCaptures` with `AnyRegexOutput`.
rxwei Mar 21, 2022
c97cd0d
Merge pull request #221 from rxwei/rename-regex-match
rxwei Mar 21, 2022
f00bfe0
Merge pull request #222 from rxwei/anyregexoutput
rxwei Mar 21, 2022
f20e24b
Add `AnyRegexOutput.as(_:)`.
rxwei Mar 21, 2022
50ec05d
Merge pull request #223 from rxwei/existential-to-concrete-output
rxwei Mar 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,446 changes: 1,446 additions & 0 deletions Documentation/Evolution/RegexBuilderDSL.md

Large diffs are not rendered by default.

524 changes: 524 additions & 0 deletions Documentation/Evolution/RegexTypeOverview.md

Large diffs are not rendered by default.

294 changes: 140 additions & 154 deletions Documentation/Evolution/StronglyTypedCaptures.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ See [Declarative String Processing Overview][decl-string]

## Requirements

- [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2022-02-03 or later.
- [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2022-03-09 or later.

## Integration with Swift

Expand Down Expand Up @@ -45,8 +45,9 @@ A pair of corresponding branches are expected to build successfully together and
To integrate the latest changes in apple/swift-experimental-string-processing to apple/swift, carefully follow the workflow:

- Create pull requests.
- Create a pull request in apple/swift-experimental-string-processing from `main` to `swift/main`, e.g. "[Integration] main -> swift/main".
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift.
- Create a branch from a commit on `main` that you would like to integrate into `swift/main`.
- Create a pull request in apple/swift-experimental-string-processing from that branch to `swift/main`, e.g. "[Integration] main (<commit>) -> swift/main".
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift. **Note:** Since CI in apple/swift-experimental-string-processing has not yet been set up to run full toolchain tests, you should create a PR in apple/swift regardless; if the integartion does not require changing apple/swift, create a dummy PR in apple/swift by changing the README and just not merge it in the end.
- Trigger CI.
- In the apple/swift-experimental-string-processing pull request, trigger CI using the following command (replacing `<PR NUMBER>` with the apple/swift pull request number, if any):
```
Expand Down
22 changes: 11 additions & 11 deletions Sources/Exercises/Participants/RegexParticipant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ private func extractFromCaptures(
}

@inline(__always) // get rid of generic please
private func graphemeBreakPropertyData<RP: RegexProtocol>(
private func graphemeBreakPropertyData<RP: RegexComponent>(
forLine line: String,
using regex: RP
) -> GraphemeBreakEntry? where RP.Match == (Substring, Substring, Substring?, Substring) {
line.match(regex).map(\.match).flatMap(extractFromCaptures)
) -> GraphemeBreakEntry? where RP.Output == (Substring, Substring, Substring?, Substring) {
line.match(regex).map(\.output).flatMap(extractFromCaptures)
}

private func graphemeBreakPropertyDataLiteral(
Expand All @@ -80,18 +80,18 @@ private func graphemeBreakPropertyData(
forLine line: String
) -> GraphemeBreakEntry? {
line.match {
tryCapture(oneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
optionally {
TryCapture(OneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
Optionally {
".."
tryCapture(oneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
TryCapture(OneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
}
oneOrMore(.whitespace)
OneOrMore(.whitespace)
";"
oneOrMore(.whitespace)
tryCapture(oneOrMore(.word)) { Unicode.GraphemeBreakProperty($0) }
zeroOrMore(.any)
OneOrMore(.whitespace)
TryCapture(OneOrMore(.word)) { Unicode.GraphemeBreakProperty($0) }
ZeroOrMore(.any)
}.map {
let (_, lower, upper, property) = $0.match
let (_, lower, upper, property) = $0.output
return GraphemeBreakEntry(lower...(upper ?? lower), property)
}
}
22 changes: 11 additions & 11 deletions Sources/Prototypes/TourOfTypes/Literal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ enum SemanticsLevel {
}

/// Conformers can be ran as a regex / pattern
protocol RegexProtocol {
protocol RegexComponent {
var level: SemanticsLevel? { get }
}

/// Provide the option to encode semantic level statically
protocol RegexLiteralProtocol: ExpressibleByRegexLiteral {
associatedtype ScalarSemanticRegex: RegexProtocol
associatedtype GraphemeSemanticRegex: RegexProtocol
associatedtype POSIXSemanticRegex: RegexProtocol
associatedtype UnspecifiedSemanticRegex: RegexProtocol = RegexLiteral
associatedtype ScalarSemanticRegex: RegexComponent
associatedtype GraphemeSemanticRegex: RegexComponent
associatedtype POSIXSemanticRegex: RegexComponent
associatedtype UnspecifiedSemanticRegex: RegexComponent = RegexLiteral

var scalarSemantic: ScalarSemanticRegex { get }
var graphemeSemantic: GraphemeSemanticRegex { get }
Expand All @@ -84,16 +84,16 @@ struct StaticSemanticRegexLiteral: RegexLiteralProtocol {
*/

/// A regex that has statically bound its semantic level
struct ScalarSemanticRegex: RegexProtocol {
struct ScalarSemanticRegex: RegexComponent {
var level: SemanticsLevel? { .scalar }
}
struct GraphemeSemanticRegex: RegexProtocol {
struct GraphemeSemanticRegex: RegexComponent {
var level: SemanticsLevel? { .graphemeCluster }
}
struct POSIXSemanticRegex: RegexProtocol {
struct POSIXSemanticRegex: RegexComponent {
var level: SemanticsLevel? { .posix }
}
struct UnspecifiedSemanticRegex: RegexProtocol {
struct UnspecifiedSemanticRegex: RegexComponent {
var level: SemanticsLevel? { nil }
}

Expand Down Expand Up @@ -132,9 +132,9 @@ struct RegexLiteral: ExpressibleByRegexLiteral {
}
}

extension RegexLiteral: RegexProtocol, RegexLiteralProtocol {
extension RegexLiteral: RegexComponent, RegexLiteralProtocol {
/// A regex that has finally bound its semantic level (dynamically)
struct BoundSemantic: RegexProtocol {
struct BoundSemantic: RegexComponent {
var _level: SemanticsLevel // Bound semantic level
var level: SemanticsLevel? { _level }
}
Expand Down
Loading