Skip to content

Commit a03ed43

Browse files
[Syntax] Add node definition for enums and enum cases (#15196)
1 parent 5795bdf commit a03ed43

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

utils/gyb_syntax_support/DeclNodes.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,98 @@
511511
]),
512512
Child('Bindings', kind='PatternBindingList'),
513513
]),
514+
515+
Node('EnumCaseElement', kind='Syntax',
516+
description='''
517+
An element of an enum case, containing the name of the case and, \
518+
optionally, either associated values or an assignment to a raw value.
519+
''',
520+
traits=['WithTrailingComma'],
521+
children=[
522+
Child('Identifier', kind='IdentifierToken',
523+
description='The name of this case.'),
524+
Child('AssociatedValue', kind='TupleType', is_optional=True,
525+
description='The set of associated values of the case.'),
526+
Child('EqualsToken', kind='EqualsToken', is_optional=True,
527+
description='''
528+
The equals token, if this case is assigned to a raw value.
529+
'''),
530+
Child('RawValue', kind='Expr', is_optional=True,
531+
description='''
532+
The raw value of this enum element, if present.
533+
'''),
534+
Child('TrailingComma', kind='CommaToken', is_optional=True,
535+
description='''
536+
The trailing comma of this element, if the case has \
537+
multiple elements.
538+
'''),
539+
]),
540+
541+
Node('EnumCaseElementList', kind='SyntaxCollection',
542+
description='A collection of 0 or more `EnumCaseElement`s.',
543+
element='EnumCaseElement'),
544+
545+
Node('EnumCaseDecl', kind='Decl',
546+
description='''
547+
A `case` declaration of a Swift `enum`. It can have 1 or more \
548+
`EnumCaseElement`s inside, each declaring a different case of the
549+
enum.
550+
''',
551+
children=[
552+
Child('IndirectKeyword', kind='IndirectToken', is_optional=True,
553+
description='''
554+
The `indirect` keyword, if this case is indirect.
555+
'''),
556+
Child('CaseKeyword', kind='CaseToken',
557+
description='The `case` keyword for this case.'),
558+
Child('Elements', kind='EnumCaseElementList',
559+
description='The elements this case declares.')
560+
]),
561+
562+
Node('EnumDecl', kind='Decl', traits=['IdentifiedDecl'],
563+
description='A Swift `enum` declaration.',
564+
children=[
565+
Child('Attributes', kind='AttributeList', is_optional=True,
566+
description='''
567+
The attributes applied to the enum declaration.
568+
'''),
569+
Child('Modifiers', kind='ModifierList', is_optional=True,
570+
description='''
571+
The declaration modifiers applied to the enum declaration.
572+
'''),
573+
Child('IndirectKeyword', kind='IndirectToken', is_optional=True,
574+
description='''
575+
The `indirect` keyword that applies to all cases in this \
576+
enum.
577+
'''),
578+
Child('EnumKeyword', kind='EnumToken',
579+
description='''
580+
The `enum` keyword for this declaration.
581+
'''),
582+
Child('Identifier', kind='IdentifierToken',
583+
description='''
584+
The name of this enum.
585+
'''),
586+
Child('GenericParameters', kind='GenericParameterClause',
587+
is_optional=True,
588+
description='''
589+
The generic parameters, if any, for this enum.
590+
'''),
591+
Child('InheritanceClause', kind='TypeInheritanceClause',
592+
is_optional=True,
593+
description='''
594+
The inheritance clause describing conformances or raw \
595+
values for this enum.
596+
'''),
597+
Child('GenericWhereClause', kind='GenericWhereClause',
598+
is_optional=True,
599+
description='''
600+
The `where` clause that applies to the generic parameters of \
601+
this enum.
602+
'''),
603+
Child('Members', kind='MemberDeclBlock',
604+
description='''
605+
The cases and other members of this enum.
606+
''')
607+
]),
514608
]

0 commit comments

Comments
 (0)