@@ -82,7 +82,7 @@ extension Regex {
8282 let tree : DSLTree
8383
8484 /// OptionSet of compiler options for testing purposes
85- fileprivate var compileOptions : Compiler . CompileOptions = . default
85+ fileprivate var compileOptions : CompileOptions = . default
8686
8787 private final class ProgramBox {
8888 let value : MEProgram
@@ -138,16 +138,37 @@ extension Regex {
138138@available ( SwiftStdlib 5 . 7 , * )
139139@_spi ( RegexBenchmark)
140140extension Regex {
141- /// Compiles the stored DSLTree into bytecode and return if it was successful
142- /// For measuring compilation times
143- ///
144- /// Note: This bypasses the cached program that is normally used
145- public func _compileRegex( ) -> Bool {
141+ public struct QueryResult {
142+
143+ }
144+
145+ public func _queryRegex( ) -> QueryResult {
146+ QueryResult ( )
147+ }
148+
149+ public enum _RegexInternalAction {
150+ case parse( String )
151+ case recompile
152+ case setOptions( CompileOptions )
153+ }
154+
155+ /// Internal API for RegexBenchmark
156+ /// Forces the regex to perform the given action, returning if it was successful
157+ public mutating func _forceAction( _ action: _RegexInternalAction ) -> Bool {
146158 do {
147- let _ = try Compiler (
148- tree: program. tree,
149- compileOptions: program. compileOptions) . emit ( )
150- return true
159+ switch action {
160+ case . setOptions( let opts) :
161+ _setCompilerOptionsForTesting ( opts)
162+ return true
163+ case . parse( let pattern) :
164+ let _ = try parse ( pattern, . traditional)
165+ return true
166+ case . recompile:
167+ let _ = try Compiler (
168+ tree: program. tree,
169+ compileOptions: program. compileOptions) . emit ( )
170+ return true
171+ }
151172 } catch {
152173 return false
153174 }
@@ -156,7 +177,9 @@ extension Regex {
156177
157178@available ( SwiftStdlib 5 . 7 , * )
158179extension Regex {
159- internal mutating func _setCompilerOptionsForTesting( _ opts: Compiler . CompileOptions ) {
180+ internal mutating func _setCompilerOptionsForTesting(
181+ _ opts: CompileOptions
182+ ) {
160183 program. compileOptions = opts
161184 program. _loweredProgramStorage = nil
162185 }
0 commit comments