Skip to content

Commit 13458b6

Browse files
committed
cleanup
1 parent 23b80ac commit 13458b6

File tree

1 file changed

+8
-34
lines changed

1 file changed

+8
-34
lines changed

Sources/_MatchingEngine/Regex/Parse/CaptureStructure.swift

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ extension CaptureStructure {
4242
}
4343

4444
extension CaptureStructure.Constructor {
45-
private func atom(
46-
_ name: String? = nil , _ type: AnyType? = nil
47-
) -> CaptureStructure {
48-
.atom(name: name, type: type)
49-
}
50-
5145
public mutating func alternating<C: Collection>(
5246
_ children: C
5347
) -> CaptureStructure where C.Element: _TreeNode {
@@ -66,48 +60,28 @@ extension CaptureStructure.Constructor {
6660

6761
public mutating func grouping<T: _TreeNode>(
6862
_ child: T,
69-
as kind: AST.Group.Kind,
70-
withType type: AnyType? = nil
63+
as kind: AST.Group.Kind
7164
) -> CaptureStructure {
72-
let innerCaptures = child._captureStructure(&self)
7365
switch kind {
7466
case .capture:
75-
return atom(nil, type) + innerCaptures
67+
return capturing(child)
7668
case .namedCapture(let name):
77-
return atom(name.value, type) + innerCaptures
69+
return capturing(name: name.value, child)
7870
case .balancedCapture(let b):
79-
return atom(b.name?.value, type) + innerCaptures
71+
return capturing(name: b.name?.value, child)
8072
default:
8173
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)
10275
}
10376
}
10477

10578
public mutating func capturing<T: _TreeNode>(
106-
name: String?,
79+
name: String? = nil,
10780
_ child: T,
10881
withType type: AnyType? = nil
10982
) -> CaptureStructure {
110-
atom(name, type) + child._captureStructure(&self)
83+
.atom(name: name, type: type)
84+
+ child._captureStructure(&self)
11185
}
11286

11387
// TODO: We'll likely want/need a generalization of

0 commit comments

Comments
 (0)