Skip to content

Commit 96e6850

Browse files
authored
Merge pull request #1457 from hamishknight/eof
2 parents c7dd3f4 + 17289d4 commit 96e6850

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

Sources/SwiftParser/Lexer/Cursor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,8 @@ extension Lexer.Cursor {
17721772
}
17731773

17741774
mutating func lexInStringLiteral(stringLiteralKind: StringLiteralKind, delimiterLength: Int) -> Lexer.Result {
1775+
if self.isAtEndOfFile { return .init(.eof) }
1776+
17751777
var error: LexingDiagnostic? = nil
17761778

17771779
while true {

Sources/SwiftParser/Lexer/LexemeSequence.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,7 @@ extension Lexer {
4343

4444
mutating func advance() -> Lexer.Lexeme {
4545
defer {
46-
if self.cursor.isAtEndOfFile {
47-
self.nextToken = Lexeme(
48-
tokenKind: .eof,
49-
flags: [],
50-
diagnostic: nil,
51-
start: self.cursor.pointer,
52-
leadingTriviaLength: 0,
53-
textLength: 0,
54-
trailingTriviaLength: 0,
55-
cursor: self.cursor
56-
)
57-
} else {
58-
self.nextToken = self.cursor.nextToken(sourceBufferStart: self.sourceBufferStart, stateAllocator: lexerStateAllocator)
59-
}
46+
self.nextToken = self.cursor.nextToken(sourceBufferStart: self.sourceBufferStart, stateAllocator: lexerStateAllocator)
6047
}
6148
return self.nextToken
6249
}

0 commit comments

Comments
 (0)