         }
     }
     
-    private static let keywords: [String: TokenType] = [
-        "and": .AND,
-        "class": .CLASS,
-        "else": .ELSE,
-        "false": .FALSE,
-        "for": .FOR,
-        "fun": .FUN,
-        "if": .IF,
-        "nil": .NIL,
-        "or": .OR,
-        "print": .PRINT,
-        "return": .RETURN,
-        "super": .SUPER,
-        "this": .THIS,
-        "true": .TRUE,
-        "var": .VAR,
-        "while": .WHILE
-    ]
-    
     private func identifier() {
-        while (isAlphaNumeric(peek())) { let _ = advance() }
-        
-        let text = source[start..<current]
-        
-        let type = Scanner.keywords[text] ?? .IDENTIFIER
+        while isAlphaNumeric(peek) { _ = advance() }
+        
+        let type = TokenType(keyword: currentText) ?? .IDENTIFIER
         addToken(type)
     }
     
     private func number() {
-        while isDigit(peek()) { let _ = advance() }
-        
-        if peek() == "." && isDigit(peekNext()) {
+        while isDigit(peek) { _ = advance() }
+        
+        if peek == "." && isDigit(peekNext) {
             // Consume the "."
-            let _ = advance()
-            
-            while isDigit(peek()) { let _ = advance() }
-        }
-        
-        let strvalue = source[start..<current]
-        
-        addToken(.NUMBER, Double(strvalue)!)
+            _ = advance()
+            
+            while isDigit(peek) { _ = advance() }
+        }
+        
+        addToken(.NUMBER, Double(currentText)!)
     }
     
     private func string() {
-        while (peek() != "\"" && !isAtEnd()) {
-            if (peek() == "\n") { line += 1 }
-            let _ = advance()
+        while (peek != "\"" && !isAtEnd) {
+            if (peek == "\n") { line += 1 }
+            _ = advance()
         }
         
         // Unterminated string.
-        if (isAtEnd()) {
+        if (isAtEnd) {
             Lox.error(line, "Unterminated string.")
             return
         }
         
         // The closing ".
-        let _ = advance()
+        _ = advance()
         
         let range = source.index(after: start)..<source.index(before: current)
         let value = source[range]

    }
    
    func scanTokens() -> [Token] {
        while (!isAtEnd()) {
            start = current
            scanToken()
        }
        
        tokens.append(Token(.EOF, "", NSNull(), line))
        return tokens
    }
    
    private func isAtEnd() -> Bool {
        return current >= source.endIndex
    }
    
    private func scanToken() {

    }
    
    private func addToken(_ type: TokenType, _ literal: Any) {
        tokens.append(Token(type, currentText, literal, line))
    }
}
