diff --git a/LICENSE b/LICENSE index 9a990fb..1f2859f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,9 @@ The MIT License (MIT) -Copyright (c) 2014-2015 Sam Soffes http://soff.es +Copyright (c) 2014-2016 Sam Soffes http://soff.es +Copyright (c) 2016-2021 Alexander Hedges. +Copyright (c) 2021 Zheng Wu. +All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..a8200ed --- /dev/null +++ b/Package.swift @@ -0,0 +1,32 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SyntaxKit", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "SyntaxKit", + targets: ["SyntaxKit"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "SyntaxKit", + dependencies: [] + ), + .testTarget( + name: "SyntaxKitTests", + dependencies: ["SyntaxKit"], + exclude: ["Fixtures"] + ), + ] +) diff --git a/Readme.markdown b/README.md similarity index 100% rename from Readme.markdown rename to README.md diff --git a/SyntaxKit/Resources/Info.plist b/Resources/Info.plist similarity index 85% rename from SyntaxKit/Resources/Info.plist rename to Resources/Info.plist index 17dee6f..06fe941 100644 --- a/SyntaxKit/Resources/Info.plist +++ b/Resources/Info.plist @@ -21,7 +21,7 @@ CFBundleVersion $(CURRENT_PROJECT_VERSION) NSHumanReadableCopyright - Copyright © 2015-2016 Sam Soffes. Copyright © 2016 Alexander Hedges. All rights reserved. + Copyright © 2015-2016 Sam Soffes. Copyright © 2016-2021 Alexander Hedges. Copyright © 2021 Zheng Wu. All rights reserved. NSPrincipalClass diff --git a/SyntaxKit/AttributedParser.swift b/Sources/SyntaxKit/AttributedParser.swift similarity index 100% rename from SyntaxKit/AttributedParser.swift rename to Sources/SyntaxKit/AttributedParser.swift diff --git a/SyntaxKit/AttributedParsingOperation.swift b/Sources/SyntaxKit/AttributedParsingOperation.swift similarity index 80% rename from SyntaxKit/AttributedParsingOperation.swift rename to Sources/SyntaxKit/AttributedParsingOperation.swift index 1350d8e..8c8458c 100644 --- a/SyntaxKit/AttributedParsingOperation.swift +++ b/Sources/SyntaxKit/AttributedParsingOperation.swift @@ -18,6 +18,8 @@ // Copyright © 2016 Alexander Hedges. All rights reserved. // +import Foundation + /// Represents one change (insertion or deletion) between two strings internal struct Diff { @@ -26,6 +28,7 @@ internal struct Diff { /// - Insertion: The inserted sting /// - Deletion: The empty string var change: String + /// The range of the change in the old string /// /// - Insertion: The location of the insertion and length 0 @@ -60,23 +63,28 @@ open class AttributedParsingOperation: Operation { /// /// The sender is passed in so it can be used to check if the operation was /// cancelled after the call. - public typealias OperationCallback = ([(range: NSRange, attributes: Attributes?)], AttributedParsingOperation) -> Void + #if DEBUG + public typealias OperationTuple = (scope: String, range: NSRange, attributes: Attributes?) + #else + public typealias OperationTuple = (range: NSRange, attributes: Attributes?) + #endif + public typealias OperationCallback = ([OperationTuple], AttributedParsingOperation) -> Void // MARK: - Properties private let parser: AttributedParser private let operationCallback: OperationCallback - private var parsedRange: NSRange? + private var outdatedRange: NSRange? // MARK: - Initializers - + /// Initializer for the first instance in the NSOperationQueue /// /// Can also be used if no incremental parsing is desired public init(string: String, language: Language, theme: Theme, callback: @escaping OperationCallback) { - parser = AttributedParser(language: language, theme: theme) - parser.toParse = ScopedString(string: string) - operationCallback = callback + self.parser = AttributedParser(language: language, theme: theme) + self.parser.toParse = ScopedString(string: string) + self.operationCallback = callback super.init() } @@ -94,8 +102,8 @@ open class AttributedParsingOperation: Operation { /// string that was added. /// - parameter callback: The callback to call with results. public init(string: String, previousOperation: AttributedParsingOperation, changeIsInsertion insertion: Bool, changedRange range: NSRange, newCallback callback: OperationCallback? = nil) { - parser = previousOperation.parser - operationCallback = callback ?? previousOperation.operationCallback + self.parser = AttributedParser(language: previousOperation.parser.language, theme: previousOperation.parser.theme) + self.operationCallback = callback ?? previousOperation.operationCallback super.init() @@ -106,8 +114,10 @@ open class AttributedParsingOperation: Operation { diff = Diff(change: "", range: range) } - if diff.representsChanges(from: parser.toParse.string, to: string) { - self.parsedRange = AttributedParsingOperation.outdatedRange(in: string as NSString, forChange: diff, updatingPreviousResult: &self.parser.toParse) + var prevParse = previousOperation.parser.toParse + if diff.representsChanges(from: prevParse.string, to: string) { + self.outdatedRange = AttributedParsingOperation.outdatedRange(in: string as NSString, forChange: diff, updatingPreviousResult: &prevParse) + self.parser.toParse = prevParse } else { self.parser.toParse = ScopedString(string: string) } @@ -116,22 +126,30 @@ open class AttributedParsingOperation: Operation { // MARK: - NSOperation Implementation open override func main() { - var resultsArray: [(range: NSRange, attributes: Attributes?)] = [] + var resultsArray: [OperationTuple] = [] + #if DEBUG + let callback = { (scope: String, range: NSRange, attributes: Attributes?) in + if let attributes = attributes { + resultsArray.append((scope, range, attributes)) + } + } + #else let callback = { (_: String, range: NSRange, attributes: Attributes?) in if let attributes = attributes { resultsArray.append((range, attributes)) } } + #endif - parser.parse(in: self.parsedRange, match: callback) + self.parser.parse(in: self.outdatedRange, match: callback) - if !parser.aborted { - operationCallback(resultsArray, self) + if !self.parser.aborted { + self.operationCallback(resultsArray, self) } } open override func cancel() { - parser.aborted = true + self.parser.aborted = true super.cancel() } @@ -157,7 +175,7 @@ open class AttributedParsingOperation: Operation { /// /// - returns: A range in newString that can be safely re-parsed. Or nil if /// everything has to be reparsed. - class func outdatedRange(in newString: NSString, forChange diff: Diff, updatingPreviousResult previous: inout ScopedString) -> NSRange? { + class func outdatedRange(in newString: NSString, forChange diff: Diff, updatingPreviousResult previous: inout ScopedString) -> NSRange { let linesRange: NSRange let range: NSRange if diff.isInsertion() { diff --git a/Sources/SyntaxKit/Attributes.swift b/Sources/SyntaxKit/Attributes.swift new file mode 100644 index 0000000..5f9c2dd --- /dev/null +++ b/Sources/SyntaxKit/Attributes.swift @@ -0,0 +1,38 @@ +// +// Attributes.swift +// +// +// Created by Zheng Wu on 2021/3/10. +// Copyright © 2021 Zheng Wu. All rights reserved. +// + +import Foundation + +public typealias Attributes = [NSAttributedString.Key: Any] + +public extension NSAttributedString.Key { + // Shared + static let foreground = NSAttributedString.Key("foreground") + static let background = NSAttributedString.Key("background") + + // Text Only + static let fontName = NSAttributedString.Key("fontName") + static let fontSize = NSAttributedString.Key("fontSize") + static let fontStyle = NSAttributedString.Key("fontStyle") + static let caret = NSAttributedString.Key("caret") + static let selection = NSAttributedString.Key("selection") + static let invisibles = NSAttributedString.Key("invisibles") + static let lineHighlight = NSAttributedString.Key("lineHighlight") + + // Gutter Only + static let divider = NSAttributedString.Key("divider") + static let selectionBorder = NSAttributedString.Key("selectionBorder") + static let icons = NSAttributedString.Key("icons") + static let iconsHover = NSAttributedString.Key("iconsHover") + static let iconsPressed = NSAttributedString.Key("iconsPressed") + static let selectionForeground = NSAttributedString.Key("selectionForeground") + static let selectionBackground = NSAttributedString.Key("selectionBackground") + static let selectionIcons = NSAttributedString.Key("selectionIcons") + static let selectionIconsHover = NSAttributedString.Key("selectionIconsHover") + static let selectionIconsPressed = NSAttributedString.Key("selectionIconsPressed") +} diff --git a/SyntaxKit/BundleManager.swift b/Sources/SyntaxKit/BundleManager.swift similarity index 54% rename from SyntaxKit/BundleManager.swift rename to Sources/SyntaxKit/BundleManager.swift index b33d109..c1f0a54 100644 --- a/SyntaxKit/BundleManager.swift +++ b/Sources/SyntaxKit/BundleManager.swift @@ -12,6 +12,8 @@ // Copyright © 2016 Alexander Hedges. All rights reserved. // +import Foundation + open class BundleManager { public enum TextMateFileType { @@ -37,10 +39,15 @@ open class BundleManager { /// has to be done separately using clearLanguageCache. open var languageCaching: Bool = true + /// You probably want to leave the themeCaching property set to true. + /// + /// - note: Setting it to false will not invalidate or purge the cache. This + /// has to be done separately using clearThemeCache. + open var themeCaching: Bool = true + public static var defaultManager: BundleManager? private var bundleCallback: BundleLocationCallback - private var dependencies: [Language] = [] private var cachedLanguages: [String: Language] = [:] private var cachedThemes: [String: Theme] = [:] @@ -70,56 +77,78 @@ open class BundleManager { return language } - self.dependencies = [] - var language = self.loadRawLanguage(withIdentifier: identifier) - language?.validate(with: self.dependencies) + guard let newLanguage = includeLanguage(withIdentifier: identifier) else { + return nil + } + + var languageSet = Set(arrayLiteral: newLanguage) + var languageDependencies = [Language]() + + while let language = languageSet.popFirst() { + languageDependencies.append(language) + for childLanguageRef in language.referencedLanguageRefs { + if languageDependencies.map({ $0.scopeName }).contains(childLanguageRef) { + continue + } + guard let childLanguage = includeLanguage(withIdentifier: childLanguageRef) else { + continue + } + languageSet.insert(childLanguage) + } + } + + // Now we finally got all helper languages + newLanguage.validate(with: languageDependencies) - if languageCaching && language != nil { - self.cachedLanguages[identifier] = language + if languageCaching { + self.cachedLanguages[identifier] = newLanguage } - self.dependencies = [] - return language + return newLanguage } - open func theme(withIdentifier identifier: String) -> Theme? { + open func theme(withIdentifier identifier: String, fontCallback: Theme.FontCallback? = nil) -> Theme? { if let theme = cachedThemes[identifier] { return theme } - guard let dictURL = self.bundleCallback(identifier, .theme), - let plist = NSDictionary(contentsOf: dictURL) as? [String: Any], - let newTheme = Theme(dictionary: plist) else { - return nil + guard let newTheme = includeTheme(withIdentifier: identifier, fontCallback: fontCallback) else { + return nil } - cachedThemes[identifier] = newTheme + if themeCaching { + self.cachedThemes[identifier] = newTheme + } return newTheme } - /// Clears the language cache. Use if low on memory. - open func clearLanguageCache() { - self.cachedLanguages = [:] + /// Use if low on memory. + open func clearCaches() { + self.cachedLanguages.removeAll() + self.cachedThemes.removeAll() } // MARK: - Internal Interface /// - parameter identifier: The identifier of the requested language. - /// - returns: The Language with unresolved extenal references, if found - func loadRawLanguage(withIdentifier identifier: String) -> Language? { - let indexOfStoredLanguage = self.dependencies.firstIndex { (lang: Language) in lang.scopeName == identifier } - - if let index = indexOfStoredLanguage { - return self.dependencies[index] - } else { - guard let dictURL = self.bundleCallback(identifier, .language), - let plist = NSDictionary(contentsOf: dictURL) as? [String: Any], - let newLanguage = Language(dictionary: plist, manager: self) else { - return nil - } - - self.dependencies.append(newLanguage) - return newLanguage + /// - returns: The Language with unresolved extenal references, if found. + private func includeLanguage(withIdentifier identifier: String) -> Language? { + guard let dictURL = self.bundleCallback(identifier, .language), + let plist = NSDictionary(contentsOf: dictURL) as? [String: Any], + let newLanguage = Language(dictionary: plist, manager: self) else { + return nil } + return newLanguage + } + + /// - parameter identifier: The identifier of the requested theme. + /// - returns: The Theme with unresolved extenal references, if found. + private func includeTheme(withIdentifier identifier: String, fontCallback: Theme.FontCallback? = nil) -> Theme? { + guard let dictURL = self.bundleCallback(identifier, .theme), + let plist = NSDictionary(contentsOf: dictURL) as? [String: Any], + let newTheme = Theme(dictionary: plist, fontCallback: fontCallback) else { + return nil + } + return newTheme } } diff --git a/SyntaxKit/Capture.swift b/Sources/SyntaxKit/Capture.swift similarity index 96% rename from SyntaxKit/Capture.swift rename to Sources/SyntaxKit/Capture.swift index 839f771..8db21ec 100644 --- a/SyntaxKit/Capture.swift +++ b/Sources/SyntaxKit/Capture.swift @@ -8,6 +8,8 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + internal struct Capture { // MARK: - Properties diff --git a/SyntaxKit/CaptureCollection.swift b/Sources/SyntaxKit/CaptureCollection.swift similarity index 98% rename from SyntaxKit/CaptureCollection.swift rename to Sources/SyntaxKit/CaptureCollection.swift index 0aedf7d..bd1ea49 100644 --- a/SyntaxKit/CaptureCollection.swift +++ b/Sources/SyntaxKit/CaptureCollection.swift @@ -8,6 +8,8 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + internal struct CaptureCollection { // MARK: - Properties diff --git a/SyntaxKit/Color.swift b/Sources/SyntaxKit/Color.swift similarity index 99% rename from SyntaxKit/Color.swift rename to Sources/SyntaxKit/Color.swift index 36326f4..9f03645 100644 --- a/SyntaxKit/Color.swift +++ b/Sources/SyntaxKit/Color.swift @@ -6,7 +6,7 @@ // Copyright © 2015 Sam Soffes. All rights reserved. // -#if os(OSX) +#if os(macOS) import AppKit.NSColor public typealias ColorType = NSColor diff --git a/Sources/SyntaxKit/Font.swift b/Sources/SyntaxKit/Font.swift new file mode 100644 index 0000000..eae738e --- /dev/null +++ b/Sources/SyntaxKit/Font.swift @@ -0,0 +1,67 @@ +// +// Font.swift +// SyntaxKit +// +// Created by Zheng Wu on 2021/3/6. +// Copyright © 2021 Zheng Wu. All rights reserved. +// + +#if os(macOS) +import AppKit.NSFont +public typealias FontType = NSFont + +extension NSFont { + func withTraits(traits: NSFontTraitMask) -> NSFont { + return NSFontManager.shared.convert( + self, + toHaveTrait: traits + ) + } + + func bold() -> NSFont { + return withTraits(traits: .boldFontMask) + } + + func italic() -> NSFont { + return withTraits(traits: .italicFontMask) + } + + func boldItalic() -> NSFont { + return withTraits(traits: [.boldFontMask, .italicFontMask]) + } +} +#else +import UIKit.UIFont +public typealias FontType = UIFont + +extension UIFont { + func withTraits(traits: UIFontDescriptor.SymbolicTraits) -> UIFont { + let descriptor = fontDescriptor.withSymbolicTraits(traits) + return UIFont(descriptor: descriptor!, size: 0) // size 0 means keep the size as it is + } + + func bold() -> UIFont { + return withTraits(traits: .traitBold) + } + + func italic() -> UIFont { + return withTraits(traits: .traitItalic) + } + + func boldItalic() -> UIFont { + return withTraits(traits: [.traitBold, .traitItalic]) + } +} +#endif + +public typealias Font = FontType + +public enum FontStyle: String { + case initial + case plain + case bold + case italic + case boldItalic + case underline + case strikethrough +} diff --git a/SyntaxKit/Language.swift b/Sources/SyntaxKit/Language.swift similarity index 68% rename from SyntaxKit/Language.swift rename to Sources/SyntaxKit/Language.swift index b23b9ee..8e94ff6 100644 --- a/SyntaxKit/Language.swift +++ b/Sources/SyntaxKit/Language.swift @@ -9,18 +9,33 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // -public struct Language { +import Foundation + +public struct Language: Hashable { + + public static func == (lhs: Language, rhs: Language) -> Bool { + return lhs.uuid == rhs.uuid && lhs.name == rhs.name && lhs.scopeName == rhs.scopeName + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(uuid) + hasher.combine(name) + hasher.combine(scopeName) + } // MARK: - Properties public let uuid: UUID public let name: String public let scopeName: String + public let fileTypes: [String] let pattern: Pattern = Pattern() let referenceManager: ReferenceManager let repository: Repository + var referencedLanguageRefs: [String] { referenceManager.includedLanguageRefs } + static let globalScope: String = "GLOBAL" // MARK: - Initializers @@ -30,15 +45,20 @@ public struct Language { let uuid = UUID(uuidString: uuidString), let name = dictionary["name"] as? String, let scopeName = dictionary["scopeName"] as? String, - let array = dictionary["patterns"] as? [[String: Any]] + let patterns = dictionary["patterns"] as? [[String: Any]] else { return nil } self.uuid = uuid self.name = name self.scopeName = scopeName + if let fileTypes = dictionary["fileTypes"] as? [String] { + self.fileTypes = fileTypes + } else { + self.fileTypes = [] + } self.referenceManager = ReferenceManager(bundleManager: manager) - self.pattern.subpatterns = referenceManager.patterns(for: array, in: nil, caller: nil) + self.pattern.subpatterns = referenceManager.patterns(for: patterns, in: nil, caller: nil) self.repository = Repository(repo: dictionary["repository"] as? [String: [AnyHashable: Any]] ?? [:], inParent: nil, with: referenceManager) referenceManager.resolveInternalReferences(with: repository, in: self) } @@ -49,7 +69,7 @@ public struct Language { /// - parameter helperLanguages: The languages that the language has /// references to resolve against. This should at least contain the /// language itself. - mutating func validate(with helperLanguages: [Language]) { + func validate(with helperLanguages: [Language]) { ReferenceManager.resolveExternalReferences(between: helperLanguages, basename: self.scopeName) } } diff --git a/SyntaxKit/Parser.swift b/Sources/SyntaxKit/Parser.swift similarity index 81% rename from SyntaxKit/Parser.swift rename to Sources/SyntaxKit/Parser.swift index f0cdba4..a390cc9 100644 --- a/SyntaxKit/Parser.swift +++ b/Sources/SyntaxKit/Parser.swift @@ -10,6 +10,8 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + open class Parser { // MARK: - Types @@ -66,7 +68,7 @@ open class Parser { while startIndex < endIndex { let endPattern = endScope.attribute as? Pattern ?? language.pattern - guard let results = self.matchSubpatterns(of: endPattern, in: NSRange(location: startIndex, length: endIndex - startIndex)) else { + guard let results = self.matchSubpatterns(of: endPattern, in: NSRange(location: startIndex, length: endIndex - startIndex), beginResults: nil) else { return } @@ -115,7 +117,7 @@ open class Parser { /// /// - returns: The result set containing the lexical scope names with range /// information or nil if aborted. May exceed range. - private func matchSubpatterns(of pattern: Pattern, in range: NSRange) -> ResultSet? { + private func matchSubpatterns(of pattern: Pattern, in range: NSRange, beginResults begin: ResultSet?) -> ResultSet? { let stop = range.location + range.length var lineStart = range.location var lineEnd = range.location @@ -130,23 +132,24 @@ open class Parser { return nil } - let bestMatchForMiddle = match(pattern.subpatterns, in: range) + let bestMatchForMiddle = self.match(pattern.subpatterns, in: range) - if let patternEnd = pattern.end, - let endMatchResult = self.match(patternEnd, in: range, captures: pattern.endCaptures) { - if let middleMatch = bestMatchForMiddle { - if !pattern.applyEndPatternLast && endMatchResult.range.location <= middleMatch.match.range.location || endMatchResult.range.location < middleMatch.match.range.location { + if let patternEnd = pattern.end { + if let endMatchResult = self.match(patternEnd.expandedRegularExpression(with: toParse.string, matches: begin), in: range, captures: pattern.endCaptures) { + if let middleMatch = bestMatchForMiddle { + if !pattern.applyEndPatternLast && endMatchResult.range.location <= middleMatch.match.range.location || endMatchResult.range.location < middleMatch.match.range.location { + result.add(endMatchResult) + return result + } + } else { result.add(endMatchResult) return result } - } else { - result.add(endMatchResult) - return result } } guard let middleMatch = bestMatchForMiddle, - let middleResult = middleMatch.pattern.match != nil ? middleMatch.match : matchAfterBegin(of: middleMatch.pattern, beginResults: middleMatch.match) else { + let middleResult = middleMatch.pattern.match != nil ? middleMatch.match : self.matchAfterBegin(of: middleMatch.pattern, beginResults: middleMatch.match) else { break } if middleResult.range.length == 0 { @@ -178,7 +181,7 @@ open class Parser { var interestingBounds = range var bestResult: (pattern: Pattern, match: ResultSet)? for pattern in patterns { - let currentMatch = self.firstMatch(of: pattern, in: range) + let currentMatch = self.firstMatch(of: pattern, in: range, beginResults: bestResult?.match) if currentMatch?.match.range.location == range.location { return currentMatch } else if let currMatch = currentMatch { @@ -202,19 +205,19 @@ open class Parser { /// - parameter range: The range in which to match the pattern /// /// - returns: The matched pattern and the matching result. Nil on failure. - private func firstMatch(of pattern: Pattern, in range: NSRange) -> (pattern: Pattern, match: ResultSet)? { + private func firstMatch(of pattern: Pattern, in range: NSRange, beginResults begin: ResultSet?) -> (pattern: Pattern, match: ResultSet)? { if let expression = pattern.match { - if let resultSet = match(expression, in: range, captures: pattern.captures, baseSelector: pattern.name) { + if let resultSet = self.match(expression.expandedRegularExpression(with: toParse.string, matches: begin), in: range, captures: pattern.captures, baseSelector: pattern.name) { if resultSet.range.length != 0 { return (pattern, resultSet) } } } else if let begin = pattern.begin { - if let beginResults = match(begin, in: range, captures: pattern.beginCaptures) { + if let beginResults = self.match(begin, in: range, captures: pattern.beginCaptures) { return (pattern, beginResults) } } else if pattern.subpatterns.count >= 1 { - return match(pattern.subpatterns, in: range) + return self.match(pattern.subpatterns, in: range) } return nil } @@ -230,19 +233,19 @@ open class Parser { /// - parameter begin: The match result of the beginning /// - returns: The result of matching the given pattern or nil on abortion. private func matchAfterBegin(of pattern: Pattern, beginResults begin: ResultSet) -> ResultSet? { - let newLocation = NSMaxRange(begin.range) - guard let endResults = matchSubpatterns(of: pattern, in: NSRange(location: newLocation, length: (toParse.string as NSString).length - newLocation)) else { - return nil - } + let newLocation = NSMaxRange(begin.range) + guard let endResults = self.matchSubpatterns(of: pattern, in: NSRange(location: newLocation, length: (toParse.string as NSString).length - newLocation), beginResults: begin) else { + return nil + } - let result = ResultSet(startingRange: endResults.range) - if let patternName = pattern.name { - result.add(Result(identifier: patternName, range: NSUnionRange(begin.range, endResults.range))) - } - result.add(Scope(identifier: pattern.name ?? "", range: NSRange(location: begin.range.location + begin.range.length, length: NSUnionRange(begin.range, endResults.range).length - begin.range.length), attribute: pattern)) - result.add(begin) - result.add(endResults) - return result + let result = ResultSet(startingRange: endResults.range) + if let patternName = pattern.name { + result.add(Result(identifier: patternName, range: NSUnionRange(begin.range, endResults.range))) + } + result.add(Scope(identifier: pattern.name ?? "", range: NSRange(location: begin.range.location + begin.range.length, length: NSUnionRange(begin.range, endResults.range).length - begin.range.length), attribute: pattern)) + result.add(begin) + result.add(endResults) + return result } /// Matches a given regular expression in the String and returns range @@ -258,14 +261,14 @@ open class Parser { /// - returns: The set containing the results. May be nil if the expression /// could not match any part of the string. It may also be empty /// and only contain range information to show what it matched. - private func match(_ expression: NSRegularExpression, in range: NSRange, captures: CaptureCollection?, baseSelector: String? = nil) -> ResultSet? { + private func match(_ expression: RegularExpression, in range: NSRange, captures: CaptureCollection?, baseSelector: String? = nil) -> ResultSet? { guard let result = expression.firstMatch(in: toParse.string, options: [.withTransparentBounds], range: range) else { return nil } let resultSet = ResultSet(startingRange: result.range) if let base = baseSelector { - resultSet.add(Result(identifier: base, range: result.range)) + resultSet.add(Result(identifier: base, range: result.range, result: result)) } if let captures = captures { @@ -278,9 +281,9 @@ open class Parser { if range.location == NSNotFound { continue } - + if let scope = captures[index]?.name { - resultSet.add(Result(identifier: scope, range: range)) + resultSet.add(Result(identifier: scope, range: range, result: result)) } } } diff --git a/SyntaxKit/Pattern.swift b/Sources/SyntaxKit/Pattern.swift similarity index 84% rename from SyntaxKit/Pattern.swift rename to Sources/SyntaxKit/Pattern.swift index 4e27605..784d434 100644 --- a/SyntaxKit/Pattern.swift +++ b/Sources/SyntaxKit/Pattern.swift @@ -19,17 +19,19 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + @objc(SKPattern) internal class Pattern: NSObject { // MARK: - Properties var name: String? { return _name } - var match: NSRegularExpression? { return _match } + var match: RegularExpression? { return _match } var captures: CaptureCollection? { return _captures } - var begin: NSRegularExpression? { return _begin } + var begin: RegularExpression? { return _begin } var beginCaptures: CaptureCollection? { return _beginCaptures } - var end: NSRegularExpression? { return _end } + var end: RegularExpression? { return _end } var endCaptures: CaptureCollection? { return _endCaptures } var applyEndPatternLast: Bool { return _applyEndPatternLast } var parent: Pattern? { return _parent } @@ -37,11 +39,11 @@ internal class Pattern: NSObject { // swiftlint:disable strict_fileprivate fileprivate var _name: String? - fileprivate var _match: NSRegularExpression? + fileprivate var _match: RegularExpression? fileprivate var _captures: CaptureCollection? - fileprivate var _begin: NSRegularExpression? + fileprivate var _begin: RegularExpression? fileprivate var _beginCaptures: CaptureCollection? - fileprivate var _end: NSRegularExpression? + fileprivate var _end: RegularExpression? fileprivate var _endCaptures: CaptureCollection? fileprivate var _applyEndPatternLast: Bool = false fileprivate weak var _parent: Pattern? @@ -55,15 +57,15 @@ internal class Pattern: NSObject { _name = dictionary["name"] as? String if let matchExpr = dictionary["match"] as? String { - _match = try? NSRegularExpression(pattern: matchExpr, options: [.anchorsMatchLines]) + _match = try? RegularExpression(pattern: matchExpr, options: [.anchorsMatchLines]) } if let beginExpr = dictionary["begin"] as? String { - _begin = try? NSRegularExpression(pattern: beginExpr, options: [.anchorsMatchLines]) + _begin = try? RegularExpression(pattern: beginExpr, options: [.anchorsMatchLines]) } if let endExpr = dictionary["end"] as? String { - _end = try? NSRegularExpression(pattern: endExpr, options: [.anchorsMatchLines]) + _end = try? RegularExpression(pattern: endExpr, options: [.anchorsMatchLines]) } _applyEndPatternLast = dictionary["applyEndPatternLast"] as? Bool ?? false @@ -131,9 +133,20 @@ internal class Include: Pattern { private var type: ReferenceType private var associatedRepository: Repository? + var languageRef: String? { + switch type { + case let .toForeignRepository(_, languageRef): + return languageRef + case let .toForeign(languageRef): + return languageRef + default: + return nil + } + } + // MARK: - Initializers - init(reference: String, in repository: Repository? = nil, parent: Pattern?, manager: BundleManager) { + init(reference: String, in repository: Repository? = nil, parent: Pattern?, manager: BundleManager /* not used but inherits from Pattern */) { self.associatedRepository = repository if reference.hasPrefix("#") { self.type = .toRepository(repositoryRef: String(reference[reference.index(after: reference.startIndex)...])) @@ -145,14 +158,11 @@ internal class Include: Pattern { if let hashRange = reference.range(of: "#") { let languagePart = String(reference[.. [Pattern] { guard let manager = bundleManager else { - assert(false) - return [] + fatalError("bundleManager not set") } var results: [Pattern] = [] for rawPattern in patterns { @@ -61,7 +66,7 @@ internal class ReferenceManager { for language in languages { let includes = language.referenceManager.includes for include in includes { - include.resolveExternalReference(from: language, in: otherLanguages, baseName: basename) + include.resolveExternalReference(in: otherLanguages, baseName: basename) } } } diff --git a/Sources/SyntaxKit/RegularExpression.swift b/Sources/SyntaxKit/RegularExpression.swift new file mode 100644 index 0000000..a8030d4 --- /dev/null +++ b/Sources/SyntaxKit/RegularExpression.swift @@ -0,0 +1,266 @@ +// +// RegularExpression.swift +// SyntaxKit +// +// Created by Zheng Wu on 2021/2/19. +// Copyright © 2021 Zheng Wu. All rights reserved. +// + +import Foundation + +internal extension String { + static let zeroCChar = "0".cString(using: .ascii)![0] + static let backslashCChar = "\\".cString(using: .ascii)![0] + static let dollarCChar = "$".cString(using: .ascii)![0] + + var hasBackReferencePlaceholder: Bool { + var escape = false + let buf = cString(using: .utf8)!.dropLast() + for ch in buf { + if escape && isdigit(Int32(ch)) != 0 { + return true + } + escape = !escape && ch == String.backslashCChar + } + return false + } + + // Converts into an escaped regex string + func addingRegexEscapedCharacters() -> String { + let special = "\\|([{}]).?*+^$".cString(using: .ascii) + let buf = cString(using: .utf8)!.dropLast() + var res = "" + for ch in buf { + if strchr(special, Int32(ch)) != nil { + res += "\\" + } + res += String(format: "%c", ch) + } + return res + } + + // Converts a back-referenced regex string to an ICU back-referenced regex string + func convertToICUBackReferencedRegex() -> String { + var escape = false + let buf = cString(using: .utf8)!.dropLast() + var res = "" + for ch in buf { + if escape && isdigit(Int32(ch)) != 0 { + res += String(format: "$%c", ch) + escape = false + continue + } + escape = !escape && ch == String.backslashCChar + if !escape { + res += String(format: "%c", ch) + } + } + return res + } + + // Converts an ICU back-referenced regex string to a back-referenced regex string + func convertToBackReferencedRegex() -> String { + var escape = false + var capture = false + let buf = cString(using: .utf8)!.dropLast() + var res = "" + for ch in buf { + if !escape && capture && isdigit(Int32(ch)) != 0 { + capture = false + res += String(format: "\\%c", ch) + continue + } + if escape { + escape = false + res += String(format: "%c", ch) + continue + } + if !escape && ch == String.dollarCChar { + capture = true + continue + } + if ch == String.backslashCChar { + escape = true + continue + } + res += String(format: "%c", ch) + } + return res + } + + // Expand a back-referenced regex string with original content and matches + func removingBackReferencePlaceholders(content: String, matches: NSTextCheckingResult) -> String { + var escape = false + let buf = cString(using: .utf8)!.dropLast() + var res = "" + for ch in buf { + if escape && isdigit(Int32(ch)) != 0 { + let i = Int(ch - String.zeroCChar) + if i <= matches.numberOfRanges - 1 { + let refRange = matches.range(at: i) + if refRange.location != NSNotFound { + res += (content as NSString).substring(with: refRange).addingRegexEscapedCharacters() + } + } + escape = false + continue + } + if escape { + res += "\\" + } + escape = !escape && ch == String.backslashCChar + if !escape { + res += String(format: "%c", ch) + } + } + return res + } +} + +internal class RegularExpression { + + // MARK: - Properties + + var pattern: String { return _pattern } + var options: RegularExpression.Options { return _options } + var isTemplate: Bool { return _isTemplate } + var expression: NSRegularExpression? { return _expression } + + // swiftlint:disable strict_fileprivate + fileprivate var _pattern: String + fileprivate var _options: RegularExpression.Options + fileprivate var _isTemplate: Bool + fileprivate var _expression: NSRegularExpression? + // swiftlint:enable strict_fileprivate + + // MARK: - Initializer + + init(pattern: String, options: RegularExpression.Options = []) throws { + self._pattern = pattern + self._options = options + self._isTemplate = pattern.hasBackReferencePlaceholder + if !self._isTemplate { + self._expression = try NSRegularExpression(pattern: pattern, options: NSRegularExpression.Options(rawValue: options.rawValue)) + } + } + + func expandedRegularExpression(with referencedContent: String, matches: ResultSet?) -> RegularExpression { + return RegularExpression.expandRegularExpression(self, with: referencedContent, matches: matches) + } + + private static func expandRegularExpression(_ regex: RegularExpression, with referencedContent: String, matches: ResultSet?) -> RegularExpression { + guard regex.isTemplate, + let matches = matches, + let result = matches.results.first?.result else { + return regex + } + return ( + try? RegularExpression( + pattern: regex.pattern.removingBackReferencePlaceholders(content: referencedContent, matches: result), + options: regex.options + ) + ) ?? regex + } +} + +/* NSRegularExpression Implementation */ + +internal extension RegularExpression { + struct Options : OptionSet { + let rawValue: UInt + init(rawValue: UInt) { + self.rawValue = rawValue + } + static let caseInsensitive = Options(rawValue: NSRegularExpression.Options.caseInsensitive.rawValue) + static let allowCommentsAndWhitespace = Options(rawValue: NSRegularExpression.Options.allowCommentsAndWhitespace.rawValue) + static let ignoreMetacharacters = Options(rawValue: NSRegularExpression.Options.ignoreMetacharacters.rawValue) + static let dotMatchesLineSeparators = Options(rawValue: NSRegularExpression.Options.dotMatchesLineSeparators.rawValue) + static let anchorsMatchLines = Options(rawValue: NSRegularExpression.Options.anchorsMatchLines.rawValue) + static let useUnixLineSeparators = Options(rawValue: NSRegularExpression.Options.useUnixLineSeparators.rawValue) + static let useUnicodeWordBoundaries = Options(rawValue: NSRegularExpression.Options.useUnicodeWordBoundaries.rawValue) + } + + struct MatchingOptions : OptionSet { + let rawValue: UInt + init(rawValue: UInt) { + self.rawValue = rawValue + } + static let reportProgress = MatchingOptions(rawValue: NSRegularExpression.MatchingOptions.reportProgress.rawValue) + static let reportCompletion = MatchingOptions(rawValue: NSRegularExpression.MatchingOptions.reportCompletion.rawValue) + static let anchored = MatchingOptions(rawValue: NSRegularExpression.MatchingOptions.anchored.rawValue) + static let withTransparentBounds = MatchingOptions(rawValue: NSRegularExpression.MatchingOptions.withTransparentBounds.rawValue) + static let withoutAnchoringBounds = MatchingOptions(rawValue: NSRegularExpression.MatchingOptions.withoutAnchoringBounds.rawValue) + } + + struct MatchingFlags : OptionSet { + let rawValue: UInt + init(rawValue: UInt) { + self.rawValue = rawValue + } + static var progress = MatchingFlags(rawValue: NSRegularExpression.MatchingFlags.progress.rawValue) + static var completed = MatchingFlags(rawValue: NSRegularExpression.MatchingFlags.completed.rawValue) + static var hitEnd = MatchingFlags(rawValue: NSRegularExpression.MatchingFlags.hitEnd.rawValue) + static var requiredEnd = MatchingFlags(rawValue: NSRegularExpression.MatchingFlags.requiredEnd.rawValue) + static var internalError = MatchingFlags(rawValue: NSRegularExpression.MatchingFlags.internalError.rawValue) + } +} + +internal extension RegularExpression { + + var numberOfCaptureGroups: Int { + return _expression?.numberOfCaptureGroups ?? 0 + } + + static func escapedPattern(for string: String) -> String { + return NSRegularExpression.escapedPattern(for: string) + } + +} + +internal extension RegularExpression { + + func enumerateMatches(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange, using block: (NSTextCheckingResult?, RegularExpression.MatchingFlags, UnsafeMutablePointer) -> Void) { + _expression?.enumerateMatches(in: string, options: NSRegularExpression.MatchingOptions(rawValue: options.rawValue), range: range) { (result, flags, stop) in + block(result, RegularExpression.MatchingFlags(rawValue: flags.rawValue), stop) + } + } + + func matches(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange) -> [NSTextCheckingResult] { + return _expression?.matches(in: string, options: NSRegularExpression.MatchingOptions(rawValue: options.rawValue), range: range) ?? [] + } + + func numberOfMatches(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange) -> Int { + return _expression?.numberOfMatches(in: string, options: NSRegularExpression.MatchingOptions(rawValue: options.rawValue), range: range) ?? 0 + } + + func firstMatch(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange) -> NSTextCheckingResult? { + return _expression?.firstMatch(in: string, options: NSRegularExpression.MatchingOptions(rawValue: options.rawValue), range: range) + } + + func rangeOfFirstMatch(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange) -> NSRange { + return _expression?.rangeOfFirstMatch(in: string, options: NSRegularExpression.MatchingOptions(rawValue: options.rawValue), range: range) ?? NSRange(location: NSNotFound, length: 0) + } + +} + +/* NSRegularExpression's find-and-replace methods, not used. */ + +internal extension RegularExpression { + + func stringByReplacingMatches(in string: String, options: RegularExpression.MatchingOptions = [], range: NSRange, withTemplate templ: String) -> String { + fatalError("not supported") + } + + func replaceMatches(in string: NSMutableString, options: RegularExpression.MatchingOptions = [], range: NSRange, withTemplate templ: String) -> Int { + fatalError("not supported") + } + + func replacementString(for result: NSTextCheckingResult, in string: String, offset: Int, template templ: String) -> String { + fatalError("not supported") + } + + class func escapedTemplate(for string: String) -> String { + fatalError("not supported") + } + +} diff --git a/SyntaxKit/Repository.swift b/Sources/SyntaxKit/Repository.swift similarity index 98% rename from SyntaxKit/Repository.swift rename to Sources/SyntaxKit/Repository.swift index a2f72ff..4edd3ba 100644 --- a/SyntaxKit/Repository.swift +++ b/Sources/SyntaxKit/Repository.swift @@ -9,6 +9,8 @@ // Copyright © 2016 Alexander Hedges. All rights reserved. // +import Foundation + internal class Repository { // MARK: - Properties diff --git a/SyntaxKit/Result.swift b/Sources/SyntaxKit/Result.swift similarity index 76% rename from SyntaxKit/Result.swift rename to Sources/SyntaxKit/Result.swift index ba1442f..201d0a0 100644 --- a/SyntaxKit/Result.swift +++ b/Sources/SyntaxKit/Result.swift @@ -8,19 +8,23 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + internal struct Result: Equatable { // MARK: - Properties let patternIdentifier: String var range: NSRange + let result: NSTextCheckingResult? let attribute: AnyObject? // MARK: - Initializers - init(identifier: String, range: NSRange, attribute: AnyObject? = nil) { + init(identifier: String, range: NSRange, result: NSTextCheckingResult? = nil, attribute: AnyObject? = nil) { self.patternIdentifier = identifier self.range = range + self.result = result self.attribute = attribute } } diff --git a/SyntaxKit/ResultSet.swift b/Sources/SyntaxKit/ResultSet.swift similarity index 98% rename from SyntaxKit/ResultSet.swift rename to Sources/SyntaxKit/ResultSet.swift index 0f379b3..222fbba 100644 --- a/SyntaxKit/ResultSet.swift +++ b/Sources/SyntaxKit/ResultSet.swift @@ -8,6 +8,8 @@ // Copyright © 2014-2015 Sam Soffes. All rights reserved. // +import Foundation + internal class ResultSet { // MARK: - Properties diff --git a/SyntaxKit/ScopedString.swift b/Sources/SyntaxKit/ScopedString.swift similarity index 99% rename from SyntaxKit/ScopedString.swift rename to Sources/SyntaxKit/ScopedString.swift index 5d6f612..018482e 100644 --- a/SyntaxKit/ScopedString.swift +++ b/Sources/SyntaxKit/ScopedString.swift @@ -257,7 +257,7 @@ internal struct ScopedString { for pattern in levels[level] { let range = pattern.range if range.length == 0 { - assert(false) + fatalError("empty range") } else if range.length == 1 { levelString = (levelString as NSString).replacingCharacters(in: range, with: "|") } else { diff --git a/Sources/SyntaxKit/SyntaxKit.swift b/Sources/SyntaxKit/SyntaxKit.swift new file mode 100644 index 0000000..10051c7 --- /dev/null +++ b/Sources/SyntaxKit/SyntaxKit.swift @@ -0,0 +1 @@ +// Placeholder diff --git a/Sources/SyntaxKit/Theme.swift b/Sources/SyntaxKit/Theme.swift new file mode 100644 index 0000000..0a83278 --- /dev/null +++ b/Sources/SyntaxKit/Theme.swift @@ -0,0 +1,198 @@ +// +// Theme.swift +// SyntaxKit +// +// Represents a TextMate theme file (.tmTheme). Currently only supports the +// foreground text color attribute on a local scope. +// +// Created by Sam Soffes on 10/11/14. +// Copyright © 2014-2015 Sam Soffes. All rights reserved. +// + +#if os(macOS) + import AppKit +#else + import UIKit +#endif + +public struct Theme { + + // MARK: - Public Types + + public typealias FontCallback = (_ fontName: String, _ fontSize: CGFloat, _ fontStyle: FontStyle) -> (Font?) + + // MARK: - Private Defaults + + private var fontName: String = Theme.defaultFontName + private var fontSize: CGFloat = Theme.defaultFontSize + private var fontCallback: FontCallback? + + // MARK: - Properties + + public let uuid: UUID + public let name: String + public let semanticClass: String? + public let attributes: [String: Attributes] + + public let gutterSettings: Attributes? + public var globalSettings: Attributes? { attributes[Theme.globalScope] } + + // MARK: - Global Convenience + + public var font: Font { + return (globalSettings?[.font] as? Font) ?? Theme.defaultFontWithStyle(.initial) + } + + public var foregroundColor: Color { + return (globalSettings?[.foregroundColor] as? Color) ?? Theme.defaultForegroundColor + } + + public var backgroundColor: Color { + return (globalSettings?[.backgroundColor] as? Color) ?? Theme.defaultBackgroundColor + } + + public var caretColor: Color? { + return globalSettings?[.caret] as? Color + } + + public var selectionColor: Color? { + return globalSettings?[.selection] as? Color + } + + public var invisiblesColor: Color? { + return globalSettings?[.invisibles] as? Color + } + + public var lineHighlightColor: Color? { + return globalSettings?[.lineHighlight] as? Color + } + + // MARK: - Static Convenience + private static func defaultFontWithStyle(_ style: FontStyle) -> Font { + if #available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) { + switch style { + case .bold: + return Font.monospacedSystemFont(ofSize: defaultFontSize, weight: .bold) + case .italic: + return Font.monospacedSystemFont(ofSize: defaultFontSize, weight: .regular).italic() + case .boldItalic: + return Font.monospacedSystemFont(ofSize: defaultFontSize, weight: .bold).italic() + default: + return Font.monospacedSystemFont(ofSize: defaultFontSize, weight: .regular) + } + } else { + // Fallback on earlier versions + #if os(macOS) + switch style { + case .bold: + return Font.userFixedPitchFont(ofSize: defaultFontSize)!.bold() + case .italic: + return Font.userFixedPitchFont(ofSize: defaultFontSize)!.italic() + case .boldItalic: + return Font.userFixedPitchFont(ofSize: defaultFontSize)!.boldItalic() + default: + return Font.userFixedPitchFont(ofSize: defaultFontSize)! + } + #else + switch style { + case .bold: + return Font(name: "Menlo-Bold", size: defaultFontSize)! + case .italic: + return Font(name: "Menlo-Italic", size: defaultFontSize)! + case .boldItalic: + return Font(name: "Menlo-BoldItalic", size: defaultFontSize)! + default: + return Font(name: "Menlo-Regular", size: defaultFontSize)! + } + #endif + } + } + private static var defaultFontName : String = defaultFontWithStyle(.initial).fontName + private static var defaultFontSize : CGFloat = 12.0 + private static var defaultBackgroundColor = Color.white + private static var defaultForegroundColor = Color.black + + private static let globalScope: String = "GLOBAL" + + // MARK: - Initializers + + init?(dictionary: [String: Any], fontCallback: FontCallback? = nil) { + guard let uuidString = dictionary["uuid"] as? String, + let uuid = UUID(uuidString: uuidString), + let name = dictionary["name"] as? String, + let rawSettings = dictionary["settings"] as? [[String: AnyObject]] + else { return nil } + + self.uuid = uuid + self.name = name + + if let semanticClass = dictionary["semanticClass"] as? String { + self.semanticClass = semanticClass + } else { + self.semanticClass = nil + } + + if let rawGutterSettings = dictionary["gutterSettings"] as? [String: AnyObject] { + var gutterSettings = Attributes() + for rawGutter in rawGutterSettings { + gutterSettings[NSAttributedString.Key(rawValue: rawGutter.key)] = rawGutter.value + } + self.gutterSettings = gutterSettings + } else { + self.gutterSettings = nil + } + + var attributes = [String: Attributes]() + for raw in rawSettings { + guard var setting = raw["settings"] as? [NSAttributedString.Key: Any] else { continue } + + if let value = setting.removeValue(forKey: .foreground) as? String { + setting[NSAttributedString.Key.foregroundColor] = Color(hex: value) + } + + if let value = setting.removeValue(forKey: .background) as? String { + setting[NSAttributedString.Key.backgroundColor] = Color(hex: value) + } + + if let value = setting.removeValue(forKey: .fontStyle) as? String, let fontStyle = FontStyle(rawValue: value) { + switch fontStyle { + case .initial, .plain, .bold, .italic, .boldItalic: + setting[NSAttributedString.Key.font] = fontCallback?(self.fontName, self.fontSize, fontStyle) ?? Theme.defaultFontWithStyle(fontStyle) + case .underline: // plain + underline + setting[NSAttributedString.Key.font] = fontCallback?(self.fontName, self.fontSize, .plain) ?? Theme.defaultFontWithStyle(.plain) + setting[NSAttributedString.Key.underlineStyle] = NSUnderlineStyle.single.rawValue + case .strikethrough: // plain + strikethrough + setting[NSAttributedString.Key.font] = fontCallback?(self.fontName, self.fontSize, .plain) ?? Theme.defaultFontWithStyle(.plain) + setting[NSAttributedString.Key.strikethroughStyle] = NSUnderlineStyle.single.rawValue + } + } else { + setting[NSAttributedString.Key.font] = fontCallback?(self.fontName, self.fontSize, .plain) ?? Theme.defaultFontWithStyle(.plain) + } + + if let patternIdentifiers = raw["scope"] as? String { + for patternIdentifier in patternIdentifiers.components(separatedBy: ",") { + let key = patternIdentifier.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) + attributes[key] = setting + } + } else if !setting.isEmpty { + + if let fontCallback = fontCallback { + let fontName = (setting.removeValue(forKey: .fontName) as? String) ?? Theme.defaultFontName + let fontSize = (setting.removeValue(forKey: .fontSize) as? CGFloat) ?? Theme.defaultFontSize + if let font = fontCallback(fontName, fontSize, .initial) { + setting[NSAttributedString.Key.font] = font + self.fontName = font.fontName + self.fontSize = font.pointSize + } + } else { + setting[NSAttributedString.Key.font] = Theme.defaultFontWithStyle(.initial) + } + + attributes[Theme.globalScope] = setting + } + } + + self.attributes = attributes + self.fontCallback = fontCallback + } +} diff --git a/SyntaxKit.podspec b/SyntaxKit.podspec deleted file mode 100644 index 9dcc333..0000000 --- a/SyntaxKit.podspec +++ /dev/null @@ -1,19 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'SyntaxKit' - spec.version = '1.0' - spec.authors = {'Sam Soffes' => 'sam@soff.es'} - spec.homepage = 'https://github.com/soffes/SyntaxKit' - spec.summary = 'TextMate-style syntax highlighting.' - spec.source = {:git => 'https://github.com/soffes/SyntaxKit.git', :tag => "v#{spec.version}"} - spec.license = { :type => 'MIT', :file => 'LICENSE' } - - spec.ios.deployment_target = '8.0' - spec.ios.frameworks = 'Foundation', 'UIKit' - - spec.osx.deployment_target = '10.9' - spec.osx.frameworks = 'Foundation', 'AppKit' - - spec.source_files = 'SyntaxKit/*.{h,m,swift}' - - spec.module_name = 'SyntaxKit' -end diff --git a/SyntaxKit.xcodeproj/project.pbxproj b/SyntaxKit.xcodeproj/project.pbxproj index 281827a..cbc6809 100644 --- a/SyntaxKit.xcodeproj/project.pbxproj +++ b/SyntaxKit.xcodeproj/project.pbxproj @@ -7,130 +7,121 @@ objects = { /* Begin PBXBuildFile section */ - 210299DE1B2E892E009C61EE /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299CF1B2E8924009C61EE /* LanguageTests.swift */; }; - 210299DF1B2E892E009C61EE /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299D01B2E8924009C61EE /* AttributedParserTests.swift */; }; - 210BF26D1B37C04E008AA4F0 /* test.rb.txt in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26C1B37C04E008AA4F0 /* test.rb.txt */; }; - 210BF26E1B37C04E008AA4F0 /* test.rb.txt in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26C1B37C04E008AA4F0 /* test.rb.txt */; }; - 210BF2701B37C0A2008AA4F0 /* Ruby.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26F1B37C0A2008AA4F0 /* Ruby.tmLanguage */; }; - 210BF2711B37C0A2008AA4F0 /* Ruby.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26F1B37C0A2008AA4F0 /* Ruby.tmLanguage */; }; 211826E41D257A71003F2BF2 /* SyntaxKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 211826DA1D257A71003F2BF2 /* SyntaxKit.framework */; }; - 211826F11D257A7E003F2BF2 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */; }; - 211826F21D257A7E003F2BF2 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898D1B2EC38B00F0D786 /* Capture.swift */; }; - 211826F31D257A7E003F2BF2 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */; }; - 211826F51D257A7E003F2BF2 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989911B2EC38B00F0D786 /* Parser.swift */; }; - 211826F61D257A7E003F2BF2 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989921B2EC38B00F0D786 /* Pattern.swift */; }; - 211826F71D257A7E003F2BF2 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989931B2EC38B00F0D786 /* Result.swift */; }; - 211826F81D257A7E003F2BF2 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989941B2EC38B00F0D786 /* ResultSet.swift */; }; - 211826F91D257A7E003F2BF2 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989961B2EC38B00F0D786 /* Theme.swift */; }; - 211826FA1D257A84003F2BF2 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989821B2EB18000F0D786 /* TestHelper.swift */; }; - 211826FB1D257A84003F2BF2 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989881B2EB8D400F0D786 /* ParserTests.swift */; }; - 211826FC1D257A84003F2BF2 /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299D01B2E8924009C61EE /* AttributedParserTests.swift */; }; - 211826FD1D257A84003F2BF2 /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299CF1B2E8924009C61EE /* LanguageTests.swift */; }; - 211826FE1D257A84003F2BF2 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898A1B2EBA2C00F0D786 /* ThemeTests.swift */; }; - 211826FF1D257A8A003F2BF2 /* Ruby.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26F1B37C0A2008AA4F0 /* Ruby.tmLanguage */; }; - 211827001D257A8A003F2BF2 /* test.rb.txt in Resources */ = {isa = PBXBuildFile; fileRef = 210BF26C1B37C04E008AA4F0 /* test.rb.txt */; }; - 211827011D257A8A003F2BF2 /* Tomorrow.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 2119897E1B2EAF0900F0D786 /* Tomorrow.tmTheme */; }; - 211827021D257A8A003F2BF2 /* Yaml.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 2119897F1B2EAF0900F0D786 /* Yaml.tmLanguage */; }; - 211827031D257AA3003F2BF2 /* SyntaxKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 211989951B2EC38B00F0D786 /* SyntaxKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 211989801B2EAF0900F0D786 /* Tomorrow.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 2119897E1B2EAF0900F0D786 /* Tomorrow.tmTheme */; }; - 211989811B2EAF0900F0D786 /* Yaml.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 2119897F1B2EAF0900F0D786 /* Yaml.tmLanguage */; }; - 211989841B2EB18600F0D786 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989821B2EB18000F0D786 /* TestHelper.swift */; }; - 211989891B2EB8D400F0D786 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989881B2EB8D400F0D786 /* ParserTests.swift */; }; - 2119898B1B2EBA2C00F0D786 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898A1B2EBA2C00F0D786 /* ThemeTests.swift */; }; - 211989971B2EC38B00F0D786 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */; }; - 211989981B2EC38B00F0D786 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898D1B2EC38B00F0D786 /* Capture.swift */; }; - 211989991B2EC38B00F0D786 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */; }; - 2119899C1B2EC38B00F0D786 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989911B2EC38B00F0D786 /* Parser.swift */; }; - 2119899D1B2EC38B00F0D786 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989921B2EC38B00F0D786 /* Pattern.swift */; }; - 2119899E1B2EC38B00F0D786 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989931B2EC38B00F0D786 /* Result.swift */; }; - 2119899F1B2EC38B00F0D786 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989941B2EC38B00F0D786 /* ResultSet.swift */; }; - 211989A01B2EC38B00F0D786 /* SyntaxKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 211989951B2EC38B00F0D786 /* SyntaxKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 211989A11B2EC38B00F0D786 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989961B2EC38B00F0D786 /* Theme.swift */; }; 211989B11B2EC3B600F0D786 /* SyntaxKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 211989A71B2EC3B600F0D786 /* SyntaxKit.framework */; }; - 211989BE1B2EC40000F0D786 /* SyntaxKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 211989951B2EC38B00F0D786 /* SyntaxKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 211989BF1B2EC40500F0D786 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */; }; - 211989C01B2EC40500F0D786 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898D1B2EC38B00F0D786 /* Capture.swift */; }; - 211989C11B2EC40500F0D786 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */; }; - 211989C41B2EC40500F0D786 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989911B2EC38B00F0D786 /* Parser.swift */; }; - 211989C51B2EC40500F0D786 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989921B2EC38B00F0D786 /* Pattern.swift */; }; - 211989C61B2EC40500F0D786 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989931B2EC38B00F0D786 /* Result.swift */; }; - 211989C71B2EC40500F0D786 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989941B2EC38B00F0D786 /* ResultSet.swift */; }; - 211989C81B2EC40500F0D786 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989961B2EC38B00F0D786 /* Theme.swift */; }; - 211989C91B2EC40900F0D786 /* Tomorrow.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 2119897E1B2EAF0900F0D786 /* Tomorrow.tmTheme */; }; - 211989CA1B2EC40900F0D786 /* Yaml.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 2119897F1B2EAF0900F0D786 /* Yaml.tmLanguage */; }; - 211989CB1B2EC40C00F0D786 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989821B2EB18000F0D786 /* TestHelper.swift */; }; - 211989CC1B2EC40C00F0D786 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989881B2EB8D400F0D786 /* ParserTests.swift */; }; - 211989CD1B2EC40C00F0D786 /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299D01B2E8924009C61EE /* AttributedParserTests.swift */; }; - 211989CE1B2EC40C00F0D786 /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210299CF1B2E8924009C61EE /* LanguageTests.swift */; }; - 211989CF1B2EC40C00F0D786 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898A1B2EBA2C00F0D786 /* ThemeTests.swift */; }; 2122A6EA1B22B9320006409B /* SyntaxKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2122A6DE1B22B9320006409B /* SyntaxKit.framework */; }; - 2198CED21B36D5DE00BD463F /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */; }; - 2198CED31B36D5DE00BD463F /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898D1B2EC38B00F0D786 /* Capture.swift */; }; - 2198CED41B36D5DE00BD463F /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */; }; - 2198CED71B36D5DE00BD463F /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989911B2EC38B00F0D786 /* Parser.swift */; }; - 2198CED81B36D5DE00BD463F /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989921B2EC38B00F0D786 /* Pattern.swift */; }; - 2198CED91B36D5DE00BD463F /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989931B2EC38B00F0D786 /* Result.swift */; }; - 2198CEDA1B36D5DE00BD463F /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989941B2EC38B00F0D786 /* ResultSet.swift */; }; - 2198CEDB1B36D5DE00BD463F /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211989961B2EC38B00F0D786 /* Theme.swift */; }; - 2198CEDC1B36D5E100BD463F /* SyntaxKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 211989951B2EC38B00F0D786 /* SyntaxKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8C08C3C71C36FD6D00D8548F /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C08C3C61C36FD6D00D8548F /* Color.swift */; }; - 8C10B6441CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */; }; - 8C10B6451CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */; }; - 8C10B6461CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */; }; - 8C10B6471CC3937F00740E00 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C08C3C61C36FD6D00D8548F /* Color.swift */; }; - 8C10B6481CC3938100740E00 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C08C3C61C36FD6D00D8548F /* Color.swift */; }; - 8C10B6491CC393E700740E00 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */; }; - 8C2EB3571D4B50EE005ECE2B /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C08C3C61C36FD6D00D8548F /* Color.swift */; }; - 8C2EB3581D4B510F005ECE2B /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE64FE21C74B48D0007BA57 /* Language.swift */; }; - 8C2EB3591D4B5126005ECE2B /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */; }; - 8C2EB35A1D4B5126005ECE2B /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */; }; - 8C2EB35B1D4B5126005ECE2B /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD6F1A1C71594B0063915A /* BundleManager.swift */; }; - 8C2EB35C1D4B5126005ECE2B /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0E11C411F9700BF3E85 /* Repository.swift */; }; - 8C2EB35D1D4B5126005ECE2B /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */; }; - 8C2EB35E1D4B524F005ECE2B /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE8D1161C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift */; }; - 8C2EB35F1D4B524F005ECE2B /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C71A05C1C59587700041EC6 /* IncrementalParsingTests.swift */; }; - 8C2EB3601D4B524F005ECE2B /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE6BE2D1C5D1BBA002676BD /* ScopedStringTests.swift */; }; - 8C2EB3611D4B525A005ECE2B /* Swift.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8CE8D1131C4EBF58005A86B3 /* Swift.tmLanguage */; }; - 8C2EB3621D4B525A005ECE2B /* swifttest.swift.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD221C4D877D008ECD6D /* swifttest.swift.txt */; }; - 8C2EB3631D4B525A005ECE2B /* Solarized.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD251C4D87D6008ECD6D /* Solarized.tmTheme */; }; - 8C4D09C01E1EAF750034974A /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4D09BF1E1EAF750034974A /* PerformanceTests.swift */; }; - 8C4D09C11E1EAF750034974A /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4D09BF1E1EAF750034974A /* PerformanceTests.swift */; }; - 8C4D09C21E1EAF750034974A /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4D09BF1E1EAF750034974A /* PerformanceTests.swift */; }; - 8C4D09C41E1EB0670034974A /* Latex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C31E1EB0670034974A /* Latex.tmLanguage */; }; - 8C4D09C51E1EB0670034974A /* Latex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C31E1EB0670034974A /* Latex.tmLanguage */; }; - 8C4D09C61E1EB0670034974A /* Latex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C31E1EB0670034974A /* Latex.tmLanguage */; }; - 8C4D09C81E1EB07D0034974A /* Tex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C71E1EB07D0034974A /* Tex.tmLanguage */; }; - 8C4D09C91E1EB07D0034974A /* Tex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C71E1EB07D0034974A /* Tex.tmLanguage */; }; - 8C4D09CA1E1EB07D0034974A /* Tex.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09C71E1EB07D0034974A /* Tex.tmLanguage */; }; - 8C4D09CC1E1EB16C0034974A /* textest.tex.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09CB1E1EB16C0034974A /* textest.tex.txt */; }; - 8C4D09CD1E1EB16C0034974A /* textest.tex.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09CB1E1EB16C0034974A /* textest.tex.txt */; }; - 8C4D09CE1E1EB16C0034974A /* textest.tex.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8C4D09CB1E1EB16C0034974A /* textest.tex.txt */; }; - 8C71A05D1C59587700041EC6 /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C71A05C1C59587700041EC6 /* IncrementalParsingTests.swift */; }; - 8C71A05E1C59587700041EC6 /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C71A05C1C59587700041EC6 /* IncrementalParsingTests.swift */; }; - 8C9003331C5C0B0D00CBA5B0 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */; }; - 8C9003341C5C0B0D00CBA5B0 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */; }; - 8CAEC6BA1D3BB297001C57D3 /* swifttest.swift.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD221C4D877D008ECD6D /* swifttest.swift.txt */; }; - 8CB2FD261C4D87D6008ECD6D /* Solarized.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD251C4D87D6008ECD6D /* Solarized.tmTheme */; }; - 8CB2FD271C4D87D6008ECD6D /* Solarized.tmTheme in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD251C4D87D6008ECD6D /* Solarized.tmTheme */; }; - 8CB2FD281C4D891A008ECD6D /* swifttest.swift.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2FD221C4D877D008ECD6D /* swifttest.swift.txt */; }; - 8CDD6F1B1C71594B0063915A /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD6F1A1C71594B0063915A /* BundleManager.swift */; }; - 8CDD6F1C1C71594B0063915A /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD6F1A1C71594B0063915A /* BundleManager.swift */; }; - 8CDD6F1D1C71594B0063915A /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD6F1A1C71594B0063915A /* BundleManager.swift */; }; - 8CE64FE31C74B48D0007BA57 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE64FE21C74B48D0007BA57 /* Language.swift */; }; - 8CE64FE41C74B48D0007BA57 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE64FE21C74B48D0007BA57 /* Language.swift */; }; - 8CE64FE51C74B48D0007BA57 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE64FE21C74B48D0007BA57 /* Language.swift */; }; - 8CE6BE2E1C5D1BBA002676BD /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE6BE2D1C5D1BBA002676BD /* ScopedStringTests.swift */; }; - 8CE6BE2F1C5D1BBA002676BD /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE6BE2D1C5D1BBA002676BD /* ScopedStringTests.swift */; }; - 8CE8D1141C4EBF58005A86B3 /* Swift.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8CE8D1131C4EBF58005A86B3 /* Swift.tmLanguage */; }; - 8CE8D1151C4EBF58005A86B3 /* Swift.tmLanguage in Resources */ = {isa = PBXBuildFile; fileRef = 8CE8D1131C4EBF58005A86B3 /* Swift.tmLanguage */; }; - 8CE8D1171C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE8D1161C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift */; }; - 8CE8D1181C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CE8D1161C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift */; }; - 8CEEC0DE1C411C8600BF3E85 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */; }; - 8CEEC0DF1C411C8600BF3E85 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */; }; - 8CEEC0E01C411C8600BF3E85 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */; }; - 8CEEC0E21C411F9700BF3E85 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0E11C411F9700BF3E85 /* Repository.swift */; }; - 8CEEC0E31C411F9700BF3E85 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0E11C411F9700BF3E85 /* Repository.swift */; }; - 8CEEC0E41C411F9700BF3E85 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CEEC0E11C411F9700BF3E85 /* Repository.swift */; }; + CCA6D13525F90D20000690C4 /* SyntaxKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12125F90D20000690C4 /* SyntaxKit.swift */; }; + CCA6D13625F90D20000690C4 /* SyntaxKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12125F90D20000690C4 /* SyntaxKit.swift */; }; + CCA6D13725F90D20000690C4 /* SyntaxKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12125F90D20000690C4 /* SyntaxKit.swift */; }; + CCA6D13825F90D20000690C4 /* SyntaxKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12125F90D20000690C4 /* SyntaxKit.swift */; }; + CCA6D13925F90D20000690C4 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12225F90D20000690C4 /* ScopedString.swift */; }; + CCA6D13A25F90D20000690C4 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12225F90D20000690C4 /* ScopedString.swift */; }; + CCA6D13B25F90D20000690C4 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12225F90D20000690C4 /* ScopedString.swift */; }; + CCA6D13C25F90D20000690C4 /* ScopedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12225F90D20000690C4 /* ScopedString.swift */; }; + CCA6D13D25F90D20000690C4 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12325F90D20000690C4 /* CaptureCollection.swift */; }; + CCA6D13E25F90D20000690C4 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12325F90D20000690C4 /* CaptureCollection.swift */; }; + CCA6D13F25F90D20000690C4 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12325F90D20000690C4 /* CaptureCollection.swift */; }; + CCA6D14025F90D20000690C4 /* CaptureCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12325F90D20000690C4 /* CaptureCollection.swift */; }; + CCA6D14125F90D20000690C4 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12425F90D20000690C4 /* Language.swift */; }; + CCA6D14225F90D20000690C4 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12425F90D20000690C4 /* Language.swift */; }; + CCA6D14325F90D20000690C4 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12425F90D20000690C4 /* Language.swift */; }; + CCA6D14425F90D20000690C4 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12425F90D20000690C4 /* Language.swift */; }; + CCA6D14525F90D20000690C4 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */; }; + CCA6D14625F90D20000690C4 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */; }; + CCA6D14725F90D20000690C4 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */; }; + CCA6D14825F90D20000690C4 /* AttributedParsingOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */; }; + CCA6D14925F90D20000690C4 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12625F90D20000690C4 /* Capture.swift */; }; + CCA6D14A25F90D20000690C4 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12625F90D20000690C4 /* Capture.swift */; }; + CCA6D14B25F90D20000690C4 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12625F90D20000690C4 /* Capture.swift */; }; + CCA6D14C25F90D20000690C4 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12625F90D20000690C4 /* Capture.swift */; }; + CCA6D14D25F90D21000690C4 /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12725F90D20000690C4 /* BundleManager.swift */; }; + CCA6D14E25F90D21000690C4 /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12725F90D20000690C4 /* BundleManager.swift */; }; + CCA6D14F25F90D21000690C4 /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12725F90D20000690C4 /* BundleManager.swift */; }; + CCA6D15025F90D21000690C4 /* BundleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12725F90D20000690C4 /* BundleManager.swift */; }; + CCA6D15125F90D21000690C4 /* Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12825F90D20000690C4 /* Attributes.swift */; }; + CCA6D15225F90D21000690C4 /* Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12825F90D20000690C4 /* Attributes.swift */; }; + CCA6D15325F90D21000690C4 /* Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12825F90D20000690C4 /* Attributes.swift */; }; + CCA6D15425F90D21000690C4 /* Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12825F90D20000690C4 /* Attributes.swift */; }; + CCA6D15525F90D21000690C4 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12925F90D20000690C4 /* Result.swift */; }; + CCA6D15625F90D21000690C4 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12925F90D20000690C4 /* Result.swift */; }; + CCA6D15725F90D21000690C4 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12925F90D20000690C4 /* Result.swift */; }; + CCA6D15825F90D21000690C4 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12925F90D20000690C4 /* Result.swift */; }; + CCA6D15925F90D21000690C4 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */; }; + CCA6D15A25F90D21000690C4 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */; }; + CCA6D15B25F90D21000690C4 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */; }; + CCA6D15C25F90D21000690C4 /* ReferenceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */; }; + CCA6D16125F90D21000690C4 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12C25F90D20000690C4 /* Repository.swift */; }; + CCA6D16225F90D21000690C4 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12C25F90D20000690C4 /* Repository.swift */; }; + CCA6D16325F90D21000690C4 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12C25F90D20000690C4 /* Repository.swift */; }; + CCA6D16425F90D21000690C4 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12C25F90D20000690C4 /* Repository.swift */; }; + CCA6D16525F90D21000690C4 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12D25F90D20000690C4 /* Parser.swift */; }; + CCA6D16625F90D21000690C4 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12D25F90D20000690C4 /* Parser.swift */; }; + CCA6D16725F90D21000690C4 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12D25F90D20000690C4 /* Parser.swift */; }; + CCA6D16825F90D21000690C4 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12D25F90D20000690C4 /* Parser.swift */; }; + CCA6D16925F90D21000690C4 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12E25F90D20000690C4 /* AttributedParser.swift */; }; + CCA6D16A25F90D21000690C4 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12E25F90D20000690C4 /* AttributedParser.swift */; }; + CCA6D16B25F90D21000690C4 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12E25F90D20000690C4 /* AttributedParser.swift */; }; + CCA6D16C25F90D21000690C4 /* AttributedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12E25F90D20000690C4 /* AttributedParser.swift */; }; + CCA6D16D25F90D21000690C4 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12F25F90D20000690C4 /* Theme.swift */; }; + CCA6D16E25F90D21000690C4 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12F25F90D20000690C4 /* Theme.swift */; }; + CCA6D16F25F90D21000690C4 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12F25F90D20000690C4 /* Theme.swift */; }; + CCA6D17025F90D21000690C4 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D12F25F90D20000690C4 /* Theme.swift */; }; + CCA6D17125F90D21000690C4 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13025F90D20000690C4 /* Font.swift */; }; + CCA6D17225F90D21000690C4 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13025F90D20000690C4 /* Font.swift */; }; + CCA6D17325F90D21000690C4 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13025F90D20000690C4 /* Font.swift */; }; + CCA6D17425F90D21000690C4 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13025F90D20000690C4 /* Font.swift */; }; + CCA6D17525F90D21000690C4 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13125F90D20000690C4 /* Pattern.swift */; }; + CCA6D17625F90D21000690C4 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13125F90D20000690C4 /* Pattern.swift */; }; + CCA6D17725F90D21000690C4 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13125F90D20000690C4 /* Pattern.swift */; }; + CCA6D17825F90D21000690C4 /* Pattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13125F90D20000690C4 /* Pattern.swift */; }; + CCA6D17925F90D21000690C4 /* RegularExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13225F90D20000690C4 /* RegularExpression.swift */; }; + CCA6D17A25F90D21000690C4 /* RegularExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13225F90D20000690C4 /* RegularExpression.swift */; }; + CCA6D17B25F90D21000690C4 /* RegularExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13225F90D20000690C4 /* RegularExpression.swift */; }; + CCA6D17C25F90D21000690C4 /* RegularExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13225F90D20000690C4 /* RegularExpression.swift */; }; + CCA6D17D25F90D21000690C4 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13325F90D20000690C4 /* ResultSet.swift */; }; + CCA6D17E25F90D21000690C4 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13325F90D20000690C4 /* ResultSet.swift */; }; + CCA6D17F25F90D21000690C4 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13325F90D20000690C4 /* ResultSet.swift */; }; + CCA6D18025F90D21000690C4 /* ResultSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13325F90D20000690C4 /* ResultSet.swift */; }; + CCA6D18125F90D21000690C4 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13425F90D20000690C4 /* Color.swift */; }; + CCA6D18225F90D21000690C4 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13425F90D20000690C4 /* Color.swift */; }; + CCA6D18325F90D21000690C4 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13425F90D20000690C4 /* Color.swift */; }; + CCA6D18425F90D21000690C4 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D13425F90D20000690C4 /* Color.swift */; }; + CCA6D19C25F90D2E000690C4 /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18C25F90D2E000690C4 /* AttributedParserTests.swift */; }; + CCA6D19D25F90D2E000690C4 /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18C25F90D2E000690C4 /* AttributedParserTests.swift */; }; + CCA6D19E25F90D2E000690C4 /* AttributedParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18C25F90D2E000690C4 /* AttributedParserTests.swift */; }; + CCA6D19F25F90D2E000690C4 /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18D25F90D2E000690C4 /* ScopedStringTests.swift */; }; + CCA6D1A025F90D2E000690C4 /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18D25F90D2E000690C4 /* ScopedStringTests.swift */; }; + CCA6D1A125F90D2E000690C4 /* ScopedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18D25F90D2E000690C4 /* ScopedStringTests.swift */; }; + CCA6D1A225F90D2E000690C4 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18E25F90D2E000690C4 /* XCTestManifests.swift */; }; + CCA6D1A325F90D2E000690C4 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18E25F90D2E000690C4 /* XCTestManifests.swift */; }; + CCA6D1A425F90D2E000690C4 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18E25F90D2E000690C4 /* XCTestManifests.swift */; }; + CCA6D1A525F90D2E000690C4 /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18F25F90D2E000690C4 /* LanguageTests.swift */; }; + CCA6D1A625F90D2E000690C4 /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18F25F90D2E000690C4 /* LanguageTests.swift */; }; + CCA6D1A725F90D2E000690C4 /* LanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D18F25F90D2E000690C4 /* LanguageTests.swift */; }; + CCA6D1A825F90D2E000690C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19025F90D2E000690C4 /* TestHelper.swift */; }; + CCA6D1A925F90D2E000690C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19025F90D2E000690C4 /* TestHelper.swift */; }; + CCA6D1AA25F90D2E000690C4 /* TestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19025F90D2E000690C4 /* TestHelper.swift */; }; + CCA6D1AB25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19125F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift */; }; + CCA6D1AC25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19125F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift */; }; + CCA6D1AD25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19125F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift */; }; + CCA6D1AE25F90D2E000690C4 /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19225F90D2E000690C4 /* PerformanceTests.swift */; }; + CCA6D1AF25F90D2E000690C4 /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19225F90D2E000690C4 /* PerformanceTests.swift */; }; + CCA6D1B025F90D2E000690C4 /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19225F90D2E000690C4 /* PerformanceTests.swift */; }; + CCA6D1B125F90D2E000690C4 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19325F90D2E000690C4 /* ParserTests.swift */; }; + CCA6D1B225F90D2E000690C4 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19325F90D2E000690C4 /* ParserTests.swift */; }; + CCA6D1B325F90D2E000690C4 /* ParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19325F90D2E000690C4 /* ParserTests.swift */; }; + CCA6D1B425F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */ = {isa = PBXBuildFile; fileRef = CCA6D19525F90D2E000690C4 /* TestSyntaxKit.bundle */; }; + CCA6D1B525F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */ = {isa = PBXBuildFile; fileRef = CCA6D19525F90D2E000690C4 /* TestSyntaxKit.bundle */; }; + CCA6D1B625F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */ = {isa = PBXBuildFile; fileRef = CCA6D19525F90D2E000690C4 /* TestSyntaxKit.bundle */; }; + CCA6D1B725F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19625F90D2E000690C4 /* IncrementalParsingTests.swift */; }; + CCA6D1B825F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19625F90D2E000690C4 /* IncrementalParsingTests.swift */; }; + CCA6D1B925F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19625F90D2E000690C4 /* IncrementalParsingTests.swift */; }; + CCA6D1BA25F90D2E000690C4 /* BackReferenceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19725F90D2E000690C4 /* BackReferenceTests.swift */; }; + CCA6D1BB25F90D2E000690C4 /* BackReferenceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19725F90D2E000690C4 /* BackReferenceTests.swift */; }; + CCA6D1BC25F90D2E000690C4 /* BackReferenceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19725F90D2E000690C4 /* BackReferenceTests.swift */; }; + CCA6D1BD25F90D2E000690C4 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19825F90D2E000690C4 /* ThemeTests.swift */; }; + CCA6D1BE25F90D2E000690C4 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19825F90D2E000690C4 /* ThemeTests.swift */; }; + CCA6D1BF25F90D2E000690C4 /* ThemeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCA6D19825F90D2E000690C4 /* ThemeTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -191,50 +182,45 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 210299C21B2E8924009C61EE /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 210299CF1B2E8924009C61EE /* LanguageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageTests.swift; sourceTree = ""; }; - 210299D01B2E8924009C61EE /* AttributedParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedParserTests.swift; sourceTree = ""; }; - 210299E41B2E8AFC009C61EE /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 210BF26C1B37C04E008AA4F0 /* test.rb.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test.rb.txt; sourceTree = ""; }; - 210BF26F1B37C0A2008AA4F0 /* Ruby.tmLanguage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Ruby.tmLanguage; sourceTree = ""; }; 211826DA1D257A71003F2BF2 /* SyntaxKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SyntaxKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 211826E31D257A71003F2BF2 /* SyntaxKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SyntaxKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 2119897E1B2EAF0900F0D786 /* Tomorrow.tmTheme */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Tomorrow.tmTheme; sourceTree = ""; }; - 2119897F1B2EAF0900F0D786 /* Yaml.tmLanguage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Yaml.tmLanguage; sourceTree = ""; }; - 211989821B2EB18000F0D786 /* TestHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestHelper.swift; sourceTree = ""; }; - 211989881B2EB8D400F0D786 /* ParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParserTests.swift; sourceTree = ""; }; - 2119898A1B2EBA2C00F0D786 /* ThemeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeTests.swift; sourceTree = ""; }; - 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedParser.swift; sourceTree = ""; }; - 2119898D1B2EC38B00F0D786 /* Capture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = ""; }; - 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureCollection.swift; sourceTree = ""; }; - 211989911B2EC38B00F0D786 /* Parser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Parser.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 211989921B2EC38B00F0D786 /* Pattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Pattern.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 211989931B2EC38B00F0D786 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; - 211989941B2EC38B00F0D786 /* ResultSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultSet.swift; sourceTree = ""; }; - 211989951B2EC38B00F0D786 /* SyntaxKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxKit.h; sourceTree = ""; }; - 211989961B2EC38B00F0D786 /* Theme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; 211989A71B2EC3B600F0D786 /* SyntaxKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SyntaxKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 211989B01B2EC3B600F0D786 /* SyntaxKitTests-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SyntaxKitTests-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2122A6DE1B22B9320006409B /* SyntaxKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SyntaxKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2122A6E91B22B9320006409B /* SyntaxKitTests-macOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SyntaxKitTests-macOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2198CECA1B36D5D700BD463F /* SyntaxKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SyntaxKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 8C08C3C61C36FD6D00D8548F /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Color.swift; path = ../Color.swift; sourceTree = ""; }; - 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AttributedParsingOperation.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 8C4D09BF1E1EAF750034974A /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = ""; }; - 8C4D09C31E1EB0670034974A /* Latex.tmLanguage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Latex.tmLanguage; sourceTree = ""; }; - 8C4D09C71E1EB07D0034974A /* Tex.tmLanguage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Tex.tmLanguage; sourceTree = ""; }; - 8C4D09CB1E1EB16C0034974A /* textest.tex.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = textest.tex.txt; sourceTree = ""; }; - 8C71A05C1C59587700041EC6 /* IncrementalParsingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IncrementalParsingTests.swift; sourceTree = ""; }; - 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScopedString.swift; sourceTree = ""; }; - 8CB2FD221C4D877D008ECD6D /* swifttest.swift.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = swifttest.swift.txt; sourceTree = ""; }; - 8CB2FD251C4D87D6008ECD6D /* Solarized.tmTheme */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Solarized.tmTheme; sourceTree = ""; }; - 8CDD6F1A1C71594B0063915A /* BundleManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = BundleManager.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 8CE64FE21C74B48D0007BA57 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Language.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 8CE6BE2D1C5D1BBA002676BD /* ScopedStringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScopedStringTests.swift; sourceTree = ""; }; - 8CE8D1131C4EBF58005A86B3 /* Swift.tmLanguage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Swift.tmLanguage; sourceTree = ""; }; - 8CE8D1161C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftBaselineHighlightingTests.swift; sourceTree = ""; }; - 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ReferenceManager.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 8CEEC0E11C411F9700BF3E85 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Repository.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + CCA6D12125F90D20000690C4 /* SyntaxKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyntaxKit.swift; sourceTree = ""; }; + CCA6D12225F90D20000690C4 /* ScopedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScopedString.swift; sourceTree = ""; }; + CCA6D12325F90D20000690C4 /* CaptureCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureCollection.swift; sourceTree = ""; }; + CCA6D12425F90D20000690C4 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Language.swift; sourceTree = ""; }; + CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedParsingOperation.swift; sourceTree = ""; }; + CCA6D12625F90D20000690C4 /* Capture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = ""; }; + CCA6D12725F90D20000690C4 /* BundleManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BundleManager.swift; sourceTree = ""; }; + CCA6D12825F90D20000690C4 /* Attributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attributes.swift; sourceTree = ""; }; + CCA6D12925F90D20000690C4 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; + CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReferenceManager.swift; sourceTree = ""; }; + CCA6D12C25F90D20000690C4 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = ""; }; + CCA6D12D25F90D20000690C4 /* Parser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parser.swift; sourceTree = ""; }; + CCA6D12E25F90D20000690C4 /* AttributedParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedParser.swift; sourceTree = ""; }; + CCA6D12F25F90D20000690C4 /* Theme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; + CCA6D13025F90D20000690C4 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = ""; }; + CCA6D13125F90D20000690C4 /* Pattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pattern.swift; sourceTree = ""; }; + CCA6D13225F90D20000690C4 /* RegularExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegularExpression.swift; sourceTree = ""; }; + CCA6D13325F90D20000690C4 /* ResultSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultSet.swift; sourceTree = ""; }; + CCA6D13425F90D20000690C4 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; + CCA6D18C25F90D2E000690C4 /* AttributedParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedParserTests.swift; sourceTree = ""; }; + CCA6D18D25F90D2E000690C4 /* ScopedStringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScopedStringTests.swift; sourceTree = ""; }; + CCA6D18E25F90D2E000690C4 /* XCTestManifests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTestManifests.swift; sourceTree = ""; }; + CCA6D18F25F90D2E000690C4 /* LanguageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageTests.swift; sourceTree = ""; }; + CCA6D19025F90D2E000690C4 /* TestHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestHelper.swift; sourceTree = ""; }; + CCA6D19125F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftBaselineHighlightingTests.swift; sourceTree = ""; }; + CCA6D19225F90D2E000690C4 /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = ""; }; + CCA6D19325F90D2E000690C4 /* ParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParserTests.swift; sourceTree = ""; }; + CCA6D19525F90D2E000690C4 /* TestSyntaxKit.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestSyntaxKit.bundle; sourceTree = ""; }; + CCA6D19625F90D2E000690C4 /* IncrementalParsingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IncrementalParsingTests.swift; sourceTree = ""; }; + CCA6D19725F90D2E000690C4 /* BackReferenceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackReferenceTests.swift; sourceTree = ""; }; + CCA6D19825F90D2E000690C4 /* ThemeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeTests.swift; sourceTree = ""; }; + CCA6D1E125F90DBD000690C4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -293,102 +279,105 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 210299C11B2E8924009C61EE /* Resources */ = { + 2122A6D41B22B9320006409B = { isa = PBXGroup; children = ( - 8C08C3C61C36FD6D00D8548F /* Color.swift */, - 210299C21B2E8924009C61EE /* Info.plist */, + CCA6D1E025F90DBD000690C4 /* Resources */, + CCA6D11F25F90D20000690C4 /* Sources */, + CCA6D18925F90D2E000690C4 /* Tests */, + 2122A6DF1B22B9320006409B /* Products */, ); - path = Resources; sourceTree = ""; }; - 210299CD1B2E8924009C61EE /* Tests */ = { + 2122A6DF1B22B9320006409B /* Products */ = { isa = PBXGroup; children = ( - 210299E11B2E8AFC009C61EE /* Resources */, - 211989821B2EB18000F0D786 /* TestHelper.swift */, - 211989881B2EB8D400F0D786 /* ParserTests.swift */, - 210299D01B2E8924009C61EE /* AttributedParserTests.swift */, - 8C4D09BF1E1EAF750034974A /* PerformanceTests.swift */, - 8CE8D1161C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift */, - 8C71A05C1C59587700041EC6 /* IncrementalParsingTests.swift */, - 8CE6BE2D1C5D1BBA002676BD /* ScopedStringTests.swift */, - 210299CF1B2E8924009C61EE /* LanguageTests.swift */, - 2119898A1B2EBA2C00F0D786 /* ThemeTests.swift */, + 2122A6DE1B22B9320006409B /* SyntaxKit.framework */, + 2122A6E91B22B9320006409B /* SyntaxKitTests-macOS.xctest */, + 211989A71B2EC3B600F0D786 /* SyntaxKit.framework */, + 211989B01B2EC3B600F0D786 /* SyntaxKitTests-iOS.xctest */, + 2198CECA1B36D5D700BD463F /* SyntaxKit.framework */, + 211826DA1D257A71003F2BF2 /* SyntaxKit.framework */, + 211826E31D257A71003F2BF2 /* SyntaxKitTests.xctest */, ); - path = Tests; + name = Products; sourceTree = ""; }; - 210299E11B2E8AFC009C61EE /* Resources */ = { + CCA6D11F25F90D20000690C4 /* Sources */ = { isa = PBXGroup; children = ( - 210299E21B2E8AFC009C61EE /* Fixtures */, - 210299E41B2E8AFC009C61EE /* Info.plist */, + CCA6D12025F90D20000690C4 /* SyntaxKit */, ); - path = Resources; + path = Sources; sourceTree = ""; }; - 210299E21B2E8AFC009C61EE /* Fixtures */ = { + CCA6D12025F90D20000690C4 /* SyntaxKit */ = { isa = PBXGroup; children = ( - 210BF26F1B37C0A2008AA4F0 /* Ruby.tmLanguage */, - 8CE8D1131C4EBF58005A86B3 /* Swift.tmLanguage */, - 8C4D09C31E1EB0670034974A /* Latex.tmLanguage */, - 8C4D09C71E1EB07D0034974A /* Tex.tmLanguage */, - 8CB2FD221C4D877D008ECD6D /* swifttest.swift.txt */, - 8C4D09CB1E1EB16C0034974A /* textest.tex.txt */, - 210BF26C1B37C04E008AA4F0 /* test.rb.txt */, - 8CB2FD251C4D87D6008ECD6D /* Solarized.tmTheme */, - 2119897E1B2EAF0900F0D786 /* Tomorrow.tmTheme */, - 2119897F1B2EAF0900F0D786 /* Yaml.tmLanguage */, + CCA6D12E25F90D20000690C4 /* AttributedParser.swift */, + CCA6D12525F90D20000690C4 /* AttributedParsingOperation.swift */, + CCA6D12825F90D20000690C4 /* Attributes.swift */, + CCA6D12725F90D20000690C4 /* BundleManager.swift */, + CCA6D12625F90D20000690C4 /* Capture.swift */, + CCA6D12325F90D20000690C4 /* CaptureCollection.swift */, + CCA6D13425F90D20000690C4 /* Color.swift */, + CCA6D13025F90D20000690C4 /* Font.swift */, + CCA6D12425F90D20000690C4 /* Language.swift */, + CCA6D12D25F90D20000690C4 /* Parser.swift */, + CCA6D13125F90D20000690C4 /* Pattern.swift */, + CCA6D12A25F90D20000690C4 /* ReferenceManager.swift */, + CCA6D13225F90D20000690C4 /* RegularExpression.swift */, + CCA6D12C25F90D20000690C4 /* Repository.swift */, + CCA6D12925F90D20000690C4 /* Result.swift */, + CCA6D13325F90D20000690C4 /* ResultSet.swift */, + CCA6D12225F90D20000690C4 /* ScopedString.swift */, + CCA6D12125F90D20000690C4 /* SyntaxKit.swift */, + CCA6D12F25F90D20000690C4 /* Theme.swift */, ); - path = Fixtures; + path = SyntaxKit; sourceTree = ""; }; - 2122A6D41B22B9320006409B = { + CCA6D18925F90D2E000690C4 /* Tests */ = { isa = PBXGroup; children = ( - 2122A6E01B22B9320006409B /* SyntaxKit */, - 2122A6DF1B22B9320006409B /* Products */, + CCA6D18B25F90D2E000690C4 /* SyntaxKitTests */, ); + path = Tests; sourceTree = ""; }; - 2122A6DF1B22B9320006409B /* Products */ = { + CCA6D18B25F90D2E000690C4 /* SyntaxKitTests */ = { isa = PBXGroup; children = ( - 2122A6DE1B22B9320006409B /* SyntaxKit.framework */, - 2122A6E91B22B9320006409B /* SyntaxKitTests-macOS.xctest */, - 211989A71B2EC3B600F0D786 /* SyntaxKit.framework */, - 211989B01B2EC3B600F0D786 /* SyntaxKitTests-iOS.xctest */, - 2198CECA1B36D5D700BD463F /* SyntaxKit.framework */, - 211826DA1D257A71003F2BF2 /* SyntaxKit.framework */, - 211826E31D257A71003F2BF2 /* SyntaxKitTests.xctest */, + CCA6D19425F90D2E000690C4 /* Fixtures */, + CCA6D18C25F90D2E000690C4 /* AttributedParserTests.swift */, + CCA6D19725F90D2E000690C4 /* BackReferenceTests.swift */, + CCA6D19625F90D2E000690C4 /* IncrementalParsingTests.swift */, + CCA6D18F25F90D2E000690C4 /* LanguageTests.swift */, + CCA6D19325F90D2E000690C4 /* ParserTests.swift */, + CCA6D19225F90D2E000690C4 /* PerformanceTests.swift */, + CCA6D18D25F90D2E000690C4 /* ScopedStringTests.swift */, + CCA6D19125F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift */, + CCA6D19025F90D2E000690C4 /* TestHelper.swift */, + CCA6D19825F90D2E000690C4 /* ThemeTests.swift */, + CCA6D18E25F90D2E000690C4 /* XCTestManifests.swift */, + ); + path = SyntaxKitTests; + sourceTree = ""; + }; + CCA6D19425F90D2E000690C4 /* Fixtures */ = { + isa = PBXGroup; + children = ( + CCA6D19525F90D2E000690C4 /* TestSyntaxKit.bundle */, ); - name = Products; + path = Fixtures; sourceTree = ""; }; - 2122A6E01B22B9320006409B /* SyntaxKit */ = { + CCA6D1E025F90DBD000690C4 /* Resources */ = { isa = PBXGroup; children = ( - 211989951B2EC38B00F0D786 /* SyntaxKit.h */, - 8C10B6431CC38E5200740E00 /* AttributedParsingOperation.swift */, - 2119898C1B2EC38B00F0D786 /* AttributedParser.swift */, - 211989911B2EC38B00F0D786 /* Parser.swift */, - 8C9003321C5C0B0D00CBA5B0 /* ScopedString.swift */, - 211989941B2EC38B00F0D786 /* ResultSet.swift */, - 211989931B2EC38B00F0D786 /* Result.swift */, - 8CDD6F1A1C71594B0063915A /* BundleManager.swift */, - 211989961B2EC38B00F0D786 /* Theme.swift */, - 8CE64FE21C74B48D0007BA57 /* Language.swift */, - 8CEEC0E11C411F9700BF3E85 /* Repository.swift */, - 8CEEC0DD1C411C8600BF3E85 /* ReferenceManager.swift */, - 211989921B2EC38B00F0D786 /* Pattern.swift */, - 2119898E1B2EC38B00F0D786 /* CaptureCollection.swift */, - 2119898D1B2EC38B00F0D786 /* Capture.swift */, - 210299C11B2E8924009C61EE /* Resources */, - 210299CD1B2E8924009C61EE /* Tests */, + CCA6D1E125F90DBD000690C4 /* Info.plist */, ); - path = SyntaxKit; + path = Resources; sourceTree = ""; }; /* End PBXGroup section */ @@ -398,7 +387,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 211827031D257AA3003F2BF2 /* SyntaxKit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -406,7 +394,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 211989BE1B2EC40000F0D786 /* SyntaxKit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -414,7 +401,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 211989A01B2EC38B00F0D786 /* SyntaxKit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -422,7 +408,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 2198CEDC1B36D5E100BD463F /* SyntaxKit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -566,7 +551,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1030; + LastUpgradeCheck = 1240; ORGANIZATIONNAME = "Sam Soffes"; TargetAttributes = { 211826D91D257A71003F2BF2 = { @@ -585,9 +570,11 @@ }; 2122A6DD1B22B9320006409B = { CreatedOnToolsVersion = 6.3.2; + LastSwiftMigration = 1240; }; 2122A6E81B22B9320006409B = { CreatedOnToolsVersion = 6.3.2; + LastSwiftMigration = 1240; }; 2198CEC91B36D5D700BD463F = { CreatedOnToolsVersion = 7.0; @@ -607,12 +594,12 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 2122A6DD1B22B9320006409B /* SyntaxKit-macOS */, - 2122A6E81B22B9320006409B /* SyntaxKitTests-macOS */, 211989A61B2EC3B600F0D786 /* SyntaxKit-iOS */, - 211989AF1B2EC3B600F0D786 /* SyntaxKitTests-iOS */, - 2198CEC91B36D5D700BD463F /* SyntaxKit-watchOS */, + 2122A6DD1B22B9320006409B /* SyntaxKit-macOS */, 211826D91D257A71003F2BF2 /* SyntaxKit-tvOS */, + 2198CEC91B36D5D700BD463F /* SyntaxKit-watchOS */, + 211989AF1B2EC3B600F0D786 /* SyntaxKitTests-iOS */, + 2122A6E81B22B9320006409B /* SyntaxKitTests-macOS */, 211826E21D257A71003F2BF2 /* SyntaxKitTests-tvOS */, ); }; @@ -630,16 +617,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8C2EB3611D4B525A005ECE2B /* Swift.tmLanguage in Resources */, - 8C2EB3621D4B525A005ECE2B /* swifttest.swift.txt in Resources */, - 8C2EB3631D4B525A005ECE2B /* Solarized.tmTheme in Resources */, - 8C4D09CA1E1EB07D0034974A /* Tex.tmLanguage in Resources */, - 211826FF1D257A8A003F2BF2 /* Ruby.tmLanguage in Resources */, - 8C4D09C61E1EB0670034974A /* Latex.tmLanguage in Resources */, - 211827021D257A8A003F2BF2 /* Yaml.tmLanguage in Resources */, - 211827001D257A8A003F2BF2 /* test.rb.txt in Resources */, - 211827011D257A8A003F2BF2 /* Tomorrow.tmTheme in Resources */, - 8C4D09CE1E1EB16C0034974A /* textest.tex.txt in Resources */, + CCA6D1B625F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -654,16 +632,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8CE8D1151C4EBF58005A86B3 /* Swift.tmLanguage in Resources */, - 210BF2711B37C0A2008AA4F0 /* Ruby.tmLanguage in Resources */, - 211989CA1B2EC40900F0D786 /* Yaml.tmLanguage in Resources */, - 8C4D09C91E1EB07D0034974A /* Tex.tmLanguage in Resources */, - 211989C91B2EC40900F0D786 /* Tomorrow.tmTheme in Resources */, - 8C4D09C51E1EB0670034974A /* Latex.tmLanguage in Resources */, - 8CB2FD271C4D87D6008ECD6D /* Solarized.tmTheme in Resources */, - 210BF26E1B37C04E008AA4F0 /* test.rb.txt in Resources */, - 8CB2FD281C4D891A008ECD6D /* swifttest.swift.txt in Resources */, - 8C4D09CD1E1EB16C0034974A /* textest.tex.txt in Resources */, + CCA6D1B525F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -678,16 +647,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8CE8D1141C4EBF58005A86B3 /* Swift.tmLanguage in Resources */, - 210BF2701B37C0A2008AA4F0 /* Ruby.tmLanguage in Resources */, - 211989811B2EAF0900F0D786 /* Yaml.tmLanguage in Resources */, - 8C4D09C81E1EB07D0034974A /* Tex.tmLanguage in Resources */, - 211989801B2EAF0900F0D786 /* Tomorrow.tmTheme in Resources */, - 8C4D09C41E1EB0670034974A /* Latex.tmLanguage in Resources */, - 8CB2FD261C4D87D6008ECD6D /* Solarized.tmTheme in Resources */, - 210BF26D1B37C04E008AA4F0 /* test.rb.txt in Resources */, - 8CAEC6BA1D3BB297001C57D3 /* swifttest.swift.txt in Resources */, - 8C4D09CC1E1EB16C0034974A /* textest.tex.txt in Resources */, + CCA6D1B425F90D2E000690C4 /* TestSyntaxKit.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -721,21 +681,25 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8C2EB3591D4B5126005ECE2B /* AttributedParsingOperation.swift in Sources */, - 8C2EB35A1D4B5126005ECE2B /* ScopedString.swift in Sources */, - 8C2EB35B1D4B5126005ECE2B /* BundleManager.swift in Sources */, - 8C2EB35C1D4B5126005ECE2B /* Repository.swift in Sources */, - 8C2EB35D1D4B5126005ECE2B /* ReferenceManager.swift in Sources */, - 8C2EB3581D4B510F005ECE2B /* Language.swift in Sources */, - 8C2EB3571D4B50EE005ECE2B /* Color.swift in Sources */, - 211826F91D257A7E003F2BF2 /* Theme.swift in Sources */, - 211826F61D257A7E003F2BF2 /* Pattern.swift in Sources */, - 211826F21D257A7E003F2BF2 /* Capture.swift in Sources */, - 211826F51D257A7E003F2BF2 /* Parser.swift in Sources */, - 211826F71D257A7E003F2BF2 /* Result.swift in Sources */, - 211826F81D257A7E003F2BF2 /* ResultSet.swift in Sources */, - 211826F31D257A7E003F2BF2 /* CaptureCollection.swift in Sources */, - 211826F11D257A7E003F2BF2 /* AttributedParser.swift in Sources */, + CCA6D15825F90D21000690C4 /* Result.swift in Sources */, + CCA6D16C25F90D21000690C4 /* AttributedParser.swift in Sources */, + CCA6D17425F90D21000690C4 /* Font.swift in Sources */, + CCA6D15C25F90D21000690C4 /* ReferenceManager.swift in Sources */, + CCA6D15025F90D21000690C4 /* BundleManager.swift in Sources */, + CCA6D18025F90D21000690C4 /* ResultSet.swift in Sources */, + CCA6D14C25F90D20000690C4 /* Capture.swift in Sources */, + CCA6D17825F90D21000690C4 /* Pattern.swift in Sources */, + CCA6D15425F90D21000690C4 /* Attributes.swift in Sources */, + CCA6D16425F90D21000690C4 /* Repository.swift in Sources */, + CCA6D13C25F90D20000690C4 /* ScopedString.swift in Sources */, + CCA6D18425F90D21000690C4 /* Color.swift in Sources */, + CCA6D14825F90D20000690C4 /* AttributedParsingOperation.swift in Sources */, + CCA6D16825F90D21000690C4 /* Parser.swift in Sources */, + CCA6D14425F90D20000690C4 /* Language.swift in Sources */, + CCA6D17C25F90D21000690C4 /* RegularExpression.swift in Sources */, + CCA6D14025F90D20000690C4 /* CaptureCollection.swift in Sources */, + CCA6D13825F90D20000690C4 /* SyntaxKit.swift in Sources */, + CCA6D17025F90D21000690C4 /* Theme.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -743,15 +707,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8C2EB35E1D4B524F005ECE2B /* SwiftBaselineHighlightingTests.swift in Sources */, - 8C2EB35F1D4B524F005ECE2B /* IncrementalParsingTests.swift in Sources */, - 8C2EB3601D4B524F005ECE2B /* ScopedStringTests.swift in Sources */, - 211826FD1D257A84003F2BF2 /* LanguageTests.swift in Sources */, - 211826FA1D257A84003F2BF2 /* TestHelper.swift in Sources */, - 211826FC1D257A84003F2BF2 /* AttributedParserTests.swift in Sources */, - 211826FB1D257A84003F2BF2 /* ParserTests.swift in Sources */, - 211826FE1D257A84003F2BF2 /* ThemeTests.swift in Sources */, - 8C4D09C21E1EAF750034974A /* PerformanceTests.swift in Sources */, + CCA6D1BC25F90D2E000690C4 /* BackReferenceTests.swift in Sources */, + CCA6D19E25F90D2E000690C4 /* AttributedParserTests.swift in Sources */, + CCA6D1B925F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */, + CCA6D1A725F90D2E000690C4 /* LanguageTests.swift in Sources */, + CCA6D1A425F90D2E000690C4 /* XCTestManifests.swift in Sources */, + CCA6D1BF25F90D2E000690C4 /* ThemeTests.swift in Sources */, + CCA6D1AA25F90D2E000690C4 /* TestHelper.swift in Sources */, + CCA6D1A125F90D2E000690C4 /* ScopedStringTests.swift in Sources */, + CCA6D1AD25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */, + CCA6D1B025F90D2E000690C4 /* PerformanceTests.swift in Sources */, + CCA6D1B325F90D2E000690C4 /* ParserTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -759,21 +725,25 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 211989C01B2EC40500F0D786 /* Capture.swift in Sources */, - 211989C41B2EC40500F0D786 /* Parser.swift in Sources */, - 8C08C3C71C36FD6D00D8548F /* Color.swift in Sources */, - 8C9003341C5C0B0D00CBA5B0 /* ScopedString.swift in Sources */, - 211989C11B2EC40500F0D786 /* CaptureCollection.swift in Sources */, - 8CEEC0DF1C411C8600BF3E85 /* ReferenceManager.swift in Sources */, - 211989C71B2EC40500F0D786 /* ResultSet.swift in Sources */, - 8C10B6451CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */, - 8CDD6F1C1C71594B0063915A /* BundleManager.swift in Sources */, - 211989C51B2EC40500F0D786 /* Pattern.swift in Sources */, - 211989C81B2EC40500F0D786 /* Theme.swift in Sources */, - 211989C61B2EC40500F0D786 /* Result.swift in Sources */, - 8CE64FE41C74B48D0007BA57 /* Language.swift in Sources */, - 211989BF1B2EC40500F0D786 /* AttributedParser.swift in Sources */, - 8CEEC0E31C411F9700BF3E85 /* Repository.swift in Sources */, + CCA6D15625F90D21000690C4 /* Result.swift in Sources */, + CCA6D16A25F90D21000690C4 /* AttributedParser.swift in Sources */, + CCA6D17225F90D21000690C4 /* Font.swift in Sources */, + CCA6D15A25F90D21000690C4 /* ReferenceManager.swift in Sources */, + CCA6D14E25F90D21000690C4 /* BundleManager.swift in Sources */, + CCA6D17E25F90D21000690C4 /* ResultSet.swift in Sources */, + CCA6D14A25F90D20000690C4 /* Capture.swift in Sources */, + CCA6D17625F90D21000690C4 /* Pattern.swift in Sources */, + CCA6D15225F90D21000690C4 /* Attributes.swift in Sources */, + CCA6D16225F90D21000690C4 /* Repository.swift in Sources */, + CCA6D13A25F90D20000690C4 /* ScopedString.swift in Sources */, + CCA6D18225F90D21000690C4 /* Color.swift in Sources */, + CCA6D14625F90D20000690C4 /* AttributedParsingOperation.swift in Sources */, + CCA6D16625F90D21000690C4 /* Parser.swift in Sources */, + CCA6D14225F90D20000690C4 /* Language.swift in Sources */, + CCA6D17A25F90D21000690C4 /* RegularExpression.swift in Sources */, + CCA6D13E25F90D20000690C4 /* CaptureCollection.swift in Sources */, + CCA6D13625F90D20000690C4 /* SyntaxKit.swift in Sources */, + CCA6D16E25F90D21000690C4 /* Theme.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -781,15 +751,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 211989CF1B2EC40C00F0D786 /* ThemeTests.swift in Sources */, - 211989CC1B2EC40C00F0D786 /* ParserTests.swift in Sources */, - 8CE6BE2F1C5D1BBA002676BD /* ScopedStringTests.swift in Sources */, - 8C71A05E1C59587700041EC6 /* IncrementalParsingTests.swift in Sources */, - 211989CE1B2EC40C00F0D786 /* LanguageTests.swift in Sources */, - 211989CB1B2EC40C00F0D786 /* TestHelper.swift in Sources */, - 8CE8D1181C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift in Sources */, - 211989CD1B2EC40C00F0D786 /* AttributedParserTests.swift in Sources */, - 8C4D09C11E1EAF750034974A /* PerformanceTests.swift in Sources */, + CCA6D1BB25F90D2E000690C4 /* BackReferenceTests.swift in Sources */, + CCA6D19D25F90D2E000690C4 /* AttributedParserTests.swift in Sources */, + CCA6D1B825F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */, + CCA6D1A625F90D2E000690C4 /* LanguageTests.swift in Sources */, + CCA6D1A325F90D2E000690C4 /* XCTestManifests.swift in Sources */, + CCA6D1BE25F90D2E000690C4 /* ThemeTests.swift in Sources */, + CCA6D1A925F90D2E000690C4 /* TestHelper.swift in Sources */, + CCA6D1A025F90D2E000690C4 /* ScopedStringTests.swift in Sources */, + CCA6D1AC25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */, + CCA6D1AF25F90D2E000690C4 /* PerformanceTests.swift in Sources */, + CCA6D1B225F90D2E000690C4 /* ParserTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -797,21 +769,25 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 211989981B2EC38B00F0D786 /* Capture.swift in Sources */, - 8CDD6F1B1C71594B0063915A /* BundleManager.swift in Sources */, - 2119899C1B2EC38B00F0D786 /* Parser.swift in Sources */, - 211989991B2EC38B00F0D786 /* CaptureCollection.swift in Sources */, - 8C10B6441CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */, - 8CEEC0DE1C411C8600BF3E85 /* ReferenceManager.swift in Sources */, - 8CEEC0E21C411F9700BF3E85 /* Repository.swift in Sources */, - 2119899F1B2EC38B00F0D786 /* ResultSet.swift in Sources */, - 8C10B6471CC3937F00740E00 /* Color.swift in Sources */, - 2119899D1B2EC38B00F0D786 /* Pattern.swift in Sources */, - 211989A11B2EC38B00F0D786 /* Theme.swift in Sources */, - 2119899E1B2EC38B00F0D786 /* Result.swift in Sources */, - 8C9003331C5C0B0D00CBA5B0 /* ScopedString.swift in Sources */, - 211989971B2EC38B00F0D786 /* AttributedParser.swift in Sources */, - 8CE64FE31C74B48D0007BA57 /* Language.swift in Sources */, + CCA6D15525F90D21000690C4 /* Result.swift in Sources */, + CCA6D16925F90D21000690C4 /* AttributedParser.swift in Sources */, + CCA6D17125F90D21000690C4 /* Font.swift in Sources */, + CCA6D15925F90D21000690C4 /* ReferenceManager.swift in Sources */, + CCA6D14D25F90D21000690C4 /* BundleManager.swift in Sources */, + CCA6D17D25F90D21000690C4 /* ResultSet.swift in Sources */, + CCA6D14925F90D20000690C4 /* Capture.swift in Sources */, + CCA6D17525F90D21000690C4 /* Pattern.swift in Sources */, + CCA6D15125F90D21000690C4 /* Attributes.swift in Sources */, + CCA6D16125F90D21000690C4 /* Repository.swift in Sources */, + CCA6D13925F90D20000690C4 /* ScopedString.swift in Sources */, + CCA6D18125F90D21000690C4 /* Color.swift in Sources */, + CCA6D14525F90D20000690C4 /* AttributedParsingOperation.swift in Sources */, + CCA6D16525F90D21000690C4 /* Parser.swift in Sources */, + CCA6D14125F90D20000690C4 /* Language.swift in Sources */, + CCA6D17925F90D21000690C4 /* RegularExpression.swift in Sources */, + CCA6D13D25F90D20000690C4 /* CaptureCollection.swift in Sources */, + CCA6D13525F90D20000690C4 /* SyntaxKit.swift in Sources */, + CCA6D16D25F90D21000690C4 /* Theme.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -819,15 +795,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 211989841B2EB18600F0D786 /* TestHelper.swift in Sources */, - 8C71A05D1C59587700041EC6 /* IncrementalParsingTests.swift in Sources */, - 211989891B2EB8D400F0D786 /* ParserTests.swift in Sources */, - 210299DF1B2E892E009C61EE /* AttributedParserTests.swift in Sources */, - 8CE6BE2E1C5D1BBA002676BD /* ScopedStringTests.swift in Sources */, - 210299DE1B2E892E009C61EE /* LanguageTests.swift in Sources */, - 8CE8D1171C4EBF8F005A86B3 /* SwiftBaselineHighlightingTests.swift in Sources */, - 2119898B1B2EBA2C00F0D786 /* ThemeTests.swift in Sources */, - 8C4D09C01E1EAF750034974A /* PerformanceTests.swift in Sources */, + CCA6D1BA25F90D2E000690C4 /* BackReferenceTests.swift in Sources */, + CCA6D19C25F90D2E000690C4 /* AttributedParserTests.swift in Sources */, + CCA6D1B725F90D2E000690C4 /* IncrementalParsingTests.swift in Sources */, + CCA6D1A525F90D2E000690C4 /* LanguageTests.swift in Sources */, + CCA6D1A225F90D2E000690C4 /* XCTestManifests.swift in Sources */, + CCA6D1BD25F90D2E000690C4 /* ThemeTests.swift in Sources */, + CCA6D1A825F90D2E000690C4 /* TestHelper.swift in Sources */, + CCA6D19F25F90D2E000690C4 /* ScopedStringTests.swift in Sources */, + CCA6D1AB25F90D2E000690C4 /* SwiftBaselineHighlightingTests.swift in Sources */, + CCA6D1AE25F90D2E000690C4 /* PerformanceTests.swift in Sources */, + CCA6D1B125F90D2E000690C4 /* ParserTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -835,21 +813,25 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2198CED31B36D5DE00BD463F /* Capture.swift in Sources */, - 8CDD6F1D1C71594B0063915A /* BundleManager.swift in Sources */, - 2198CED71B36D5DE00BD463F /* Parser.swift in Sources */, - 8CE64FE51C74B48D0007BA57 /* Language.swift in Sources */, - 2198CED41B36D5DE00BD463F /* CaptureCollection.swift in Sources */, - 8CEEC0E01C411C8600BF3E85 /* ReferenceManager.swift in Sources */, - 8C10B6461CC38E5200740E00 /* AttributedParsingOperation.swift in Sources */, - 8CEEC0E41C411F9700BF3E85 /* Repository.swift in Sources */, - 2198CEDA1B36D5DE00BD463F /* ResultSet.swift in Sources */, - 8C10B6481CC3938100740E00 /* Color.swift in Sources */, - 8C10B6491CC393E700740E00 /* ScopedString.swift in Sources */, - 2198CED81B36D5DE00BD463F /* Pattern.swift in Sources */, - 2198CEDB1B36D5DE00BD463F /* Theme.swift in Sources */, - 2198CED91B36D5DE00BD463F /* Result.swift in Sources */, - 2198CED21B36D5DE00BD463F /* AttributedParser.swift in Sources */, + CCA6D15725F90D21000690C4 /* Result.swift in Sources */, + CCA6D16B25F90D21000690C4 /* AttributedParser.swift in Sources */, + CCA6D17325F90D21000690C4 /* Font.swift in Sources */, + CCA6D15B25F90D21000690C4 /* ReferenceManager.swift in Sources */, + CCA6D14F25F90D21000690C4 /* BundleManager.swift in Sources */, + CCA6D17F25F90D21000690C4 /* ResultSet.swift in Sources */, + CCA6D14B25F90D20000690C4 /* Capture.swift in Sources */, + CCA6D17725F90D21000690C4 /* Pattern.swift in Sources */, + CCA6D15325F90D21000690C4 /* Attributes.swift in Sources */, + CCA6D16325F90D21000690C4 /* Repository.swift in Sources */, + CCA6D13B25F90D20000690C4 /* ScopedString.swift in Sources */, + CCA6D18325F90D21000690C4 /* Color.swift in Sources */, + CCA6D14725F90D20000690C4 /* AttributedParsingOperation.swift in Sources */, + CCA6D16725F90D21000690C4 /* Parser.swift in Sources */, + CCA6D14325F90D20000690C4 /* Language.swift in Sources */, + CCA6D17B25F90D21000690C4 /* RegularExpression.swift in Sources */, + CCA6D13F25F90D20000690C4 /* CaptureCollection.swift in Sources */, + CCA6D13725F90D20000690C4 /* SyntaxKit.swift in Sources */, + CCA6D16F25F90D21000690C4 /* Theme.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -878,22 +860,19 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.tvos; PRODUCT_NAME = SyntaxKit; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; }; @@ -901,22 +880,19 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_NONNULL = YES; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.tvos; PRODUCT_NAME = SyntaxKit; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -924,32 +900,28 @@ 211826EF1D257A71003F2BF2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; CLANG_ANALYZER_NONNULL = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.tvos.tests; PRODUCT_NAME = SyntaxKitTests; SDKROOT = appletvos; - SWIFT_VERSION = 4.0; - TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Debug; }; 211826F01D257A71003F2BF2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; CLANG_ANALYZER_NONNULL = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.tvos.tests; PRODUCT_NAME = SyntaxKitTests; SDKROOT = appletvos; - SWIFT_VERSION = 4.0; - TVOS_DEPLOYMENT_TARGET = 9.2; VALIDATE_PRODUCT = YES; }; name = Release; @@ -957,22 +929,18 @@ 211989B91B2EC3B600F0D786 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit; PRODUCT_NAME = SyntaxKit; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -980,22 +948,18 @@ 211989BA1B2EC3B600F0D786 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit; PRODUCT_NAME = SyntaxKit; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -1004,32 +968,28 @@ 211989BC1B2EC3B600F0D786 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.samsoffes.syntaxkit-ios.tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; }; name = Debug; }; 211989BD1B2EC3B600F0D786 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.samsoffes.syntaxkit-ios.tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -1058,6 +1018,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1084,15 +1045,17 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; + TVOS_DEPLOYMENT_TARGET = 13.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; + WATCHOS_DEPLOYMENT_TARGET = 6.0; }; name = Debug; }; @@ -1120,6 +1083,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1140,14 +1104,16 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; + TVOS_DEPLOYMENT_TARGET = 13.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; + WATCHOS_DEPLOYMENT_TARGET = 6.0; }; name = Release; }; @@ -1155,23 +1121,19 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit; PRODUCT_NAME = SyntaxKit; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1179,28 +1141,26 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit; PRODUCT_NAME = SyntaxKit; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; }; name = Release; }; 2122A6F81B22B9320006409B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; COMBINE_HIDPI_IMAGES = YES; ENABLE_BITCODE = NO; @@ -1212,17 +1172,16 @@ "DEBUG=1", "$(inherited)", ); - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.samsoffes.syntaxkit-macos.tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Debug; }; 2122A6F91B22B9320006409B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; APPLICATION_EXTENSION_API_ONLY = NO; COMBINE_HIDPI_IMAGES = YES; ENABLE_BITCODE = NO; @@ -1230,58 +1189,48 @@ "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", ); - INFOPLIST_FILE = SyntaxKit/Tests/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.samsoffes.syntaxkit-macos.tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Release; }; 2198CECF1B36D5D700BD463F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.watchos; PRODUCT_NAME = SyntaxKit; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; 2198CED01B36D5D700BD463F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "$(SRCROOT)/SyntaxKit/Resources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.syntaxkit.watchos; PRODUCT_NAME = SyntaxKit; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; VALIDATE_PRODUCT = YES; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; diff --git a/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKit-iOS.xcscheme b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKit-iOS.xcscheme index 36486f5..d78a5a9 100644 --- a/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKit-iOS.xcscheme +++ b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKit-iOS.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - - - + + + + @@ -39,17 +48,6 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-macOS.xcscheme b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-macOS.xcscheme new file mode 100644 index 0000000..1146e39 --- /dev/null +++ b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-macOS.xcscheme @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-tvOS.xcscheme b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-tvOS.xcscheme new file mode 100644 index 0000000..36a5ca1 --- /dev/null +++ b/SyntaxKit.xcodeproj/xcshareddata/xcschemes/SyntaxKitTests-tvOS.xcscheme @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/SyntaxKit/SyntaxKit.h b/SyntaxKit/SyntaxKit.h deleted file mode 100644 index 72a44a4..0000000 --- a/SyntaxKit/SyntaxKit.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// SyntaxKit.h -// SyntaxKit -// -// Created by Sam Soffes on 9/18/14. -// Copyright © 2014-2015 Sam Soffes. All rights reserved. -// - -@import Foundation; - -//! Project version number for SyntaxKit. -FOUNDATION_EXPORT double SyntaxKitVersionNumber; - -//! Project version string for SyntaxKit. -FOUNDATION_EXPORT const unsigned char SyntaxKitVersionString[]; diff --git a/SyntaxKit/Tests/Resources/Info.plist b/SyntaxKit/Tests/Resources/Info.plist deleted file mode 100644 index ba72822..0000000 --- a/SyntaxKit/Tests/Resources/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/SyntaxKit/Theme.swift b/SyntaxKit/Theme.swift deleted file mode 100644 index 1a76903..0000000 --- a/SyntaxKit/Theme.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// Theme.swift -// SyntaxKit -// -// Represents a TextMate theme file (.tmTheme). Currently only supports the -// foreground text color attribute on a local scope. -// -// Created by Sam Soffes on 10/11/14. -// Copyright © 2014-2015 Sam Soffes. All rights reserved. -// - -#if os(OSX) - import AppKit -#else - import UIKit -#endif - -public typealias Attributes = [NSAttributedString.Key: Any] - -public struct Theme { - - // MARK: - Properties - - public let uuid: UUID - public let name: String - public let attributes: [String: Attributes] - - public var backgroundColor: Color { - return attributes[Language.globalScope]?[NSAttributedString.Key.backgroundColor] as? Color ?? Color.white - } - - public var foregroundColor: Color { - return attributes[Language.globalScope]?[NSAttributedString.Key.foregroundColor] as? Color ?? Color.black - } - - // MARK: - Initializers - - init?(dictionary: [String: Any]) { - guard let uuidString = dictionary["uuid"] as? String, - let uuid = UUID(uuidString: uuidString), - let name = dictionary["name"] as? String, - let rawSettings = dictionary["settings"] as? [[String: AnyObject]] - else { return nil } - - self.uuid = uuid - self.name = name - - var attributes = [String: Attributes]() - for raw in rawSettings { - guard var setting = raw["settings"] as? [NSAttributedString.Key: Any] else { continue } - - if let value = setting.removeValue(forKey: NSAttributedString.Key(rawValue: "foreground")) as? String { - setting[NSAttributedString.Key.foregroundColor] = Color(hex: value) - } - - if let value = setting.removeValue(forKey: NSAttributedString.Key(rawValue: "background")) as? String { - setting[NSAttributedString.Key.backgroundColor] = Color(hex: value) - } - - if let patternIdentifiers = raw["scope"] as? String { - for patternIdentifier in patternIdentifiers.components(separatedBy: ",") { - let key = patternIdentifier.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) - attributes[key] = setting - } - } else if !setting.isEmpty { - attributes[Language.globalScope] = setting - } - } - self.attributes = attributes - } -} diff --git a/SyntaxKit/Tests/AttributedParserTests.swift b/Tests/SyntaxKitTests/AttributedParserTests.swift similarity index 62% rename from SyntaxKit/Tests/AttributedParserTests.swift rename to Tests/SyntaxKitTests/AttributedParserTests.swift index e4b2754..ee562d9 100644 --- a/SyntaxKit/Tests/AttributedParserTests.swift +++ b/Tests/SyntaxKitTests/AttributedParserTests.swift @@ -32,9 +32,9 @@ internal class AttributedParserTests: XCTestCase { func testParsing() { let string = parser?.attributedString(for: "title: Hello World\ncount: 42\n") - XCTAssertEqual(["color": "blue"], string?.attributes(at: 0, effectiveRange: nil) as NSDictionary?) - XCTAssertEqual(["color": "red"], string?.attributes(at: 7, effectiveRange: nil) as NSDictionary?) - XCTAssertEqual(["color": "blue"], string?.attributes(at: 19, effectiveRange: nil) as NSDictionary?) - XCTAssertEqual(["color": "purple"], string?.attributes(at: 25, effectiveRange: nil) as NSDictionary?) + XCTAssertEqual("blue", string?.attributes(at: 0, effectiveRange: nil)[NSAttributedString.Key("color")] as? String) + XCTAssertEqual("red", string?.attributes(at: 7, effectiveRange: nil)[NSAttributedString.Key("color")] as? String) + XCTAssertEqual("blue", string?.attributes(at: 19, effectiveRange: nil)[NSAttributedString.Key("color")] as? String) + XCTAssertEqual("purple", string?.attributes(at: 25, effectiveRange: nil)[NSAttributedString.Key("color")] as? String) } } diff --git a/Tests/SyntaxKitTests/BackReferenceTests.swift b/Tests/SyntaxKitTests/BackReferenceTests.swift new file mode 100644 index 0000000..b5166f6 --- /dev/null +++ b/Tests/SyntaxKitTests/BackReferenceTests.swift @@ -0,0 +1,98 @@ +// +// BackReferenceTests.swift +// SyntaxKit +// +// Created by Zheng Wu on 2021/2/19. +// Copyright © 2021 Zheng Wu. All rights reserved. +// + +@testable import SyntaxKit +import XCTest + +internal class BackReferenceTests: XCTestCase { + + // MARK: - Properties + + private var parser: Parser? + private let manager: BundleManager = getBundleManager() + + // MARK: - Tests + + override func setUp() { + super.setUp() + if let lua = manager.language(withIdentifier: "source.lua") { + parser = Parser(language: lua) + } else { + XCTFail("Should be able to load lua language fixture") + } + } + + func testBackReferenceHelpers() throws { + XCTAssertFalse("title: \"Hello World\"\n".hasBackReferencePlaceholder) + XCTAssertFalse("title: Hello World\ncomments: 24\nposts: \"12\"zz\n".hasBackReferencePlaceholder) + XCTAssert("title: Hello World\ncomments: 24\nposts: \"12\\3\"zz\n".hasBackReferencePlaceholder) + + let testString1 = "title: Hello World\ncomments: \\24\nposts: \"12\\3\"zz\n" + let testString2 = "title: Hello World\ncomments: $24\nposts: \"12$3\"zz\n" + XCTAssertEqual(testString1.convertToICUBackReferencedRegex(), testString2) + XCTAssertEqual(testString2.convertToBackReferencedRegex(), testString1) + + XCTAssertEqual("(?<=\\.) {2,}(?=[A-Z])".addingRegexEscapedCharacters(), "\\(\\?<=\\\\\\.\\) \\{2,\\}\\(\\?=\\[A-Z\\]\\)") + } + + func testBackReference() throws { + var blockComment: NSRange? + var commentBegin: NSRange? + var commentEnd: NSRange? + + parser?.parse("\"Emmmm...\" --[=[ This is \na multi-line comment. ]=]") { (scope: String, range: NSRange) in + if blockComment == nil && scope.hasPrefix("comment.block.lua") { + blockComment = range + } + + if commentBegin == nil && scope.hasPrefix("punctuation.definition.comment.begin.lua") { + commentBegin = range + } + + if commentEnd == nil && scope.hasPrefix("punctuation.definition.comment.end.lua") { + commentEnd = range + } + } + + XCTAssertEqual(NSRange(location: 11, length: 40), blockComment) + XCTAssertEqual(NSRange(location: 11, length: 5), commentBegin) + XCTAssertEqual(NSRange(location: 48, length: 3), commentEnd) + + var blockString: NSRange? + var stringBegin: NSRange? + var stringEnd: NSRange? + + parser?.parse("--[=[ Emmmm...]=] [===[ This is \na multi-line string. ]===]") { (scope: String, range: NSRange) in + debugPrint(scope, range) + + if blockString == nil && scope.hasPrefix("string.quoted.other.multiline.lua") { + blockString = range + } + + if stringBegin == nil && scope.hasPrefix("punctuation.definition.string.begin.lua") { + stringBegin = range + } + + if stringEnd == nil && scope.hasPrefix("punctuation.definition.string.end.lua") { + stringEnd = range + } + } + + XCTAssertEqual(NSRange(location: 18, length: 41), blockString) + XCTAssertEqual(NSRange(location: 18, length: 5), stringBegin) + XCTAssertEqual(NSRange(location: 54, length: 5), stringEnd) + } + + func testBackReferencePerformance() throws { + self.measure { + let input = fixture("test.lua", "txt") + parser?.parse(input) { _, _ in return } + } + } + +} diff --git a/SyntaxKit/Tests/Resources/Fixtures/Latex.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Latex.tmLanguage similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Latex.tmLanguage rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Latex.tmLanguage diff --git a/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Lua.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Lua.tmLanguage new file mode 100755 index 0000000..9cf783d --- /dev/null +++ b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Lua.tmLanguage @@ -0,0 +1,368 @@ + + + + + fileTypes + + lua + p8 + rockspec + + firstLineMatch + \A#!.*?\blua(\d+(\.\d+)?)?\b|\A--\s+-\*-\s*lua\s*-\*- + keyEquivalent + ^~L + repository + + escaped_char + + patterns + + + match + \\[abfnrtvz\\"'\n] + name + constant.character.escape.lua + + + match + \\\d{1,3} + name + constant.character.escape.byte.lua + + + match + \\x[0-9A-Fa-f][0-9A-Fa-f] + name + constant.character.escape.byte.lua + + + match + \\u\{[0-9A-Fa-f]+\} + name + constant.character.escape.unicode.lua + + + match + \\. + name + invalid.illegal.character.escape.lua + + + + + uuid + 93E017CC-6F27-11D9-90EB-000D93589AF7 + patterns + + + end + \) + begin + \b((local\b)\s+)?(function)\s*(\s+[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*(:[a-zA-Z_][a-zA-Z0-9_]*)?\s*)?(\() + beginCaptures + + 3 + + name + keyword.control.lua + + 4 + + name + entity.name.function.lua + + 5 + + name + punctuation.definition.parameters.begin.lua + + 1 + + name + storage.modifier.local.lua + + + patterns + + + match + [a-zA-Z_][a-zA-Z0-9_]* + name + variable.parameter.function.lua + + + endCaptures + + 0 + + name + punctuation.definition.parameters.end.lua + + + name + meta.function.lua + + + match + (?<![\w\d.])0[xX][0-9A-Fa-f]+(?![pPeE.0-9]) + name + constant.numeric.integer.hexadecimal.lua + + + match + (?<![\w\d.])0[xX][0-9A-Fa-f]+(\.[0-9A-Fa-f]+)?([eE]-?\d*)?([pP][-+]\d+)? + name + constant.numeric.float.hexadecimal.lua + + + match + (?<![\w\d.])\d+(?![pPeE.0-9]) + name + constant.numeric.integer.lua + + + match + (?<![\w\d.])\d+(\.\d+)?([eE]-?\d*)? + name + constant.numeric.float.lua + + + end + ' + begin + ' + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + patterns + + + include + #escaped_char + + + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.single.lua + + + end + " + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + patterns + + + include + #escaped_char + + + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.double.lua + + + end + \]\1\] + begin + (?<!--)\[(=*)\[ + beginCaptures + + 0 + + name + punctuation.definition.string.begin.lua + + + endCaptures + + 0 + + name + punctuation.definition.string.end.lua + + + name + string.quoted.other.multiline.lua + + + match + \A(#!).*$\n? + captures + + 1 + + name + punctuation.definition.comment.lua + + + name + comment.line.shebang.lua + + + end + \]\1\] + begin + --\[(=*)\[ + beginCaptures + + 0 + + name + punctuation.definition.comment.begin.lua + + + endCaptures + + 0 + + name + punctuation.definition.comment.end.lua + + + name + comment.block.lua + + + end + \n + begin + -- + beginCaptures + + 0 + + name + punctuation.definition.comment.lua + + + name + comment.line.double-dash.lua + + + match + \b(goto)\s+([a-zA-Z_][a-zA-Z0-9_]*) + captures + + 1 + + name + keyword.control.goto.lua + + 2 + + name + constant.other.placeholder.lua + + + + + match + (::)[a-zA-Z_][a-zA-Z0-9_]*(::) + captures + + 1 + + name + punctuation.definition.label.begin.lua + + 2 + + name + punctuation.definition.label.end.lua + + + name + constant.other.placeholder.lua + + + match + \b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|function|local|in)\b + name + keyword.control.lua + + + match + (?<![^.]\.|:)\b(false|nil|true|_G|_VERSION|math\.(pi|huge))\b|(?<![.])\.{3}(?!\.) + name + constant.language.lua + + + match + (?<![^.]\.|:)\b(self)\b + name + variable.language.self.lua + + + match + (?<![^.]\.|:)\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\b(?=\s*(?:[({"']|\[\[)) + name + support.function.lua + + + match + (?<![^.]\.|:)\b(coroutine\.(create|resume|running|status|wrap|yield)|string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\.(concat|insert|maxn|remove|sort)|math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\.(cpath|loaded|loadlib|path|preload|seeall)|debug\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\b(?=\s*(?:[({"']|\[\[)) + name + support.function.library.lua + + + match + \b(and|or|not)\b + name + keyword.operator.lua + + + match + \b([a-zA-Z_][a-zA-Z0-9_]*)\b(?=\s*(?:[({"']|\[\[)) + name + support.function.any-method.lua + + + match + (?<=[^.]\.|:)\b([a-zA-Z_][a-zA-Z0-9_]*) + name + variable.other.lua + + + match + \+|-|%|#|\*|\/|\^|==?|~=|<=?|>=?|(?<!\.)\.{2}(?!\.) + name + keyword.operator.lua + + + comment + Lua Syntax: version 0.8 + name + Lua + scopeName + source.lua + + diff --git a/SyntaxKit/Tests/Resources/Fixtures/Ruby.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Ruby.tmLanguage similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Ruby.tmLanguage rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Ruby.tmLanguage diff --git a/SyntaxKit/Tests/Resources/Fixtures/Solarized.tmTheme b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Solarized.tmTheme similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Solarized.tmTheme rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Solarized.tmTheme diff --git a/SyntaxKit/Tests/Resources/Fixtures/Swift.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Swift.tmLanguage similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Swift.tmLanguage rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Swift.tmLanguage diff --git a/SyntaxKit/Tests/Resources/Fixtures/Tex.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Tex.tmLanguage similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Tex.tmLanguage rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Tex.tmLanguage diff --git a/SyntaxKit/Tests/Resources/Fixtures/Tomorrow.tmTheme b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Tomorrow.tmTheme similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Tomorrow.tmTheme rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Tomorrow.tmTheme diff --git a/SyntaxKit/Tests/Resources/Fixtures/Yaml.tmLanguage b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Yaml.tmLanguage similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/Yaml.tmLanguage rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/Yaml.tmLanguage diff --git a/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.lua.txt b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.lua.txt new file mode 100644 index 0000000..20239f9 --- /dev/null +++ b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.lua.txt @@ -0,0 +1,3758 @@ +#!/usr/bin/env lua + +local parser = require "lua-parser.parser" +local pp = require "lua-parser.pp" + +-- expected result, result, subject +local e, r, s + +local filename = "test.lua" + +local function parse (s) + local t,m = parser.parse(s,filename) + local r + if not t then + r = m + else + r = pp.tostring(t) + end + return r .. "\n" +end + +local function fixint (s) + return _VERSION < "Lua 5.3" and s:gsub("%.0","") or s +end + +print("> testing lexer...") + +-- syntax ok + +-- empty files + +s = [=[ +]=] +e = [=[ +{ } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- testing empty file +]=] +e = [=[ +{ } +]=] + +r = parse(s) +assert(r == e) + +-- expressions + +s = [=[ +_nil,_false,_true,_dots = nil,false,true,... +]=] +e = [=[ +{ `Set{ { `Id "_nil", `Id "_false", `Id "_true", `Id "_dots" }, { `Nil, `Boolean "false", `Boolean "true", `Dots } } } +]=] + +r = parse(s) +assert(r == e) + +-- floating points + +s = [=[ +f1 = 1. +f2 = 1.1 +]=] +e = [=[ +{ `Set{ { `Id "f1" }, { `Number "1.0" } }, `Set{ { `Id "f2" }, { `Number "1.1" } } } +]=] + +r = parse(s) +assert(r == fixint(e)) + +s = [=[ +f1 = 1.e-1 +f2 = 1.e1 +]=] +e = [=[ +{ `Set{ { `Id "f1" }, { `Number "0.1" } }, `Set{ { `Id "f2" }, { `Number "10.0" } } } +]=] + +r = parse(s) +assert(r == fixint(e)) + +s = [=[ +f1 = 1.1e+1 +f2 = 1.1e1 +]=] +e = [=[ +{ `Set{ { `Id "f1" }, { `Number "11.0" } }, `Set{ { `Id "f2" }, { `Number "11.0" } } } +]=] + +r = parse(s) +assert(r == fixint(e)) + +s = [=[ +f1 = .1 +f2 = .1e1 +]=] +e = [=[ +{ `Set{ { `Id "f1" }, { `Number "0.1" } }, `Set{ { `Id "f2" }, { `Number "1.0" } } } +]=] + +r = parse(s) +assert(r == fixint(e)) + +s = [=[ +f1 = 1E1 +f2 = 1e-1 +]=] +e = [=[ +{ `Set{ { `Id "f1" }, { `Number "10.0" } }, `Set{ { `Id "f2" }, { `Number "0.1" } } } +]=] + +r = parse(s) +assert(r == fixint(e)) + +-- integers + +s = [=[ +i = 1 +h = 0xff +]=] +e = [=[ +{ `Set{ { `Id "i" }, { `Number "1" } }, `Set{ { `Id "h" }, { `Number "255" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +h = 0x76c +i = 4294967296 -- 2^32 +]=] +e = [=[ +{ `Set{ { `Id "h" }, { `Number "1900" } }, `Set{ { `Id "i" }, { `Number "4294967296" } } } +]=] + +r = parse(s) +assert(r == e) + +-- long comments + +s = [=[ +--[======[ +testing +long +comment +[==[ one ]==] +[===[ more ]===] +[====[ time ]====] +bye +]======] +]=] +e = [=[ +{ } +]=] + +r = parse(s) +assert(r == e) + +-- long strings + +s = [=[ +--[[ +testing long string1 begin +]] + +ls1 = +[[ +testing long string +]] + +--[[ +testing long string1 end +]] +]=] +e = [=[ +{ `Set{ { `Id "ls1" }, { `String "testing long string\n" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +--[==[ +testing long string2 begin +]==] + +ls2 = [==[ testing \n [[ long ]] \t [===[ string ]===] +\a ]==] + +--[==[ +[[ testing long string2 end ]] +]==] +]=] +e = [=[ +{ `Set{ { `Id "ls2" }, { `String " testing \\n [[ long ]] \\t [===[ string ]===]\n\\a " } } } +]=] + +r = parse(s) +assert(r == e) + +-- short strings + +s = [=[ +-- short string test begin + +ss1_a = "ola mundo\a" +ss1_b = 'ola mundo\a' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "ss1_a" }, { `String "ola mundo\a" } }, `Set{ { `Id "ss1_b" }, { `String "ola mundo\a" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +ss2_a = "testando,\tteste\n1\n2\n3 --> \"tchau\"" +ss2_b = 'testando,\tteste\n1\n2\n3 --> \'tchau\'' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "ss2_a" }, { `String "testando,\tteste\n1\n2\n3 --> \"tchau\"" } }, `Set{ { `Id "ss2_b" }, { `String "testando,\tteste\n1\n2\n3 --> 'tchau'" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +ss3_a = "ola \ +'mundo'!" + +ss3_b = 'ola \ +"mundo"!' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "ss3_a" }, { `String "ola \n'mundo'!" } }, `Set{ { `Id "ss3_b" }, { `String "ola \n\"mundo\"!" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +ss4_a = "C:\\Temp/" + +ss4_b = 'C:\\Temp/' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "ss4_a" }, { `String "C:\\Temp/" } }, `Set{ { `Id "ss4_b" }, { `String "C:\\Temp/" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +lf = "\\n" + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "lf" }, { `String "\\n" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +ss5_a = "ola \ +mundo \\ \ +cruel" + +ss5_b = 'ola \ +mundo \\ \ +cruel' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "ss5_a" }, { `String "ola \nmundo \\ \ncruel" } }, `Set{ { `Id "ss5_b" }, { `String "ola \nmundo \\ \ncruel" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +s1 = 'a \z b' +s2 = "adeus \z + mundo\ +\z maravilhoso" + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "s1" }, { `String "a b" } }, `Set{ { `Id "s2" }, { `String "adeus mundo\nmaravilhoso" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +deci = '\28' +hex = '\x1C' +uni = '\u{001C}' + +-- short string test end +]=] +e = [=[ +{ `Set{ { `Id "deci" }, { `String "\028" } }, `Set{ { `Id "hex" }, { `String "\028" } }, `Set{ { `Id "uni" }, { `String "\028" } } } +]=] + +r = parse(s) +assert(r == e) + +-- syntax error + +-- floating points + +s = [=[ +f = 9e +]=] +e = [=[ +test.lua:2:1: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = 5.e +]=] +e = [=[ +test.lua:2:1: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = .9e- +]=] +e = [=[ +test.lua:2:1: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = 5.9e+ +]=] +e = [=[ +test.lua:2:1: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +-- integers + +s = [=[ +-- invalid hexadecimal number + +hex = 0xG +]=] +e = [=[ +test.lua:3:9: syntax error, expected one or more hexadecimal digits after '0x' +]=] + +r = parse(s) +assert(r == e) + +-- long strings + +s = [=[ +--[==[ +testing long string3 begin +]==] + +ls3 = [===[ +testing +unfinised +long string +]==] + +--[==[ +[[ testing long string3 end ]] +]==] +]=] +e = [=[ +test.lua:14:1: syntax error, unclosed long string +]=] + +r = parse(s) +assert(r == e) + +-- short strings + +s = [=[ +-- short string test begin + +ss6 = "testing unfinished string + +-- short string test end +]=] +e = [=[ +test.lua:4:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +-- short string test begin + +ss7 = 'testing \\ +unfinished \\ +string' + +-- short string test end +]=] +e = [=[ +test.lua:4:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +-- unfinished comments + +s = [=[ +--[[ testing +unfinished +comment +]=] +e = [=[ +test.lua:4:1: syntax error, unclosed long string +]=] + +r = parse(s) +assert(r == e) + +print("> testing parser...") + +-- syntax ok + +-- anonymous functions + +s = [=[ +local a,b,c = function () end +]=] +e = [=[ +{ `Local{ { `Id "a", `Id "b", `Id "c" }, { `Function{ { }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local test = function ( a , b , ... ) end +]=] +e = [=[ +{ `Local{ { `Id "test" }, { `Function{ { `Id "a", `Id "b", `Dots }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +test = function (...) return ...,0 end +]=] +e = [=[ +{ `Set{ { `Id "test" }, { `Function{ { `Dots }, { `Return{ `Dots, `Number "0" } } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- arithmetic expressions + +s = [=[ +arithmetic = 1 - 2 * 3 + 4 +]=] +e = [=[ +{ `Set{ { `Id "arithmetic" }, { `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +pow = -3^-2^2 +]=] +e = [=[ +{ `Set{ { `Id "pow" }, { `Op{ "unm", `Op{ "pow", `Number "3", `Op{ "unm", `Op{ "pow", `Number "2", `Number "2" } } } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +q, r, f = 3//2, 3%2, 3/2 +]=] +e = [=[ +{ `Set{ { `Id "q", `Id "r", `Id "f" }, { `Op{ "idiv", `Number "3", `Number "2" }, `Op{ "mod", `Number "3", `Number "2" }, `Op{ "div", `Number "3", `Number "2" } } } } +]=] + +r = parse(s) +assert(r == e) + +-- assignments + +s = [=[ +a = f()[1] +]=] +e = [=[ +{ `Set{ { `Id "a" }, { `Index{ `Call{ `Id "f" }, `Number "1" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +a()[1] = 1; +]=] +e = [=[ +{ `Set{ { `Index{ `Call{ `Id "a" }, `Number "1" } }, { `Number "1" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +i = a.f(1) +]=] +e = [=[ +{ `Set{ { `Id "i" }, { `Call{ `Index{ `Id "a", `String "f" }, `Number "1" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +i = a[f(1)] +]=] +e = [=[ +{ `Set{ { `Id "i" }, { `Index{ `Id "a", `Call{ `Id "f", `Number "1" } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +a[f()] = sub +i = i + 1 +]=] +e = [=[ +{ `Set{ { `Index{ `Id "a", `Call{ `Id "f" } } }, { `Id "sub" } }, `Set{ { `Id "i" }, { `Op{ "add", `Id "i", `Number "1" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +a:b(1)._ = some_value +]=] +e = [=[ +{ `Set{ { `Index{ `Invoke{ `Id "a", `String "b", `Number "1" }, `String "_" } }, { `Id "some_value" } } } +]=] + +r = parse(s) +assert(r == e) + +-- bitwise expressions + +s = [=[ +b = 1 & 0 | 1 ~ 1 +]=] +e = [=[ +{ `Set{ { `Id "b" }, { `Op{ "bor", `Op{ "band", `Number "1", `Number "0" }, `Op{ "bxor", `Number "1", `Number "1" } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +b = 1 & 0 | 1 >> 1 ~ 1 +]=] +e = [=[ +{ `Set{ { `Id "b" }, { `Op{ "bor", `Op{ "band", `Number "1", `Number "0" }, `Op{ "bxor", `Op{ "shr", `Number "1", `Number "1" }, `Number "1" } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- break + +s = [=[ +while 1 do + break +end +]=] +e = [=[ +{ `While{ `Number "1", { `Break } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while 1 do + while 1 do + break + end + break +end +]=] +e = [=[ +{ `While{ `Number "1", { `While{ `Number "1", { `Break } }, `Break } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +repeat + if 2 > 1 then break end +until 1 +]=] +e = [=[ +{ `Repeat{ { `If{ `Op{ "gt", `Number "2", `Number "1" }, { `Break } } }, `Number "1" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for i=1,10 do + do + break + break + return + end +end +]=] +e = [=[ +{ `Fornum{ `Id "i", `Number "1", `Number "10", { `Do{ `Break, `Break, `Return } } } } +]=] + +r = parse(s) +assert(r == e) + +-- block statements + +s = [=[ +do + var = 2+2; + return +end +]=] +e = [=[ +{ `Do{ `Set{ { `Id "var" }, { `Op{ "add", `Number "2", `Number "2" } } }, `Return } } +]=] + +r = parse(s) +assert(r == e) + +-- concatenation expressions + +s = [=[ +concat1 = 1 .. 2^3 +]=] +e = [=[ +{ `Set{ { `Id "concat1" }, { `Op{ "concat", `Number "1", `Op{ "pow", `Number "2", `Number "3" } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- empty files + +s = [=[ +; +]=] +e = [=[ +{ } +]=] + +r = parse(s) +assert(r == e) + +-- for generic + +s = [=[ +for k,v in pairs(t) do print (k,v) end +]=] +e = [=[ +{ `Forin{ { `Id "k", `Id "v" }, { `Call{ `Id "pairs", `Id "t" } }, { `Call{ `Id "print", `Id "k", `Id "v" } } } } +]=] + +r = parse(s) +assert(r == e) + +-- for numeric + +s = [=[ +for i = 1 , 10 , 2 do end +]=] +e = [=[ +{ `Fornum{ `Id "i", `Number "1", `Number "10", `Number "2", { } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for i=1,10 do end +]=] +e = [=[ +{ `Fornum{ `Id "i", `Number "1", `Number "10", { } } } +]=] + +r = parse(s) +assert(r == e) + +-- global functions + +s = [=[ +function test(a , b , ...) end +]=] +e = [=[ +{ `Set{ { `Id "test" }, { `Function{ { `Id "a", `Id "b", `Dots }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function test (...) end +]=] +e = [=[ +{ `Set{ { `Id "test" }, { `Function{ { `Dots }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function t.a:b() end +]=] +e = [=[ +{ `Set{ { `Index{ `Index{ `Id "t", `String "a" }, `String "b" } }, { `Function{ { `Id "self" }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function t.a() end +]=] +e = [=[ +{ `Set{ { `Index{ `Id "t", `String "a" } }, { `Function{ { }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function testando . funcao . com : espcacos ( e, com , parametros, ... ) end +]=] +e = [=[ +{ `Set{ { `Index{ `Index{ `Index{ `Id "testando", `String "funcao" }, `String "com" }, `String "espcacos" } }, { `Function{ { `Id "self", `Id "e", `Id "com", `Id "parametros", `Dots }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- goto + +s = [=[ +goto label +:: label :: return +]=] +e = [=[ +{ `Goto{ "label" }, `Label{ "label" }, `Return } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::label:: +goto label +]=] +e = [=[ +{ `Label{ "label" }, `Goto{ "label" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +goto label +::label:: +]=] +e = [=[ +{ `Goto{ "label" }, `Label{ "label" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::label:: +do ::label:: goto label end +]=] +e = [=[ +{ `Label{ "label" }, `Do{ `Label{ "label" }, `Goto{ "label" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::label:: +do goto label ; ::label:: end +]=] +e = [=[ +{ `Label{ "label" }, `Do{ `Goto{ "label" }, `Label{ "label" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::label:: +do goto label end +]=] +e = [=[ +{ `Label{ "label" }, `Do{ `Goto{ "label" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +do goto label end +::label:: +]=] +e = [=[ +{ `Do{ `Goto{ "label" } }, `Label{ "label" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +do do do do do goto label end end end end end +::label:: +]=] +e = [=[ +{ `Do{ `Do{ `Do{ `Do{ `Do{ `Goto{ "label" } } } } } }, `Label{ "label" } } +]=] + +r = parse(s) +assert(r == e) + +-- if-else + +s = [=[ +if a then end +]=] +e = [=[ +{ `If{ `Id "a", { } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then return a else return end +]=] +e = [=[ +{ `If{ `Id "a", { `Return{ `Id "a" } }, { `Return } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then + return a +else + local c = d + d = d + 1 + return d +end +]=] +e = [=[ +{ `If{ `Id "a", { `Return{ `Id "a" } }, { `Local{ { `Id "c" }, { `Id "d" } }, `Set{ { `Id "d" }, { `Op{ "add", `Id "d", `Number "1" } } }, `Return{ `Id "d" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then + return a +elseif b then + return b +elseif c then + return c +end +]=] +e = [=[ +{ `If{ `Id "a", { `Return{ `Id "a" } }, `Id "b", { `Return{ `Id "b" } }, `Id "c", { `Return{ `Id "c" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then return a +elseif b then return +else ; +end +]=] +e = [=[ +{ `If{ `Id "a", { `Return{ `Id "a" } }, `Id "b", { `Return }, { } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then + return +elseif c then +end +]=] +e = [=[ +{ `If{ `Id "a", { `Return }, `Id "c", { } } } +]=] + +r = parse(s) +assert(r == e) + +-- labels + +s = [=[ +::label:: +do ::label:: end +::other_label:: +]=] +e = [=[ +{ `Label{ "label" }, `Do{ `Label{ "label" } }, `Label{ "other_label" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local x = glob +::label:: +foo() +]=] +e = [=[ +{ `Local{ { `Id "x" }, { `Id "glob" } }, `Label{ "label" }, `Call{ `Id "foo" } } +]=] + +r = parse(s) +assert(r == e) + +-- locals + +s = [=[ +local a +]=] +e = [=[ +{ `Local{ { `Id "a" }, { } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local a,b,c +]=] +e = [=[ +{ `Local{ { `Id "a", `Id "b", `Id "c" }, { } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local a = 1 , 1 + 2, 5.1 +]=] +e = [=[ +{ `Local{ { `Id "a" }, { `Number "1", `Op{ "add", `Number "1", `Number "2" }, `Number "5.1" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local a,b,c = 1.9 +]=] +e = [=[ +{ `Local{ { `Id "a", `Id "b", `Id "c" }, { `Number "1.9" } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function test() end +]=] +e = [=[ +{ `Localrec{ { `Id "test" }, { `Function{ { }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function test ( a , b , c , ... ) end +]=] +e = [=[ +{ `Localrec{ { `Id "test" }, { `Function{ { `Id "a", `Id "b", `Id "c", `Dots }, { } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function test(...) return ... end +]=] +e = [=[ +{ `Localrec{ { `Id "test" }, { `Function{ { `Dots }, { `Return{ `Dots } } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- relational expressions + +s = [=[ +relational = 1 < 2 >= 3 == 4 ~= 5 < 6 <= 7 +]=] +e = [=[ +{ `Set{ { `Id "relational" }, { `Op{ "le", `Op{ "lt", `Op{ "ne", `Op{ "eq", `Op{ "ge", `Op{ "lt", `Number "1", `Number "2" }, `Number "3" }, `Number "4" }, `Number "5" }, `Number "6" }, `Number "7" } } } } +]=] + +r = parse(s) +assert(r == e) + +-- repeat + +s = [=[ +repeat + a,b,c = 1+1,2+2,3+3 + break +until a < 1 +]=] +e = [=[ +{ `Repeat{ { `Set{ { `Id "a", `Id "b", `Id "c" }, { `Op{ "add", `Number "1", `Number "1" }, `Op{ "add", `Number "2", `Number "2" }, `Op{ "add", `Number "3", `Number "3" } } }, `Break }, `Op{ "lt", `Id "a", `Number "1" } } } +]=] + +r = parse(s) +assert(r == e) + +-- return + +s = [=[ +return +]=] +e = [=[ +{ `Return } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +return 1 +]=] +e = [=[ +{ `Return{ `Number "1" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +return 1,1-2*3+4,"alo" +]=] +e = [=[ +{ `Return{ `Number "1", `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" }, `String "alo" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +return; +]=] +e = [=[ +{ `Return } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +return 1; +]=] +e = [=[ +{ `Return{ `Number "1" } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +return 1,1-2*3+4,"alo"; +]=] +e = [=[ +{ `Return{ `Number "1", `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" }, `String "alo" } } +]=] + +r = parse(s) +assert(r == e) + +-- tables + +s = [=[ +t = { [1] = "alo", alo = 1, 2; } +]=] +e = [=[ +{ `Set{ { `Id "t" }, { `Table{ `Pair{ `Number "1", `String "alo" }, `Pair{ `String "alo", `Number "1" }, `Number "2" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +t = { 1.5 } +]=] +e = [=[ +{ `Set{ { `Id "t" }, { `Table{ `Number "1.5" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +t = {1,2; +3, +4, + + + +5} +]=] +e = [=[ +{ `Set{ { `Id "t" }, { `Table{ `Number "1", `Number "2", `Number "3", `Number "4", `Number "5" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +t = {[1]=1,[2]=2; +[3]=3, +[4]=4, + + + +[5]=5} +]=] +e = [=[ +{ `Set{ { `Id "t" }, { `Table{ `Pair{ `Number "1", `Number "1" }, `Pair{ `Number "2", `Number "2" }, `Pair{ `Number "3", `Number "3" }, `Pair{ `Number "4", `Number "4" }, `Pair{ `Number "5", `Number "5" } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local t = {{{}}, {"alo"}} +]=] +e = [=[ +{ `Local{ { `Id "t" }, { `Table{ `Table{ `Table }, `Table{ `String "alo" } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local x = 0 +local t = {x} +]=] +e = [=[ +{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Id "x" } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local x = 0 +local t = {x = 1} +]=] +e = [=[ +{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Pair{ `String "x", `Number "1" } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local x = 0 +local t = {x == 1} +]=] +e = [=[ +{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Op{ "eq", `Id "x", `Number "1" } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- vararg + +s = [=[ +function f (...) + return ... +end +]=] +e = [=[ +{ `Set{ { `Id "f" }, { `Function{ { `Dots }, { `Return{ `Dots } } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function f () + function g (x, y, ...) + return ...,...,... + end +end +]=] +e = [=[ +{ `Set{ { `Id "f" }, { `Function{ { }, { `Set{ { `Id "g" }, { `Function{ { `Id "x", `Id "y", `Dots }, { `Return{ `Dots, `Dots, `Dots } } } } } } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function f (x, ...) + return ... +end +]=] +e = [=[ +{ `Localrec{ { `Id "f" }, { `Function{ { `Id "x", `Dots }, { `Return{ `Dots } } } } } } +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local f = function (x, ...) + return ... +end +]=] +e = [=[ +{ `Local{ { `Id "f" }, { `Function{ { `Id "x", `Dots }, { `Return{ `Dots } } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- while + +s = [=[ +i = 0 +while (i < 10) +do + i = i + 1 +end +]=] +e = [=[ +{ `Set{ { `Id "i" }, { `Number "0" } }, `While{ `Paren{ `Op{ "lt", `Id "i", `Number "10" } }, { `Set{ { `Id "i" }, { `Op{ "add", `Id "i", `Number "1" } } } } } } +]=] + +r = parse(s) +assert(r == e) + +-- syntax error + +-- anonymous functions + +s = [=[ +a = function (a,b,) end +]=] +e = [=[ +test.lua:1:19: syntax error, expected a variable name or '...' after ',' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +a = function (...,a) end +]=] +e = [=[ +test.lua:1:18: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local a = function (1) end +]=] +e = [=[ +test.lua:1:21: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local test = function ( a , b , c , ... ) +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the function body +]=] + +r = parse(s) +assert(r == e) + +-- arithmetic expressions + +s = [=[ +a = 3 / / 2 +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +-- bitwise expressions + +s = [=[ +b = 1 && 1 +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after '&' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +b = 1 <> 0 +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +b = 1 < < 0 +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +-- break + +s = [=[ +break +]=] +e = [=[ +test.lua:1:1: syntax error, not inside a loop +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function f (x) + if 1 then break end +end +]=] +e = [=[ +test.lua:2:13: syntax error, not inside a loop +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while 1 do +end +break +]=] +e = [=[ +test.lua:3:1: syntax error, not inside a loop +]=] + +r = parse(s) +assert(r == e) + +-- concatenation expressions + +s = [=[ +concat2 = 2^3..1 +]=] +e = [=[ +test.lua:1:15: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local s = "1 + 1 = " +print(s .. 1+1) +]=] +e = [=[ +{ `Local{ { `Id "s" }, { `String "1 + 1 = " } }, `Call{ `Id "print", `Op{ "concat", `Id "s", `Op{ "add", `Number "1", `Number "1" } } } } +]=] + +r = parse(s) +assert(r == e) + +-- for generic + +s = [=[ +for k;v in pairs(t) do end +]=] +e = [=[ +test.lua:1:6: syntax error, expected '=' or 'in' after the variable(s) +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for k,v in pairs(t:any) do end +]=] +e = [=[ +test.lua:1:23: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +-- for numeric + +s = [=[ +for i=1,10, do end +]=] +e = [=[ +test.lua:1:13: syntax error, expected a step expression for the numeric range after ',' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for i=1,n:number do end +]=] +e = [=[ +test.lua:1:18: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +-- global functions + +s = [=[ +function func(a,b,c,) end +]=] +e = [=[ +test.lua:1:21: syntax error, expected a variable name or '...' after ',' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function func(...,a) end +]=] +e = [=[ +test.lua:1:18: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function a.b:c:d () end +]=] +e = [=[ +test.lua:1:15: syntax error, expected '(' for the parameter list +]=] + +r = parse(s) +assert(r == e) + +-- goto + +s = [=[ +:: label :: return +goto label +]=] +e = [=[ +test.lua:2:1: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +goto label +]=] +e = [=[ +test.lua:1:1: syntax error, no visible label 'label' for +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +goto label +::other_label:: +]=] +e = [=[ +test.lua:1:1: syntax error, no visible label 'label' for +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::other_label:: +do do do goto label end end end +]=] +e = [=[ +test.lua:2:10: syntax error, no visible label 'label' for +]=] + +r = parse(s) +assert(r == e) + +-- if-else + +s = [=[ +if a then +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then else +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then + return a +elseif b then + return b +elseif + +end +]=] +e = [=[ +test.lua:7:1: syntax error, expected a condition after 'elseif' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a:any then else end +]=] +e = [=[ +test.lua:1:10: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +-- labels + +s = [=[ +:: blah :: +:: not :: +]=] +e = [=[ +test.lua:2:4: syntax error, expected a label name after '::' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +::label:: +::other_label:: +::label:: +]=] +e = [=[ +test.lua:3:1: syntax error, label 'label' already defined at line 1 +]=] + +r = parse(s) +assert(r == e) + +-- locals + +s = [=[ +local a = +]=] +e = [=[ +test.lua:2:1: syntax error, expected one or more expressions after '=' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function t.a() end +]=] +e = [=[ +test.lua:1:17: syntax error, expected '(' for the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function test (a,) end +]=] +e = [=[ +test.lua:1:24: syntax error, expected a variable name or '...' after ',' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function test(...,a) end +]=] +e = [=[ +test.lua:1:24: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function (a, b, c, ...) end +]=] +e = [=[ +test.lua:1:16: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +-- repeat + +s = [=[ +repeat + a,b,c = 1+1,2+2,3+3 + break +]=] +e = [=[ +test.lua:4:1: syntax error, expected 'until' at the end of the repeat loop +]=] + +r = parse(s) +assert(r == e) + +-- return + +s = [=[ +return +return 1 +return 1,1-2*3+4,"alo" +return; +return 1; +return 1,1-2*3+4,"alo"; +]=] +e = [=[ +test.lua:2:1: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +-- tables + +s = [=[ +t = { , } +]=] +e = [=[ +test.lua:1:7: syntax error, expected '}' to close the table constructor +]=] + +r = parse(s) +assert(r == e) + +-- vararg + +s = [=[ +function f () + return ... +end +]=] +e = [=[ +test.lua:2:10: syntax error, cannot use '...' outside a vararg function +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function f () + function g (x, y) + return ...,...,... + end +end +]=] +e = [=[ +test.lua:3:12: syntax error, cannot use '...' outside a vararg function +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function f (x) + return ... +end +]=] +e = [=[ +test.lua:2:10: syntax error, cannot use '...' outside a vararg function +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local f = function (x) + return ... +end +]=] +e = [=[ +test.lua:2:10: syntax error, cannot use '...' outside a vararg function +]=] + +r = parse(s) +assert(r == e) + +-- while + +s = [=[ +i = 0 +while (i < 10) + i = i + 1 +end +]=] +e = [=[ +test.lua:3:3: syntax error, expected 'do' after the condition +]=] + +r = parse(s) +assert(r == e) + +print("> testing more syntax errors...") + +-- ErrExtra +s = [=[ +return; print("hello") +]=] +e = [=[ +test.lua:1:9: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while foo do if bar then baz() end end end +]=] +e = [=[ +test.lua:1:40: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local func f() + g() +end +]=] +e = [=[ +test.lua:3:1: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function qux() + if false then + -- do + return 0 + end + end + return 1 +end +print(qux()) +]=] +e = [=[ +test.lua:8:1: syntax error, unexpected character(s), expected EOF +]=] + +r = parse(s) +assert(r == e) + +-- ErrInvalidStat +s = [=[ +find_solution() ? print("yes") : print("no") +]=] +e = [=[ +test.lua:1:17: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local i : int = 0 +]=] +e = [=[ +test.lua:1:9: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local a = 1, b = 2 +]=] +e = [=[ +test.lua:1:16: syntax error, unexpected token, invalid start of statement +]=] + +s = [=[ +x = - +y = 2 +]=] +e = [=[ +test.lua:2:3: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +obj::hello() +]=] +e = [=[ +test.lua:1:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while foo() do + // not a lua comment + bar() +end +]=] +e = [=[ +test.lua:2:3: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +repeat: + action() +until condition +end +]=] +e = [=[ +test.lua:1:7: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function f(x) + local result + ... -- TODO: compute for the next result + return result +end +]=] +e = [=[ +test.lua:3:3: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x; +]=] +e = [=[ +test.lua:1:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +a, b, c +]=] +e = [=[ +test.lua:1:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local x = 42 // the meaning of life +]=] +e = [=[ +test.lua:1:21: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +let x = 2 +]=] +e = [=[ +test.lua:1:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if p then + f() +elif q then + g() +end +]=] +e = [=[ +test.lua:3:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo() + bar() +emd +]=] +e = [=[ +test.lua:3:1: syntax error, unexpected token, invalid start of statement +]=] + +r = parse(s) +assert(r == e) + +-- ErrEndIf +s = [=[ +if 1 > 2 then print("impossible") +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if 1 > 2 then return; print("impossible") end +]=] +e = [=[ +test.lua:1:23: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if condA then doThis() +else if condB then doThat() end +]=] +e = [=[ +test.lua:3:1: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if a then + b() +else + c() +else + d() +end +]=] +e = [=[ +test.lua:5:1: syntax error, expected 'end' to close the if statement +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprIf +s = [=[ +if then print("that") end +]=] +e = [=[ +test.lua:1:4: syntax error, expected a condition after 'if' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +if !ok then error("fail") end +]=] +e = [=[ +test.lua:1:4: syntax error, expected a condition after 'if' +]=] + +r = parse(s) +assert(r == e) + +-- ErrThenIf +s = [=[ +if age < 18 + print("too young!") +end +]=] +e = [=[ +test.lua:2:3: syntax error, expected 'then' after the condition +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprEIf +s = [=[ +if age < 18 then print("too young!") +elseif then print("too old") end +]=] +e = [=[ +test.lua:2:8: syntax error, expected a condition after 'elseif' +]=] + +r = parse(s) +assert(r == e) + +-- ErrThenEIf +s = [=[ +if not result then error("fail") +elseif result > 0: + process(result) +end +]=] +e = [=[ +test.lua:2:18: syntax error, expected 'then' after the condition +]=] + +r = parse(s) +assert(r == e) + +-- ErrEndDo +s = [=[ +do something() +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the do block +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +do + return arr[i] + i = i + 1 +end +]=] +e = [=[ +test.lua:3:3: syntax error, expected 'end' to close the do block +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprWhile +s = [=[ +while !done do done = work() end +]=] +e = [=[ +test.lua:1:7: syntax error, expected a condition after 'while' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while do print("hello again!") end +]=] +e = [=[ +test.lua:1:7: syntax error, expected a condition after 'while' +]=] + +r = parse(s) +assert(r == e) + +-- ErrDoWhile +s = [=[ +while not done then work() end +]=] +e = [=[ +test.lua:1:16: syntax error, expected 'do' after the condition +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while not done + work() +end +]=] +e = [=[ +test.lua:2:3: syntax error, expected 'do' after the condition +]=] + +r = parse(s) +assert(r == e) + +-- ErrEndWhile +s = [=[ +while not found do i = i + 1 +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the while loop +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +while i < #arr do + if arr[i] == target then break + i = i +1 +end +]=] +e = [=[ +test.lua:5:1: syntax error, expected 'end' to close the while loop +]=] + +r = parse(s) +assert(r == e) + +-- ErrUntilRep +s = [=[ +repeat play_song() +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'until' at the end of the repeat loop +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprRep +s = [=[ +repeat film() until end +]=] +e = [=[ +test.lua:1:21: syntax error, expected a conditions after 'until' +]=] + +r = parse(s) +assert(r == e) + +-- ErrForRange +s = [=[ +for (key, val) in obj do + print(key .. " -> " .. val) +end +]=] +e = [=[ +test.lua:1:5: syntax error, expected a numeric or generic range after 'for' +]=] + +r = parse(s) +assert(r == e) + +-- ErrEndFor +s = [=[ +for i = 1,10 do print(i) +]=] +e = [=[ +test.lua:2:1: syntax error, expected 'end' to close the for loop +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprFor1 +s = [=[ +for i = ,10 do print(i) end +]=] +e = [=[ +test.lua:1:9: syntax error, expected a starting expression for the numeric range +]=] + +r = parse(s) +assert(r == e) + +-- ErrCommaFor +s = [=[ +for i = 1 to 10 do print(i) end +]=] +e = [=[ +test.lua:1:11: syntax error, expected ',' to split the start and end of the range +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprFor2 +s = [=[ +for i = 1, do print(i) end +]=] +e = [=[ +test.lua:1:12: syntax error, expected an ending expression for the numeric range +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprFor3 +s = [=[ +for i = 1,10, do print(i) end +]=] +e = [=[ +test.lua:1:15: syntax error, expected a step expression for the numeric range after ',' +]=] + +r = parse(s) +assert(r == e) + +-- ErrInFor +s = [=[ +for arr do print(arr[i]) end +]=] +e = [=[ +test.lua:1:9: syntax error, expected '=' or 'in' after the variable(s) +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for nums := 1,10 do print(i) end +]=] +e = [=[ +test.lua:1:10: syntax error, expected '=' or 'in' after the variable(s) +]=] + +r = parse(s) +assert(r == e) + +-- ErrEListFor +s = [=[ +for i in ? do print(i) end +]=] +e = [=[ +test.lua:1:10: syntax error, expected one or more expressions after 'in' +]=] + +r = parse(s) +assert(r == e) + +-- ErrDoFor +s = [=[ +for i = 1,10 doo print(i) end +]=] +e = [=[ +test.lua:1:14: syntax error, expected 'do' after the range of the for loop +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +for _, elem in ipairs(list) + print(elem) +end +]=] +e = [=[ +test.lua:2:3: syntax error, expected 'do' after the range of the for loop +]=] + +r = parse(s) +assert(r == e) + +-- ErrDefLocal +s = [=[ +local +]=] +e = [=[ +test.lua:2:1: syntax error, expected a function definition or assignment after local +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local; x = 2 +]=] +e = [=[ +test.lua:1:6: syntax error, expected a function definition or assignment after local +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local *p = nil +]=] +e = [=[ +test.lua:1:7: syntax error, expected a function definition or assignment after local +]=] + +r = parse(s) +assert(r == e) + +-- ErrNameLFunc +s = [=[ +local function() return 0 end +]=] +e = [=[ +test.lua:1:15: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function 3dprint(x, y, z) end +]=] +e = [=[ +test.lua:1:16: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local function repeat(f, ntimes) for i = 1,ntimes do f() end end +]=] +e = [=[ +test.lua:1:16: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +-- ErrEListLAssign +s = [=[ +local x = ? +]=] +e = [=[ +test.lua:1:11: syntax error, expected one or more expressions after '=' +]=] + +r = parse(s) +assert(r == e) + +-- ErrEListAssign +s = [=[ +x = ? +]=] +e = [=[ +test.lua:1:5: syntax error, expected one or more expressions after '=' +]=] + +r = parse(s) +assert(r == e) + +-- ErrFuncName +s = [=[ +function() return 0 end +]=] +e = [=[ +test.lua:1:9: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function 3dprint(x, y, z) end +]=] +e = [=[ +test.lua:1:10: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function repeat(f, ntimes) for i = 1,ntimes do f() end end +]=] +e = [=[ +test.lua:1:10: syntax error, expected a function name after 'function' +]=] + +r = parse(s) +assert(r == e) + +-- ErrNameFunc1 +s = [=[ +function foo.() end +]=] +e = [=[ +test.lua:1:14: syntax error, expected a function name after '.' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo.1() end +]=] +e = [=[ +test.lua:1:14: syntax error, expected a function name after '.' +]=] + +r = parse(s) +assert(r == e) + +-- ErrNameFunc2 +s = [=[ +function foo:() end +]=] +e = [=[ +test.lua:1:14: syntax error, expected a method name after ':' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo:1() end +]=] +e = [=[ +test.lua:1:14: syntax error, expected a method name after ':' +]=] + +r = parse(s) +assert(r == e) + +-- ErrOParenPList +s = [=[ +function foo + return bar +end +]=] +e = [=[ +test.lua:2:3: syntax error, expected '(' for the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo?(bar) + return bar +end +]=] +e = [=[ +test.lua:1:13: syntax error, expected '(' for the parameter list +]=] + +r = parse(s) +assert(r == e) + +-- ErrCParenPList +s = [=[ +function foo(bar + return bar +end +]=] +e = [=[ +test.lua:2:3: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo(bar; baz) + return bar +end +]=] +e = [=[ +test.lua:1:17: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo(a, b, ...rest) end +]=] +e = [=[ +test.lua:1:23: syntax error, expected ')' to close the parameter list +]=] + +r = parse(s) +assert(r == e) + +-- ErrEndFunc +s = [=[ +function foo(bar) + return bar +]=] +e = [=[ +test.lua:3:1: syntax error, expected 'end' to close the function body +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +function foo() do + bar() +end +]=] +e = [=[ +test.lua:4:1: syntax error, expected 'end' to close the function body +]=] + +r = parse(s) +assert(r == e) + +-- ErrParList +s = [=[ +function foo(bar, baz,) + return bar +end +]=] +e = [=[ +test.lua:1:23: syntax error, expected a variable name or '...' after ',' +]=] + +r = parse(s) +assert(r == e) + +-- ErrLabel +s = [=[ +::1:: +]=] +e = [=[ +test.lua:1:3: syntax error, expected a label name after '::' +]=] + +r = parse(s) +assert(r == e) + +-- ErrCloseLabel +s = [=[ +::loop +]=] +e = [=[ +test.lua:2:1: syntax error, expected '::' after the label +]=] + +r = parse(s) +assert(r == e) + +-- ErrGoto +s = [=[ +goto; +]=] +e = [=[ +test.lua:1:5: syntax error, expected a label after 'goto' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +goto 1 +]=] +e = [=[ +test.lua:1:6: syntax error, expected a label after 'goto' +]=] + +r = parse(s) +assert(r == e) + +-- ErrRetList +s = [=[ +return a, b, +]=] +e = [=[ +test.lua:2:1: syntax error, expected an expression after ',' in the return statement +]=] + +r = parse(s) +assert(r == e) + +-- ErrVarList +s = [=[ +x, y, = 0, 0 +]=] +e = [=[ +test.lua:1:7: syntax error, expected a variable name after ',' +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprList +s = [=[ +x, y = 0, 0, +]=] +e = [=[ +test.lua:2:1: syntax error, expected an expression after ',' +]=] + +r = parse(s) +assert(r == e) + +-- ErrOrExpr +s = [=[ +foo(a or) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after 'or' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a or $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after 'or' +]=] + +r = parse(s) +assert(r == e) + +-- ErrAndExpr +s = [=[ +foo(a and) +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after 'and' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a and $b +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after 'and' +]=] + +r = parse(s) +assert(r == e) + +-- ErrRelExpr +s = [=[ +foo(a <) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a < $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a <=) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a <= $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a >) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a > $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a >=) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a >= $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a ==) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a == $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a ~=) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a ~= $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the relational operator +]=] + +r = parse(s) +assert(r == e) + +-- ErrBOrExpr +s = [=[ +foo(a |) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after '|' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a | $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after '|' +]=] + +r = parse(s) +assert(r == e) + +-- ErrBXorExpr +s = [=[ +foo(a ~) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after '~' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a ~ $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after '~' +]=] + +r = parse(s) +assert(r == e) + +-- ErrBAndExpr +s = [=[ +foo(a &) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after '&' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a & $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after '&' +]=] + +r = parse(s) +assert(r == e) + +-- ErrShiftExpr +s = [=[ +foo(a >>) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the bit shift +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a >> $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the bit shift +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a <<) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the bit shift +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a >> $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the bit shift +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a >>> b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the bit shift +]=] + +r = parse(s) +assert(r == e) + +-- ErrConcatExpr +s = [=[ +foo(a ..) +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after '..' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a .. $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after '..' +]=] + +r = parse(s) +assert(r == e) + +-- ErrAddExpr +s = [=[ +foo(a +, b) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after the additive operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a + $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the additive operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a -, b) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after the additive operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a - $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the additive operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +arr[i++] +]=] +e = [=[ +test.lua:1:7: syntax error, expected an expression after the additive operator +]=] + +r = parse(s) +assert(r == e) + +-- ErrMulExpr +s = [=[ +foo(b, a *) +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a * $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(b, a /) +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a / $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(b, a //) +]=] +e = [=[ +test.lua:1:12: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a // $b +]=] +e = [=[ +test.lua:1:10: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(b, a %) +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a % $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after the multiplicative operator +]=] + +r = parse(s) +assert(r == e) + +-- ErrUnaryExpr +s = [=[ +x, y = a + not, b +]=] +e = [=[ +test.lua:1:15: syntax error, expected an expression after the unary operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x, y = a + -, b +]=] +e = [=[ +test.lua:1:13: syntax error, expected an expression after the unary operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x, y = a + #, b +]=] +e = [=[ +test.lua:1:13: syntax error, expected an expression after the unary operator +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x, y = a + ~, b +]=] +e = [=[ +test.lua:1:13: syntax error, expected an expression after the unary operator +]=] + +r = parse(s) +assert(r == e) + +-- ErrPowExpr +s = [=[ +foo(a ^) +]=] +e = [=[ +test.lua:1:8: syntax error, expected an expression after '^' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x = a ^ $b +]=] +e = [=[ +test.lua:1:9: syntax error, expected an expression after '^' +]=] + +r = parse(s) +-- assert(r == e) + +-- ErrExprParen +s = [=[ +x = () +]=] +e = [=[ +test.lua:1:6: syntax error, expected an expression after '(' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +y = (???) +]=] +e = [=[ +test.lua:1:6: syntax error, expected an expression after '(' +]=] + +r = parse(s) +assert(r == e) + +-- ErrCParenExpr +s = [=[ +z = a*(b+c +]=] +e = [=[ +test.lua:2:1: syntax error, expected ')' to close the expression +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +w = (0xBV) +]=] +e = [=[ +test.lua:1:9: syntax error, expected ')' to close the expression +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +ans = 2^(m*(n-1) +]=] +e = [=[ +test.lua:2:1: syntax error, expected ')' to close the expression +]=] + +r = parse(s) +assert(r == e) + +-- ErrNameIndex +s = [=[ +f = t. +]=] +e = [=[ +test.lua:2:1: syntax error, expected a field name after '.' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = t.['f'] +]=] +e = [=[ +test.lua:1:7: syntax error, expected a field name after '.' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x. +]=] +e = [=[ +test.lua:2:1: syntax error, expected a field name after '.' +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprIndex +s = [=[ +f = t[] +]=] +e = [=[ +test.lua:1:7: syntax error, expected an expression after '[' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = t[?] +]=] +e = [=[ +test.lua:1:7: syntax error, expected an expression after '[' +]=] + +r = parse(s) +assert(r == e) + +-- ErrCBracketIndex +s = [=[ +f = t[x[y] +]=] +e = [=[ +test.lua:2:1: syntax error, expected ']' to close the indexing expression +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +f = t[x,y] +]=] +e = [=[ +test.lua:1:8: syntax error, expected ']' to close the indexing expression +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +arr[i--] +]=] +e = [=[ +test.lua:2:1: syntax error, expected ']' to close the indexing expression +]=] + +r = parse(s) +assert(r == e) + +-- ErrNameMeth +s = [=[ +x = obj: +]=] +e = [=[ +test.lua:2:1: syntax error, expected a method name after ':' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +x := 0 +]=] +e = [=[ +test.lua:1:4: syntax error, expected a method name after ':' +]=] + +r = parse(s) +assert(r == e) + +-- ErrMethArgs +s = [=[ +cow:moo +]=] +e = [=[ +test.lua:2:1: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +dog:bark msg +]=] +e = [=[ +test.lua:1:10: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +duck:quack[4] +]=] +e = [=[ +test.lua:1:11: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local t = { + x = X: + y = Y; +} +]=] +e = [=[ +test.lua:3:5: syntax error, expected some arguments for the method call (or '()') +]=] + +r = parse(s) +assert(r == e) + +-- ErrArgList +s = [=[ +foo(a, b, ) +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after ',' in the argument list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(a, b, ..) +]=] +e = [=[ +test.lua:1:11: syntax error, expected an expression after ',' in the argument list +]=] + +r = parse(s) +assert(r == e) + +-- ErrCParenArgs +s = [=[ +foo(a + (b - c) +]=] +e = [=[ +test.lua:2:1: syntax error, expected ')' to close the argument list +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +foo(arg1 arg2) +]=] +e = [=[ +test.lua:1:10: syntax error, expected ')' to close the argument list +]=] + +r = parse(s) +assert(r == e) + +-- ErrCBraceTable +s = [=[ +nums = {1, 2, 3] +]=] +e = [=[ +test.lua:1:16: syntax error, expected '}' to close the table constructor +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +nums = { + one = 1; + two = 2 + three = 3; + four = 4 +} +]=] +e = [=[ +test.lua:4:3: syntax error, expected '}' to close the table constructor +]=] + +r = parse(s) +assert(r == e) + +-- ErrEqField +s = [=[ +words2nums = { ['one'] -> 1 } +]=] +e = [=[ +test.lua:1:24: syntax error, expected '=' after the table key +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprField +s = [=[ +words2nums = { ['one'] => 2 } +]=] +e = [=[ +test.lua:1:25: syntax error, expected an expression after '=' +]=] + +r = parse(s) +assert(r == e) + +-- ErrExprFKey +s = [=[ +table = { [] = value } +]=] +e = [=[ +test.lua:1:12: syntax error, expected an expression after '[' for the table key +]=] + +r = parse(s) +assert(r == e) + +-- ErrCBracketFKey +s = [=[ +table = { [key = value } +]=] +e = [=[ +test.lua:1:16: syntax error, expected ']' to close the table key +]=] + +r = parse(s) +assert(r == e) + + +-- ErrDigitHex +s = [=[ +print(0x) +]=] +e = [=[ +test.lua:1:9: syntax error, expected one or more hexadecimal digits after '0x' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print(0xGG) +]=] +e = [=[ +test.lua:1:9: syntax error, expected one or more hexadecimal digits after '0x' +]=] + +r = parse(s) +assert(r == e) + +-- ErrDigitDeci +s = [=[ +print(1 + . 0625) +]=] +e = [=[ +test.lua:1:12: syntax error, expected one or more digits after the decimal point +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print(.) +]=] +e = [=[ +test.lua:1:8: syntax error, expected one or more digits after the decimal point +]=] + +r = parse(s) +assert(r == e) + +-- ErrDigitExpo +s = [=[ +print(1.0E) +]=] +e = [=[ +test.lua:1:11: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print(3E) +]=] +e = [=[ +test.lua:1:9: syntax error, expected one or more digits for the exponent +]=] + +r = parse(s) +assert(r == e) + +-- ErrQuote +s = [=[ +local message = "Hello +]=] +e = [=[ +test.lua:2:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local message = "******* +Welcome +*******" +]=] +e = [=[ +test.lua:2:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local message = 'Hello +]=] +e = [=[ +test.lua:2:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +local message = '******* +Welcome +*******' +]=] +e = [=[ +test.lua:2:1: syntax error, unclosed string +]=] + +r = parse(s) +assert(r == e) + +-- ErrHexEsc +s = [=[ +print("\x") +]=] +e = [=[ +test.lua:1:10: syntax error, expected exactly two hexadecimal digits after '\x' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print("\xF") +]=] +e = [=[ +test.lua:1:10: syntax error, expected exactly two hexadecimal digits after '\x' +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print("\xG") +]=] +e = [=[ +test.lua:1:10: syntax error, expected exactly two hexadecimal digits after '\x' +]=] + +r = parse(s) +assert(r == e) + +-- ErrOBraceUEsc +s = [=[ +print("\u3D") +]=] +e = [=[ +test.lua:1:10: syntax error, expected '{' after '\u' +]=] + +r = parse(s) +assert(r == e) + +-- ErrDigitUEsc +s = [=[ +print("\u{}") +]=] +e = [=[ +test.lua:1:11: syntax error, expected one or more hexadecimal digits for the UTF-8 code point +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print("\u{XD}") +]=] +e = [=[ +test.lua:1:11: syntax error, expected one or more hexadecimal digits for the UTF-8 code point +]=] + +r = parse(s) +assert(r == e) + +-- ErrCBraceUEsc +s = [=[ +print("\u{0x3D}") +]=] +e = [=[ +test.lua:1:12: syntax error, expected '}' after the code point +]=] + +r = parse(s) +assert(r == e) + +s = [=[ +print("\u{FFFF Hi") +]=] +e = [=[ +test.lua:1:15: syntax error, expected '}' after the code point +]=] + +r = parse(s) +assert(r == e) + +-- ErrEscSeq +s = [=[ +print("\m") +]=] +e = [=[ +test.lua:1:9: syntax error, invalid escape sequence +]=] + +r = parse(s) +assert(r == e) + +-- ErrCloseLStr +s = [===[ +local message = [==[ + ******* + WELCOME + ******* +]=] +]===] +e = [=[ +test.lua:6:1: syntax error, unclosed long string +]=] + +r = parse(s) +assert(r == e) + +print("> testing issues...") + +-- issue #12 +s = [===[ +gl_f_ct = 0 + +function f() + if gl_f_ct <= 0 then + gl_f_ct=1 + return 1000 + end + return -1000 +end + +print( f("1st call") > f("2nd call") ) +gl_f_ct = 0 +print( f("1st call") < f("2nd call") ) +]===] +e = [=[ +{ `Set{ { `Id "gl_f_ct" }, { `Number "0" } }, `Set{ { `Id "f" }, { `Function{ { }, { `If{ `Op{ "le", `Id "gl_f_ct", `Number "0" }, { `Set{ { `Id "gl_f_ct" }, { `Number "1" } }, `Return{ `Number "1000" } } }, `Return{ `Op{ "unm", `Number "1000" } } } } } }, `Call{ `Id "print", `Op{ "gt", `Call{ `Id "f", `String "1st call" }, `Call{ `Id "f", `String "2nd call" } } }, `Set{ { `Id "gl_f_ct" }, { `Number "0" } }, `Call{ `Id "print", `Op{ "lt", `Call{ `Id "f", `String "1st call" }, `Call{ `Id "f", `String "2nd call" } } } } +]=] + +r = parse(s) +assert(r == e) + +print("OK") diff --git a/SyntaxKit/Tests/Resources/Fixtures/test.rb.txt b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.rb.txt similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/test.rb.txt rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.rb.txt diff --git a/SyntaxKit/Tests/Resources/Fixtures/swifttest.swift.txt b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.swift.txt similarity index 99% rename from SyntaxKit/Tests/Resources/Fixtures/swifttest.swift.txt rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.swift.txt index 12e7413..3e82356 100644 --- a/SyntaxKit/Tests/Resources/Fixtures/swifttest.swift.txt +++ b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.swift.txt @@ -72,4 +72,4 @@ final class Pattern { } self.patterns = patterns } -} \ No newline at end of file +} diff --git a/SyntaxKit/Tests/Resources/Fixtures/textest.tex.txt b/Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.tex.txt similarity index 100% rename from SyntaxKit/Tests/Resources/Fixtures/textest.tex.txt rename to Tests/SyntaxKitTests/Fixtures/TestSyntaxKit.bundle/test.tex.txt diff --git a/SyntaxKit/Tests/IncrementalParsingTests.swift b/Tests/SyntaxKitTests/IncrementalParsingTests.swift similarity index 94% rename from SyntaxKit/Tests/IncrementalParsingTests.swift rename to Tests/SyntaxKitTests/IncrementalParsingTests.swift index 29028fb..cf70adf 100644 --- a/SyntaxKit/Tests/IncrementalParsingTests.swift +++ b/Tests/SyntaxKitTests/IncrementalParsingTests.swift @@ -25,7 +25,7 @@ internal class IncrementalParsingTests: XCTestCase { } func testEdits() { - input = fixture("swifttest.swift", "txt") + input = fixture("test.swift", "txt") parsingOperation = getParsingOperation() parsingOperation?.main() @@ -62,7 +62,7 @@ internal class IncrementalParsingTests: XCTestCase { } func testPerformanceInScope() { - input = fixture("swifttest.swift", "txt") + input = fixture("test.swift", "txt") parsingOperation = getParsingOperation() parsingOperation?.main() @@ -75,7 +75,7 @@ internal class IncrementalParsingTests: XCTestCase { } func testPerformanceEdgeCases() { - input = fixture("swifttest.swift", "txt") + input = fixture("test.swift", "txt") parsingOperation = getParsingOperation() parsingOperation?.main() @@ -92,7 +92,7 @@ internal class IncrementalParsingTests: XCTestCase { private func getParsingOperation() -> AttributedParsingOperation? { if let language = manager.language(withIdentifier: "Source.swift"), let theme = manager.theme(withIdentifier: "tomorrow") { - return AttributedParsingOperation(string: input, language: language, theme: theme) { (results: [(range: NSRange, attributes: Attributes?)], _: AttributedParsingOperation) in + return AttributedParsingOperation(string: input, language: language, theme: theme) { (results: [AttributedParsingOperation.OperationTuple], _: AttributedParsingOperation) in for result in results { if let range = self.totalRange { self.totalRange = NSUnionRange(range, result.range) diff --git a/SyntaxKit/Tests/LanguageTests.swift b/Tests/SyntaxKitTests/LanguageTests.swift similarity index 100% rename from SyntaxKit/Tests/LanguageTests.swift rename to Tests/SyntaxKitTests/LanguageTests.swift diff --git a/SyntaxKit/Tests/ParserTests.swift b/Tests/SyntaxKitTests/ParserTests.swift similarity index 100% rename from SyntaxKit/Tests/ParserTests.swift rename to Tests/SyntaxKitTests/ParserTests.swift diff --git a/SyntaxKit/Tests/PerformanceTests.swift b/Tests/SyntaxKitTests/PerformanceTests.swift similarity index 94% rename from SyntaxKit/Tests/PerformanceTests.swift rename to Tests/SyntaxKitTests/PerformanceTests.swift index 17849c4..af83820 100644 --- a/SyntaxKit/Tests/PerformanceTests.swift +++ b/Tests/SyntaxKitTests/PerformanceTests.swift @@ -27,7 +27,7 @@ internal class PerformanceTests: XCTestCase { } func testLongTexFilePerformance() { - let input = fixture("textest.tex", "txt") + let input = fixture("test.tex", "txt") self.measure { _ = self.parser?.attributedString(for: input) } diff --git a/SyntaxKit/Tests/ScopedStringTests.swift b/Tests/SyntaxKitTests/ScopedStringTests.swift similarity index 100% rename from SyntaxKit/Tests/ScopedStringTests.swift rename to Tests/SyntaxKitTests/ScopedStringTests.swift diff --git a/SyntaxKit/Tests/SwiftBaselineHighlightingTests.swift b/Tests/SyntaxKitTests/SwiftBaselineHighlightingTests.swift similarity index 96% rename from SyntaxKit/Tests/SwiftBaselineHighlightingTests.swift rename to Tests/SyntaxKitTests/SwiftBaselineHighlightingTests.swift index a5be91c..1719d70 100644 --- a/SyntaxKit/Tests/SwiftBaselineHighlightingTests.swift +++ b/Tests/SyntaxKitTests/SwiftBaselineHighlightingTests.swift @@ -30,7 +30,7 @@ internal class SwiftBaselineHighlightingTests: XCTestCase { } func testColors() { - let input = fixture("swifttest.swift", "txt") + let input = fixture("test.swift", "txt") if let string = parser?.attributedString(for: input) { // line comment assertEqualColors(Color(hex: "#93A1A1"), string.attributes(at: 10, effectiveRange: nil)[NSAttributedString.Key.foregroundColor] as? Color) @@ -59,7 +59,7 @@ internal class SwiftBaselineHighlightingTests: XCTestCase { } func testHighlightingPerformance() { - let input = fixture("swifttest.swift", "txt") + let input = fixture("test.swift", "txt") self.measure { _ = self.parser?.attributedString(for: input) } diff --git a/SyntaxKit/Tests/TestHelper.swift b/Tests/SyntaxKitTests/TestHelper.swift similarity index 78% rename from SyntaxKit/Tests/TestHelper.swift rename to Tests/SyntaxKitTests/TestHelper.swift index facf4d6..9569024 100644 --- a/SyntaxKit/Tests/TestHelper.swift +++ b/Tests/SyntaxKitTests/TestHelper.swift @@ -10,22 +10,28 @@ import Foundation @testable import SyntaxKit import XCTest +private let fixturesBundleURL = URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures").appendingPathComponent("TestSyntaxKit.bundle") + internal func fixture(_ name: String, _ type: String) -> String { - if let path = Bundle(for: LanguageTests.self).path(forResource: name, ofType: type) { - do { - return try String(contentsOfFile: path) - } catch { - return "" - } + guard let testBundle = Bundle(url: fixturesBundleURL) else { + return "" + } + guard let url = testBundle.url(forResource: name, withExtension: type) else { + return "" + } + do { + return try String(contentsOf: url) + } catch { + return "" } - return "" } internal func getBundleManager() -> BundleManager { return BundleManager { identifier, kind in let name = kind == .language ? String(identifier.split(separator: ".")[1]) : identifier let ext = kind == .language ? ".tmLanguage" : ".tmTheme" - return Bundle(for: LanguageTests.self).url(forResource: name.capitalized, withExtension: ext) ?? URL(fileURLWithPath: "") + print("[*] Loading resources for \(name.capitalized)\(ext)") + return Bundle(url: fixturesBundleURL)?.url(forResource: name.capitalized, withExtension: ext) ?? URL(fileURLWithPath: "") } } diff --git a/SyntaxKit/Tests/ThemeTests.swift b/Tests/SyntaxKitTests/ThemeTests.swift similarity index 100% rename from SyntaxKit/Tests/ThemeTests.swift rename to Tests/SyntaxKitTests/ThemeTests.swift diff --git a/Tests/SyntaxKitTests/XCTestManifests.swift b/Tests/SyntaxKitTests/XCTestManifests.swift new file mode 100644 index 0000000..c1f363b --- /dev/null +++ b/Tests/SyntaxKitTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(SyntaxKitTests.allTests), + ] +} +#endif