Skip to content

Commit dd5d247

Browse files
committed
Remove (?X) and (?u) for now
1 parent 32afc43 commit dd5d247

File tree

5 files changed

+54
-37
lines changed

5 files changed

+54
-37
lines changed

Sources/_RegexParser/Regex/Parse/LexicalAnalysis.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,10 @@ extension Source {
767767
return opt
768768

769769
// Swift semantic level options
770-
case "X": return advanceAndReturn(.graphemeClusterSemantics)
771-
case "u": return advanceAndReturn(.unicodeScalarSemantics)
770+
// These are disabled for now until we figure out the right semantics for
771+
// them
772+
// case "X": return advanceAndReturn(.graphemeClusterSemantics)
773+
// case "u": return advanceAndReturn(.unicodeScalarSemantics)
772774
case "b": return advanceAndReturn(.byteSemantics)
773775

774776
default:

Tests/RegexTests/CompileTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ 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: Reenable these tests once we figure out (?u) semantics
129+
//try expectInitialOptions(
130+
// "(?im)(?s).(?u)",
131+
// matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
130132

131133
try expectInitialOptions(
132134
"(?i:.)",

Tests/RegexTests/MatchTests.swift

Lines changed: 30 additions & 24 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-
firstMatchTests(
1024-
#"(?u)\u{65}\Y"#, // Grapheme non-boundary assertion
1025-
("Cafe\u{301}", "e"),
1026-
("Sol Cafe", nil))
1023+
1024+
// FIXME: Reenable these tests once we figure out (?u) semantics
1025+
//firstMatchTests(
1026+
// #"(?u)\u{65}\Y"#, // Grapheme non-boundary assertion
1027+
// ("Cafe\u{301}", "e"),
1028+
// ("Sol Cafe", nil))
10271029
}
10281030

10291031
func testMatchGroups() {
@@ -1594,7 +1596,8 @@ extension RegexTests {
15941596
// a single Unicode scalar value, leaving any other grapheme scalar
15951597
// components to be matched.
15961598

1597-
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e")
1599+
// FIXME: Reenable these tests once we figure out (?u) semantics
1600+
//firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e")
15981601

15991602
matchTest(
16001603
#".\u{301}"#,
@@ -1605,18 +1608,19 @@ extension RegexTests {
16051608
(eComposed, false),
16061609
(eDecomposed, false))
16071610

1611+
// FIXME: Reenable these tests once we figure out (?u) semantics
16081612
// FIXME: \O is unsupported
1609-
firstMatchTest(#"(?u)\O\u{301}"#, input: eDecomposed, match: eDecomposed)
1610-
firstMatchTest(#"(?u)e\O"#, input: eDecomposed, match: eDecomposed)
1611-
firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
1612-
firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
1613-
xfail: true)
1614-
1615-
matchTest(
1616-
#"(?u).\u{301}"#,
1617-
(eComposed, false),
1618-
(eDecomposed, true))
1619-
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed)
1613+
//firstMatchTest(#"(?u)\O\u{301}"#, input: eDecomposed, match: eDecomposed)
1614+
//firstMatchTest(#"(?u)e\O"#, input: eDecomposed, match: eDecomposed)
1615+
//firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
1616+
//firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
1617+
// xfail: true)
1618+
1619+
//matchTest(
1620+
// #"(?u).\u{301}"#,
1621+
// (eComposed, false),
1622+
// (eDecomposed, true))
1623+
//firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed)
16201624

16211625
// Option permutations for 'u' and 's'
16221626
matchTest(
@@ -1629,14 +1633,16 @@ extension RegexTests {
16291633
("e\u{301}ab", false),
16301634
("e\u{301}abc", true),
16311635
("e\u{301}\nab", true))
1632-
matchTest(
1633-
#"(?u)...."#,
1634-
("e\u{301}ab", true),
1635-
("e\u{301}\na", false))
1636-
matchTest(
1637-
#"(?us)...."#,
1638-
("e\u{301}ab", true),
1639-
("e\u{301}\na", true))
1636+
1637+
// FIXME: Reenable these tests once we figure out (?u) semantics
1638+
//matchTest(
1639+
// #"(?u)...."#,
1640+
// ("e\u{301}ab", true),
1641+
// ("e\u{301}\na", false))
1642+
//matchTest(
1643+
// #"(?us)...."#,
1644+
// ("e\u{301}ab", true),
1645+
// ("e\u{301}\na", true))
16401646
}
16411647

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

Tests/RegexTests/ParseTests.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,14 +1060,18 @@ extension RegexTests {
10601060
.singleLine, .reluctantByDefault, .extraExtended, .extended,
10611061
.unicodeWordBoundaries, .asciiOnlyDigit, .asciiOnlyPOSIXProps,
10621062
.asciiOnlySpace, .asciiOnlyWord, .textSegmentGraphemeMode,
1063-
.textSegmentWordMode, .graphemeClusterSemantics, .unicodeScalarSemantics,
1063+
.textSegmentWordMode,
1064+
// FIXME: Add these back once we figure out (?X) and (?u) semantics
1065+
//.graphemeClusterSemantics, .unicodeScalarSemantics,
10641066
.byteSemantics
10651067
]
1066-
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}Xub-iJmnsUxxxwDPSW)", changeMatchingOptions(
1067-
matchingOptions(adding: allOptions, removing: allOptions.dropLast(5))
1068+
1069+
1070+
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}b-iJmnsUxxxwDPSW)", changeMatchingOptions(
1071+
matchingOptions(adding: allOptions, removing: allOptions.dropLast(3))
10681072
), throwsError: .unsupported)
1069-
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}Xub-iJmnsUxxxwDPSW:)", changeMatchingOptions(
1070-
matchingOptions(adding: allOptions, removing: allOptions.dropLast(5)), empty()
1073+
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}b-iJmnsUxxxwDPSW:)", changeMatchingOptions(
1074+
matchingOptions(adding: allOptions, removing: allOptions.dropLast(3)), empty()
10711075
), throwsError: .unsupported)
10721076

10731077
parseTest(
@@ -2734,8 +2738,9 @@ extension RegexTests {
27342738
diagnosticTest("(?-y{g})", .cannotRemoveTextSegmentOptions)
27352739
diagnosticTest("(?-y{w})", .cannotRemoveTextSegmentOptions)
27362740

2737-
diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2738-
diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
2741+
// FIXME: Reenable once we figure out (?X) and (?u) semantics
2742+
//diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2743+
//diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
27392744
diagnosticTest("(?-b)", .cannotRemoveSemanticsOptions)
27402745

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

Tests/RegexTests/UTS18Tests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ 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: Reenable these tests once we figure out (?u) semantics
471+
//XCTAssertTrue("👩‍👩‍👧‍👦".contains(regex(#"(?u).\N{ZERO WIDTH JOINER}"#)))
470472
}
471473

472474
func testIndividuallyNamedCharacters_XFail() {

0 commit comments

Comments
 (0)