| 1 | package Text::Xatena::LineScanner; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 141 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | 141 | my ($class, $str) = @_; | |||||||||||||||||||||||||||
| 8 | 141 | my $lines = [ split /\n/, $str ]; | |||||||||||||||||||||||||||
| 9 | 141 | bless { | |||||||||||||||||||||||||||
| 10 | matched => undef, | ||||||||||||||||||||||||||||
| 11 | line => 0, | ||||||||||||||||||||||||||||
| 12 | eos => !@$lines, | ||||||||||||||||||||||||||||
| 13 | lines => $lines, | ||||||||||||||||||||||||||||
| 14 | }, $class; | ||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4873 | ▶ | sub scan { | ||||||||||||||||||||||||||
|
Subroutine
scan: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 4873 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | 4873 | ▶ | if (my @matched = ($self->{lines}->[$self->{line}] =~ $_[0])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 224 | unshift @matched, $self->{lines}->[$self->{line}]; | |||||||||||||||||||||||||||
| 21 | 224 | $self->{matched} = \@matched; | |||||||||||||||||||||||||||
| 22 | 224 | $self->{line}++; | |||||||||||||||||||||||||||
| 23 | 224 | $self->{eos} = ($self->{line} >= @{ $self->{lines} }); | |||||||||||||||||||||||||||
| 24 | 224 | $matched[0]; | |||||||||||||||||||||||||||
| 25 | } else { | ||||||||||||||||||||||||||||
| 26 | 4649 | undef $self->{matched}; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 274 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 274 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 274 | my $ret = $self->{lines}->[$self->{line}]; | |||||||||||||||||||||||||||
| 33 | 274 | $self->{line}++; | |||||||||||||||||||||||||||
| 34 | 274 | $self->{eos} = ($self->{line} >= @{ $self->{lines} }); | |||||||||||||||||||||||||||
| 35 | 274 | $ret; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 22 | ▶ | sub scan_until { | ||||||||||||||||||||||||||
|
Subroutine
scan_until: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 22 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 22 | my $ret = []; | |||||||||||||||||||||||||||
| 41 | 22 | ▶ | until ($self->{eos} || $self->scan($_[0])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"eos"} or $self->scan($_[0])
MC/DC100%2/2
$self->{"eos"} or $self->scan($_[0])
$self->{"eos"}
$self->scan($_[0])
Truth table100%3/3
A or B
A= $self->{"eos"}B= $self->scan($_[0])
| |||||||||||||||||||||||||||||
| 42 | 68 | push @$ret, $self->{lines}->[$self->{line}]; | |||||||||||||||||||||||||||
| 43 | 68 | $self->{line}++; | |||||||||||||||||||||||||||
| 44 | 68 | $self->{eos} = ($self->{line} >= @{ $self->{lines} }); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 22 | ▶ | push @$ret, $self->{matched}->[0] if $self->{matched}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 22 | ▶ | wantarray? @$ret : $ret; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 315 | ▶ | sub matched { | ||||||||||||||||||||||||||
|
Subroutine
matched: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 315 | $_[0]->{matched}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub current { | ||||||||||||||||||||||||||
|
Subroutine
current: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | $_[0]->{lines}->[$_[0]->{line}]; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 648 | ▶ | sub eos { | ||||||||||||||||||||||||||
|
Subroutine
eos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | $_[0]->{eos} | ||||||||||||||||||||||||||||
| 60 | 648 | } | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 20 | 1; | |||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||