diff options
author | Yves Orton <demerphq@gmail.com> | 2022-02-21 07:14:52 +0100 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-02-23 10:40:52 -0700 |
commit | 3c92cb142a9eee345370ce910513ccddbcccb93a (patch) | |
tree | 06c9968e029aff6d639c549b57e9c9467e8fe709 /t/re | |
parent | 5070f532622b3fabf067638f9a15ca2e515ed50d (diff) | |
download | perl-3c92cb142a9eee345370ce910513ccddbcccb93a.tar.gz |
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.
Diffstat (limited to 't/re')
-rw-r--r-- | t/re/reg_mesg.t | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index 6fce6e6e2b..17b337a537 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -136,6 +136,11 @@ my @death = '/(?<= .*)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= .*)/', + '/(?<= a+)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a+)/', + '/(?<= a{255})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{255})/', + '/(?<= a{0,255})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{0,255})/', + '/(?<= a{200}b{55})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{200}b{55})/', + '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= x{1000})/', '/(?@)/' => 'Sequence (?@...) not implemented {#} m/(?@{#})/', @@ -318,7 +323,10 @@ my @death = '/\w{/' => 'Unescaped left brace in regex is illegal here {#} m/\w{{#}/', '/\q{/' => 'Unescaped left brace in regex is illegal here {#} m/\q{{#}/', '/\A{/' => 'Unescaped left brace in regex is illegal here {#} m/\A{{#}/', - '/(?<=/' => 'Sequence (?... not terminated {#} m/(?<={#}/', # [perl #128170] + '/(?<=/' => 'Sequence (?<=... not terminated {#} m/(?<={#}/', # [perl #128170] + '/(?<!/' => 'Sequence (?<!... not terminated {#} m/(?<!{#}/', + '/(?!/' => 'Sequence (?!... not terminated {#} m/(?!{#}/', + '/(?=/' => 'Sequence (?=... not terminated {#} m/(?={#}/', '/\p{vertical tab}/' => 'Can\'t find Unicode property definition "vertical tab" {#} m/\\p{vertical tab}{#}/', # [perl #132055] "/$bug133423/" => "Unexpected ']' with no following ')' in (?[... {#} m/(?[(?^:(?[\\ '/[^/' => 'Unmatched [ {#} m/[{#}^/', # [perl #133767] |