     private var start: String.Index
     private var current: String.Index
     private var line = 1
+    
+    private var currentText: String {
+        return source[start..<current]
+    }
+
+    private var isAtEnd: Bool {
+        return current >= source.endIndex
+    }
+    
+    private var peek: Character {
+        if current >= source.endIndex { return "\0" }
+        return source[current]
+    }
+    
+    private var peekNext: Character {
+        let next = source.index(after: current)
+        if next >= source.endIndex { return "\0" }
+        return source[next]
+    }
     
     init(_ source: String) {
         self.source = source

            
        case "/":
            if match("/") {
                while (peek() != "\n" && !isAtEnd()) { let _ = advance() }
            } else {
                addToken(.SLASH)
            }

        }
    }
    
    private func identifier() {
        while isAlphaNumeric(peek) { _ = advance() }
        
        let type = TokenType(keyword: currentText) ?? .IDENTIFIER
        addToken(type)
    }
    
    private func number() {
        while isDigit(peek) { _ = advance() }
        
        if peek == "." && isDigit(peekNext) {
            // Consume the "."
            _ = advance()
            
            while isDigit(peek) { _ = advance() }
        }
        
        addToken(.NUMBER, Double(currentText)!)
    }
    
    private func string() {
        while (peek != "\"" && !isAtEnd) {
            if (peek == "\n") { line += 1 }
            _ = advance()
        }
        
        // Unterminated string.
        if (isAtEnd) {
            Lox.error(line, "Unterminated string.")
            return
        }
        
        // The closing ".
        _ = advance()
        
        let range = source.index(after: start)..<source.index(before: current)
        let value = source[range]
