1313//===----------------------------------------------------------------------===//
1414
1515public let ATTRIBUTE_NODES : [ Node ] = [
16+ // attribute-list -> attribute attribute-list?
1617 Node ( name: " AttributeList " ,
1718 nameForDiagnostics: " attributes " ,
1819 kind: " SyntaxCollection " ,
@@ -21,6 +22,16 @@ public let ATTRIBUTE_NODES: [Node] = [
2122 elementChoices: [ " Attribute " , " IfConfigDecl " ] ,
2223 omitWhenEmpty: true ) ,
2324
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+ // )? ')'?
2435 Node ( name: " Attribute " ,
2536 nameForDiagnostics: " attribute " ,
2637 description: " An `@` attribute. " ,
@@ -108,6 +119,7 @@ public let ATTRIBUTE_NODES: [Node] = [
108119 kind: . token( choices: [ . token( tokenKind: " SemicolonToken " ) ] ) )
109120 ] ) ,
110121
122+ // back-deploy-version-entry -> availability-version-restriction ','?
111123 Node ( name: " AvailabilityVersionRestrictionListEntry " ,
112124 nameForDiagnostics: " version " ,
113125 description: " A single platform/version pair in an attribute, e.g. `iOS 10.1`. " ,
@@ -122,11 +134,15 @@ public let ATTRIBUTE_NODES: [Node] = [
122134 isOptional: true )
123135 ] ) ,
124136
137+ // back-deploy-version-list ->
138+ // back-deploy-version-entry back-deploy-version-list?
125139 Node ( name: " AvailabilityVersionRestrictionList " ,
126140 nameForDiagnostics: " version list " ,
127141 kind: " SyntaxCollection " ,
128142 element: " AvailabilityVersionRestrictionListEntry " ) ,
129143
144+ // The arguments of '@backDeployed(...)'
145+ // back-deployed-attr-spec-list -> 'before' ':' back-deployed-version-list
130146 Node ( name: " BackDeployedAttributeSpecList " ,
131147 nameForDiagnostics: " '@backDeployed' arguments " ,
132148 description: " A collection of arguments for the `@backDeployed` attribute " ,
@@ -143,6 +159,7 @@ public let ATTRIBUTE_NODES: [Node] = [
143159 description: " The list of OS versions in which the declaration became ABI stable. " )
144160 ] ) ,
145161
162+ // convention-attribute-arguments -> token ',' 'cType'? ':' string-literal
146163 Node ( name: " ConventionAttributeArguments " ,
147164 nameForDiagnostics: " @convention(...) arguments " ,
148165 description: " The arguments for the '@convention(...)'. " ,
@@ -165,6 +182,7 @@ public let ATTRIBUTE_NODES: [Node] = [
165182 isOptional: true )
166183 ] ) ,
167184
185+ // convention-attribute-arguments -> 'witness_method' ':' identifier
168186 Node ( name: " ConventionWitnessMethodAttributeArguments " ,
169187 nameForDiagnostics: " @convention(...) arguments for witness methods " ,
170188 description: " The arguments for the '@convention(witness_method: ...)'. " ,
@@ -193,6 +211,12 @@ public let ATTRIBUTE_NODES: [Node] = [
193211 isOptional: true )
194212 ] ) ,
195213
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?
196220 Node ( name: " DerivativeRegistrationAttributeArguments " ,
197221 nameForDiagnostics: " attribute arguments " ,
198222 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] = [
223247 isOptional: true )
224248 ] ) ,
225249
250+ // differentiability-param-list ->
251+ // differentiability-param differentiability-param-list?
226252 Node ( name: " DifferentiabilityParamList " ,
227253 nameForDiagnostics: " differentiability parameters " ,
228254 kind: " SyntaxCollection " ,
229255 element: " DifferentiabilityParam " ) ,
230256
257+ // differentiability-param -> ('self' | identifier | integer-literal) ','?
231258 Node ( name: " DifferentiabilityParam " ,
232259 nameForDiagnostics: " differentiability parameter " ,
233260 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] = [
243270 isOptional: true )
244271 ] ) ,
245272
273+ // differentiability-params-clause ->
274+ // 'wrt' ':' (differentiability-param | differentiability-params)
246275 Node ( name: " DifferentiabilityParamsClause " ,
247276 nameForDiagnostics: " '@differentiable' argument " ,
248277 description: " A clause containing differentiability parameters. " ,
@@ -264,6 +293,7 @@ public let ATTRIBUTE_NODES: [Node] = [
264293 nameForDiagnostics: " parameters " )
265294 ] ) ,
266295
296+ // differentiability-params -> '(' differentiability-param-list ')'
267297 Node ( name: " DifferentiabilityParams " ,
268298 nameForDiagnostics: " differentiability parameters " ,
269299 description: " The differentiability parameters. " ,
@@ -278,6 +308,10 @@ public let ATTRIBUTE_NODES: [Node] = [
278308 kind: . token( choices: [ . token( tokenKind: " RightParenToken " ) ] ) )
279309 ] ) ,
280310
311+ // The argument of '@differentiable(...)'.
312+ // differentiable-attr-arguments ->
313+ // differentiability-kind? '.'? differentiability-params-clause? ','?
314+ // generic-where-clause?
281315 Node ( name: " DifferentiableAttributeArguments " ,
282316 nameForDiagnostics: " '@differentiable' arguments " ,
283317 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] = [
317351 Child ( name: " Value " ,
318352 kind: . nodeChoices( choices: [
319353 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
321355 Child ( name: " String " ,
322356 kind: . node( kind: " StringLiteralExpr " ) )
323357 ] ) ) ,
@@ -367,6 +401,9 @@ public let ATTRIBUTE_NODES: [Node] = [
367401 isOptional: true )
368402 ] ) ,
369403
404+ // The argument of '@_implements(...)'
405+ // implements-attr-arguments -> simple-type-identifier ','
406+ // (identifier | operator) decl-name-arguments
370407 Node ( name: " ImplementsAttributeArguments " ,
371408 nameForDiagnostics: " @_implements arguemnts " ,
372409 description: " The arguments for the `@_implements` attribute of the form `Type, methodName(arg1Label:arg2Label:)` " ,
@@ -390,6 +427,8 @@ public let ATTRIBUTE_NODES: [Node] = [
390427 isOptional: true )
391428 ] ) ,
392429
430+ // Representation of e.g. 'exported: true,'
431+ // labeled-specialize-entry -> identifier ':' token ','?
393432 Node ( name: " LabeledSpecializeEntry " ,
394433 nameForDiagnostics: " attribute argument " ,
395434 description: " A labeled argument for the `@_specialize` attribute like `exported: true` " ,
@@ -415,6 +454,7 @@ public let ATTRIBUTE_NODES: [Node] = [
415454 isOptional: true )
416455 ] ) ,
417456
457+ // objc-selector-piece -> identifier? ':'?
418458 Node ( name: " ObjCSelectorPiece " ,
419459 nameForDiagnostics: " Objective-C selector piece " ,
420460 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] = [
429469 isOptional: true )
430470 ] ) ,
431471
472+ // objc-selector -> objc-selector-piece objc-selector?
432473 Node ( name: " ObjCSelector " ,
433474 nameForDiagnostics: " Objective-C selector " ,
434475 kind: " SyntaxCollection " ,
435476 element: " ObjCSelectorPiece " ) ,
436477
478+ // opaque-return-type-of-arguments -> string-literal ',' integer-literal
437479 Node ( name: " OpaqueReturnTypeOfAttributeArguments " ,
438480 nameForDiagnostics: " opaque return type arguments " ,
439481 description: " The arguments for the '@_opaqueReturnTypeOf()'. " ,
@@ -466,6 +508,15 @@ public let ATTRIBUTE_NODES: [Node] = [
466508 kind: . collection( kind: " AvailabilityVersionRestrictionList " , collectionElementName: " Platform " ) )
467509 ] ) ,
468510
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
469520 Node ( name: " QualifiedDeclName " ,
470521 nameForDiagnostics: " declaration name " ,
471522 description: " An optionally qualified function declaration name (e.g. `+(_:_:)`, `A.B.C.foo(_:_:)`). " ,
@@ -490,6 +541,11 @@ public let ATTRIBUTE_NODES: [Node] = [
490541 isOptional: true )
491542 ] ) ,
492543
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?
493549 Node ( name: " SpecializeAttributeSpecList " ,
494550 nameForDiagnostics: " argument to '@_specialize " ,
495551 description: " A collection of arguments for the `@_specialize` attribute " ,
@@ -498,6 +554,8 @@ public let ATTRIBUTE_NODES: [Node] = [
498554 elementName: " SpecializeAttribute " ,
499555 elementChoices: [ " LabeledSpecializeEntry " , " AvailabilityEntry " , " TargetFunctionEntry " , " GenericWhereClause " ] ) ,
500556
557+ // Representation of e.g. 'exported: true,'
558+ // labeled-specialize-entry -> identifier ':' token ','?
501559 Node ( name: " TargetFunctionEntry " ,
502560 nameForDiagnostics: " attribute argument " ,
503561 description: " A labeled argument for the `@_specialize` attribute with a function decl value like `target: myFunc(_:)` " ,
0 commit comments