Skip to content

Commit 18b2726

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

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 41 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,87 @@ 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+
279+
case // Treat all other keywords as expression keywords in the absence of any better information.
280+
.__owned,
281+
.__shared,
282+
._Class,
283+
._compilerInitialized,
284+
._const,
285+
._forward,
286+
._linear,
287+
._move,
288+
._NativeClass,
289+
._NativeRefCountedObject,
290+
._noMetadata,
291+
._opaqueReturnTypeOf,
292+
._PackageDescription,
293+
._RefCountedObject,
294+
._Trivial,
295+
._TrivialAtMost,
280296
._underlyingVersion,
281297
._UnknownLayout,
282298
._version,
283299
.accesses,
284300
.any,
285301
.assignment,
286302
.associativity,
287-
.attached,
288303
.autoclosure,
289304
.availability,
290-
.available,
291-
.backDeployed,
292305
.before,
293306
.block,
294307
.canImport,
295308
.compiler,
296309
.convention,
297310
.cType,
298311
.deprecated,
299-
.derivative,
300-
.differentiable,
301312
.escaping,
302-
.exclusivity,
303313
.exported,
304314
.file,
305315
.discard,
306316
.forward,
307317
.higherThan,
308318
.initializes,
309-
.inline,
310319
.introduced,
311320
.kind,
312321
.left,
@@ -320,7 +329,6 @@ enum TokenPrecedence: Comparable {
320329
.noDerivative,
321330
.noescape,
322331
.none,
323-
.objc,
324332
.obsoleted,
325333
.of,
326334
.Protocol,
@@ -334,7 +342,6 @@ enum TokenPrecedence: Comparable {
334342
.spiModule,
335343
.swift,
336344
.target,
337-
.transpose,
338345
.Type,
339346
.unavailable,
340347
.unchecked,

0 commit comments

Comments
 (0)