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

    }
    
    private func addToken(_ type: TokenType, _ literal: Any) {
        let text = source[start..<current]
        tokens.append(Token(type, text, literal, line))
    }
}


import Foundation

extension TokenType {
    init?(keyword: String) {
        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
        ]
        
        guard let type = keywords[keyword]
            else { return nil }
        
        self = type
    }
}

class Scanner {
    private let source: String
    private var tokens: [Token] = []
