13
13
//===----------------------------------------------------------------------===//
14
14
15
15
public let ATTRIBUTE_NODES : [ Node ] = [
16
+ // attribute-list -> attribute attribute-list?
16
17
Node ( name: " AttributeList " ,
17
18
nameForDiagnostics: " attributes " ,
18
19
kind: " SyntaxCollection " ,
@@ -21,6 +22,16 @@ public let ATTRIBUTE_NODES: [Node] = [
21
22
elementChoices: [ " Attribute " , " IfConfigDecl " ] ,
22
23
omitWhenEmpty: true ) ,
23
24
25
+ // attribute -> '@' identifier '('?
26
+ // ( identifier
27
+ // | string-literal
28
+ // | integer-literal
29
+ // | availability-spec-list
30
+ // | specialize-attr-spec-list
31
+ // | implements-attr-arguments
32
+ // | named-attribute-string-argument
33
+ // | back-deploy-attr-spec-list
34
+ // )? ')'?
24
35
Node ( name: " Attribute " ,
25
36
nameForDiagnostics: " attribute " ,
26
37
description: " An `@` attribute. " ,
@@ -108,6 +119,7 @@ public let ATTRIBUTE_NODES: [Node] = [
108
119
kind: . token( choices: [ . token( tokenKind: " SemicolonToken " ) ] ) )
109
120
] ) ,
110
121
122
+ // back-deploy-version-entry -> availability-version-restriction ','?
111
123
Node ( name: " AvailabilityVersionRestrictionListEntry " ,
112
124
nameForDiagnostics: " version " ,
113
125
description: " A single platform/version pair in an attribute, e.g. `iOS 10.1`. " ,
@@ -122,11 +134,15 @@ public let ATTRIBUTE_NODES: [Node] = [
122
134
isOptional: true )
123
135
] ) ,
124
136
137
+ // back-deploy-version-list ->
138
+ // back-deploy-version-entry back-deploy-version-list?
125
139
Node ( name: " AvailabilityVersionRestrictionList " ,
126
140
nameForDiagnostics: " version list " ,
127
141
kind: " SyntaxCollection " ,
128
142
element: " AvailabilityVersionRestrictionListEntry " ) ,
129
143
144
+ // The arguments of '@backDeployed(...)'
145
+ // back-deployed-attr-spec-list -> 'before' ':' back-deployed-version-list
130
146
Node ( name: " BackDeployedAttributeSpecList " ,
131
147
nameForDiagnostics: " '@backDeployed' arguments " ,
132
148
description: " A collection of arguments for the `@backDeployed` attribute " ,
@@ -143,6 +159,7 @@ public let ATTRIBUTE_NODES: [Node] = [
143
159
description: " The list of OS versions in which the declaration became ABI stable. " )
144
160
] ) ,
145
161
162
+ // convention-attribute-arguments -> token ',' 'cType'? ':' string-literal
146
163
Node ( name: " ConventionAttributeArguments " ,
147
164
nameForDiagnostics: " @convention(...) arguments " ,
148
165
description: " The arguments for the '@convention(...)'. " ,
@@ -165,6 +182,7 @@ public let ATTRIBUTE_NODES: [Node] = [
165
182
isOptional: true )
166
183
] ) ,
167
184
185
+ // convention-attribute-arguments -> 'witness_method' ':' identifier
168
186
Node ( name: " ConventionWitnessMethodAttributeArguments " ,
169
187
nameForDiagnostics: " @convention(...) arguments for witness methods " ,
170
188
description: " The arguments for the '@convention(witness_method: ...)'. " ,
@@ -193,6 +211,12 @@ public let ATTRIBUTE_NODES: [Node] = [
193
211
isOptional: true )
194
212
] ) ,
195
213
214
+ // The argument of the derivative registration attribute
215
+ // '@derivative(of: ...)' and the transpose registration attribute
216
+ // '@transpose(of: ...)'.
217
+ //
218
+ // derivative-registration-attr-arguments ->
219
+ // 'of' ':' func-decl-name ','? differentiability-params-clause?
196
220
Node ( name: " DerivativeRegistrationAttributeArguments " ,
197
221
nameForDiagnostics: " attribute arguments " ,
198
222
description: " The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list. " ,
@@ -223,11 +247,14 @@ public let ATTRIBUTE_NODES: [Node] = [
223
247
isOptional: true )
224
248
] ) ,
225
249
250
+ // differentiability-param-list ->
251
+ // differentiability-param differentiability-param-list?
226
252
Node ( name: " DifferentiabilityParamList " ,
227
253
nameForDiagnostics: " differentiability parameters " ,
228
254
kind: " SyntaxCollection " ,
229
255
element: " DifferentiabilityParam " ) ,
230
256
257
+ // differentiability-param -> ('self' | identifier | integer-literal) ','?
231
258
Node ( name: " DifferentiabilityParam " ,
232
259
nameForDiagnostics: " differentiability parameter " ,
233
260
description: " A differentiability parameter: either the \" self \" identifier, a function parameter name, or a function parameter index. " ,
@@ -243,6 +270,8 @@ public let ATTRIBUTE_NODES: [Node] = [
243
270
isOptional: true )
244
271
] ) ,
245
272
273
+ // differentiability-params-clause ->
274
+ // 'wrt' ':' (differentiability-param | differentiability-params)
246
275
Node ( name: " DifferentiabilityParamsClause " ,
247
276
nameForDiagnostics: " '@differentiable' argument " ,
248
277
description: " A clause containing differentiability parameters. " ,
@@ -264,6 +293,7 @@ public let ATTRIBUTE_NODES: [Node] = [
264
293
nameForDiagnostics: " parameters " )
265
294
] ) ,
266
295
296
+ // differentiability-params -> '(' differentiability-param-list ')'
267
297
Node ( name: " DifferentiabilityParams " ,
268
298
nameForDiagnostics: " differentiability parameters " ,
269
299
description: " The differentiability parameters. " ,
@@ -278,6 +308,10 @@ public let ATTRIBUTE_NODES: [Node] = [
278
308
kind: . token( choices: [ . token( tokenKind: " RightParenToken " ) ] ) )
279
309
] ) ,
280
310
311
+ // The argument of '@differentiable(...)'.
312
+ // differentiable-attr-arguments ->
313
+ // differentiability-kind? '.'? differentiability-params-clause? ','?
314
+ // generic-where-clause?
281
315
Node ( name: " DifferentiableAttributeArguments " ,
282
316
nameForDiagnostics: " '@differentiable' arguments " ,
283
317
description: " The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause. " ,
@@ -317,7 +351,7 @@ public let ATTRIBUTE_NODES: [Node] = [
317
351
Child ( name: " Value " ,
318
352
kind: . nodeChoices( choices: [
319
353
Child ( name: " Token " ,
320
- kind: . token( choices: [ . token( tokenKind: " IdentifierToken " ) , . token( tokenKind: " KeywordToken " ) ] ) ) ,
354
+ kind: . token( choices: [ . token( tokenKind: " IdentifierToken " ) , . token( tokenKind: " KeywordToken " ) ] ) ) , // Keywords can be: public, internal, private, fileprivate, open
321
355
Child ( name: " String " ,
322
356
kind: . node( kind: " StringLiteralExpr " ) )
323
357
] ) ) ,
@@ -367,6 +401,9 @@ public let ATTRIBUTE_NODES: [Node] = [
367
401
isOptional: true )
368
402
] ) ,
369
403
404
+ // The argument of '@_implements(...)'
405
+ // implements-attr-arguments -> simple-type-identifier ','
406
+ // (identifier | operator) decl-name-arguments
370
407
Node ( name: " ImplementsAttributeArguments " ,
371
408
nameForDiagnostics: " @_implements arguemnts " ,
372
409
description: " The arguments for the `@_implements` attribute of the form `Type, methodName(arg1Label:arg2Label:)` " ,
@@ -390,6 +427,8 @@ public let ATTRIBUTE_NODES: [Node] = [
390
427
isOptional: true )
391
428
] ) ,
392
429
430
+ // Representation of e.g. 'exported: true,'
431
+ // labeled-specialize-entry -> identifier ':' token ','?
393
432
Node ( name: " LabeledSpecializeEntry " ,
394
433
nameForDiagnostics: " attribute argument " ,
395
434
description: " A labeled argument for the `@_specialize` attribute like `exported: true` " ,
@@ -415,6 +454,7 @@ public let ATTRIBUTE_NODES: [Node] = [
415
454
isOptional: true )
416
455
] ) ,
417
456
457
+ // objc-selector-piece -> identifier? ':'?
418
458
Node ( name: " ObjCSelectorPiece " ,
419
459
nameForDiagnostics: " Objective-C selector piece " ,
420
460
description: " A piece of an Objective-C selector. Either consisting of just an identifier for a nullary selector, an identifier and a colon for a labeled argument or just a colon for an unlabeled argument " ,
@@ -429,11 +469,13 @@ public let ATTRIBUTE_NODES: [Node] = [
429
469
isOptional: true )
430
470
] ) ,
431
471
472
+ // objc-selector -> objc-selector-piece objc-selector?
432
473
Node ( name: " ObjCSelector " ,
433
474
nameForDiagnostics: " Objective-C selector " ,
434
475
kind: " SyntaxCollection " ,
435
476
element: " ObjCSelectorPiece " ) ,
436
477
478
+ // opaque-return-type-of-arguments -> string-literal ',' integer-literal
437
479
Node ( name: " OpaqueReturnTypeOfAttributeArguments " ,
438
480
nameForDiagnostics: " opaque return type arguments " ,
439
481
description: " The arguments for the '@_opaqueReturnTypeOf()'. " ,
@@ -466,6 +508,15 @@ public let ATTRIBUTE_NODES: [Node] = [
466
508
kind: . collection( kind: " AvailabilityVersionRestrictionList " , collectionElementName: " Platform " ) )
467
509
] ) ,
468
510
511
+ // An optionally qualified declaration name.
512
+ // Currently used only for `@derivative` and `@transpose` attribute.
513
+ // TODO(TF-1066): Use module qualified name syntax/parsing instead of custom
514
+ // qualified name syntax/parsing.
515
+ //
516
+ // qualified-decl-name ->
517
+ // base-type? '.'? (identifier | operator) decl-name-arguments?
518
+ // base-type ->
519
+ // member-type-identifier | base-type-identifier
469
520
Node ( name: " QualifiedDeclName " ,
470
521
nameForDiagnostics: " declaration name " ,
471
522
description: " An optionally qualified function declaration name (e.g. `+(_:_:)`, `A.B.C.foo(_:_:)`). " ,
@@ -490,6 +541,11 @@ public let ATTRIBUTE_NODES: [Node] = [
490
541
isOptional: true )
491
542
] ) ,
492
543
544
+ // The argument of '@_specialize(...)'
545
+ // specialize-attr-spec-list -> labeled-specialize-entry
546
+ // specialize-spec-attr-list?
547
+ // | generic-where-clause
548
+ // specialize-spec-attr-list?
493
549
Node ( name: " SpecializeAttributeSpecList " ,
494
550
nameForDiagnostics: " argument to '@_specialize " ,
495
551
description: " A collection of arguments for the `@_specialize` attribute " ,
@@ -498,6 +554,8 @@ public let ATTRIBUTE_NODES: [Node] = [
498
554
elementName: " SpecializeAttribute " ,
499
555
elementChoices: [ " LabeledSpecializeEntry " , " AvailabilityEntry " , " TargetFunctionEntry " , " GenericWhereClause " ] ) ,
500
556
557
+ // Representation of e.g. 'exported: true,'
558
+ // labeled-specialize-entry -> identifier ':' token ','?
501
559
Node ( name: " TargetFunctionEntry " ,
502
560
nameForDiagnostics: " attribute argument " ,
503
561
description: " A labeled argument for the `@_specialize` attribute with a function decl value like `target: myFunc(_:)` " ,
0 commit comments