line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CodeGen::Cpppp::AntiCharacter; |
2
|
8
|
|
|
8
|
|
235049
|
use v5.20; |
|
8
|
|
|
|
|
37
|
|
3
|
8
|
|
|
8
|
|
49
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
239
|
|
4
|
8
|
|
|
8
|
|
45
|
use Carp; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
826
|
|
5
|
|
|
|
|
|
|
use overload |
6
|
|
|
|
|
|
|
'.' => \&concat, |
7
|
8
|
|
|
8
|
|
63
|
'""' => sub { $_[0][2] }; |
|
8
|
|
|
5
|
|
24
|
|
|
8
|
|
|
|
|
112
|
|
|
5
|
|
|
|
|
15
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
46
|
|
|
46
|
0
|
212
|
my ($class, $negate, $skip)= @_; |
11
|
46
|
|
100
|
|
|
170
|
$skip //= ''; |
12
|
46
|
50
|
|
|
|
111
|
ref $negate eq 'Regexp' or croak "Expected qr// for negation argument"; |
13
|
46
|
|
|
|
|
147
|
bless [ $negate, $skip, '' ], $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub concat { |
17
|
15
|
|
|
15
|
0
|
9006
|
my ($negate, $skip, $suffix)= @{$_[0]}; |
|
15
|
|
|
|
|
40
|
|
18
|
15
|
50
|
|
|
|
38
|
if ($_[2]) { # $string . $anticharacter; perform character destruction |
19
|
15
|
|
|
|
|
25
|
my $tmp= $_[1]; |
20
|
|
|
|
|
|
|
# does this entire string consist of 'skip' pattern? If so, need to |
21
|
|
|
|
|
|
|
# try again later. |
22
|
15
|
100
|
66
|
|
|
201
|
if (!length $tmp || $tmp =~ /^$skip\Z/) { |
23
|
1
|
|
|
|
|
9
|
return bless [ $negate, $skip, $tmp . $suffix ], ref $_[0]; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
# Does it match the pattern we're trying to cancel? |
26
|
14
|
50
|
|
|
|
352
|
if ($tmp =~ /($negate)$skip\Z/) { |
27
|
14
|
|
|
|
|
108
|
substr($tmp, $-[1], $+[1] - $-[1], ''); |
28
|
|
|
|
|
|
|
# Did it run into the start of the string, and could it cancel more? |
29
|
14
|
100
|
100
|
|
|
122
|
if ($-[1] == 0 |
30
|
|
|
|
|
|
|
&& (substr($_[1],0,1) . $_[1]) =~ /^($negate)$skip\Z/ |
31
|
|
|
|
|
|
|
) { |
32
|
1
|
|
|
|
|
14
|
return bless [ $negate, $skip, $tmp . $suffix ], ref $_[0]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
13
|
|
|
|
|
81
|
return $tmp . $suffix; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { # $anticharacter . $string; carry suffix for later |
38
|
0
|
|
|
|
|
|
return bless [ $negate, $skip, $suffix . $_[1] ], ref $_[0]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |