Skip to content

[Integration] main (96fb215) -> swift/main #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9212b43
Validate optimizations when a match fails
hamishknight Jul 7, 2022
33856e7
Merge pull request #559 from hamishknight/validate-test
hamishknight Jul 7, 2022
33acdeb
Break out of quantification loop if there is no forward progress (#560)
rctcwyvrn Jul 11, 2022
7752047
Optimize matching to match on scalar values when possible (#525)
rctcwyvrn Jul 12, 2022
8f93498
Rip out unused _CharacterClassModel API
hamishknight Jul 14, 2022
297a69d
Remove _CharacterClassModel conformance to RegexComponent
hamishknight Jul 14, 2022
7d5e86d
Internalize `_CharacterClassModel`
hamishknight Jul 14, 2022
99e5e51
Merge pull request #578 from hamishknight/internalize-character-model
hamishknight Jul 14, 2022
d5010fb
Fix `CharacterClass.newlineSequence`
hamishknight Jul 14, 2022
446bfd4
Rename `any` -> `dot`
hamishknight Jul 14, 2022
efe90d1
Re-introduce `DSLTree.Atom.any`
hamishknight Jul 14, 2022
8f8c7d0
Fix `CharacterClass.any`
hamishknight Jul 14, 2022
657351e
Rename `startOfLine`/`endOfLine` -> `caretAnchor`/`dollarAnchor`
hamishknight Jul 14, 2022
21ca2fb
Move AssertionKind onto the DSL
hamishknight Jul 14, 2022
210bfa3
Fix `Anchor.startOfLine` and `Anchor.endOfLine`
hamishknight Jul 14, 2022
f111a57
Add some tests for `CharacterClass.anyGraphemeCluster`
hamishknight Jul 14, 2022
9a545a0
Add some tests for `CharacterClass.horizontalWhitespace`
hamishknight Jul 14, 2022
9456c54
Implement `CharacterClass.anyNonNewline`
hamishknight Jul 14, 2022
9bcb72f
Rename various APIs
Azoy Jul 13, 2022
33566dc
Merge pull request #575 from Azoy/various-tidbits
Azoy Jul 14, 2022
9f1f309
Move options from RegexComponent to Regex
Azoy Jul 13, 2022
991d90c
Merge pull request #576 from Azoy/options-regex
Azoy Jul 14, 2022
1f2ae04
Merge pull request #580 from hamishknight/character-work
hamishknight Jul 15, 2022
96fb215
Benchmarker improvements and more benchmarks (#581)
rctcwyvrn Jul 15, 2022
3a2a785
Merge branch 'main' into main-merge
hamishknight Jul 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move options from RegexComponent to Regex
  • Loading branch information
Azoy committed Jul 14, 2022
commit 9f1f309dd9e5cd07319d5ae2a78a4d95463b910c
2 changes: 1 addition & 1 deletion Sources/_StringProcessing/Regex/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@_implementationOnly import _RegexParser

@available(SwiftStdlib 5.7, *)
extension RegexComponent {
extension Regex {
/// Returns a regular expression that ignores case when matching.
///
/// - Parameter ignoresCase: A Boolean value indicating whether to ignore case.
Expand Down
69 changes: 43 additions & 26 deletions Tests/RegexBuilderTests/RegexDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ class RegexDSLTests: XCTestCase {
("abcabc", "abcabc"),
("abcABCaBc", "abcABCaBc"),
matchType: Substring.self, ==) {
OneOrMore {
"abc"
Regex {
OneOrMore {
"abc"
}
}.ignoresCase(true)
}

Expand All @@ -251,8 +253,10 @@ class RegexDSLTests: XCTestCase {
("abcabc", "abcabc"),
("abcABCaBc", "abcABCaBc"),
matchType: Substring.self, ==) {
OneOrMore {
"abc"
Regex {
OneOrMore {
"abc"
}
}
.ignoresCase(true)
.ignoresCase(false)
Expand All @@ -268,9 +272,13 @@ class RegexDSLTests: XCTestCase {
("abcabc", "abcabc"),
("abcdeABCdeaBcde", "abcdeABCdeaBcde"),
matchType: Substring.self, ==) {
OneOrMore {
"abc".ignoresCase(true)
Optionally("de")
Regex {
OneOrMore {
Regex {
"abc"
}.ignoresCase(true)
Optionally("de")
}
}
.ignoresCase(false)
}
Expand Down Expand Up @@ -307,11 +315,13 @@ class RegexDSLTests: XCTestCase {
"stop"
" "

Capture {
OneOrMore(.word)
Anchor.wordBoundary
}
.wordBoundaryKind(.simple)
Regex {
Capture {
OneOrMore(.word)
Anchor.wordBoundary
}
}.wordBoundaryKind(.simple)

OneOrMore(.any, .reluctant)
"stop"
}
Expand All @@ -321,15 +331,17 @@ class RegexDSLTests: XCTestCase {
matchType: (Substring, Substring, Substring).self, ==) {
Capture {
// Reluctant behavior due to option
OneOrMore(.anyOf("abcd"))
.repetitionBehavior(.reluctant)
Regex {
OneOrMore(.anyOf("abcd"))
}.repetitionBehavior(.reluctant)
}
ZeroOrMore("a"..."z")

Capture {
// Eager behavior due to explicit parameter, despite option
OneOrMore(.digit, .eager)
.repetitionBehavior(.reluctant)
Regex {
OneOrMore(.digit, .eager)
}.repetitionBehavior(.reluctant)
}
ZeroOrMore(.digit)
}
Expand All @@ -338,10 +350,11 @@ class RegexDSLTests: XCTestCase {
("abcdefg", ("abcdefg", "abcdefg")),
("abcdéfg", ("abcdéfg", "abcd")),
matchType: (Substring, Substring).self, ==) {
Capture {
OneOrMore(.word)
}
.asciiOnlyWordCharacters()
Regex {
Capture {
OneOrMore(.word)
}
}.asciiOnlyWordCharacters()

ZeroOrMore(.any)
}
Expand Down Expand Up @@ -372,8 +385,10 @@ class RegexDSLTests: XCTestCase {
("abc1def2", ("abc1def2", "1")),
matchType: (Substring, Substring).self, ==)
{
OneOrMore(.reluctant) {
One(.word)
Regex {
OneOrMore(.reluctant) {
One(.word)
}
}.repetitionBehavior(.possessive)
Capture(.digit)
ZeroOrMore(.any)
Expand Down Expand Up @@ -425,8 +440,9 @@ class RegexDSLTests: XCTestCase {
{
Regex {
Capture {
OneOrMore("a")
.repetitionBehavior(.eager)
Regex {
OneOrMore("a")
}.repetitionBehavior(.eager)
}
OneOrMore("a")
}.repetitionBehavior(.possessive)
Expand All @@ -438,8 +454,9 @@ class RegexDSLTests: XCTestCase {
{
Regex {
Capture {
OneOrMore("a")
.repetitionBehavior(.reluctant)
Regex {
OneOrMore("a")
}.repetitionBehavior(.reluctant)
}
OneOrMore("a")
}.repetitionBehavior(.possessive)
Expand Down