Moved swift4.0 support into single file

This commit is contained in:
andy
2018-10-01 14:54:10 +01:00
parent 66a9bc563a
commit 9bd86d9fd5
6 changed files with 50 additions and 54 deletions

View File

@@ -22,17 +22,10 @@ struct Lexer {
init(templateName: String? = nil, templateString: String) {
self.templateName = templateName
self.templateString = templateString
#if swift(>=4.1)
self.lines = templateString.components(separatedBy: .newlines).enumerated().compactMap {
guard !$0.element.isEmpty else { return nil }
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
}
#else
self.lines = templateString.components(separatedBy: .newlines).enumerated().flatMap {
guard !$0.element.isEmpty else { return nil }
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
}
#endif
self.lines = templateString.components(separatedBy: .newlines).enumerated().compactMap {
guard !$0.element.isEmpty else { return nil }
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
}
}
/// Create a token that will be passed on to the parser, with the given