     convenience init (keywords: [String], tokenType: JLTokenType) {
         self.init(keywords: keywords, prefix: "\\b", suffix: "\\b", tokenType: tokenType)
     }
-
+    
     /// Create a JLKeywordScope with a space-separated keyword string
     convenience init(keywords: String, tokenType: JLTokenType) {
         self.init(keywords: keywords.componentsSeparatedByString(" "), tokenType: tokenType)
     }
 }
 
+extension String
+    {
+    func characterAtIndex(index:Int) -> unichar
+    {
+        return self.utf16[index]
+    }
+    
+    // Allows us to use String[index] notation
+    subscript(index:Int) -> unichar
+        {
+        return characterAtIndex(index)
+    }
+}
+
 private protocol Node {
     var pattern: String {get}
 }
- extension String: Node {
-    var pattern: String {
-        return NSRegularExpression.escapedPatternForString(self) as String
-    }
+
+private struct Leaf: Node {
+    init() {}
+    var pattern: String { return "" }
 }
 
 private struct Branch: Node, Printable {
-    var children = [String: Node]()
-    init(array: [String]) {
+    var children = [Node]()
+    var character: String
+    
+    func perform(string: NSString, range: Range<Int>) {
+        for i in range {
+            
+        }
+    }
+    
+    init(character: String, array: [String]) {
+        self.character = character
         var dictionary = [String: [String]]()
         for string in array {
             if countElements(string) > 0 {


class JLKeywordScope: JLRegexScope {
    init(keywords: [String], prefix: String, suffix: String, tokenType: JLTokenType) {
        let pattern = prefix + Branch(array: keywords).description + suffix
        println(pattern)
        let expression = NSRegularExpression(pattern: pattern, options: nil, error: nil)
        super.init(regularExpression: expression, tokenTypes: [tokenType])

                    dictionary[firstCharacter] = [remainingString]
                }
            } else {
                // This means end of a match
                children += Leaf()
            }
        }
        for (key, value) in dictionary {
            children += Branch(character: key, array: value)
        }
        
    }
    
    var pattern: String {
    var array = children.map { $0.pattern }
    array.sort { countElements($0) < countElements($1) }
        
    switch array.count {
        case 0: return character + ""
        case 1: return character + array[0]
        default: return character + "(?:" + join("|", array) + ")"
    }
    }
    
    var description: String {
