line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::P::Toy::Value::Regex; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
7232
|
use strict; |
|
24
|
|
|
|
|
53
|
|
|
24
|
|
|
|
|
899
|
|
4
|
24
|
|
|
24
|
|
134
|
use warnings; |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
757
|
|
5
|
24
|
|
|
24
|
|
124
|
use base qw(Language::P::Toy::Value::Code); |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
2675
|
|
6
|
|
|
|
|
|
|
|
7
|
24
|
|
|
24
|
|
163
|
use Language::P::ParseTree qw(:all); |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
34593
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant |
10
|
24
|
|
|
|
|
10264
|
{ REGEXP_NO_MORE_MATCHES => -1, |
11
|
|
|
|
|
|
|
REGEXP_SCAN_ALL => -2, |
12
|
24
|
|
|
24
|
|
214
|
}; |
|
24
|
|
|
|
|
59
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub next_start { |
15
|
0
|
|
|
0
|
0
|
0
|
my( $self, $start ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
return REGEXP_SCAN_ALL; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub match { |
21
|
47
|
|
|
47
|
0
|
239
|
my( $self, $runtime, $string ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# print "String: $string\n"; |
24
|
|
|
|
|
|
|
|
25
|
47
|
|
|
|
|
78
|
my $rv; |
26
|
|
|
|
|
|
|
# make space for the values |
27
|
47
|
|
|
|
|
77
|
push @{$runtime->{_stack}}, 0, $string; |
|
47
|
|
|
|
|
178
|
|
28
|
47
|
|
|
|
|
189
|
foreach my $i ( 0 .. length( $string ) ) { |
29
|
145
|
|
|
0
|
|
953
|
local $SIG{__WARN__} = sub { Carp::confess @_ }; |
|
0
|
|
|
|
|
0
|
|
30
|
145
|
|
|
|
|
500
|
$runtime->{_stack}[-2] = $i; |
31
|
|
|
|
|
|
|
# print "Start: $i\n"; |
32
|
145
|
|
|
|
|
572
|
$self->call( $runtime, -2, CXT_VOID ); # -2 so we can blindly add 1 |
33
|
145
|
|
|
|
|
451
|
$runtime->run; |
34
|
145
|
|
|
|
|
159
|
$rv = pop @{$runtime->{_stack}}; |
|
145
|
|
|
|
|
303
|
|
35
|
|
|
|
|
|
|
|
36
|
145
|
100
|
|
|
|
872
|
next unless $rv->{matched}; |
37
|
|
|
|
|
|
|
|
38
|
39
|
|
|
|
|
85
|
$rv->{match_start} = $i; |
39
|
|
|
|
|
|
|
# print 'Matched: "' . substr( $string, $i, $rv->{match_end} - $i ) |
40
|
|
|
|
|
|
|
# . "\"\n"; |
41
|
39
|
|
|
|
|
299
|
last; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
# clean stack |
44
|
47
|
|
|
|
|
77
|
pop @{$runtime->{_stack}}; |
|
47
|
|
|
|
|
95
|
|
45
|
47
|
|
|
|
|
79
|
pop @{$runtime->{_stack}}; |
|
47
|
|
|
|
|
95
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# if( !$rv->{matched} ) { |
48
|
|
|
|
|
|
|
# print "No match\n"; |
49
|
|
|
|
|
|
|
# } |
50
|
|
|
|
|
|
|
|
51
|
47
|
|
|
|
|
348
|
return $rv; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |