Skip to content

Commit 9fe36d4

Browse files
authored
Split complex Regex expression (#1376)
1 parent 6b24aaf commit 9fe36d4

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Sources/BuiltinRegistryGenerator/BuiltinRegistryGenerator.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,24 @@ struct BuiltinRegistryGenerator: ParsableCommand {
132132
// [platform] [version], ...
133133
let platform = Reference(Substring.self)
134134
let version = Reference(Double?.self)
135-
let expression = Regex {
136-
Capture(as: platform) {
137-
OneOrMore(.word)
135+
let platformExpr = Capture(as: platform) {
136+
OneOrMore(.word)
137+
}
138+
let versionExpr = Capture(as: version) {
139+
OneOrMore(.digit)
140+
Optionally {
141+
"."
142+
OneOrMore(.digit)
138143
}
144+
} transform: {
145+
Double($0)
146+
}
147+
148+
let expression = Regex {
149+
platformExpr
139150
Optionally {
140151
OneOrMore(.whitespace)
141-
Capture(as: version) {
142-
OneOrMore(.digit)
143-
Optionally {
144-
"."
145-
OneOrMore(.digit)
146-
}
147-
} transform: {
148-
Double($0)
149-
}
152+
versionExpr
150153
}
151154
}
152155
let availability = String(match[availability])

0 commit comments

Comments
 (0)