Skip to content

Commit c646b27

Browse files
committed
Add new group for special declarations attributes with spacial syntax
1 parent 3e14cfe commit c646b27

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 40 additions & 34 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 declarationAttributeWithSpecialSyntax
3940
/// The '{' token because it typically marks the body of a declaration.
4041
/// `closingDelimiter` must have type `strongPunctuator`
4142
case openingBrace(closingDelimiter: RawTokenKind)
@@ -82,18 +83,20 @@ enum TokenPrecedence: Comparable {
8283
return 6
8384
case .stmtKeyword:
8485
return 7
85-
case .strongPunctuator:
86+
case .declarationAttributeWithSpecialSyntax:
8687
return 8
87-
case .openingBrace:
88+
case .strongPunctuator:
8889
return 9
89-
case .closingBrace:
90+
case .openingBrace:
9091
return 10
91-
case .declKeyword:
92+
case .closingBrace:
9293
return 11
93-
case .openingPoundIf:
94+
case .declKeyword:
9495
return 12
95-
case .closingPoundIf:
96+
case .openingPoundIf:
9697
return 13
98+
case .closingPoundIf:
99+
return 14
97100
}
98101
}
99102

@@ -232,81 +235,86 @@ enum TokenPrecedence: Comparable {
232235
.__setter_access, .indirect, .isolated, .nonisolated, .distributed, ._local,
233236
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume,
234237
// Accessors
235-
.get, .set, .didSet, .willSet,.unsafeAddress, .addressWithOwner, .addressWithNativeOwner, .unsafeMutableAddress,
238+
.get, .set, .didSet, .willSet, .unsafeAddress, .addressWithOwner, .addressWithNativeOwner, .unsafeMutableAddress,
236239
.mutableAddressWithOwner, .mutableAddressWithNativeOwner, ._read, ._modify,
237240
// Misc
238241
.import:
239242
self = .declKeyword
240243

241-
case // Treat all other keywords as expression keywords in the absence of any better information.
242-
.__owned,
243-
.__shared,
244-
._alignment,
244+
case // `DeclarationAttributeWithSpecialSyntax`
245+
._alignment,
245246
._backDeploy,
246247
._cdecl,
247-
._Class,
248-
._compilerInitialized,
249-
._const,
250248
._documentation,
251249
._dynamicReplacement,
252250
._effects,
253251
._expose,
254-
._forward,
255252
._implements,
256-
._linear,
257-
._move,
258-
._NativeClass,
259-
._NativeRefCountedObject,
260-
._noMetadata,
261253
._nonSendable,
262254
._objcImplementation,
263255
._objcRuntimeName,
264-
._opaqueReturnTypeOf,
265256
._optimize,
266257
._originallyDefinedIn,
267-
._PackageDescription,
268258
._private,
269259
._projectedValueProperty,
270-
._RefCountedObject,
271260
._semantics,
272261
._specialize,
273262
._spi,
274263
._spi_available,
275264
._swift_native_objc_runtime_base,
276-
._Trivial,
277-
._TrivialAtMost,
278265
._typeEraser,
279266
._unavailableFromAsync,
267+
.`rethrows`,
268+
.attached,
269+
.available,
270+
.backDeployed,
271+
.derivative,
272+
.differentiable,
273+
.exclusivity,
274+
.inline,
275+
.objc,
276+
.transpose:
277+
self = .declarationAttributeWithSpecialSyntax
278+
case // Treat all other keywords as expression keywords in the absence of any better information.
279+
.__owned,
280+
.__shared,
281+
._Class,
282+
._compilerInitialized,
283+
._const,
284+
._forward,
285+
._linear,
286+
._move,
287+
._NativeClass,
288+
._NativeRefCountedObject,
289+
._noMetadata,
290+
._opaqueReturnTypeOf,
291+
._PackageDescription,
292+
._RefCountedObject,
293+
._Trivial,
294+
._TrivialAtMost,
280295
._underlyingVersion,
281296
._UnknownLayout,
282297
._version,
283298
.accesses,
284299
.any,
285300
.assignment,
286301
.associativity,
287-
.attached,
288302
.autoclosure,
289303
.availability,
290-
.available,
291-
.backDeployed,
292304
.before,
293305
.block,
294306
.canImport,
295307
.compiler,
296308
.convention,
297309
.cType,
298310
.deprecated,
299-
.derivative,
300-
.differentiable,
301311
.escaping,
302-
.exclusivity,
303312
.exported,
304313
.file,
305314
.discard,
306315
.forward,
307316
.higherThan,
308317
.initializes,
309-
.inline,
310318
.introduced,
311319
.kind,
312320
.left,
@@ -320,7 +328,6 @@ enum TokenPrecedence: Comparable {
320328
.noDerivative,
321329
.noescape,
322330
.none,
323-
.objc,
324331
.obsoleted,
325332
.of,
326333
.Protocol,
@@ -334,7 +341,6 @@ enum TokenPrecedence: Comparable {
334341
.spiModule,
335342
.swift,
336343
.target,
337-
.transpose,
338344
.Type,
339345
.unavailable,
340346
.unchecked,

0 commit comments

Comments
 (0)