@@ -845,10 +845,7 @@ extension Lexer.Cursor {
845
845
}
846
846
847
847
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 ( ) {
852
849
case " " , " \r " , " \n " , " \t " , // whitespace
853
850
" ) " , " ] " , " } " , // closing delimiters
854
851
" , " , " ; " , " : " : // expression separators
@@ -878,6 +875,8 @@ extension Lexer.Cursor {
878
875
} else {
879
876
return true
880
877
}
878
+ case nil :
879
+ return false // last char in file
881
880
default :
882
881
return true
883
882
}
@@ -891,10 +890,7 @@ extension Lexer.Cursor {
891
890
sourceBufferStart: Lexer . Cursor ,
892
891
preferRegexOverBinaryOperator: Bool
893
892
) -> Lexer . Result {
894
- guard let c = self . peek ( ) else {
895
- return Lexer . Result ( . endOfFile)
896
- }
897
- switch c {
893
+ switch self . peek ( ) {
898
894
case " @ " : _ = self . advance ( ) ; return Lexer . Result ( . atSign)
899
895
case " { " : _ = self . advance ( ) ; return Lexer . Result ( . leftBrace)
900
896
case " [ " : _ = self . advance ( ) ; return Lexer . Result ( . leftSquare)
@@ -964,6 +960,8 @@ extension Lexer.Cursor {
964
960
965
961
case " ` " :
966
962
return self . lexEscapedIdentifier ( )
963
+ case nil :
964
+ return Lexer . Result ( . endOfFile)
967
965
default :
968
966
var tmp = self
969
967
if tmp. advance ( if: { Unicode . Scalar ( $0) . isValidIdentifierStartCodePoint } ) {
0 commit comments