This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: consistent NOTHING/OPFAIL optimizations for lookaround
authorYves Orton <demerphq@gmail.com>
Mon, 21 Feb 2022 06:14:52 +0000 (07:14 +0100)
committerKarl Williamson <khw@cpan.org>
Wed, 23 Feb 2022 17:40:52 +0000 (10:40 -0700)
commit3c92cb142a9eee345370ce910513ccddbcccb93a
tree06c9968e029aff6d639c549b57e9c9467e8fe709
parent5070f532622b3fabf067638f9a15ca2e515ed50d
regcomp.c: consistent NOTHING/OPFAIL optimizations for lookaround

Add funcs to parse empty constructs which boil down to OPFAIL or NOTHING,
and then consistently use them while parsing lookahead and lookbehind.

This allows us to eliminate duplicated code and optimize the various cases
which boil down to these constructs.

Eg. (?!) and (?<!) are equivalent to OPFAIL ops,
and (?=) and (?<=) are equivalent to NOTHING ops.

This patch does not deal with the (* ... ) forms, that will come in a
follow up.

One advantage of this optimization is it does not need to set the various
special flags related to lookaround as they aren't really lookaround ops.

As a bonus this also improves the error messages from incomplete patterns,
and add tests for various error messages.

Note the functions are given awkward but shortish names so they are not
always forced to be line broken. I would prefer to name them something
more descriptive, but that would make their use harder to read by
forcing line breaks. So I chose to use an abbreviation.
embed.fnc
embed.h
pod/perldiag.pod
proto.h
regcomp.c
regcomp.h
t/re/reg_mesg.t