File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Sources/SwiftParser/Lexer Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -790,7 +790,8 @@ extension Lexer.Cursor {
790
790
return result
791
791
}
792
792
793
- let unknownClassification = self . lexUnknown ( tokenStart: start)
793
+ let unknownClassification = start. lexUnknown ( )
794
+ self = start
794
795
assert ( unknownClassification == . lexemeContents, " Invalid UTF-8 sequence should be eaten by lexTrivia as LeadingTrivia " )
795
796
return Lexer . Result ( . unknown)
796
797
}
@@ -919,7 +920,9 @@ extension Lexer.Cursor {
919
920
break
920
921
}
921
922
922
- if self . lexUnknown ( tokenStart: start) == . trivia {
923
+ // `lexUnknown` expects that the first character has not been consumed yet.
924
+ self = start
925
+ if self . lexUnknown ( ) == . trivia {
923
926
continue
924
927
} else {
925
928
break
@@ -2010,9 +2013,9 @@ extension Lexer.Cursor {
2010
2013
/// Assuming the cursor is positioned at neighter a valid identifier nor a
2011
2014
/// valid operator start, advance the cursor by what can be considered a
2012
2015
/// lexeme.
2013
- mutating func lexUnknown( tokenStart : Lexer . Cursor ) -> UnknownCharactersClassification {
2014
- assert ( tokenStart . peekScalar ( ) ? . isValidIdentifierStartCodePoint == false && tokenStart . peekScalar ( ) ? . isOperatorStartCodePoint == false )
2015
- var tmp = tokenStart
2016
+ mutating func lexUnknown( ) -> UnknownCharactersClassification {
2017
+ assert ( self . peekScalar ( ) ? . isValidIdentifierStartCodePoint == false && self . peekScalar ( ) ? . isOperatorStartCodePoint == false )
2018
+ var tmp = self
2016
2019
if tmp. advance ( if: { Unicode . Scalar ( $0) . isValidIdentifierContinuationCodePoint } ) {
2017
2020
// If this is a valid identifier continuation, but not a valid identifier
2018
2021
// start, attempt to recover by eating more continuation characters.
You can’t perform that action at this time.
0 commit comments