Skip to content

Commit 625e923

Browse files
authored
Merge pull request swiftlang#551 from hamishknight/scalar-support-5.7
[5.7] Update to match Unicode proposal
2 parents 4cb4d9c + 52fc547 commit 625e923

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

Sources/RegexBuilder/CharacterClass.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,10 @@ extension RegexComponent where Self == CharacterClass {
4848
.init(DSLTree.CustomCharacterClass(members: [.atom(.any)]))
4949
}
5050

51-
public static var anyGrapheme: CharacterClass {
51+
public static var anyGraphemeCluster: CharacterClass {
5252
.init(unconverted: .anyGrapheme)
5353
}
5454

55-
public static var anyUnicodeScalar: CharacterClass {
56-
.init(unconverted: .anyUnicodeScalar)
57-
}
58-
5955
public static var whitespace: CharacterClass {
6056
.init(unconverted: .whitespace)
6157
}

Sources/_RegexParser/Regex/Parse/Sema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ extension RegexValidator {
220220
_ esc: AST.Atom.EscapedBuiltin, at loc: SourceLocation
221221
) {
222222
switch esc {
223-
case .resetStartOfMatch, .singleDataUnit,
223+
case .resetStartOfMatch, .singleDataUnit, .trueAnychar,
224224
// '\N' needs to be emitted using 'emitAny'.
225225
.notNewline:
226226
error(.unsupported("'\\\(esc.character)'"), at: loc)
227227

228228
// Character classes.
229229
case .decimalDigit, .notDecimalDigit, .whitespace, .notWhitespace,
230-
.wordCharacter, .notWordCharacter, .graphemeCluster, .trueAnychar,
230+
.wordCharacter, .notWordCharacter, .graphemeCluster,
231231
.horizontalWhitespace, .notHorizontalWhitespace,
232232
.verticalTab, .notVerticalTab:
233233
break

Tests/RegexBuilderTests/AlgorithmsTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class AlgorithmsResultBuilderTests: XCTestCase {
260260
func testStartsAndContains() throws {
261261
let fam = "👨‍👩‍👧‍👦👨‍👨‍👧‍👧 we Ⓡ family"
262262
let startsWithGrapheme = fam.starts {
263-
OneOrMore(.anyGrapheme)
263+
OneOrMore(.anyGraphemeCluster)
264264
OneOrMore(.whitespace)
265265
}
266266
XCTAssertEqual(startsWithGrapheme, true)
@@ -272,7 +272,7 @@ class AlgorithmsResultBuilderTests: XCTestCase {
272272

273273
let content = {
274274
Regex {
275-
OneOrMore(.anyGrapheme)
275+
OneOrMore(.anyGraphemeCluster)
276276
OneOrMore(.whitespace)
277277
}
278278
}
@@ -321,7 +321,7 @@ class AlgorithmsResultBuilderTests: XCTestCase {
321321

322322
var mutable = "👨‍👩‍👧‍👦 we Ⓡ family"
323323
mutable.trimPrefix {
324-
.anyGrapheme
324+
.anyGraphemeCluster
325325
ZeroOrMore(.whitespace)
326326
}
327327
XCTAssertEqual(mutable, "we Ⓡ family")

Tests/RegexTests/MatchTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ extension RegexTests {
17861786
match: eDecomposed,
17871787
xfail: true
17881788
)
1789-
firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
1789+
firstMatchTest(#"\O"#, input: eComposed, match: eComposed, xfail: true)
17901790
firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
17911791
xfail: true)
17921792

Tests/RegexTests/ParseTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ extension RegexTests {
806806
parseTest(#"\M-\C--"#, atom(.keyboardMetaControl("-")), unsupported: true)
807807
parseTest(#"\M-a"#, atom(.keyboardMeta("a")), unsupported: true)
808808

809+
parseTest(#"\O"#, escaped(.trueAnychar), unsupported: true)
810+
809811
// MARK: Comments
810812

811813
parseTest(

0 commit comments

Comments
 (0)