Skip to content

Commit a5894ca

Browse files
committed
Update sourcecode to use new endOfFile naming
1 parent fddaa84 commit a5894ca

28 files changed

+75
-75
lines changed

Sources/SwiftBasicFormat/BasicFormat.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ open class BasicFormat: SyntaxRewriter {
208208
(.backslash, _),
209209
(.backtick, _),
210210
(.dollarIdentifier, .period), // a.b
211-
(.eof, _),
211+
(.endOfFile, _),
212212
(.exclamationMark, .leftParen), // myOptionalClosure!()
213213
(.exclamationMark, .period), // myOptionalBar!.foo()
214214
(.extendedRegexDelimiter, .leftParen), // opening extended regex delimiter should never be separate by a space
@@ -254,7 +254,7 @@ open class BasicFormat: SyntaxRewriter {
254254
(.stringSegment, _),
255255
(_, .comma),
256256
(_, .ellipsis),
257-
(_, .eof),
257+
(_, .endOfFile),
258258
(_, .exclamationMark),
259259
(_, .postfixOperator),
260260
(_, .postfixQuestionMark),

Sources/SwiftParser/Attributes.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ extension Parser {
287287
// The contents of the @_effects attribute are parsed in SIL, we just
288288
// represent the contents as a list of tokens in SwiftSyntax.
289289
var tokens: [RawTokenSyntax] = []
290-
while !parser.at(.rightParen, .eof) {
290+
while !parser.at(.rightParen, .endOfFile) {
291291
tokens.append(parser.consumeAnyToken())
292292
}
293293
return .effectsArguments(RawEffectsArgumentsSyntax(elements: tokens, arena: parser.arena))
@@ -425,7 +425,7 @@ extension Parser {
425425

426426
var elements = [RawDifferentiabilityParamSyntax]()
427427
var loopProgress = LoopProgressCondition()
428-
while !self.at(.eof, .rightParen) && loopProgress.evaluate(currentToken) {
428+
while !self.at(.endOfFile, .rightParen) && loopProgress.evaluate(currentToken) {
429429
guard let param = self.parseDifferentiabilityParameter() else {
430430
break
431431
}
@@ -648,7 +648,7 @@ extension Parser {
648648
var elements = [RawSpecializeAttributeSpecListSyntax.Element]()
649649
// Parse optional "exported" and "kind" labeled parameters.
650650
var loopProgress = LoopProgressCondition()
651-
while !self.at(.eof, .rightParen, .keyword(.where)) && loopProgress.evaluate(currentToken) {
651+
while !self.at(.endOfFile, .rightParen, .keyword(.where)) && loopProgress.evaluate(currentToken) {
652652
switch self.at(anyIn: SpecializeParameter.self) {
653653
case (.target, let handle)?:
654654
let ident = self.eat(handle)

Sources/SwiftParser/Declarations.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension TokenConsumer {
8585
}
8686

8787
if hasAttribute {
88-
if subparser.at(.rightBrace) || subparser.at(.eof) || subparser.at(.poundEndifKeyword) {
88+
if subparser.at(.rightBrace) || subparser.at(.endOfFile) || subparser.at(.poundEndifKeyword) {
8989
return true
9090
}
9191
}
@@ -776,7 +776,7 @@ extension Parser {
776776
let (unexpectedBeforeLBrace, lbrace) = self.expect(.leftBrace)
777777
do {
778778
var loopProgress = LoopProgressCondition()
779-
while !self.at(.eof, .rightBrace) && loopProgress.evaluate(currentToken) {
779+
while !self.at(.endOfFile, .rightBrace) && loopProgress.evaluate(currentToken) {
780780
let newItemAtStartOfLine = self.currentToken.isAtStartOfLine
781781
guard let newElement = self.parseMemberDeclListItem() else {
782782
break
@@ -1539,7 +1539,7 @@ extension Parser {
15391539
var elements = [RawAccessorDeclSyntax]()
15401540
do {
15411541
var loopProgress = LoopProgressCondition()
1542-
while !self.at(.eof, .rightBrace) && loopProgress.evaluate(currentToken) {
1542+
while !self.at(.endOfFile, .rightBrace) && loopProgress.evaluate(currentToken) {
15431543
guard let introducer = self.parseAccessorIntroducer() else {
15441544
// There can only be an implicit getter if no other accessors were
15451545
// seen before this one.
@@ -1758,7 +1758,7 @@ extension Parser {
17581758
var loopProgress = LoopProgressCondition()
17591759
while (identifiersAfterOperatorName.last ?? name).trailingTriviaByteLength == 0,
17601760
self.currentToken.leadingTriviaByteLength == 0,
1761-
!self.at(.colon, .leftBrace, .eof),
1761+
!self.at(.colon, .leftBrace, .endOfFile),
17621762
loopProgress.evaluate(self.currentToken)
17631763
{
17641764
identifiersAfterOperatorName.append(consumeAnyToken())
@@ -1906,7 +1906,7 @@ extension Parser {
19061906
var elements = [RawPrecedenceGroupAttributeListSyntax.Element]()
19071907
do {
19081908
var attributesProgress = LoopProgressCondition()
1909-
LOOP: while !self.at(.eof, .rightBrace) && attributesProgress.evaluate(currentToken) {
1909+
LOOP: while !self.at(.endOfFile, .rightBrace) && attributesProgress.evaluate(currentToken) {
19101910
switch self.at(anyIn: LabelText.self) {
19111911
case (.associativity, let handle)?:
19121912
let associativity = self.eat(handle)

Sources/SwiftParser/Directives.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ extension Parser {
195195
) -> [Element] {
196196
var elements = [Element]()
197197
var elementsProgress = LoopProgressCondition()
198-
while !self.at(.eof)
198+
while !self.at(.endOfFile)
199199
&& !self.at(.poundElseKeyword, .poundElseifKeyword, .poundEndifKeyword)
200200
&& !self.atElifTypo()
201201
&& elementsProgress.evaluate(currentToken)

Sources/SwiftParser/Expressions.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ extension Parser {
924924
var loopProgress = LoopProgressCondition()
925925
repeat {
926926
backtrack.eat(.poundIfKeyword)
927-
while !backtrack.at(.eof) && !backtrack.currentToken.isAtStartOfLine {
927+
while !backtrack.at(.endOfFile) && !backtrack.currentToken.isAtStartOfLine {
928928
backtrack.skipSingle()
929929
}
930930
} while backtrack.at(.poundIfKeyword) && loopProgress.evaluate(backtrack.currentToken)
@@ -1713,12 +1713,12 @@ extension Parser {
17131713
// If we saw a comma, that's a strong indicator we have more elements
17141714
// to process. If that's not the case, we have to do some legwork to
17151715
// determine if we should bail out.
1716-
guard comma == nil || self.at(.rightSquare, .eof) else {
1716+
guard comma == nil || self.at(.rightSquare, .endOfFile) else {
17171717
continue
17181718
}
17191719

17201720
// If we found EOF or the closing square bracket, bailout.
1721-
if self.at(.rightSquare, .eof) {
1721+
if self.at(.rightSquare, .endOfFile) {
17221722
break
17231723
}
17241724

@@ -1924,7 +1924,7 @@ extension Parser {
19241924
}
19251925
// We were promised a right square bracket, so we're going to get it.
19261926
var unexpectedNodes = [RawSyntax]()
1927-
while !self.at(.eof) && !self.at(.rightSquare) && !self.at(.keyword(.in)) {
1927+
while !self.at(.endOfFile) && !self.at(.rightSquare) && !self.at(.keyword(.in)) {
19281928
unexpectedNodes.append(RawSyntax(self.consumeAnyToken()))
19291929
}
19301930
let (unexpectedBeforeRSquare, rsquare) = self.expect(.rightSquare)
@@ -2230,7 +2230,7 @@ extension Parser.Lookahead {
22302230
var backtrack = self.lookahead()
22312231
backtrack.eat(.leftBrace)
22322232
var loopProgress = LoopProgressCondition()
2233-
while !backtrack.at(.eof, .rightBrace)
2233+
while !backtrack.at(.endOfFile, .rightBrace)
22342234
&& !backtrack.at(.poundEndifKeyword, .poundElseKeyword, .poundElseifKeyword)
22352235
&& loopProgress.evaluate(backtrack.currentToken)
22362236
{
@@ -2383,7 +2383,7 @@ extension Parser {
23832383
mutating func parseSwitchCases(allowStandaloneStmtRecovery: Bool) -> RawSwitchCaseListSyntax {
23842384
var elements = [RawSwitchCaseListSyntax.Element]()
23852385
var elementsProgress = LoopProgressCondition()
2386-
while !self.at(.eof, .rightBrace) && !self.at(.poundEndifKeyword, .poundElseifKeyword, .poundElseKeyword)
2386+
while !self.at(.endOfFile, .rightBrace) && !self.at(.poundEndifKeyword, .poundElseifKeyword, .poundElseKeyword)
23872387
&& elementsProgress.evaluate(currentToken)
23882388
{
23892389
if self.withLookahead({ $0.isAtStartOfSwitchCase(allowRecovery: false) }) {
@@ -2691,7 +2691,7 @@ extension Parser.Lookahead {
26912691

26922692
// While we don't have '->' or ')', eat balanced tokens.
26932693
var skipProgress = LoopProgressCondition()
2694-
while !lookahead.at(.eof, .rightParen) && skipProgress.evaluate(lookahead.currentToken) {
2694+
while !lookahead.at(.endOfFile, .rightParen) && skipProgress.evaluate(lookahead.currentToken) {
26952695
lookahead.skipSingle()
26962696
}
26972697

Sources/SwiftParser/Lexer/Cursor.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ extension Lexer.Cursor {
972972
case UInt8(ascii: "`"):
973973
return self.lexEscapedIdentifier()
974974
case nil:
975-
return Lexer.Result(.eof)
975+
return Lexer.Result(.endOfFile)
976976
default:
977977
var tmp = self
978978
if tmp.advance(if: { Unicode.Scalar($0).isValidIdentifierStartCodePoint }) {
@@ -1000,7 +1000,7 @@ extension Lexer.Cursor {
10001000
case UInt8(ascii: #"'"#), UInt8(ascii: #"""#):
10011001
return self.lexStringQuote(isOpening: true, leadingDelimiterLength: delimiterLength)
10021002
case nil:
1003-
return Lexer.Result(.eof)
1003+
return Lexer.Result(.endOfFile)
10041004
default:
10051005
preconditionFailure("state 'afterRawStringDelimiter' expects to be positioned at a quote")
10061006
}
@@ -1011,7 +1011,7 @@ extension Lexer.Cursor {
10111011
case UInt8(ascii: #"'"#), UInt8(ascii: #"""#):
10121012
return self.lexStringQuote(isOpening: false, leadingDelimiterLength: 0)
10131013
case nil:
1014-
return Lexer.Result(.eof)
1014+
return Lexer.Result(.endOfFile)
10151015
default:
10161016
preconditionFailure("state 'isAfterStringLiteral' expects to be positioned at a quote")
10171017
}
@@ -1023,7 +1023,7 @@ extension Lexer.Cursor {
10231023
self.advance(while: { $0 == Unicode.Scalar("#") })
10241024
return Lexer.Result(.rawStringDelimiter, stateTransition: .pop)
10251025
case nil:
1026-
return Lexer.Result(.eof)
1026+
return Lexer.Result(.endOfFile)
10271027
default:
10281028
preconditionFailure("state 'afterClosingStringQuote' expects to be positioned at a '#'")
10291029
}
@@ -1045,7 +1045,7 @@ extension Lexer.Cursor {
10451045
_ = self.advance()
10461046
return Lexer.Result(.leftParen, stateTransition: .replace(newState: .inStringInterpolation(stringLiteralKind: stringLiteralKind, parenCount: 0)))
10471047
case nil:
1048-
return Lexer.Result(.eof)
1048+
return Lexer.Result(.endOfFile)
10491049
default:
10501050
preconditionFailure("state 'afterBackslashOfStringInterpolation' expects to be positioned at '#' or '('")
10511051
}
@@ -1884,7 +1884,7 @@ extension Lexer.Cursor {
18841884
}
18851885

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

18891889
var error: LexingDiagnostic? = nil
18901890

Sources/SwiftParser/Lexer/RegexLiteralLexer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ extension Lexer.Cursor {
602602
return true
603603

604604
// Cannot lex at the end of the buffer.
605-
case .eof:
605+
case .endOfFile:
606606
return false
607607

608608
// Prefix grammar that appears before an expression.

Sources/SwiftParser/Lookahead.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ extension Parser.Lookahead {
196196
} while self.consume(if: .period) != nil
197197

198198
if self.consume(if: .leftParen) != nil {
199-
while !self.at(.eof, .rightParen, .poundEndifKeyword) {
199+
while !self.at(.endOfFile, .rightParen, .poundEndifKeyword) {
200200
self.skipSingle()
201201
}
202202
self.consume(if: .rightParen)
@@ -291,7 +291,7 @@ extension Parser.Lookahead {
291291
}
292292

293293
mutating func skipUntilEndOfLine() {
294-
while !self.at(.eof) && !self.currentToken.isAtStartOfLine {
294+
while !self.at(.endOfFile) && !self.currentToken.isAtStartOfLine {
295295
self.skipSingle()
296296
}
297297
}
@@ -393,7 +393,7 @@ extension Parser.Lookahead {
393393
return
394394
}
395395
case .skipUntil(let t1, let t2):
396-
if !self.at(.eof, t1, t2) && !self.at(.poundEndifKeyword, .poundElseKeyword, .poundElseifKeyword) {
396+
if !self.at(.endOfFile, t1, t2) && !self.at(.poundEndifKeyword, .poundElseKeyword, .poundElseifKeyword) {
397397
stack += [.skipUntil(t1, t2), .skipSingle]
398398
}
399399
}

Sources/SwiftParser/Names.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ extension Parser {
115115
var elements = [RawDeclNameArgumentSyntax]()
116116
do {
117117
var loopProgress = LoopProgressCondition()
118-
while !self.at(.eof, .rightParen) && loopProgress.evaluate(currentToken) {
118+
while !self.at(.endOfFile, .rightParen) && loopProgress.evaluate(currentToken) {
119119
// Check to see if there is an argument label.
120120
precondition(self.currentToken.canBeArgumentLabel() && self.peek().rawTokenKind == .colon)
121121
let name = self.consumeAnyToken()
@@ -240,7 +240,7 @@ extension Parser.Lookahead {
240240
}
241241

242242
var loopProgress = LoopProgressCondition()
243-
while !lookahead.at(.eof, .rightParen) && loopProgress.evaluate(lookahead.currentToken) {
243+
while !lookahead.at(.endOfFile, .rightParen) && loopProgress.evaluate(lookahead.currentToken) {
244244
// Check to see if there is an argument label.
245245
guard lookahead.currentToken.canBeArgumentLabel() && lookahead.peek().rawTokenKind == .colon else {
246246
return false

Sources/SwiftParser/Nominals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ extension Parser {
376376
return self.withLookahead {
377377
$0.consume(if: .leftParen)
378378
guard $0.canParseType() else { return false }
379-
return $0.at(.rightParen, .keyword(.where), .leftBrace) || $0.at(.eof)
379+
return $0.at(.rightParen, .keyword(.where), .leftBrace) || $0.at(.endOfFile)
380380
}
381381
}
382382
}

Sources/SwiftParser/Parameters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extension Parser {
284284
if !shouldSkipParameterParsing {
285285
var keepGoing = true
286286
var loopProgress = LoopProgressCondition()
287-
while !self.at(.eof, .rightParen)
287+
while !self.at(.endOfFile, .rightParen)
288288
&& keepGoing
289289
&& loopProgress.evaluate(currentToken)
290290
{

Sources/SwiftParser/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public struct Parser {
9090
var arena: ParsingSyntaxArena
9191
/// A view of the sequence of lexemes in the input.
9292
var lexemes: Lexer.LexemeSequence
93-
/// The current token. If there was no input, this token will have a kind of `.eof`.
93+
/// The current token. If there was no input, this token will have a kind of `.endOfFile`.
9494
var currentToken: Lexer.Lexeme
9595

9696
/// The current nesting level, i.e. the number of tokens that

Sources/SwiftParser/Patterns.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ extension Parser {
215215
do {
216216
var keepGoing = true
217217
var loopProgress = LoopProgressCondition()
218-
while !self.at(.eof, .rightParen) && keepGoing && loopProgress.evaluate(currentToken) {
218+
while !self.at(.endOfFile, .rightParen) && keepGoing && loopProgress.evaluate(currentToken) {
219219
// If the tuple element has a label, parse it.
220220
let labelAndColon = self.consume(if: .identifier, followedBy: .colon)
221221
var (label, colon) = (labelAndColon?.0, labelAndColon?.1)

Sources/SwiftParser/Recovery.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ extension Parser.Lookahead {
7676
let recoveryPrecedence = min(spec1.recoveryPrecedence, spec2.recoveryPrecedence, spec3.recoveryPrecedence)
7777
let shouldSkipOverNewlines = recoveryPrecedence.shouldSkipOverNewlines && spec1.allowAtStartOfLine && spec2.allowAtStartOfLine && spec3.allowAtStartOfLine
7878

79-
while !self.at(.eof) {
79+
while !self.at(.endOfFile) {
8080
if !shouldSkipOverNewlines, self.currentToken.isAtStartOfLine {
8181
break
8282
}
@@ -139,7 +139,7 @@ extension Parser.Lookahead {
139139
return $0.spec.recoveryPrecedence
140140
}).min()!
141141
var loopProgress = LoopProgressCondition()
142-
while !self.at(.eof) && loopProgress.evaluate(self.currentToken) {
142+
while !self.at(.endOfFile) && loopProgress.evaluate(self.currentToken) {
143143
if !recoveryPrecedence.shouldSkipOverNewlines,
144144
self.currentToken.isAtStartOfLine
145145
{

Sources/SwiftParser/Statements.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ extension Parser {
694694
case poundEndifKeyword
695695
case poundElseKeyword
696696
case poundElseifKeyword
697-
case eof
697+
case endOfFile
698698

699699
init?(lexeme: Lexer.Lexeme) {
700700
switch PrepareForKeywordMatch(lexeme) {
@@ -706,7 +706,7 @@ extension Parser {
706706
case TokenSpec(.poundEndifKeyword): self = .poundEndifKeyword
707707
case TokenSpec(.poundElseKeyword): self = .poundElseKeyword
708708
case TokenSpec(.poundElseifKeyword): self = .poundElseifKeyword
709-
case TokenSpec(.eof): self = .eof
709+
case TokenSpec(.endOfFile): self = .endOfFile
710710
default: return nil
711711
}
712712
}
@@ -721,7 +721,7 @@ extension Parser {
721721
case .poundEndifKeyword: return .poundEndifKeyword
722722
case .poundElseKeyword: return .poundElseKeyword
723723
case .poundElseifKeyword: return .poundElseifKeyword
724-
case .eof: return .eof
724+
case .endOfFile: return .endOfFile
725725
}
726726
}
727727
}
@@ -798,7 +798,7 @@ extension Parser {
798798
var keepGoing = true
799799
var elementList = [RawYieldExprListElementSyntax]()
800800
var loopProgress = LoopProgressCondition()
801-
while !self.at(.eof, .rightParen) && keepGoing && loopProgress.evaluate(currentToken) {
801+
while !self.at(.endOfFile, .rightParen) && keepGoing && loopProgress.evaluate(currentToken) {
802802
let expr = self.parseExpression()
803803
let comma = self.consume(if: .comma)
804804
elementList.append(

Sources/SwiftParser/StringLiterals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ extension Parser {
503503
// This allows us to skip over extraneous identifiers etc. in an unterminated string interpolation.
504504
var unexpectedBeforeRightParen: [RawTokenSyntax] = []
505505
var unexpectedProgress = LoopProgressCondition()
506-
while !self.at(.rightParen, .stringSegment, .backslash) && !self.at(TokenSpec(openQuoteKind), .eof) && unexpectedProgress.evaluate(self.currentToken) {
506+
while !self.at(.rightParen, .stringSegment, .backslash) && !self.at(TokenSpec(openQuoteKind), .endOfFile) && unexpectedProgress.evaluate(self.currentToken) {
507507
unexpectedBeforeRightParen.append(self.consumeAnyToken())
508508
}
509509
// Consume the right paren if present, ensuring that it's on the same

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ enum TokenPrecedence: Comparable {
170170
// Arrow is a strong indicator in a function type that we are now in the return type
171171
.arrow,
172172
// EOF is here because it is a very stong marker and doesn't belong anywhere else
173-
.eof:
173+
.endOfFile:
174174
self = .strongPunctuator
175175

176176
// MARK: Strong bracket close

0 commit comments

Comments
 (0)