From aba97e245a62a732d1b22929283136ddbcaa0ce5 Mon Sep 17 00:00:00 2001 From: Johannes Lund Date: Sun, 21 Dec 2014 19:35:27 +0100 Subject: [PATCH] Make it compilable again --- Chromatism/Chromatism/JLKeywordScope.swift | 2 +- Chromatism/Chromatism/JLLanguage.swift | 2 +- Chromatism/Chromatism/JLRegexScope.swift | 12 +++--------- Chromatism/Chromatism/JLTokenizingScope.swift | 2 +- .../SwiftChromatismDemo/AppDelegate.swift | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Chromatism/Chromatism/JLKeywordScope.swift b/Chromatism/Chromatism/JLKeywordScope.swift index df0ffc8..41c4136 100644 --- a/Chromatism/Chromatism/JLKeywordScope.swift +++ b/Chromatism/Chromatism/JLKeywordScope.swift @@ -12,7 +12,7 @@ class JLKeywordScope: JLRegexScope { init(keywords: [String], prefix: String, suffix: String, tokenType: JLTokenType) { let pattern = prefix + Branch(character: "", array: keywords).description + suffix let expression = NSRegularExpression(pattern: pattern, options: nil, error: nil) - super.init(regularExpression: expression, tokenTypes: [tokenType]) + super.init(regularExpression: expression!, tokenTypes: [tokenType]) } /// Create a JLKeywordScope with prefix and suffix of word boundaries (\\b) diff --git a/Chromatism/Chromatism/JLLanguage.swift b/Chromatism/Chromatism/JLLanguage.swift index c1bb7e6..f25b743 100644 --- a/Chromatism/Chromatism/JLLanguage.swift +++ b/Chromatism/Chromatism/JLLanguage.swift @@ -53,7 +53,7 @@ public class JLLanguage { var strings = JLRegexScope(pattern: "(\"|@\")[^\"\\n]*(@\"|\")", tokenTypes: .String) var angularImports = JLRegexScope(pattern: "<.*?>", tokenTypes: .String) var numbers = JLRegexScope(pattern: "(?<=\\s)\\d+", tokenTypes: .Number) - var functions = JLRegexScope(pattern: "\\w+\\s*(?>\\(.*\\)", tokenTypes: .OtherMethodNames) + var functions = JLRegexScope(pattern: "\\w+\\s*(?>\\(.*\\))", tokenTypes: .OtherMethodNames) var keywords = JLKeywordScope(keywords: "true false YES NO TRUE FALSE bool BOOL nil id void self NULL if else strong weak nonatomic atomic assign copy typedef enum auto break case const char continue do default double extern float for goto int long register return short signed sizeof static struct switch typedef union unsigned volatile while nonatomic atomic nonatomic readonly super", tokenType: .Keyword) diff --git a/Chromatism/Chromatism/JLRegexScope.swift b/Chromatism/Chromatism/JLRegexScope.swift index 77d1cc4..9486285 100644 --- a/Chromatism/Chromatism/JLRegexScope.swift +++ b/Chromatism/Chromatism/JLRegexScope.swift @@ -22,15 +22,9 @@ public class JLRegexScope: JLScope { super.init() } - convenience init(pattern: String, options: NSRegularExpressionOptions, tokenTypes: JLTokenType...) { + convenience init(pattern: String, options: NSRegularExpressionOptions = .AnchorsMatchLines, tokenTypes: JLTokenType...) { let expression = NSRegularExpression(pattern: pattern, options: options, error: nil) - self.init(regularExpression: expression, tokenTypes: tokenTypes) - } - - /// Creates a JLRegexScope with .AnchorsMatchLines options - convenience init(pattern: String, tokenTypes: JLTokenType...) { - let expression = NSRegularExpression(pattern: pattern, options: .AnchorsMatchLines, error: nil) - self.init(regularExpression: expression, tokenTypes: tokenTypes) + self.init(regularExpression: expression!, tokenTypes: tokenTypes) } override func perform(parentIndexSet: NSIndexSet) { @@ -56,6 +50,6 @@ public class JLRegexScope: JLScope { } override public var description: String { - return "JLToken" + return "JLToken" } } diff --git a/Chromatism/Chromatism/JLTokenizingScope.swift b/Chromatism/Chromatism/JLTokenizingScope.swift index 324c788..a6e94d9 100644 --- a/Chromatism/Chromatism/JLTokenizingScope.swift +++ b/Chromatism/Chromatism/JLTokenizingScope.swift @@ -26,7 +26,7 @@ public class JLTokenizingScope: JLScope { init(pattern: String, delta: Int) { self.delta = delta - self.expression = NSRegularExpression(pattern: pattern, options: nil, error: nil) + self.expression = NSRegularExpression(pattern: pattern, options: nil, error: nil)! } } diff --git a/SwiftChromatismDemo/SwiftChromatismDemo/AppDelegate.swift b/SwiftChromatismDemo/SwiftChromatismDemo/AppDelegate.swift index fbe453e..6827c90 100644 --- a/SwiftChromatismDemo/SwiftChromatismDemo/AppDelegate.swift +++ b/SwiftChromatismDemo/SwiftChromatismDemo/AppDelegate.swift @@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let url = NSBundle.mainBundle().URLForResource("objc", withExtension: "txt"); let string = NSString(contentsOfURL: url!, encoding: NSUTF8StringEncoding, error: nil) - let viewController = JLTextViewController(text: string, language: .ObjectiveC, theme: .Default) + let viewController = JLTextViewController(text: string!, language: .ObjectiveC, theme: .Default) viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Resign", style: .Plain, target: viewController.textView, action:"resignFirstResponder")