Skip to content

Commit a2cf2df

Browse files
committed
Rename TokenKind.floatingLiteral -> floatLiteral
This is consistent with `FloatLiteralExprSyntax`
1 parent d54a829 commit a2cf2df

26 files changed

+93
-68
lines changed

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public let EXPR_NODES: [Node] = [
770770
Child(
771771
name: "Literal",
772772
deprecatedName: "FloatingDigits",
773-
kind: .token(choices: [.token(tokenKind: "FloatingLiteralToken")])
773+
kind: .token(choices: [.token(tokenKind: "FloatLiteralToken")])
774774
)
775775
]
776776
),

CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
7979
.other(name: "endOfFile", nameForDiagnostics: "end of file", text: ""),
8080
.punctuator(name: "equal", text: "="),
8181
.punctuator(name: "exclamationMark", text: "!"),
82-
.other(name: "floatingLiteral", nameForDiagnostics: "floating literal"),
82+
.other(name: "floatLiteral", nameForDiagnostics: "float literal"),
8383
.other(name: "identifier", nameForDiagnostics: "identifier"),
8484
.punctuator(name: "infixQuestionMark", text: "?"),
8585
.other(name: "integerLiteral", nameForDiagnostics: "integer literal"),

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ValidateSyntaxNodes: XCTestCase {
178178
}
179179
}
180180

181-
case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatingLiteralToken"):
181+
case .token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .token(tokenKind: "FloatLiteralToken"):
182182
// We allow arbitrary naming of identifiers and literals
183183
break
184184
case .token(tokenKind: "CommaToken"):

Sources/SwiftIDEUtils/SyntaxClassification.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public enum SyntaxClassification {
2828
/// An editor placeholder of the form `<#content#>`
2929
case editorPlaceholder
3030
/// A floating point literal.
31-
case floatingLiteral
31+
case floatLiteral
3232
/// A generic identifier.
3333
case identifier
3434
/// An integer literal.
@@ -51,6 +51,11 @@ public enum SyntaxClassification {
5151
case stringLiteral
5252
/// An identifier referring to a type.
5353
case typeIdentifier
54+
55+
@available(*, deprecated, renamed: "floatLiteral")
56+
public static var floatingLiteral: Self {
57+
return .floatLiteral
58+
}
5459
}
5560

5661
extension SyntaxClassification {
@@ -124,8 +129,8 @@ extension RawTokenKind {
124129
return .none
125130
case .exclamationMark:
126131
return .none
127-
case .floatingLiteral:
128-
return .floatingLiteral
132+
case .floatLiteral:
133+
return .floatLiteral
129134
case .identifier:
130135
return .identifier
131136
case .infixQuestionMark:

Sources/SwiftParser/Availability.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ extension Parser {
210210
}
211211

212212
let version: RawVersionTupleSyntax?
213-
if self.at(.integerLiteral, .floatingLiteral) {
213+
if self.at(.integerLiteral, .floatLiteral) {
214214
version = self.parseVersionTuple(maxComponentCount: 3)
215215
} else {
216216
version = nil
@@ -237,7 +237,7 @@ extension Parser {
237237
return self.consumeAnyToken()
238238
}
239239

240-
/// Consume the unexpected version token(e.g. integerLiteral, floatingLiteral, identifier) until the period no longer appears.
240+
/// Consume the unexpected version token(e.g. integerLiteral, floatLiteral, identifier) until the period no longer appears.
241241
private mutating func parseUnexpectedVersionTokens() -> RawUnexpectedNodesSyntax? {
242242
var unexpectedTokens: [RawTokenSyntax] = []
243243
var keepGoing: RawTokenSyntax? = nil
@@ -246,7 +246,7 @@ extension Parser {
246246
if let keepGoing {
247247
unexpectedTokens.append(keepGoing)
248248
}
249-
if let unexpectedVersion = self.consume(if: .integerLiteral, .floatingLiteral, .identifier) {
249+
if let unexpectedVersion = self.consume(if: .integerLiteral, .floatLiteral, .identifier) {
250250
unexpectedTokens.append(unexpectedVersion)
251251
}
252252
keepGoing = self.consume(if: .period)
@@ -256,7 +256,7 @@ extension Parser {
256256

257257
/// Parse a dot-separated list of version numbers.
258258
mutating func parseVersionTuple(maxComponentCount: Int) -> RawVersionTupleSyntax {
259-
if self.at(.floatingLiteral),
259+
if self.at(.floatLiteral),
260260
let periodIndex = self.currentToken.tokenText.firstIndex(of: UInt8(ascii: ".")),
261261
self.currentToken.tokenText[0..<periodIndex].allSatisfy({ Unicode.Scalar($0).isDigit })
262262
{

Sources/SwiftParser/Expressions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ extension Parser {
10971097
arena: self.arena
10981098
)
10991099
)
1100-
case (.floatingLiteral, let handle)?:
1100+
case (.floatLiteral, let handle)?:
11011101
let literal = self.eat(handle)
11021102
return RawExprSyntax(
11031103
RawFloatLiteralExprSyntax(
@@ -1186,7 +1186,7 @@ extension Parser {
11861186
return RawExprSyntax(
11871187
RawFloatLiteralExprSyntax(
11881188
literal: RawTokenSyntax(
1189-
missing: .floatingLiteral,
1189+
missing: .floatLiteral,
11901190
text: text,
11911191
arena: self.arena
11921192
),

Sources/SwiftParser/Lexer/Cursor.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ extension Lexer.Cursor {
14071407
let errorPos = tmp
14081408
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
14091409
return Lexer.Result(
1410-
.floatingLiteral,
1410+
.floatLiteral,
14111411
error: LexingDiagnostic(errorKind, position: errorPos)
14121412
)
14131413
}
@@ -1419,13 +1419,13 @@ extension Lexer.Cursor {
14191419
let errorPos = tmp
14201420
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
14211421
return Lexer.Result(
1422-
.floatingLiteral,
1422+
.floatLiteral,
14231423
error: LexingDiagnostic(.invalidFloatingPointExponentDigit, position: errorPos)
14241424
)
14251425
}
14261426
}
14271427

1428-
return Lexer.Result(.floatingLiteral)
1428+
return Lexer.Result(.floatLiteral)
14291429
}
14301430

14311431
mutating func lexHexNumber() -> Lexer.Result {
@@ -1529,7 +1529,7 @@ extension Lexer.Cursor {
15291529
let errorPos = tmp
15301530
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
15311531
return Lexer.Result(
1532-
.floatingLiteral,
1532+
.floatLiteral,
15331533
error: LexingDiagnostic(errorKind, position: errorPos)
15341534
)
15351535
}
@@ -1541,11 +1541,11 @@ extension Lexer.Cursor {
15411541
let errorPos = tmp
15421542
self.advance(while: { $0.isValidIdentifierContinuationCodePoint })
15431543
return Lexer.Result(
1544-
.floatingLiteral,
1544+
.floatLiteral,
15451545
error: LexingDiagnostic(.invalidFloatingPointExponentDigit, position: errorPos)
15461546
)
15471547
}
1548-
return Lexer.Result(.floatingLiteral)
1548+
return Lexer.Result(.floatLiteral)
15491549
}
15501550
}
15511551

Sources/SwiftParser/Lexer/RegexLiteralLexer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ extension Lexer.Cursor {
640640
return false
641641

642642
// Literals are themselves expressions and therefore don't sequence expressions.
643-
case .floatingLiteral, .integerLiteral:
643+
case .floatLiteral, .integerLiteral:
644644
return false
645645

646646
// Pound keywords that do not generally sequence expressions.

Sources/SwiftParser/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ extension Parser {
524524
self.missingToken(.identifier)
525525
)
526526
}
527-
if let number = self.consume(if: .integerLiteral, .floatingLiteral, .dollarIdentifier) {
527+
if let number = self.consume(if: .integerLiteral, .floatLiteral, .dollarIdentifier) {
528528
return (
529529
RawUnexpectedNodesSyntax(elements: [RawSyntax(number)], arena: self.arena),
530530
self.missingToken(.identifier)

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum TokenPrecedence: Comparable {
117117
self = .unknownToken
118118
// MARK: Identifier like
119119
case // Literals
120-
.floatingLiteral, .integerLiteral,
120+
.floatLiteral, .integerLiteral,
121121
// Pound literals
122122
.poundAvailable, .poundSourceLocation, .poundUnavailable,
123123
// Identifiers

0 commit comments

Comments
 (0)