line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Search::Tools::TokenListPP; |
2
|
2
|
|
|
2
|
|
7
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
3
|
|
|
|
|
|
|
extends 'Search::Tools::Object'; |
4
|
|
|
|
|
|
|
use overload |
5
|
3
|
|
|
3
|
|
224
|
'""' => sub { $_[0]->str; }, |
6
|
8
|
|
|
8
|
|
123
|
'bool' => sub { $_[0]->len; }, |
7
|
2
|
|
|
2
|
|
458
|
fallback => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
16
|
|
8
|
2
|
|
|
2
|
|
111
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
735
|
|
9
|
|
|
|
|
|
|
with 'Search::Tools::TokenListUtils'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.004'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'pos' => ( is => 'rw' ); |
14
|
|
|
|
|
|
|
has 'num' => ( is => 'rw' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub len { |
17
|
16
|
|
|
16
|
1
|
3127
|
return scalar @{ $_[0]->{tokens} }; |
|
16
|
|
|
|
|
51
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_heat { |
21
|
2
|
|
|
2
|
1
|
31
|
return $_[0]->{heat}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub next { |
25
|
200
|
|
|
200
|
1
|
200
|
my $self = shift; |
26
|
200
|
|
|
|
|
252
|
my $tokens = $self->{tokens}; |
27
|
200
|
|
|
|
|
209
|
my $len = scalar(@$tokens) - 1; |
28
|
200
|
50
|
|
|
|
432
|
if ( $len == -1 ) { |
|
|
100
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif ( $self->{pos} > $len ) { |
32
|
6
|
|
|
|
|
14
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
194
|
|
|
|
|
428
|
return $tokens->[ $self->{pos}++ ]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub prev { |
40
|
6
|
|
|
6
|
1
|
12
|
my $self = shift; |
41
|
6
|
|
|
|
|
13
|
my $tokens = $self->{tokens}; |
42
|
6
|
|
|
|
|
13
|
my $len = scalar(@$tokens) - 1; |
43
|
6
|
50
|
|
|
|
27
|
if ( $len == -1 ) { |
|
|
50
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ( $self->{pos} < 0 ) { |
47
|
0
|
|
|
|
|
0
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
6
|
|
|
|
|
28
|
return $tokens->[ --$self->{pos} ]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub reset { |
55
|
0
|
|
|
0
|
1
|
0
|
$_[0]->{pos} = 0; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub set_pos { |
59
|
0
|
|
|
0
|
1
|
0
|
$_[0]->{pos} = $_[1]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_token { |
63
|
62
|
|
|
62
|
1
|
43
|
my $self = shift; |
64
|
62
|
|
|
|
|
40
|
my $len = scalar( @{ $self->{tokens} } ) - 1; |
|
62
|
|
|
|
|
66
|
|
65
|
62
|
|
|
|
|
42
|
my $i = shift; |
66
|
62
|
50
|
|
|
|
90
|
if ( !defined $i ) { |
67
|
0
|
|
|
|
|
0
|
croak "index position required"; |
68
|
|
|
|
|
|
|
} |
69
|
62
|
50
|
|
|
|
74
|
if ( !defined $self->{tokens}->[$i] ) { |
70
|
0
|
|
|
|
|
0
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
62
|
|
|
|
|
153
|
return $self->{tokens}->[$i]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub as_array { |
78
|
14
|
|
|
14
|
1
|
51
|
return $_[0]->{tokens}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub matches { |
82
|
6
|
|
|
6
|
1
|
13
|
return [ grep { $_->{is_match} } @{ $_[0]->{tokens} } ]; |
|
188
|
|
|
|
|
258
|
|
|
6
|
|
|
|
|
22
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub num_matches { |
86
|
0
|
|
|
0
|
1
|
|
return scalar @{ shift->matches }; |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |