@@ -42,12 +42,6 @@ extension CaptureStructure {
42
42
}
43
43
44
44
extension CaptureStructure . Constructor {
45
- private func atom(
46
- _ name: String ? = nil , _ type: AnyType ? = nil
47
- ) -> CaptureStructure {
48
- . atom( name: name, type: type)
49
- }
50
-
51
45
public mutating func alternating< C: Collection > (
52
46
_ children: C
53
47
) -> CaptureStructure where C. Element: _TreeNode {
@@ -66,48 +60,28 @@ extension CaptureStructure.Constructor {
66
60
67
61
public mutating func grouping< T: _TreeNode > (
68
62
_ child: T ,
69
- as kind: AST . Group . Kind ,
70
- withType type: AnyType ? = nil
63
+ as kind: AST . Group . Kind
71
64
) -> CaptureStructure {
72
- let innerCaptures = child. _captureStructure ( & self )
73
65
switch kind {
74
66
case . capture:
75
- return atom ( nil , type ) + innerCaptures
67
+ return capturing ( child )
76
68
case . namedCapture( let name) :
77
- return atom ( name. value, type ) + innerCaptures
69
+ return capturing ( name: name . value, child )
78
70
case . balancedCapture( let b) :
79
- return atom ( b. name? . value, type ) + innerCaptures
71
+ return capturing ( name : b. name? . value, child )
80
72
default :
81
73
precondition ( !kind. isCapturing)
82
- return innerCaptures
83
- }
84
- }
85
-
86
- public mutating func grouping< T: _TreeNode > (
87
- _ child: T ,
88
- as kind: AST . Group . Kind ,
89
- withTransform transform: CaptureTransform
90
- ) -> CaptureStructure {
91
- let innerCaptures = child. _captureStructure ( & self )
92
- let type = AnyType ( transform. resultType)
93
- switch kind {
94
- case . capture:
95
- return atom ( nil , type) + innerCaptures
96
- case . namedCapture( let name) :
97
- return atom ( name. value, type) + innerCaptures
98
- case . balancedCapture( let b) :
99
- return atom ( b. name? . value, type) + innerCaptures
100
- default :
101
- return innerCaptures
74
+ return child. _captureStructure ( & self )
102
75
}
103
76
}
104
77
105
78
public mutating func capturing< T: _TreeNode > (
106
- name: String ? ,
79
+ name: String ? = nil ,
107
80
_ child: T ,
108
81
withType type: AnyType ? = nil
109
82
) -> CaptureStructure {
110
- atom ( name, type) + child. _captureStructure ( & self )
83
+ . atom( name: name, type: type)
84
+ + child. _captureStructure ( & self )
111
85
}
112
86
113
87
// TODO: We'll likely want/need a generalization of
0 commit comments