@@ -24,21 +24,41 @@ struct Executor {
2424 in inputRange: Range < String . Index > ,
2525 _ mode: MatchMode
2626 ) throws -> RegexMatch < Match > ? {
27- guard let ( endIdx, capList) = engine. consume (
28- input, in: inputRange, matchMode: mode
29- ) else {
27+ var cpu = engine. makeProcessor (
28+ input: input, bounds: inputRange, matchMode: mode)
29+
30+ guard let endIdx = cpu. consume ( ) else {
3031 return nil
3132 }
33+
34+ let capList = CaptureList (
35+ values: cpu. storedCaptures,
36+ referencedCaptureOffsets: engine. program. referencedCaptureOffsets)
37+
3238 let capStruct = engine. program. captureStructure
3339 let range = inputRange. lowerBound..< endIdx
3440 let caps = try capStruct. structuralize (
3541 capList, input)
3642
43+ // FIXME: This is a workaround for not tracking (or
44+ // specially compiling) whole-match values.
45+ let value : Any ?
46+ if Match . self != Substring . self,
47+ Match . self != ( Substring, DynamicCaptures) . self,
48+ caps. isEmpty
49+ {
50+ value = cpu. registers. values. first
51+ assert ( value != nil , " hmm, what would this mean? " )
52+ } else {
53+ value = nil
54+ }
55+
3756 return RegexMatch (
3857 input: input,
3958 range: range,
4059 rawCaptures: caps,
41- referencedCaptureOffsets: capList. referencedCaptureOffsets)
60+ referencedCaptureOffsets: capList. referencedCaptureOffsets,
61+ value: value)
4262 }
4363
4464 func dynamicMatch(
0 commit comments