line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Xatena::LineScanner; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
109
|
use strict; |
|
20
|
|
|
|
|
43
|
|
|
20
|
|
|
|
|
1108
|
|
4
|
20
|
|
|
20
|
|
148
|
use warnings; |
|
20
|
|
|
|
|
38
|
|
|
20
|
|
|
|
|
9060
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
120
|
|
|
120
|
0
|
220
|
my ($class, $str) = @_; |
8
|
120
|
|
|
|
|
638
|
my $lines = [ split /\n/, $str ]; |
9
|
120
|
|
|
|
|
1006
|
bless { |
10
|
|
|
|
|
|
|
matched => undef, |
11
|
|
|
|
|
|
|
line => 0, |
12
|
|
|
|
|
|
|
eos => !@$lines, |
13
|
|
|
|
|
|
|
lines => $lines, |
14
|
|
|
|
|
|
|
}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub scan { |
18
|
4461
|
|
|
4461
|
0
|
5063
|
my $self = shift; |
19
|
4461
|
100
|
|
|
|
20109
|
if (my @matched = ($self->{lines}->[$self->{line}] =~ $_[0])) { |
20
|
207
|
|
|
|
|
540
|
unshift @matched, $self->{lines}->[$self->{line}]; |
21
|
207
|
|
|
|
|
363
|
$self->{matched} = \@matched; |
22
|
207
|
|
|
|
|
308
|
$self->{line}++; |
23
|
207
|
|
|
|
|
284
|
$self->{eos} = ($self->{line} >= @{ $self->{lines} }); |
|
207
|
|
|
|
|
394
|
|
24
|
207
|
|
|
|
|
986
|
$matched[0]; |
25
|
|
|
|
|
|
|
} else { |
26
|
4254
|
|
|
|
|
25200
|
undef $self->{matched}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub next { |
31
|
250
|
|
|
250
|
0
|
338
|
my $self = shift; |
32
|
250
|
|
|
|
|
680
|
my $ret = $self->{lines}->[$self->{line}]; |
33
|
250
|
|
|
|
|
337
|
$self->{line}++; |
34
|
250
|
|
|
|
|
327
|
$self->{eos} = ($self->{line} >= @{ $self->{lines} }); |
|
250
|
|
|
|
|
568
|
|
35
|
250
|
|
|
|
|
936
|
$ret; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub scan_until { |
39
|
22
|
|
|
22
|
0
|
39
|
my $self = shift; |
40
|
22
|
|
|
|
|
46
|
my $ret = []; |
41
|
22
|
|
100
|
|
|
110
|
until ($self->{eos} || $self->scan($_[0])) { |
42
|
68
|
|
|
|
|
160
|
push @$ret, $self->{lines}->[$self->{line}]; |
43
|
68
|
|
|
|
|
82
|
$self->{line}++; |
44
|
68
|
|
|
|
|
86
|
$self->{eos} = ($self->{line} >= @{ $self->{lines} }); |
|
68
|
|
|
|
|
252
|
|
45
|
|
|
|
|
|
|
} |
46
|
22
|
100
|
|
|
|
93
|
push @$ret, $self->{matched}->[0] if $self->{matched}; |
47
|
22
|
50
|
|
|
|
80
|
wantarray? @$ret : $ret; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub matched { |
51
|
295
|
|
|
295
|
0
|
1760
|
$_[0]->{matched}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub current { |
55
|
0
|
|
|
0
|
0
|
0
|
$_[0]->{lines}->[$_[0]->{line}]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub eos { |
59
|
586
|
|
|
586
|
0
|
2497
|
$_[0]->{eos} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |