1
1
import Foundation
2
2
3
3
package class Parser {
4
- private let formatter : XcbeautifyLib . Formatter
5
-
6
4
package private( set) var outputType = OutputType . undefined
7
5
8
6
private lazy var captureGroupTypes : [ CaptureGroup . Type ] = [
@@ -94,28 +92,16 @@ package class Parser {
94
92
95
93
// MARK: - Init
96
94
97
- package init (
98
- colored: Bool = true ,
99
- renderer: Renderer ,
100
- preserveUnbeautifiedLines: Bool = false ,
101
- additionalLines: @escaping ( ) -> ( String ? )
102
- ) {
103
- self . formatter = Formatter (
104
- colored: colored,
105
- renderer: renderer,
106
- preserveUnbeautifiedLines: preserveUnbeautifiedLines,
107
- additionalLines: additionalLines
108
- )
109
- }
95
+ public init ( ) { }
110
96
111
- package func parse( line: String ) -> String ? {
97
+ public func parse( line: String ) -> CaptureGroup ? {
112
98
// Find first parser that can parse specified string
113
99
guard let idx = captureGroupTypes. firstIndex ( where: { $0. regex. match ( string: line) } ) else {
114
100
// Some uncommon cases, which have additional logic and don't follow default flow
115
101
116
102
// Nothing found?
117
103
outputType = OutputType . undefined
118
- return formatter . preserveUnbeautifiedLines ? line : nil
104
+ return nil
119
105
}
120
106
121
107
guard let captureGroupType = captureGroupTypes [ safe: idx] else {
@@ -134,7 +120,7 @@ package class Parser {
134
120
// Move found parser to the top, so next time it will be checked first
135
121
captureGroupTypes. insert ( captureGroupTypes. remove ( at: idx) , at: 0 )
136
122
137
- return formatter . format ( captureGroup: captureGroup )
123
+ return captureGroup
138
124
}
139
125
}
140
126
0 commit comments