Commit 2f405f3
committed
syntax: permit empty character classes
An empty character class is effectively a way to write something that
can never match anything. The regex crate has pretty much always
returned an error for such things because it was never taught how to
handle "always fail" states. Partly because I just didn't think about it
when initially writing the regex engines and partly because it isn't
often useful.
With that said, it should be supported for completeness and because
there is no real reason to not support it. Moreover, it can be useful in
certain contexts where regexes are generated and you want to insert an
expression that can never match. It's somewhat contrived, but it
happens when the interface is a regex pattern.
Previously, the ban on empty character classes was implemented in the
regex-syntax crate. But with the rewrite in #656 getting closer and
closer to landing, it's now time to relax this restriction. However, we
do keep the overall restriction in the 'regex' API by returning an error
in the NFA compiler. Once #656 is done, the new regex engines will
permit this case.1 parent ff61c8c commit 2f405f3
3 files changed
+15
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 81 | | |
88 | 82 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 83 | | |
97 | 84 | | |
98 | 85 | | |
| |||
118 | 105 | | |
119 | 106 | | |
120 | 107 | | |
121 | | - | |
122 | 108 | | |
123 | 109 | | |
124 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | 325 | | |
332 | 326 | | |
333 | 327 | | |
| |||
337 | 331 | | |
338 | 332 | | |
339 | 333 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | 334 | | |
348 | 335 | | |
349 | 336 | | |
| |||
839 | 826 | | |
840 | 827 | | |
841 | 828 | | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | 829 | | |
848 | 830 | | |
849 | 831 | | |
| |||
2357 | 2339 | | |
2358 | 2340 | | |
2359 | 2341 | | |
2360 | | - | |
2361 | | - | |
2362 | | - | |
2363 | | - | |
2364 | | - | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
2369 | | - | |
| 2342 | + | |
2370 | 2343 | | |
2371 | 2344 | | |
2372 | 2345 | | |
| |||
2518 | 2491 | | |
2519 | 2492 | | |
2520 | 2493 | | |
2521 | | - | |
2522 | | - | |
2523 | | - | |
2524 | | - | |
2525 | | - | |
2526 | | - | |
2527 | | - | |
2528 | | - | |
2529 | | - | |
2530 | | - | |
| 2494 | + | |
2531 | 2495 | | |
2532 | | - | |
2533 | | - | |
2534 | | - | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
2541 | | - | |
| 2496 | + | |
2542 | 2497 | | |
2543 | 2498 | | |
2544 | 2499 | | |
| |||
2686 | 2641 | | |
2687 | 2642 | | |
2688 | 2643 | | |
2689 | | - | |
2690 | | - | |
2691 | | - | |
2692 | | - | |
2693 | | - | |
2694 | | - | |
2695 | | - | |
2696 | | - | |
2697 | | - | |
2698 | | - | |
| 2644 | + | |
2699 | 2645 | | |
2700 | | - | |
2701 | | - | |
2702 | | - | |
2703 | | - | |
2704 | | - | |
2705 | | - | |
2706 | | - | |
2707 | | - | |
2708 | | - | |
2709 | | - | |
| 2646 | + | |
2710 | 2647 | | |
2711 | 2648 | | |
2712 | 2649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
461 | 465 | | |
462 | 466 | | |
463 | 467 | | |
| |||
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
485 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
486 | 494 | | |
487 | 495 | | |
488 | 496 | | |
| |||
0 commit comments