Skip to content

Commit 37095f0

Browse files
committed
Let's use the right name for the list
1 parent f343f04 commit 37095f0

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

Sources/_StringProcessing/LiteralPrinter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension Regex {
3636
@available(SwiftStdlib 6.0, *)
3737
public var _literalPattern: String? {
3838
var gen = LiteralPrinter(options: MatchingOptions())
39-
var list = self.program.tree.nodes[...]
39+
var list = self.program.list.nodes[...]
4040
try? gen.outputList(&list)
4141
return gen.canonicalLiteralString
4242
}

Sources/_StringProcessing/Regex/AnyRegexOutput.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ extension Regex {
265265
/// - Parameter name: The name to look for among the regular expression's
266266
/// capture groups. Capture group names are case sensitive.
267267
public func contains(captureNamed name: String) -> Bool {
268-
program.tree.captureList.captures.contains(where: {
268+
program.list.captureList.captures.contains(where: {
269269
$0.name == name
270270
})
271271
}

Sources/_StringProcessing/Regex/Core.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public struct Regex<Output>: RegexComponent {
9393
let program: Program
9494

9595
var hasCapture: Bool {
96-
program.tree.hasCapture
96+
program.list.hasCapture
9797
}
9898
var hasChildren: Bool {
99-
program.tree.hasChildren
99+
program.list.hasChildren
100100
}
101101

102102
init(ast: AST) {
@@ -153,7 +153,7 @@ extension Regex {
153153
/// FIXME: If Regex is the unit of composition, then it should be a Node instead,
154154
/// and we should have a separate type that handled both global options and,
155155
/// likely, compilation/caching.
156-
var tree: DSLList
156+
var list: DSLList
157157

158158
/// OptionSet of compiler options for testing purposes
159159
fileprivate var compileOptions: _CompileOptions = .default
@@ -183,7 +183,7 @@ extension Regex {
183183
}
184184

185185
// Compile the DSLTree into a lowered program and store it atomically.
186-
let compiledProgram = try! Compiler(tree: tree, compileOptions: compileOptions).emit()
186+
let compiledProgram = try! Compiler(tree: list, compileOptions: compileOptions).emit()
187187
let storedNewProgram = _stdlib_atomicInitializeARCRef(
188188
object: _loweredProgramStoragePtr,
189189
desired: ProgramBox(compiledProgram))
@@ -196,15 +196,15 @@ extension Regex {
196196
}
197197

198198
init(ast: AST) {
199-
self.tree = DSLList(ast: ast)
199+
self.list = DSLList(ast: ast)
200200
}
201201

202202
init(tree: DSLTree) {
203-
self.tree = DSLList(tree: tree)
203+
self.list = DSLList(tree: tree)
204204
}
205205

206206
init(list: DSLList) {
207-
self.tree = list
207+
self.list = list
208208
}
209209
}
210210

@@ -228,7 +228,7 @@ extension Regex {
228228
// }
229229

230230
var list: DSLList {
231-
program.tree
231+
program.list
232232
}
233233

234234
init(node: DSLTree.Node) {
@@ -240,19 +240,19 @@ extension Regex {
240240
}
241241

242242
func appending<T>(_ node: DSLTree.Node) -> Regex<T> {
243-
var list = program.tree
243+
var list = program.list
244244
list.append(node)
245245
return Regex<T>(list: list)
246246
}
247247

248248
func appending<T>(contentsOf node: some Collection<DSLTree.Node>) -> Regex<T> {
249-
var list = program.tree
249+
var list = program.list
250250
list.append(contentsOf: node)
251251
return Regex<T>(list: list)
252252
}
253253

254254
func concatenating<T>(_ other: some Collection<DSLTree.Node>) -> Regex<T> {
255-
var nodes = program.tree.nodes
255+
var nodes = program.list.nodes
256256
switch nodes[0] {
257257
case .concatenation(let children):
258258
nodes[0] = .concatenation(Array(repeating: TEMP_FAKE_NODE, count: children.count + 1))
@@ -265,7 +265,7 @@ extension Regex {
265265
}
266266

267267
func alternating<T>(with other: some Collection<DSLTree.Node>) -> Regex<T> {
268-
var nodes = program.tree.nodes
268+
var nodes = program.list.nodes
269269
switch nodes[0] {
270270
case .orderedChoice(let children):
271271
nodes[0] = .orderedChoice(Array(repeating: TEMP_FAKE_NODE, count: children.count + 1))
@@ -278,13 +278,13 @@ extension Regex {
278278
}
279279

280280
func prepending<T>(_ node: DSLTree.Node) -> Regex<T> {
281-
var list = program.tree
281+
var list = program.list
282282
list.prepend(node)
283283
return Regex<T>(list: list)
284284
}
285285

286286
func prepending<T>(contentsOf node: some Collection<DSLTree.Node>) -> Regex<T> {
287-
var list = program.tree
287+
var list = program.list
288288
list.prepend(contentsOf: node)
289289
return Regex<T>(list: list)
290290
}
@@ -309,7 +309,7 @@ extension Regex {
309309
return true
310310
case .recompile:
311311
let _ = try Compiler(
312-
tree: program.tree,
312+
tree: program.list,
313313
compileOptions: program.compileOptions).emit()
314314
return true
315315
}

Sources/_StringProcessing/Regex/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ extension RegexComponent {
295295
? AST.MatchingOptionSequence(adding: [.init(option, location: .fake)])
296296
: AST.MatchingOptionSequence(removing: [.init(option, location: .fake)])
297297

298-
var list = regex.program.tree
298+
var list = regex.program.list
299299
list.nodes.insert(.nonCapturingGroup(.init(ast: .changeMatchingOptions(sequence)), TEMP_FAKE_NODE), at: 0)
300300
return Regex(list: list)
301301
}

Sources/_StringProcessing/Utility/RegexFactory.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ public struct _RegexFactory {
2828
// Don't wrap `child` again if it's a leaf node.
2929
child.regex.list.hasChildren
3030
? child.regex.prepending(.ignoreCapturesInTypedOutput(TEMP_FAKE_NODE)) as Regex<Substring>
31-
: .init(list: child.regex.program.tree)
31+
: .init(list: child.regex.program.list)
3232
}
3333

3434
@available(SwiftStdlib 5.7, *)
3535
public func accumulate<Output>(
3636
_ left: some RegexComponent,
3737
_ right: some RegexComponent
3838
) -> Regex<Output> {
39-
left.regex.concatenating(right.regex.program.tree.nodes)
39+
left.regex.concatenating(right.regex.program.list.nodes)
4040
}
4141

4242
@available(SwiftStdlib 5.7, *)
4343
public func accumulateAlternation<Output>(
4444
_ left: some RegexComponent,
4545
_ right: some RegexComponent
4646
) -> Regex<Output> {
47-
left.regex.alternating(with: right.regex.program.tree.nodes)
47+
left.regex.alternating(with: right.regex.program.list.nodes)
4848
}
4949

5050
@_spi(RegexBuilder)

Sources/_StringProcessing/Utility/TypeVerification.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension Regex {
2121
var tupleElements: [Any.Type] = []
2222
var labels = ""
2323

24-
for capture in program.tree.captureList.captures {
24+
for capture in program.list.captureList.captures {
2525
var captureType = capture.type
2626
var i = capture.optionalDepth
2727

@@ -41,7 +41,7 @@ extension Regex {
4141

4242
// If we have no captures, then our Regex must be Regex<Substring>.
4343
if tupleElements.count == 1 {
44-
let wholeMatchType = program.tree.wholeMatchType
44+
let wholeMatchType = program.list.wholeMatchType
4545
return (Output.self == wholeMatchType, wholeMatchType)
4646
}
4747

Tests/RegexTests/DSLListTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ struct DSLListTests {
2121
(#/a(?:b+)c*/#, 8), // literal, concat, a, noncap grp, quant, b, quant, c
2222
])
2323
func convertedNodeCount(regex: Regex<Substring>, nodeCount: Int) {
24-
let dslList = regex.program.tree
24+
let dslList = regex.program.list
2525
#expect(dslList.nodes.count == nodeCount)
2626
}
2727

2828
@Test(arguments: [#/a|b/#, #/a+b?c/#, #/abc/#, #/a(?:b+)c*/#, #/;[\r\n]/#, #/(?=(?:[1-9]|(?:a|b)))/#])
2929
func compilationComparison(regex: Regex<Substring>) throws {
30-
let listCompiler = Compiler(list: regex.program.tree)
30+
let listCompiler = Compiler(list: regex.program.list)
3131
let listProgram = try listCompiler.emitViaList()
3232

3333
// #expect(treeProgram.instructions == listProgram.instructions)

Tests/RegexTests/OptimizationTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ import Testing
1717
@available(macOS 9999, *)
1818
@Test(arguments: [#/a/#, #/a+/#, #/(?:a+)/#, #/(?:a)+/#, #/(?m)a+/#, #/ab?c/#, #/(?:a+)+$/#, #/(?:(?:a+b)+b)/#])
1919
func requiredFirstAtom(pattern: Regex<Substring>) throws {
20-
let list = pattern.program.tree
20+
let list = pattern.program.list
2121
let atom = list.requiredFirstAtom(allowOptionsChanges: true)
2222
#expect(atom?.literalCharacterValue == "a", "Missing first character atom in '\(pattern._literalPattern!)'")
2323
}
2424

2525
@available(macOS 9999, *)
2626
@Test(arguments: [#/a?/#, #/(?:a|b)/#, #/[a]/#, #/a?bc/#])
2727
func noRequiredFirstAtom(pattern: Regex<Substring>) throws {
28-
let list = pattern.program.tree
28+
let list = pattern.program.list
2929
let atom = list.requiredFirstAtom(allowOptionsChanges: true)
3030
#expect(atom == nil, "Unexpected required first atom in '\(pattern._literalPattern!)'")
3131
}
3232

3333
@available(macOS 9999, *)
3434
@Test(arguments: [#/a+b/#, #/a*b/#, #/\w+\s/#, #/(?:a+b|b+a)/#, #/\d+a/#, #/a+A/#])
3535
func autoPossessify(pattern: Regex<Substring>) throws {
36-
var list = pattern.program.tree
36+
var list = pattern.program.list
3737
list.autoPossessify()
3838
for node in list.nodes {
3939
switch node {
@@ -53,7 +53,7 @@ import Testing
5353
#/(?:(?:ab)+b)/#, // single atom quantifications only
5454
])
5555
func noAutoPossessify(pattern: Regex<Substring>) throws {
56-
var list = pattern.program.tree
56+
var list = pattern.program.list
5757
list.autoPossessify()
5858
for node in list.nodes {
5959
switch node {

0 commit comments

Comments
 (0)