mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
libSyntax: specialize struct declaration syntax node. (#13307)
To construct struct syntax, this patch first specialized type inheritance clause. For protocol's class requirement, we currently treat it as an unknown type. This patch also teaches SyntaxParsingContext to collect syntax nodes from back in place. This is useful to squash multiple decl modifiers for declarations like function. This is not used for struct declaration because only accessibility modifier is allowed.
This commit is contained in:
@@ -81,11 +81,20 @@ DECL_NODES = [
|
||||
Child('Detail', kind='TokenList'),
|
||||
]),
|
||||
|
||||
Node('InheritedType', kind='Syntax',
|
||||
children=[
|
||||
Child('TypeName', kind='Type'),
|
||||
Child('TrailingComma', kind='CommaToken', is_optional=True),
|
||||
]),
|
||||
|
||||
Node('InheritedTypeList', kind='SyntaxCollection',
|
||||
element='InheritedType'),
|
||||
|
||||
# type-inheritance-clause -> ':' type
|
||||
Node('TypeInheritanceClause', kind='Syntax',
|
||||
children=[
|
||||
Child('Colon', kind='ColonToken'),
|
||||
Child('InheritedType', kind='Type'),
|
||||
Child('InheritedTypeCollection', kind='InheritedTypeList'),
|
||||
]),
|
||||
|
||||
# struct-declaration -> attributes? access-level-modifier?
|
||||
@@ -99,7 +108,7 @@ DECL_NODES = [
|
||||
children=[
|
||||
Child('Attributes', kind='AttributeList',
|
||||
is_optional=True),
|
||||
Child('AccessLevelModifier', kind='AccessLevelModifier',
|
||||
Child('AccessLevelModifier', kind='DeclModifier',
|
||||
is_optional=True),
|
||||
Child('StructKeyword', kind='StructToken'),
|
||||
Child('Identifier', kind='IdentifierToken'),
|
||||
|
||||
Reference in New Issue
Block a user