@@ -4,43 +4,43 @@ import Foundation
4
4
@testable @_spi ( PatternConverter) import _StringProcessing
5
5
6
6
struct DSLConverter {
7
- func convert( _ pattern: String , matchingOptions: [ String ] = [ ] ) throws -> String {
8
- let ast = try _RegexParser. parse ( pattern, . traditional)
9
- var builderDSL = renderAsBuilderDSL ( ast: ast)
10
- if builderDSL. last == " \n " {
11
- builderDSL = String ( builderDSL. dropLast ( ) )
12
- }
13
-
14
- if matchingOptions. contains ( " m " ) {
15
- builderDSL. append ( " \n " )
16
- builderDSL. append ( " .anchorsMatchLineEndings() " )
17
- }
18
- if matchingOptions. contains ( " i " ) {
19
- builderDSL. append ( " \n " )
20
- builderDSL. append ( " .ignoresCase() " )
21
- }
22
- if matchingOptions. contains ( " s " ) {
23
- builderDSL. append ( " \n " )
24
- builderDSL. append ( " .dotMatchesNewlines() " )
25
- }
26
- if matchingOptions. contains ( " asciiOnlyWordCharacters " ) {
27
- builderDSL. append ( " \n " )
28
- builderDSL. append ( " .asciiOnlyWordCharacters() " )
29
- }
30
- if matchingOptions. contains ( " asciiOnlyDigits " ) {
31
- builderDSL. append ( " \n " )
32
- builderDSL. append ( " .asciiOnlyDigits() " )
33
- }
34
- if matchingOptions. contains ( " asciiOnlyWhitespace " ) {
35
- builderDSL. append ( " \n " )
36
- builderDSL. append ( " .asciiOnlyWhitespace() " )
37
- }
38
- if matchingOptions. contains ( " asciiOnlyCharacterClasses " ) {
39
- builderDSL. append ( " \n " )
40
- builderDSL. append ( " .asciiOnlyCharacterClasses() " )
41
- }
42
- builderDSL. append ( " \n " )
7
+ func convert( _ pattern: String , matchingOptions: [ String ] = [ ] ) throws -> String {
8
+ let ast = try _RegexParser. parse ( pattern, . traditional)
9
+ var builderDSL = renderAsBuilderDSL ( ast: ast)
10
+ if builderDSL. last == " \n " {
11
+ builderDSL = String ( builderDSL. dropLast ( ) )
12
+ }
43
13
44
- return builderDSL
14
+ if matchingOptions. contains ( " m " ) {
15
+ builderDSL. append ( " \n " )
16
+ builderDSL. append ( " .anchorsMatchLineEndings() " )
17
+ }
18
+ if matchingOptions. contains ( " i " ) {
19
+ builderDSL. append ( " \n " )
20
+ builderDSL. append ( " .ignoresCase() " )
21
+ }
22
+ if matchingOptions. contains ( " s " ) {
23
+ builderDSL. append ( " \n " )
24
+ builderDSL. append ( " .dotMatchesNewlines() " )
25
+ }
26
+ if matchingOptions. contains ( " asciiOnlyWordCharacters " ) {
27
+ builderDSL. append ( " \n " )
28
+ builderDSL. append ( " .asciiOnlyWordCharacters() " )
45
29
}
30
+ if matchingOptions. contains ( " asciiOnlyDigits " ) {
31
+ builderDSL. append ( " \n " )
32
+ builderDSL. append ( " .asciiOnlyDigits() " )
33
+ }
34
+ if matchingOptions. contains ( " asciiOnlyWhitespace " ) {
35
+ builderDSL. append ( " \n " )
36
+ builderDSL. append ( " .asciiOnlyWhitespace() " )
37
+ }
38
+ if matchingOptions. contains ( " asciiOnlyCharacterClasses " ) {
39
+ builderDSL. append ( " \n " )
40
+ builderDSL. append ( " .asciiOnlyCharacterClasses() " )
41
+ }
42
+ builderDSL. append ( " \n " )
43
+
44
+ return builderDSL
45
+ }
46
46
}
0 commit comments