11private typealias ASCIIBitset = DSLTree . CustomCharacterClass . AsciiBitset
22
33extension Processor {
4- func _doASCIIBitsetMatch(
5- _: AsciiBitsetRegister
6- ) -> Input . Index ? {
7- fatalError ( )
8- }
9- }
10-
11-
12- extension String {
13- func index( after idx: Index , isScalarSemantics: Bool ) -> Index {
14- if isScalarSemantics {
15- return unicodeScalars. index ( after: idx)
16- } else {
17- return index ( after: idx)
18- }
19- }
20- }
21-
22-
23- extension Processor {
24-
254 internal mutating func runQuantify( _ payload: QuantifyPayload ) -> Bool {
265 let matched : Bool
276 switch ( payload. quantKind, payload. minTrips, payload. maxExtraTrips) {
@@ -61,8 +40,6 @@ extension Processor {
6140 boundaryCheck: !isScalarSemantics,
6241 isCaseInsensitive: false )
6342 case . builtin:
64- guard currentPosition < end else { return nil }
65-
6643 // We only emit .quantify if it consumes a single character
6744 return input. matchBuiltinCC (
6845 payload. builtin,
@@ -72,16 +49,10 @@ extension Processor {
7249 isStrictASCII: payload. builtinIsStrict,
7350 isScalarSemantics: isScalarSemantics)
7451 case . any:
75- guard currentPosition < end else { return nil }
76-
77- if payload. anyMatchesNewline {
78- return input. index (
79- after: currentPosition, isScalarSemantics: isScalarSemantics)
80- }
81-
82- return input. matchAnyNonNewline (
52+ return input. matchRegexDot (
8353 at: currentPosition,
8454 limitedBy: end,
55+ anyMatchesNewline: payload. anyMatchesNewline,
8556 isScalarSemantics: isScalarSemantics)
8657 }
8758 }
@@ -217,20 +188,16 @@ extension Processor {
217188 assert ( currentPosition > rangeEnd)
218189 }
219190 case . any:
191+ let anyMatchesNewline = payload. anyMatchesNewline
220192 while true {
221- guard currentPosition < end else { break }
222- let next : String . Index ?
223- if payload. anyMatchesNewline {
224- next = input. index (
225- after: currentPosition, isScalarSemantics: isScalarSemantics)
226- } else {
227- next = input. matchAnyNonNewline (
228- at: currentPosition,
229- limitedBy: end,
230- isScalarSemantics: isScalarSemantics)
193+ guard let next = input. matchRegexDot (
194+ at: currentPosition,
195+ limitedBy: end,
196+ anyMatchesNewline: anyMatchesNewline,
197+ isScalarSemantics: isScalarSemantics)
198+ else {
199+ break
231200 }
232-
233- guard let next else { break }
234201 matchedOnce = true
235202 rangeEnd = currentPosition
236203 currentPosition = next
0 commit comments