Skip to content

Commit 59d1c93

Browse files
committed
Update TokenPrecedence.swift
1 parent 18b2726 commit 59d1c93

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum TokenPrecedence: Comparable {
3636
case weakBracketClose
3737
/// Keywords that start a new statement.
3838
case stmtKeyword
39+
case typeKeyword
3940
case declarationAttributeWithSpecialSyntax
4041
/// The '{' token because it typically marks the body of a declaration.
4142
/// `closingDelimiter` must have type `strongPunctuator`
@@ -83,20 +84,22 @@ enum TokenPrecedence: Comparable {
8384
return 6
8485
case .stmtKeyword:
8586
return 7
86-
case .declarationAttributeWithSpecialSyntax:
87+
case .typeKeyword:
8788
return 8
88-
case .strongPunctuator:
89+
case .declarationAttributeWithSpecialSyntax:
8990
return 9
90-
case .openingBrace:
91+
case .strongPunctuator:
9192
return 10
92-
case .closingBrace:
93+
case .openingBrace:
9394
return 11
94-
case .declKeyword:
95+
case .closingBrace:
9596
return 12
96-
case .openingPoundIf:
97+
case .declKeyword:
9798
return 13
98-
case .closingPoundIf:
99+
case .openingPoundIf:
99100
return 14
101+
case .closingPoundIf:
102+
return 15
100103
}
101104
}
102105

@@ -276,6 +279,21 @@ enum TokenPrecedence: Comparable {
276279
.transpose:
277280
self = .declarationAttributeWithSpecialSyntax
278281

282+
case // `TypeAttribute`
283+
._local,
284+
._noMetadata,
285+
._opaqueReturnTypeOf,
286+
.async,
287+
.autoclosure,
288+
.convention,
289+
.differentiable,
290+
.escaping,
291+
.noDerivative,
292+
.noescape,
293+
.Sendable,
294+
.unchecked:
295+
self = .typeKeyword
296+
279297
case // Treat all other keywords as expression keywords in the absence of any better information.
280298
.__owned,
281299
.__shared,
@@ -287,8 +305,6 @@ enum TokenPrecedence: Comparable {
287305
._move,
288306
._NativeClass,
289307
._NativeRefCountedObject,
290-
._noMetadata,
291-
._opaqueReturnTypeOf,
292308
._PackageDescription,
293309
._RefCountedObject,
294310
._Trivial,
@@ -300,16 +316,13 @@ enum TokenPrecedence: Comparable {
300316
.any,
301317
.assignment,
302318
.associativity,
303-
.autoclosure,
304319
.availability,
305320
.before,
306321
.block,
307322
.canImport,
308323
.compiler,
309-
.convention,
310324
.cType,
311325
.deprecated,
312-
.escaping,
313326
.exported,
314327
.file,
315328
.discard,
@@ -326,8 +339,6 @@ enum TokenPrecedence: Comparable {
326339
.metadata,
327340
.module,
328341
.noasync,
329-
.noDerivative,
330-
.noescape,
331342
.none,
332343
.obsoleted,
333344
.of,
@@ -336,15 +347,13 @@ enum TokenPrecedence: Comparable {
336347
.reverse,
337348
.right,
338349
.safe,
339-
.Sendable,
340350
.sourceFile,
341351
.spi,
342352
.spiModule,
343353
.swift,
344354
.target,
345355
.Type,
346356
.unavailable,
347-
.unchecked,
348357
.unowned,
349358
.visibility,
350359
.weak,

0 commit comments

Comments
 (0)