Skip to content

Commit 9e9978c

Browse files
committed
Don't use negative lookaheads for required atom
1 parent 469785a commit 9e9978c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/_StringProcessing/Regex/DSLList.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ extension DSLList {
180180
case .orderedChoice, .conditional:
181181
return .some(nil)
182182

183-
// Groups (and other parent nodes) defer to the child.
183+
// A negative lookahead rules out the existence of a safe required
184+
// character.
185+
case .nonCapturingGroup(let kind, _) where kind.isNegativeLookahead:
186+
return .some(nil)
187+
188+
// Other groups (and other parent nodes) defer to the child.
184189
case .nonCapturingGroup, .capture,
185190
.ignoreCapturesInTypedOutput,
186191
.limitCaptureNesting:
@@ -208,7 +213,6 @@ extension DSLList {
208213
return _requiredAtomImpl(&position) ?? nil
209214
}
210215

211-
212216
internal mutating func autoPossessifyNextQuantification(_ position: inout Int) -> (Int, DSLTree.Atom)? {
213217
guard position < nodes.count else {
214218
return nil

0 commit comments

Comments
 (0)