| 1 | package Statistics::R::IO::Parser; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Functions for parsing R data files | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 14 | $Statistics::R::IO::Parser::VERSION = '1.0002'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | our @EXPORT = qw( ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | our @EXPORT_OK = qw( endianness any_char char string | |||||||||||||||||||||||||||||||||||||||||
| 12 | any_uint8 any_uint16 any_uint24 any_uint32 any_real32 any_real64 any_real64_na | ||||||||||||||||||||||||||||||||||||||||||
| 13 | uint8 uint16 uint24 uint32 | ||||||||||||||||||||||||||||||||||||||||||
| 14 | any_int8 any_int16 any_int24 any_int32 any_int32_na | ||||||||||||||||||||||||||||||||||||||||||
| 15 | int8 int16 int24 int32 | ||||||||||||||||||||||||||||||||||||||||||
| 16 | count with_count many_till seq choose mreturn error add_singleton get_singleton reserve_singleton bind ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | our %EXPORT_TAGS = ( all => [ @EXPORT_OK ], | |||||||||||||||||||||||||||||||||||||||||
| 19 | num => [ qw( any_uint8 any_uint16 any_uint24 any_uint32 any_int32_na any_real32 any_real64 any_real64_na uint8 uint16 uint24 uint32 ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 20 | char => [ qw( any_char char string ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 21 | combinator => [ qw( count with_count many_till seq choose mreturn bind ) ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 14 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 55836 | ▶ | sub endianness { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endianness: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 55836 | state $endianness = '>'; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 55836 | ▶ | my $new_value = shift if @_ or return $endianness; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
@_ or return $endianness
MC/DC100%1/1
@_ or return $endianness
@_
Truth table100%2/2
A
A= @_
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 952 | ▶ | $endianness = $new_value =~ /^[<>]$/ && $new_value || $endianness; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$new_value =~ /^[<>]$/ && $new_value || $endianness
$new_value =~ /^[<>]$/ and $new_value
MC/DC0%0/3
$new_value =~ /^[<>]$/ && $new_value || $endianness
$new_value =~ /^[<>]$/
$new_value
$endianness
Truth table40%2/5
A and B || C
A= $new_value =~ /^[<>]$/B= $new_valueC= $endianness
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 277948 | ▶ | sub any_char { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_char: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 277948 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 277948 | ▶ | return undef if !$state || $state->eof; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $state or $state->eof
MC/DC50%1/2
not $state or $state->eof
not $state
$state->eof
Truth table66%2/3
not(A) or B
A= not $stateB= $state->eof
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 277933 | [$state->at, $state->next] | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | ▶ | sub char { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
char: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | ▶ | die 'Must be a single-char argument: ' . $arg unless length($arg) == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 16 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 16 | ▶ | my $state = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 16 | ▶ | return if $state->eof || $arg ne $state->at; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$state->eof or $arg ne $state->at
MC/DC100%2/2
$state->eof or $arg ne $state->at
$state->eof
$arg ne $state->at
Truth table100%3/3
A or B
A= $state->eofB= $arg ne $state->at
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | [ $arg, $state->next ] | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | } | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 1580 | ▶ | sub string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1580 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 1580 | ▶ | die 'Must be a scalar argument: ' . $arg unless $arg && !ref($arg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$arg and not ref $arg
MC/DC50%1/2
$arg and not ref $arg
$arg
not ref $arg
Truth table66%2/3
A and not(B)
A= $argB= not ref $arg
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1579 | my $chars = count(length($arg), \&any_char); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 960 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 960 | ▶ | my ($char_values, $state) = @{$chars->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&$chars(@_) || (return)
MC/DC100%1/1
&$chars(@_) || (return)
&$chars(@_)
Truth table100%2/2
A
A= &$chars(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 959 | ▶ | return unless join('', @{$char_values}) eq $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 791 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 1579 | } | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 237063 | ▶ | sub any_uint8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_uint8: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 237063 | ▶ | my ($value, $state) = @{any_char @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
any_char(@_) || (return)
MC/DC100%1/1
any_char(@_) || (return)
any_char(@_)
Truth table100%2/2
A
A= any_char(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 237051 | [ unpack('C', $value), $state ] | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 18 | ▶ | sub any_uint16 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_uint16: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 18 | ▶ | my ($value, $state) = @{count(2, \&any_uint8)->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
count(2, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
MC/DC0%0/1
count(2, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
count(2, \&Statistics::R::IO::Parser::any_uint8)->(@_)
Truth table50%1/2
A
A= count(2, \&Statistics::R::IO::Parser::any_uint8)->(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 18 | [ unpack("S" . endianness, pack 'C2' => @{$value}), | |||||||||||||||||||||||||||||||||||||||||
| 80 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 179 | ▶ | sub any_uint24 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_uint24: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 179 | ▶ | my ($value, $state) = @{count(3, \&any_uint8)->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
count(3, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
MC/DC100%1/1
count(3, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
count(3, \&Statistics::R::IO::Parser::any_uint8)->(@_)
Truth table100%2/2
A
A= count(3, \&Statistics::R::IO::Parser::any_uint8)->(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | [ unpack("L" . endianness, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 175 | ▶ | pack(endianness eq '>' ? 'xC3' : 'C3x', @{$value})), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 47385 | ▶ | sub any_uint32 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_uint32: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 47385 | ▶ | my ($value, $state) = @{count(4, \&any_uint8)->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
MC/DC100%1/1
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_)
Truth table100%2/2
A
A= count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 47379 | [ unpack("L" . endianness, pack 'C4' => @{$value}), | |||||||||||||||||||||||||||||||||||||||||
| 97 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 169 | ▶ | sub uint8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uint8: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 169 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 169 | ▶ | die 'Argument must be a number 0-255: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg <= 255 and $arg >= 0
&looks_like_number($arg) and $arg <= 255
MC/DC0%0/3
&looks_like_number($arg) and $arg <= 255 and $arg >= 0
&looks_like_number($arg)
$arg <= 255
$arg >= 0
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg <= 255C= $arg >= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | unless looks_like_number($arg) && $arg <= 0x000000FF && $arg >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 169 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 169 | ▶ | my ($value, $state) = @{any_uint8 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_uint8(@_) || (return)
MC/DC0%0/1
any_uint8(@_) || (return)
any_uint8(@_)
Truth table50%1/2
A
A= any_uint8(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 169 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 167 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 169 | } | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | ▶ | sub uint16 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uint16: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | ▶ | die 'Argument must be a number 0-65535: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg <= 65535 and $arg >= 0
&looks_like_number($arg) and $arg <= 65535
MC/DC0%0/3
&looks_like_number($arg) and $arg <= 65535 and $arg >= 0
&looks_like_number($arg)
$arg <= 65535
$arg >= 0
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg <= 65535C= $arg >= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | unless looks_like_number($arg) && $arg <= 0x0000FFFF && $arg >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | ▶ | my ($value, $state) = @{any_uint16 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_uint16(@_) || (return)
MC/DC0%0/1
any_uint16(@_) || (return)
any_uint16(@_)
Truth table50%1/2
A
A= any_uint16(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 8 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 6 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | } | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 8 | ▶ | sub uint24 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uint24: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 8 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | ▶ | die 'Argument must be a number 0-16777215: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg <= 16777215 and $arg >= 0
&looks_like_number($arg) and $arg <= 16777215
MC/DC0%0/3
&looks_like_number($arg) and $arg <= 16777215 and $arg >= 0
&looks_like_number($arg)
$arg <= 16777215
$arg >= 0
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg <= 16777215C= $arg >= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | unless looks_like_number($arg) && $arg <= 0x00FFFFFF && $arg >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 8 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | ▶ | my ($value, $state) = @{any_uint24 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
any_uint24(@_) || (return)
MC/DC100%1/1
any_uint24(@_) || (return)
any_uint24(@_)
Truth table100%2/2
A
A= any_uint24(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 8 | } | |||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 1640 | ▶ | sub uint32 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uint32: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 1640 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 1640 | ▶ | die 'Argument must be a number 0-4294967295: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg <= 4294967295 and $arg >= 0
&looks_like_number($arg) and $arg <= 4294967295
MC/DC0%0/3
&looks_like_number($arg) and $arg <= 4294967295 and $arg >= 0
&looks_like_number($arg)
$arg <= 4294967295
$arg >= 0
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg <= 4294967295C= $arg >= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | unless looks_like_number($arg) && $arg <= 0xFFFFFFFF && $arg >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 7526 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 7526 | ▶ | my ($value, $state) = @{any_uint32 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
any_uint32(@_) || (return)
MC/DC100%1/1
any_uint32(@_) || (return)
any_uint32(@_)
Truth table100%2/2
A
A= any_uint32(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 7524 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1710 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 1640 | } | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | ▶ | sub any_int8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_int8: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | my ($value, $state) = @{any_char @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_char(@_) || (return)
MC/DC0%0/1
any_char(@_) || (return)
any_char(@_)
Truth table50%1/2
A
A= any_char(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | [ unpack('c', $value), $state ] | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | sub any_int16 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_int16: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | ▶ | my ($value, $state) = @{any_uint16 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_uint16(@_) || (return)
MC/DC0%0/1
any_uint16(@_) || (return)
any_uint16(@_)
Truth table50%1/2
A
A= any_uint16(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | ▶ | $value |= 0x8000 if ($value >= 1<<15); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | [ unpack('s', pack 's' => $value), | |||||||||||||||||||||||||||||||||||||||||
| 169 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | sub any_int24 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_int24: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | my ($value, $state) = @{any_uint24 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_uint24(@_) || (return)
MC/DC0%0/1
any_uint24(@_) || (return)
any_uint24(@_)
Truth table50%1/2
A
A= any_uint24(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | ▶ | $value |= 0xff800000 if ($value >= 1<<23); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | [ unpack('l', pack 'l' => $value), | |||||||||||||||||||||||||||||||||||||||||
| 178 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 16630 | ▶ | sub any_int32 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_int32: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 16630 | ▶ | my ($value, $state) = @{any_uint32 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
any_uint32(@_) || (return)
MC/DC100%1/1
any_uint32(@_) || (return)
any_uint32(@_)
Truth table100%2/2
A
A= any_uint32(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 16628 | ▶ | $value |= 0x80000000 if ($value >= 1<<31); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 16628 | [ unpack('l', pack 'l' => $value), | |||||||||||||||||||||||||||||||||||||||||
| 187 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | sub int8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int8: called CC=4 SCAR=15.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | die 'Argument must be a number -128-127: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg < 128 and $arg >= -128
&looks_like_number($arg) and $arg < 128
MC/DC0%0/3
&looks_like_number($arg) and $arg < 128 and $arg >= -128
&looks_like_number($arg)
$arg < 128
$arg >= -128
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg < 128C= $arg >= -128
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | unless looks_like_number($arg) && $arg < 1<<7 && $arg >= -(1<<7); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | my ($value, $state) = @{any_int8 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_int8(@_) || (return)
MC/DC0%0/1
any_int8(@_) || (return)
any_int8(@_)
Truth table50%1/2
A
A= any_int8(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | } | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | sub int16 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int16: called CC=4 SCAR=15.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | die 'Argument must be a number -32768-32767: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg < 32768 and $arg >= -32768
&looks_like_number($arg) and $arg < 32768
MC/DC0%0/3
&looks_like_number($arg) and $arg < 32768 and $arg >= -32768
&looks_like_number($arg)
$arg < 32768
$arg >= -32768
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg < 32768C= $arg >= -32768
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | unless looks_like_number($arg) && $arg < 1<<15 && $arg >= -(1<<15); | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | my ($value, $state) = @{any_int16 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_int16(@_) || (return)
MC/DC0%0/1
any_int16(@_) || (return)
any_int16(@_)
Truth table50%1/2
A
A= any_int16(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | } | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | sub int24 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int24: called CC=4 SCAR=15.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | ▶ | die 'Argument must be a number 0-16777215: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg < 8388608 and $arg >= -8388608
&looks_like_number($arg) and $arg < 8388608
MC/DC0%0/3
&looks_like_number($arg) and $arg < 8388608 and $arg >= -8388608
&looks_like_number($arg)
$arg < 8388608
$arg >= -8388608
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg < 8388608C= $arg >= -8388608
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | unless looks_like_number($arg) && $arg < 1<<23 && $arg >= -(1<<23); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | my ($value, $state) = @{any_int24 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
any_int24(@_) || (return)
MC/DC0%0/1
any_int24(@_) || (return)
any_int24(@_)
Truth table50%1/2
A
A= any_int24(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | } | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1189 | ▶ | sub int32 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int32: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 1189 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 1189 | ▶ | die 'Argument must be a number -2147483648-2147483647: ' . $arg | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
&looks_like_number($arg) and $arg < 2147483648 and $arg >= '-2147483648'
&looks_like_number($arg) and $arg < 2147483648
MC/DC0%0/3
&looks_like_number($arg) and $arg < 2147483648 and $arg >= '-2147483648'
&looks_like_number($arg)
$arg < 2147483648
$arg >= '-2147483648'
Truth table25%1/4
A and B and C
A= &looks_like_number($arg)B= $arg < 2147483648C= $arg >= '-2147483648'
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | unless looks_like_number($arg) && $arg < 1<<31 && $arg >= -(1<<31); | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2738 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 2738 | ▶ | my ($value, $state) = @{any_int32 @_ or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
any_int32(@_) || (return)
MC/DC100%1/1
any_int32(@_) || (return)
any_int32(@_)
Truth table100%2/2
A
A= any_int32(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 2737 | ▶ | return unless $arg == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 121 | [ $arg, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 1189 | } | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 1186 | ▶ | sub any_int32_na { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_int32_na: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | choose(&bind(int32(-2147483648), | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 119 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 119 | mreturn(undef); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 1186 | }), | |||||||||||||||||||||||||||||||||||||||||
| 252 | \&any_int32) | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 14 | my %na_real = ( '>' => [ uint32(0x7ff00000), | |||||||||||||||||||||||||||||||||||||||||
| 256 | uint32(0x7a2) ], | ||||||||||||||||||||||||||||||||||||||||||
| 257 | '<' => [ uint32(0x7a2), | ||||||||||||||||||||||||||||||||||||||||||
| 258 | uint32(0x7ff00000) ]); | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 1319 | ▶ | sub any_real64_na { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_real64_na: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 1319 | choose(&bind(seq(@{$na_real{endianness()}}), | |||||||||||||||||||||||||||||||||||||||||
| 262 | 65 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 65 | mreturn(undef); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1319 | }), | |||||||||||||||||||||||||||||||||||||||||
| 265 | \&any_real64) | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | ▶ | sub any_real32 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_real32: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | ▶ | my ($value, $state) = @{count(4, \&any_uint8)->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
MC/DC0%0/1
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_)
Truth table50%1/2
A
A= count(4, \&Statistics::R::IO::Parser::any_uint8)->(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | [ unpack("f" . endianness, pack 'C4' => @{$value}), | |||||||||||||||||||||||||||||||||||||||||
| 273 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 5815 | ▶ | sub any_real64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_real64: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 5815 | ▶ | my ($value, $state) = @{count(8, \&any_uint8)->(@_) or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
count(8, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
MC/DC0%0/1
count(8, \&Statistics::R::IO::Parser::any_uint8)->(@_) || (return)
count(8, \&Statistics::R::IO::Parser::any_uint8)->(@_)
Truth table50%1/2
A
A= count(8, \&Statistics::R::IO::Parser::any_uint8)->(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 5815 | [ unpack("d" . endianness, pack 'C8' => @{$value}), | |||||||||||||||||||||||||||||||||||||||||
| 281 | $state ] | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 70582 | ▶ | sub count { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 70582 | my ($n, $parser) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 70015 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 70015 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 70015 | my @value; | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 70015 | for (1..$n) { | |||||||||||||||||||||||||||||||||||||||||
| 292 | 300716 | ▶ | my $result = $parser->($state) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 300701 | push @value, shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 300701 | $state = shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 70000 | return [ [ @value ], $state ]; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 70582 | } | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 10675 | ▶ | sub seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 10675 | my @parsers = @_; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 15234 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 15234 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 15234 | my @value; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 15234 | foreach my $parser (@parsers) { | |||||||||||||||||||||||||||||||||||||||||
| 311 | 22407 | ▶ | my $result = $parser->($state) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 16585 | push @value, shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 16585 | $state = shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 9412 | return [ [ @value ], $state ]; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 10675 | } | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | ▶ | sub many_till { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
many_till: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | my ($p, $end) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | die "'bind' expects two arguments" unless $p && $end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p and $end
MC/DC0%0/2
$p and $end
$p
$end
Truth table33%1/3
A and B
A= $pB= $end
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | ▶ | my $state = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | my @value; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | ▶ | until ($end->($state)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 3 | ▶ | my $result = $p->($state) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | push @value, shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | $state = shift @$result; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | return [ [ @value ], $state ] | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 3294 | ▶ | sub choose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
choose: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 3294 | my @parsers = @_; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 9403 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 9403 | ▶ | my $state = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 9403 | foreach my $parser (@parsers) { | |||||||||||||||||||||||||||||||||||||||||
| 349 | 18000 | my $result = $parser->($state); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 18000 | ▶ | return $result if $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 3294 | } | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 50561 | ▶ | sub mreturn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mreturn: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 50561 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 50561 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 50561 | [ $arg, shift ] | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 50561 | } | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 12 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 12 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 12 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 12 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 12 | croak $message . " (at " . $state->position . ")"; | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 1883 | ▶ | sub add_singleton { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 1883 | my $singleton = shift; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 1883 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 1883 | [ $singleton, shift->add_singleton($singleton) ] | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 1883 | } | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1632 | ▶ | sub get_singleton { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 1632 | my $ref_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 1632 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 1632 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 1632 | [ $state->get_singleton($ref_id), $state ] | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 1632 | } | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | ## Preallocates a space for a singleton before running a given parser, | ||||||||||||||||||||||||||||||||||||||||||
| 393 | ## and then assigns the parser's value to the singleton. | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 53 | ▶ | sub reserve_singleton { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reserve_singleton: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 53 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 397 | &bind( | ||||||||||||||||||||||||||||||||||||||||||
| 398 | seq( | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 53 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 53 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 53 | my $ref_id = scalar(@{$state->singletons}); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 53 | my $new_state = $state->add_singleton(undef); | |||||||||||||||||||||||||||||||||||||||||
| 403 | 53 | [ $ref_id, $new_state ] | |||||||||||||||||||||||||||||||||||||||||
| 404 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | $p), | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 53 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 53 | my ($ref_id, $value) = @{shift()}; | |||||||||||||||||||||||||||||||||||||||||
| 408 | 53 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 53 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 53 | $state->singletons->[$ref_id] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 53 | [ $value, $state ] | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 53 | }) | |||||||||||||||||||||||||||||||||||||||||
| 414 | 53 | } | |||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 72336 | ▶ | sub bind { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 72336 | my ($p1, $fp2) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 419 | 72336 | ▶ | die "'bind' expects two arguments" unless $p1 && $fp2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p1 and $fp2
MC/DC0%0/2
$p1 and $fp2
$p1
$fp2
Truth table33%1/3
A and B
A= $p1B= $fp2
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 93806 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 93806 | ▶ | my $v1 = $p1->(shift or return); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 93785 | ▶ | my ($value, $state) = @{$v1 or return}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$v1 || (return)
MC/DC100%1/1
$v1 || (return)
$v1
Truth table100%2/2
A
A= $v1
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 85191 | $fp2->($value)->($state) | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 72336 | } | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 4837 | ▶ | sub with_count { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_count: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 4837 | ▶ | die "'bind' expects one or two arguments" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and scalar @_ <= 2
MC/DC0%0/2
@_ and scalar @_ <= 2
@_
scalar @_ <= 2
Truth table33%1/3
A and B
A= @_B= scalar @_ <= 2
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | unless @_ and scalar(@_) <= 2; | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 4837 | ▶ | unshift(@_, \&any_uint32) if (scalar(@_) == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 4837 | my ($counter, $content) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | &bind($counter, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 4827 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 4827 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 4827 | count($n, $content) | |||||||||||||||||||||||||||||||||||||||||
| 440 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 4837 | } | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | __END__ | ||||||||||||||||||||||||||||||||||||||||||