@@ -845,10 +845,7 @@ extension Lexer.Cursor {
845845 }
846846
847847 func isRightBound( isLeftBound: Bool ) -> Bool {
848- guard let c = self . peek ( ) else {
849- return false // last char in file
850- }
851- switch c {
848+ switch self . peek ( ) {
852849 case " " , " \r " , " \n " , " \t " , // whitespace
853850 " ) " , " ] " , " } " , // closing delimiters
854851 " , " , " ; " , " : " : // expression separators
@@ -878,6 +875,8 @@ extension Lexer.Cursor {
878875 } else {
879876 return true
880877 }
878+ case nil :
879+ return false // last char in file
881880 default :
882881 return true
883882 }
@@ -891,10 +890,7 @@ extension Lexer.Cursor {
891890 sourceBufferStart: Lexer . Cursor ,
892891 preferRegexOverBinaryOperator: Bool
893892 ) -> Lexer . Result {
894- guard let c = self . peek ( ) else {
895- return Lexer . Result ( . endOfFile)
896- }
897- switch c {
893+ switch self . peek ( ) {
898894 case " @ " : _ = self . advance ( ) ; return Lexer . Result ( . atSign)
899895 case " { " : _ = self . advance ( ) ; return Lexer . Result ( . leftBrace)
900896 case " [ " : _ = self . advance ( ) ; return Lexer . Result ( . leftSquare)
@@ -964,6 +960,8 @@ extension Lexer.Cursor {
964960
965961 case " ` " :
966962 return self . lexEscapedIdentifier ( )
963+ case nil :
964+ return Lexer . Result ( . endOfFile)
967965 default :
968966 var tmp = self
969967 if tmp. advance ( if: { Unicode . Scalar ( $0) . isValidIdentifierStartCodePoint } ) {
0 commit comments