21
21
22
22
% {
23
23
"""
24
- Each Syntax node implements the protocol of a more generic node. For example,
25
- StructDeclSyntax implements DeclSyntax and can be used in contexts
26
- where DeclSyntax is expected.
27
-
28
- Each node will have:
29
- - An accessor for each child that will lazily instantiate it.
30
- - A `withX(_ x: XSyntax)` method for each child that will return a new Syntax
31
- node with the existing X child replaced with the passed-in version. This is a
32
- way to incrementally transform nodes in the tree.
33
- - An `addX(_ x: XSyntax)` method for children that are collections. This will
34
- append the provided node to the collection and return a new node with that
35
- collection replaced.
24
+ This gyb-file generates the syntax nodes for SwiftSyntax. To keep the generated
25
+ files at a managable file size, it is to be invoked multiple times with the
26
+ global variable EMIT_KIND set to a base kind listed in
27
+ gyb_syntax_support/kinds.py:SYNTAX_BASE_KINDES. It then only emits those syntax
28
+ nodes whose base kind are that specified kind.
36
29
"""
37
30
} %
38
31
@@ -44,6 +37,8 @@ Each node will have:
44
37
% elif node. collection_element:
45
38
% # Handled in SyntaxCollections. swift. gyb
46
39
% pass
40
+ % elif node. base_kind != EMIT_KIND:
41
+ % pass
47
42
% else:
48
43
% # We are actually handling this node now
49
44
// MARK: - ${node.name}
@@ -84,7 +79,6 @@ public struct ${node.name}: ${base_type}Protocol {
84
79
assert ( data. raw. kind == . ${ node. swift_syntax_kind} )
85
80
self . _syntaxNode = Syntax ( data)
86
81
}
87
-
88
82
% for child in node. children:
89
83
% child_node = NODE_MAP . get ( child. syntax_kind)
90
84
%
0 commit comments