Commit e29b915
committed
automata: make PikeVM and backtracker work without capture states
Previously, construction of these engines checked to make sure the NFA
given had some capture states in it. If the NFA didn't, construction
failed with an error.
To support the case where the NFA has no capture states at all (to avoid
gratuitous memory allocation), we remove this restriction and tweak the
engine implementations to stop assuming that the NFA has capture states.
This turned out to not be too hard, as we only assumed as much in a few
places.
The main reason why this restriction existed in the first place was
semantics. Namely, it's important that the PikeVM remain infallible. But
what happens when you ask for match offsets in a search with an NFA that
has no capture states? The PikeVM just doesn't support that. Previously
it would panic (and thus the reason construction would fail). But now
instead it will just report "no match." It's a little hokey, but we
justify it to ourselves because "simplicity" and "avoids footguns" are
non-goals of this crate.1 parent 3127e3b commit e29b915
File tree
5 files changed
+72
-61
lines changed- regex-automata/src
- meta
- nfa/thompson
5 files changed
+72
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2635 | 2635 | | |
2636 | 2636 | | |
2637 | 2637 | | |
2638 | | - | |
2639 | | - | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
2640 | 2642 | | |
2641 | 2643 | | |
2642 | 2644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 303 | | |
313 | 304 | | |
314 | 305 | | |
| |||
954 | 945 | | |
955 | 946 | | |
956 | 947 | | |
957 | | - | |
958 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
959 | 956 | | |
960 | 957 | | |
961 | 958 | | |
| |||
965 | 962 | | |
966 | 963 | | |
967 | 964 | | |
968 | | - | |
969 | | - | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
970 | 973 | | |
971 | 974 | | |
972 | 975 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
320 | | - | |
| 319 | + | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
| 332 | + | |
| 333 | + | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
336 | 339 | | |
337 | 340 | | |
338 | 341 | | |
| |||
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
367 | | - | |
368 | | - | |
| 370 | + | |
| 371 | + | |
369 | 372 | | |
370 | 373 | | |
371 | 374 | | |
| |||
374 | 377 | | |
375 | 378 | | |
376 | 379 | | |
377 | | - | |
378 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
379 | 402 | | |
380 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
381 | 407 | | |
382 | 408 | | |
383 | 409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
126 | 123 | | |
127 | 124 | | |
128 | 125 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | 126 | | |
134 | 127 | | |
135 | 128 | | |
| |||
181 | 174 | | |
182 | 175 | | |
183 | 176 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 177 | | |
190 | 178 | | |
191 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | 278 | | |
288 | 279 | | |
289 | 280 | | |
| |||
828 | 819 | | |
829 | 820 | | |
830 | 821 | | |
831 | | - | |
832 | | - | |
| 822 | + | |
| 823 | + | |
833 | 824 | | |
834 | 825 | | |
835 | 826 | | |
836 | 827 | | |
837 | 828 | | |
838 | 829 | | |
839 | | - | |
840 | | - | |
| 830 | + | |
| 831 | + | |
841 | 832 | | |
842 | 833 | | |
843 | 834 | | |
| |||
1123 | 1114 | | |
1124 | 1115 | | |
1125 | 1116 | | |
1126 | | - | |
1127 | | - | |
| 1117 | + | |
| 1118 | + | |
1128 | 1119 | | |
1129 | 1120 | | |
1130 | 1121 | | |
1131 | 1122 | | |
1132 | 1123 | | |
1133 | | - | |
1134 | | - | |
| 1124 | + | |
| 1125 | + | |
1135 | 1126 | | |
1136 | 1127 | | |
1137 | 1128 | | |
| |||
2108 | 2099 | | |
2109 | 2100 | | |
2110 | 2101 | | |
2111 | | - | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
2112 | 2106 | | |
2113 | 2107 | | |
2114 | 2108 | | |
2115 | | - | |
2116 | | - | |
2117 | | - | |
2118 | | - | |
2119 | | - | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
2120 | 2112 | | |
2121 | 2113 | | |
2122 | 2114 | | |
| |||
2170 | 2162 | | |
2171 | 2163 | | |
2172 | 2164 | | |
2173 | | - | |
| 2165 | + | |
2174 | 2166 | | |
2175 | 2167 | | |
2176 | 2168 | | |
| |||
0 commit comments