-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge re_eval jumbo fix branch into blead
This re_eval branch contains around 130 commits that collectively reimplement the /(?{})/ mechanism. See the individual commits and the changes to pod/* for more details, but the main highlights are: =item * Code blocks within patterns are now parsed in the same pass as the surrounding code; in particular it is no longer necessary to have balanced braces: this now works: /(?{ $x='{' })/ This means that this error message is longer generated: Sequence (?{...}) not terminated or not {}-balanced in regex but a new error may be seen: Sequence (?{...}) not terminated with ')' In addition, literal code blocks within run-time patterns are only compiled once, at perl compile-time: for my $p (...) { # this 'FOO' block of code is compiled once, at the same time as # the surrounding 'for' loop /$p{(?{FOO;})/; } =item * Lexical variables are now sane as regards scope, recursion and closure behaviour. In particular, C</A(?{B})C/> behaves (from a closure viewpoint) exactly like C</A/ && do { B } && /C/>, while C<qr/A(?{B})C/> is like C<sub {/A/ && do { B } && /C/}>. So this code now works how you might expect, creating three regexes that match 1,2, and 3: for my $i (0..2) { push @r, qr/^(??{$i})$/; } "1" =~ $r[1]; # matches =item * The C<use re 'eval'> pragma is now strictly only required for code blocks defined at runtime; in particular in the following, the text of the $r pattern is still interpolated into the new pattern and recompiled, but the individual compiled code-blocks within $r are reused rather than being recompiled, and C<use re 'eval'> isn't needed any more: my $r = qr/abc(?{....})def/; /xyz$r/; =item * Flow control operators no longer crash. Each code block runs in a new dynamic scope, so C<next> etc. will not see any enclosing loops and C<caller> will not see any calling subroutines. C<return> returns a value from the code block, not from any enclosing subroutine. =item * Perl normally caches the compilation of run-time patterns, and doesn't recompile if the pattern hasn't changed; but this is now disabled if required for the correct behaviour of closures; for example: my $code = '(??{$x})'; for my $x (1..3) { $x =~ /$code/; # recompile to see fresh value of $x each time } =item * C</msix> and C<(?msix)> etc. flags are now propagated into the return value from C<(??{})>; this now works: "AB" =~ /a(??{'b'})/i; =item * Warnings and errors will appear to come from the surrounding code (or for run-time code blocks, from an eval) rather than from an C<re_eval>: use re 'eval'; $c = '(?{ warn "foo" })'; /$c/; /(?{ warn "foo" })/; formerly gave: foo at (re_eval 1) line 1. foo at (re_eval 2) line 1. and now gives: foo at (eval 1) line 1. foo at /tmp/foo line 2. =item * In the pluggable regex API, the regexp_engine struct has acquired a new field C<op_comp>, which is currently just for perl's internal use, and should be initialised to NULL by other regexp plugin modules.
- Loading branch information
Showing
64 changed files
with
3,949 additions
and
1,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.