Skip to content

Commit be3cb05

Browse files
committed
Merge pull request #480 from Azoy/remove-some-flags
Remove (?X) and (?u) for now
1 parent 829a541 commit be3cb05

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed

Sources/_RegexParser/Regex/Parse/Sema.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ extension RegexValidator {
106106
case .byteSemantics:
107107
throw error(.unsupported("byte semantic mode"), at: loc)
108108

109+
case .unicodeScalarSemantics:
110+
throw error(.unsupported("unicode scalar semantic mode"), at: loc)
111+
112+
case .graphemeClusterSemantics:
113+
throw error(.unsupported("grapheme semantic mode"), at: loc)
114+
109115
case .caseInsensitive, .possessiveByDefault, .reluctantByDefault,
110-
.unicodeScalarSemantics, .graphemeClusterSemantics,
111116
.singleLine, .multiline, .namedCapturesOnly, .extended, .extraExtended,
112117
.asciiOnlyDigit, .asciiOnlyWord, .asciiOnlySpace, .asciiOnlyPOSIXProps:
113118
break

Tests/RegexTests/CompileTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ extension RegexTests {
124124
"(?im)(?s).",
125125
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
126126
try expectInitialOptions(".", matchingOptions())
127-
try expectInitialOptions(
128-
"(?im)(?s).(?u)",
129-
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
127+
128+
// FIXME: Figure out (?X) and (?u) semantics
129+
try XCTExpectFailure("Figure out (?X) and (?u) semantics") {
130+
try expectInitialOptions(
131+
"(?im)(?s).(?u)",
132+
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
133+
}
130134

131135
try expectInitialOptions(
132136
"(?i:.)",

Tests/RegexTests/MatchTests.swift

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,12 @@ extension RegexTests {
10201020
#"\u{65}\y"#, // Grapheme boundary assertion
10211021
("Cafe\u{301}", nil),
10221022
("Sol Cafe", "e"))
1023+
1024+
// FIXME: Figure out (?X) and (?u) semantics
10231025
firstMatchTests(
10241026
#"(?u)\u{65}\Y"#, // Grapheme non-boundary assertion
10251027
("Cafe\u{301}", "e"),
1026-
("Sol Cafe", nil))
1028+
("Sol Cafe", nil), xfail: true)
10271029
}
10281030

10291031
func testMatchGroups() {
@@ -1586,7 +1588,8 @@ extension RegexTests {
15861588
// a single Unicode scalar value, leaving any other grapheme scalar
15871589
// components to be matched.
15881590

1589-
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e")
1591+
// FIXME: Figure out (?X) and (?u) semantics
1592+
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e", xfail: true)
15901593

15911594
matchTest(
15921595
#".\u{301}"#,
@@ -1597,18 +1600,30 @@ extension RegexTests {
15971600
(eComposed, false),
15981601
(eDecomposed, false))
15991602

1603+
// FIXME: Figure out (?X) and (?u) semantics
16001604
// FIXME: \O is unsupported
1601-
firstMatchTest(#"(?u)\O\u{301}"#, input: eDecomposed, match: eDecomposed)
1602-
firstMatchTest(#"(?u)e\O"#, input: eDecomposed, match: eDecomposed)
1605+
firstMatchTest(
1606+
#"(?u)\O\u{301}"#,
1607+
input: eDecomposed,
1608+
match: eDecomposed,
1609+
xfail: true
1610+
)
1611+
firstMatchTest(
1612+
#"(?u)e\O"#,
1613+
input: eDecomposed,
1614+
match: eDecomposed,
1615+
xfail: true
1616+
)
16031617
firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
16041618
firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
16051619
xfail: true)
16061620

1621+
// FIXME: Figure out (?X) and (?u) semantics
16071622
matchTest(
16081623
#"(?u).\u{301}"#,
16091624
(eComposed, false),
1610-
(eDecomposed, true))
1611-
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed)
1625+
(eDecomposed, true), xfail: true)
1626+
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed, xfail: true)
16121627

16131628
// Option permutations for 'u' and 's'
16141629
matchTest(
@@ -1621,14 +1636,16 @@ extension RegexTests {
16211636
("e\u{301}ab", false),
16221637
("e\u{301}abc", true),
16231638
("e\u{301}\nab", true))
1639+
1640+
// FIXME: Figure out (?X) and (?u) semantics
16241641
matchTest(
16251642
#"(?u)...."#,
16261643
("e\u{301}ab", true),
1627-
("e\u{301}\na", false))
1644+
("e\u{301}\na", false), xfail: true)
16281645
matchTest(
16291646
#"(?us)...."#,
16301647
("e\u{301}ab", true),
1631-
("e\u{301}\na", true))
1648+
("e\u{301}\na", true), xfail: true)
16321649
}
16331650

16341651
// TODO: Add test for implied grapheme cluster requirement at group boundaries

Tests/RegexTests/ParseTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,11 @@ extension RegexTests {
10741074
.singleLine, .reluctantByDefault, .extraExtended, .extended,
10751075
.unicodeWordBoundaries, .asciiOnlyDigit, .asciiOnlyPOSIXProps,
10761076
.asciiOnlySpace, .asciiOnlyWord, .textSegmentGraphemeMode,
1077-
.textSegmentWordMode, .graphemeClusterSemantics, .unicodeScalarSemantics,
1077+
.textSegmentWordMode,
1078+
.graphemeClusterSemantics, .unicodeScalarSemantics,
10781079
.byteSemantics
10791080
]
1081+
10801082
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}Xub-iJmnsUxxxwDPSW)", changeMatchingOptions(
10811083
matchingOptions(adding: allOptions, removing: allOptions.dropLast(5))
10821084
), throwsError: .unsupported)
@@ -2787,8 +2789,9 @@ extension RegexTests {
27872789
diagnosticTest("(?-y{g})", .cannotRemoveTextSegmentOptions)
27882790
diagnosticTest("(?-y{w})", .cannotRemoveTextSegmentOptions)
27892791

2790-
diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2791-
diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
2792+
// FIXME: Reenable once we figure out (?X) and (?u) semantics
2793+
//diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2794+
//diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
27922795
diagnosticTest("(?-b)", .cannotRemoveSemanticsOptions)
27932796

27942797
diagnosticTest("(?a)", .unknownGroupKind("?a"))

Tests/RegexTests/UTS18Tests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,12 @@ extension UTS18Tests {
466466

467467
// Matching semantic level
468468
XCTAssertFalse("👩‍👩‍👧‍👦".contains(regex(#".\N{ZERO WIDTH JOINER}"#)))
469-
XCTAssertTrue("👩‍👩‍👧‍👦".contains(regex(#"(?u).\N{ZERO WIDTH JOINER}"#)))
469+
470+
// FIXME: Figure out (?X) and (?u) semantics
471+
XCTExpectFailure("Figure out (?X) and (?u) semantics") {
472+
XCTFail(#"(?u).\N{ZERO WIDTH JOINER}"#)
473+
//XCTAssertTrue("👩‍👩‍👧‍👦".contains(regex(#"(?u).\N{ZERO WIDTH JOINER}"#)))
474+
}
470475
}
471476

472477
func testIndividuallyNamedCharacters_XFail() {

0 commit comments

Comments
 (0)