Skip to content

Commit e6fec4b

Browse files
authored
Merge pull request #480 from Azoy/remove-some-flags
Remove (?X) and (?u) for now
2 parents 18f2d61 + 9624436 commit e6fec4b

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
@@ -1022,10 +1022,12 @@ extension RegexTests {
10221022
#"\u{65}\y"#, // Grapheme boundary assertion
10231023
("Cafe\u{301}", nil),
10241024
("Sol Cafe", "e"))
1025+
1026+
// FIXME: Figure out (?X) and (?u) semantics
10251027
firstMatchTests(
10261028
#"(?u)\u{65}\Y"#, // Grapheme non-boundary assertion
10271029
("Cafe\u{301}", "e"),
1028-
("Sol Cafe", nil))
1030+
("Sol Cafe", nil), xfail: true)
10291031
}
10301032

10311033
func testMatchGroups() {
@@ -1596,7 +1598,8 @@ extension RegexTests {
15961598
// a single Unicode scalar value, leaving any other grapheme scalar
15971599
// components to be matched.
15981600

1599-
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e")
1601+
// FIXME: Figure out (?X) and (?u) semantics
1602+
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e", xfail: true)
16001603

16011604
matchTest(
16021605
#".\u{301}"#,
@@ -1607,18 +1610,30 @@ extension RegexTests {
16071610
(eComposed, false),
16081611
(eDecomposed, false))
16091612

1613+
// FIXME: Figure out (?X) and (?u) semantics
16101614
// FIXME: \O is unsupported
1611-
firstMatchTest(#"(?u)\O\u{301}"#, input: eDecomposed, match: eDecomposed)
1612-
firstMatchTest(#"(?u)e\O"#, input: eDecomposed, match: eDecomposed)
1615+
firstMatchTest(
1616+
#"(?u)\O\u{301}"#,
1617+
input: eDecomposed,
1618+
match: eDecomposed,
1619+
xfail: true
1620+
)
1621+
firstMatchTest(
1622+
#"(?u)e\O"#,
1623+
input: eDecomposed,
1624+
match: eDecomposed,
1625+
xfail: true
1626+
)
16131627
firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
16141628
firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
16151629
xfail: true)
16161630

1631+
// FIXME: Figure out (?X) and (?u) semantics
16171632
matchTest(
16181633
#"(?u).\u{301}"#,
16191634
(eComposed, false),
1620-
(eDecomposed, true))
1621-
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed)
1635+
(eDecomposed, true), xfail: true)
1636+
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed, xfail: true)
16221637

16231638
// Option permutations for 'u' and 's'
16241639
matchTest(
@@ -1631,14 +1646,16 @@ extension RegexTests {
16311646
("e\u{301}ab", false),
16321647
("e\u{301}abc", true),
16331648
("e\u{301}\nab", true))
1649+
1650+
// FIXME: Figure out (?X) and (?u) semantics
16341651
matchTest(
16351652
#"(?u)...."#,
16361653
("e\u{301}ab", true),
1637-
("e\u{301}\na", false))
1654+
("e\u{301}\na", false), xfail: true)
16381655
matchTest(
16391656
#"(?us)...."#,
16401657
("e\u{301}ab", true),
1641-
("e\u{301}\na", true))
1658+
("e\u{301}\na", true), xfail: true)
16421659
}
16431660

16441661
// 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
@@ -1062,9 +1062,11 @@ extension RegexTests {
10621062
.singleLine, .reluctantByDefault, .extraExtended, .extended,
10631063
.unicodeWordBoundaries, .asciiOnlyDigit, .asciiOnlyPOSIXProps,
10641064
.asciiOnlySpace, .asciiOnlyWord, .textSegmentGraphemeMode,
1065-
.textSegmentWordMode, .graphemeClusterSemantics, .unicodeScalarSemantics,
1065+
.textSegmentWordMode,
1066+
.graphemeClusterSemantics, .unicodeScalarSemantics,
10661067
.byteSemantics
10671068
]
1069+
10681070
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}Xub-iJmnsUxxxwDPSW)", changeMatchingOptions(
10691071
matchingOptions(adding: allOptions, removing: allOptions.dropLast(5))
10701072
), throwsError: .unsupported)
@@ -2736,8 +2738,9 @@ extension RegexTests {
27362738
diagnosticTest("(?-y{g})", .cannotRemoveTextSegmentOptions)
27372739
diagnosticTest("(?-y{w})", .cannotRemoveTextSegmentOptions)
27382740

2739-
diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2740-
diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
2741+
// FIXME: Reenable once we figure out (?X) and (?u) semantics
2742+
//diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2743+
//diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
27412744
diagnosticTest("(?-b)", .cannotRemoveSemanticsOptions)
27422745

27432746
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)