Skip to content

Commit 18257c2

Browse files
committed
Explicitly handle (?x)
1 parent ac1b821 commit 18257c2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/_StringProcessing/PrintAsPattern.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,13 @@ extension DSLTree.Atom {
13391339

13401340
for option in options {
13411341
switch option.kind {
1342+
case .extended:
1343+
// We don't currently support (?x) in the DSL, so if we see it, just
1344+
// do nothing.
1345+
if options.count == 1 {
1346+
return nil
1347+
}
1348+
13421349
case .reluctantByDefault:
13431350
if isAdd {
13441351
printer.quantificationBehavior = .reluctant

Tests/RegexTests/RenderDSLTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ extension RenderDSLTests {
225225
"""#)
226226
try testConversion(#"[\u{301}]"#, #"""
227227
Regex {
228-
One(.anyOf("\u{301}"))
228+
One(CharacterClass.anyOf("\u{301}"))
229229
}
230230
"""#)
231231
try testConversion(#"[abc\u{301}]"#, #"""
232232
Regex {
233-
One(.anyOf("abc\u{301}"))
233+
One(CharacterClass.anyOf("abc\u{301}"))
234234
}
235235
"""#)
236236

0 commit comments

Comments
 (0)