@@ -2151,9 +2151,6 @@ extension RegexTests {
2151
2151
parseWithDelimitersTest ( " ##/a b/## " , concat ( " a " , " " , " b " ) )
2152
2152
parseWithDelimitersTest ( " #|a b|# " , concat ( " a " , " b " ) )
2153
2153
2154
- parseWithDelimitersTest ( " re'a b' " , concat ( " a " , " " , " b " ) )
2155
- parseWithDelimitersTest ( " rx'a b' " , concat ( " a " , " b " ) )
2156
-
2157
2154
parseWithDelimitersTest ( " #|[a b]|# " , charClass ( " a " , " b " ) )
2158
2155
parseWithDelimitersTest (
2159
2156
" #|(?-x)[a b]|# " , concat (
@@ -2176,13 +2173,13 @@ extension RegexTests {
2176
2173
parseWithDelimitersTest ( " #||||# " , alt ( empty ( ) , empty ( ) , empty ( ) ) )
2177
2174
parseWithDelimitersTest ( " #|a||# " , alt ( " a " , empty ( ) ) )
2178
2175
2179
- parseWithDelimitersTest ( " re'x*' " , zeroOrMore ( of: " x " ) )
2176
+ parseWithDelimitersTest ( " /x*/ " , zeroOrMore ( of: " x " ) )
2180
2177
2181
- parseWithDelimitersTest ( #"re' 🔥🇩🇰' "# , concat ( " 🔥 " , " 🇩🇰 " ) )
2182
- parseWithDelimitersTest ( #"re'🔥✅' "# , concat ( " 🔥 " , " ✅ " ) )
2178
+ parseWithDelimitersTest ( #"/ 🔥🇩🇰/ "# , concat ( " 🔥 " , " 🇩🇰 " ) )
2179
+ parseWithDelimitersTest ( #"/🔥✅/ "# , concat ( " 🔥 " , " ✅ " ) )
2183
2180
2184
2181
// Printable ASCII characters.
2185
- delimiterLexingTest ( ##"re' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~' "## )
2182
+ delimiterLexingTest ( ##"#/ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~/# "## )
2186
2183
2187
2184
// Make sure we can handle a combining accent as first character.
2188
2185
parseWithDelimitersTest ( " / \u{301} / " , " \u{301} " )
@@ -2294,72 +2291,61 @@ extension RegexTests {
2294
2291
/#
2295
2292
"""# , charClass ( range_m ( " a " , " b " ) ) )
2296
2293
2297
-
2298
- // MARK: Delimiter skipping: Make sure we can skip over the ending delimiter
2299
- // if it's clear that it's part of the regex syntax.
2300
-
2301
2294
parseWithDelimitersTest (
2302
- #"re' (?'a_bcA0'\')' "# , namedCapture ( " a_bcA0 " , " ' " ) )
2295
+ #"/ (?'a_bcA0'\')/ "# , namedCapture ( " a_bcA0 " , " ' " ) )
2303
2296
parseWithDelimitersTest (
2304
- #"re' (?'a_bcA0-c1A'x*)' "# ,
2297
+ #"/ (?'a_bcA0-c1A'x*)/ "# ,
2305
2298
balancedCapture ( name: " a_bcA0 " , priorName: " c1A " , zeroOrMore ( of: " x " ) ) ,
2306
2299
unsupported: true )
2307
2300
2308
2301
parseWithDelimitersTest (
2309
- #"rx' (?'a_bcA0' a b)' "# , concat ( namedCapture ( " a_bcA0 " , concat ( " a " , " b " ) ) ) )
2302
+ #"/ (?'a_bcA0' a b)/ "# , concat ( " " , namedCapture ( " a_bcA0 " , concat ( " " , " a " , " " , " b " ) ) ) )
2310
2303
2311
2304
parseWithDelimitersTest (
2312
- #"re' (?('a_bcA0')x|y)' "# , conditional (
2305
+ #"/ (?('a_bcA0')x|y)/ "# , conditional (
2313
2306
. groupMatched( ref ( " a_bcA0 " ) ) , trueBranch: " x " , falseBranch: " y " ) ,
2314
2307
unsupported: true
2315
2308
)
2316
2309
parseWithDelimitersTest (
2317
- #"re' (?('+20')\')' "# , conditional (
2310
+ #"/ (?('+20')\')/ "# , conditional (
2318
2311
. groupMatched( ref ( plus: 20 ) ) , trueBranch: " ' " , falseBranch: empty ( ) ) ,
2319
2312
unsupported: true
2320
2313
)
2321
2314
parseWithDelimitersTest (
2322
- #"re' a\k'b0A'' "# , concat ( " a " , backreference ( . named( " b0A " ) ) ) , throwsError: . invalidNamedReference( " b0A " ) )
2315
+ #"/ a\k'b0A'/ "# , concat ( " a " , backreference ( . named( " b0A " ) ) ) , throwsError: . invalidNamedReference( " b0A " ) )
2323
2316
parseWithDelimitersTest (
2324
- #"re' \k'+2-1'' "# , backreference ( ref ( plus: 2 ) , recursionLevel: - 1 ) ,
2317
+ #"/ \k'+2-1'/ "# , backreference ( ref ( plus: 2 ) , recursionLevel: - 1 ) ,
2325
2318
unsupported: true
2326
2319
)
2327
2320
2328
2321
parseWithDelimitersTest (
2329
- #"re' a\g'b0A'' "# , concat ( " a " , subpattern ( . named( " b0A " ) ) ) , unsupported: true )
2322
+ #"/ a\g'b0A'/ "# , concat ( " a " , subpattern ( . named( " b0A " ) ) ) , unsupported: true )
2330
2323
parseWithDelimitersTest (
2331
- #"re' \g'-1'\'' "# , concat ( subpattern ( ref ( minus: 1 ) ) , " ' " ) , unsupported: true )
2324
+ #"/ \g'-1'\'/ "# , concat ( subpattern ( ref ( minus: 1 ) ) , " ' " ) , unsupported: true )
2332
2325
2333
2326
parseWithDelimitersTest (
2334
- #"re' (?C'a*b\c 🔥_ ;')' "# , pcreCallout ( string: #"a*b\c 🔥_ ;"# ) ,
2327
+ #"/ (?C'a*b\c 🔥_ ;')/ "# , pcreCallout ( string: #"a*b\c 🔥_ ;"# ) ,
2335
2328
unsupported: true )
2336
2329
2337
- // Fine, because we don't end up skipping.
2338
- delimiterLexingTest ( #"re'(?'"# )
2339
- delimiterLexingTest ( #"re'(?('"# )
2340
- delimiterLexingTest ( #"re'\k'"# )
2341
- delimiterLexingTest ( #"re'\g'"# )
2342
- delimiterLexingTest ( #"re'(?C'"# )
2330
+ delimiterLexingTest ( #"/(?/"# )
2331
+ delimiterLexingTest ( #"/(?(/"# )
2332
+ delimiterLexingTest ( #"/\k/"# )
2333
+ delimiterLexingTest ( #"/\g/"# )
2334
+ delimiterLexingTest ( #"/(?C/"# )
2343
2335
2344
- // Not a valid group name, but we can still skip over it.
2345
- delimiterLexingTest ( #"re'(?'🔥')'"# )
2336
+ delimiterLexingTest ( #"/(?'🔥')/"# )
2346
2337
2347
- // Escaped, so don't skip. These will ignore the ending `'` as we've already
2348
- // closed the literal.
2349
2338
parseWithDelimitersTest (
2350
- #"re'\(?''"# , zeroOrOne ( of: " ( " ) , ignoreTrailing: true
2351
- )
2339
+ #"/\(?/"# , zeroOrOne ( of: " ( " ) )
2352
2340
parseWithDelimitersTest (
2353
- #"re'\\k''"# , concat ( " \\ " , " k " ) , ignoreTrailing: true
2354
- )
2341
+ #"/\\k/"# , concat ( " \\ " , " k " ) )
2355
2342
parseWithDelimitersTest (
2356
- #"re'\\g''"# , concat ( " \\ " , " g " ) , ignoreTrailing: true
2357
- )
2343
+ #"/\\g/"# , concat ( " \\ " , " g " ) )
2358
2344
parseWithDelimitersTest (
2359
- #"re' \(?C'' "# , concat ( zeroOrOne ( of: " ( " ) , " C " ) , ignoreTrailing : true
2360
- )
2361
- delimiterLexingTest ( #"re' (\?''"# , ignoreTrailing : true )
2362
- delimiterLexingTest ( #"re' \(?(''"# , ignoreTrailing : true )
2345
+ #"/ \(?C/ "# , concat ( zeroOrOne ( of: " ( " ) , " C " ) )
2346
+
2347
+ delimiterLexingTest ( #"/ (\?/"# )
2348
+ delimiterLexingTest ( #"/ \(?(/"# )
2363
2349
2364
2350
// MARK: Parse not-equal
2365
2351
@@ -3322,31 +3308,24 @@ extension RegexTests {
3322
3308
3323
3309
// MARK: Printable ASCII
3324
3310
3325
- delimiterLexingDiagnosticTest ( #"re'\\#n'"# , . unterminated)
3326
3311
for i : UInt8 in 0x1 ..< 0x20 where i != 0xA && i != 0xD { // U+A & U+D are \n and \r.
3327
- delimiterLexingDiagnosticTest ( " re' \( UnicodeScalar ( i) ) ' " , . unprintableASCII)
3312
+ delimiterLexingDiagnosticTest ( " / \( UnicodeScalar ( i) ) / " , . unprintableASCII)
3328
3313
}
3329
- delimiterLexingDiagnosticTest ( " re' \n ' " , . unterminated)
3330
- delimiterLexingDiagnosticTest ( " re' \r ' " , . unterminated)
3331
- delimiterLexingDiagnosticTest ( " re' \u{7F} ' " , . unprintableASCII)
3332
3314
3333
- // MARK: Delimiter skipping
3315
+ // Can only be done if pound signs are used.
3316
+ delimiterLexingDiagnosticTest ( " / \n / " , . unterminated)
3317
+ delimiterLexingDiagnosticTest ( " / \r / " , . unterminated)
3318
+ delimiterLexingDiagnosticTest ( " / \u{7F} / " , . unprintableASCII)
3334
3319
3335
- delimiterLexingDiagnosticTest ( " re'(?'' " , . unterminated)
3336
- delimiterLexingDiagnosticTest ( " re'(?'abc' " , . unterminated)
3337
- delimiterLexingDiagnosticTest ( " re'(?('abc' " , . unterminated)
3338
- delimiterLexingDiagnosticTest ( #"re'\k'ab_c0+-'"# , . unterminated)
3339
- delimiterLexingDiagnosticTest ( #"re'\g'ab_c0+-'"# , . unterminated)
3320
+ delimiterLexingDiagnosticTest ( " / " , . unterminated)
3321
+ delimiterLexingDiagnosticTest ( " /x " , . unterminated)
3340
3322
3341
3323
// MARK: Unbalanced extended syntax
3342
3324
delimiterLexingDiagnosticTest ( " #/a/ " , . unterminated)
3343
3325
delimiterLexingDiagnosticTest ( " ##/a/# " , . unterminated)
3344
3326
3345
3327
// MARK: Multiline
3346
3328
3347
- // Can only be done if pound signs are used.
3348
- delimiterLexingDiagnosticTest ( " / \n / " , . unterminated)
3349
-
3350
3329
// Opening and closing delimiters must be on a newline.
3351
3330
delimiterLexingDiagnosticTest ( " #/a \n /# " , . unterminated)
3352
3331
delimiterLexingDiagnosticTest ( " #/ \n a/# " , . multilineClosingNotOnNewline)
0 commit comments