Skip to content

Remove check for endOfFile in advance #1457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SwiftParser/Lexer/Cursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,8 @@ extension Lexer.Cursor {
}

mutating func lexInStringLiteral(stringLiteralKind: StringLiteralKind, delimiterLength: Int) -> Lexer.Result {
if self.isAtEndOfFile { return .init(.eof) }

var error: LexingDiagnostic? = nil

while true {
Expand Down
15 changes: 1 addition & 14 deletions Sources/SwiftParser/Lexer/LexemeSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,7 @@ extension Lexer {

mutating func advance() -> Lexer.Lexeme {
defer {
if self.cursor.isAtEndOfFile {
self.nextToken = Lexeme(
tokenKind: .eof,
flags: [],
diagnostic: nil,
start: self.cursor.pointer,
leadingTriviaLength: 0,
textLength: 0,
trailingTriviaLength: 0,
cursor: self.cursor
)
} else {
self.nextToken = self.cursor.nextToken(sourceBufferStart: self.sourceBufferStart, stateAllocator: lexerStateAllocator)
}
self.nextToken = self.cursor.nextToken(sourceBufferStart: self.sourceBufferStart, stateAllocator: lexerStateAllocator)
}
return self.nextToken
}
Expand Down