Closed NWilson closed 3 days ago
We might need to emit empty xclasses inside eclasses (the execution part already supports this), which could also handle the nothing match cases. This could save some space.
Yes, I was thinking that in some ways, it would be nice to have a nothing-match opcode, to model []
. But after constant-folding, we shouldn't end up with any inside an ECLASS. foo && nothing → nothing
, foo -- nothing → foo
, etc. So the only "nothing" that can remain would be if the entire ECLASS matched nothing, in which case it wouldn't need to be wrapped in an ECLASS.
The line of code that needs changing is tagged with this URL:
https://github.com/PCRE2Project/pcre2/issues/541
I won't be brave and make the change myself, because I don't understand OP_FAIL well enough. There's just a tiny loose end for someone else (hopefully) to tie up.
I am leaving a TODO in pcre2_compile.c
In the PR #511 Zoltan changed the parser so it doesn't emit OP_FAIL anymore for empty character classes. Hence (according to the comments at least) it should no longer be possible for an OP_FAIL to have a following quantifier. The code to handle this could be removed.
Or, if I'm wrong, then the TODO can be removed, and the comments updated to explain why OP_FAIL can have a quantifier after.