| 1 | package TOML::Parser; | ||||||||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use 5.010000; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 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 | 20 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 20 | our $VERSION = "0.90"; | |||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use TOML::Parser::Tokenizer qw/:constant/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use TOML::Parser::Tokenizer::Strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use TOML::Parser::Util qw/unescape_str/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use Types::Serialiser; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 15 | 56 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 16 | 56 | ▶ | my $args = (@_ == 1 and ref $_[0] eq 'HASH') ? +shift : +{ @_ }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||
| 17 | return bless +{ | ||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | inflate_datetime => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | inflate_boolean => sub { $_[0] eq 'true' ? Types::Serialiser::true : Types::Serialiser::false }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 20 | 56 | strict_mode => 0, | |||||||||||||||||||||||||||||||||||||
| 21 | %$args, | ||||||||||||||||||||||||||||||||||||||
| 22 | } => $class; | ||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | sub parse_file { | ||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | open my $fh, '<:encoding(utf-8)', $file or die $!; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return $self->parse_fh($fh); | |||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | sub parse_fh { | ||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($self, $fh) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_fh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $src = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||
| 34 | 0 | return $self->parse($src); | |||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | sub _tokenizer_class { | ||||||||||||||||||||||||||||||||||||||
| 38 | 56 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_tokenizer_class: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 39 | 56 | ▶ | return $self->{strict_mode} ? 'TOML::Parser::Tokenizer::Strict' : 'TOML::Parser::Tokenizer'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 20 | our @TOKENS; | |||||||||||||||||||||||||||||||||||||
| 43 | 20 | our $ROOT; | |||||||||||||||||||||||||||||||||||||
| 44 | 20 | our $CONTEXT; | |||||||||||||||||||||||||||||||||||||
| 45 | sub parse { | ||||||||||||||||||||||||||||||||||||||
| 46 | 56 | ▶ | my ($self, $src) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 56 | local $ROOT = {}; | |||||||||||||||||||||||||||||||||||||
| 49 | 56 | local $CONTEXT = $ROOT; | |||||||||||||||||||||||||||||||||||||
| 50 | 56 | local @TOKENS = $self->_tokenizer_class->tokenize($src); | |||||||||||||||||||||||||||||||||||||
| 51 | 36 | return $self->_parse_tokens(); | |||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | sub _parse_tokens { | ||||||||||||||||||||||||||||||||||||||
| 55 | 93 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_tokens: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 93 | ▶ | while (my $token = shift @TOKENS) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 58 | 332 | $self->_parse_token($token); | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | 88 | return $CONTEXT; | |||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | sub _parse_token { | ||||||||||||||||||||||||||||||||||||||
| 65 | 332 | ▶ | my ($self, $token) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_token: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | 332 | my ($type, $val) = @$token; | |||||||||||||||||||||||||||||||||||||
| 68 | 332 | ▶ | if ($type eq TOKEN_TABLE) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||
| 69 | 40 | $self->_parse_table($val); | |||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||
| 71 | elsif ($type eq TOKEN_ARRAY_OF_TABLE) { | ||||||||||||||||||||||||||||||||||||||
| 72 | 17 | $self->_parse_array_of_table($val); | |||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||
| 74 | elsif (my ($key, $value) = $self->_parse_key_and_value($token)) { | ||||||||||||||||||||||||||||||||||||||
| 75 | 213 | ▶ | die "Duplicate key. key:$key" if exists $CONTEXT->{$key}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 76 | 210 | $CONTEXT->{$key} = $value; | |||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||
| 78 | elsif ($type eq TOKEN_COMMENT) { | ||||||||||||||||||||||||||||||||||||||
| 79 | # pass through | ||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||
| 82 | 0 | die "Unknown case. type:$type"; | |||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | sub _parse_key_and_value { | ||||||||||||||||||||||||||||||||||||||
| 87 | 319 | ▶ | my ($self, $token) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_key_and_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | 319 | my ($type, $val) = @$token; | |||||||||||||||||||||||||||||||||||||
| 90 | 319 | ▶ | if ($type eq TOKEN_KEY) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 91 | 257 | my $token = shift @TOKENS; | |||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | 257 | my $key = $val; | |||||||||||||||||||||||||||||||||||||
| 94 | 257 | my $value = $self->_parse_value_token($token); | |||||||||||||||||||||||||||||||||||||
| 95 | 257 | return ($key, $value); | |||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||
| 98 | 62 | return; | |||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | sub _parse_table { | ||||||||||||||||||||||||||||||||||||||
| 102 | 40 | ▶ | my ($self, $keys) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_table: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||
| 103 | 40 | my @keys = @$keys; | |||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | 40 | local $CONTEXT = $ROOT; | |||||||||||||||||||||||||||||||||||||
| 106 | 40 | for my $k (@keys) { | |||||||||||||||||||||||||||||||||||||
| 107 | 67 | ▶ | if (exists $CONTEXT->{$k}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 108 | $CONTEXT = ref $CONTEXT->{$k} eq 'ARRAY' ? $CONTEXT->{$k}->[-1] : | ||||||||||||||||||||||||||||||||||||||
| 109 | 9 | ▶ | ref $CONTEXT->{$k} eq 'HASH' ? $CONTEXT->{$k} : | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 110 | 0 | die "invalid structure. @{[ join '.', @keys ]} cannot be `Table`"; | |||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||||||||||||
| 113 | 58 | ▶ | $CONTEXT = $CONTEXT->{$k} ||= +{}; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$TOML::Parser::CONTEXT->{$k} ||= {}
MC/DC0%0/1
$TOML::Parser::CONTEXT->{$k} ||= {}
$TOML::Parser::CONTEXT->{$k}
Truth table50%1/2
A
A= $TOML::Parser::CONTEXT->{$k}
| |||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | 40 | $self->_parse_tokens(); | |||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | sub _parse_array_of_table { | ||||||||||||||||||||||||||||||||||||||
| 121 | 17 | ▶ | my ($self, $keys) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_array_of_table: called CC=8 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||
| 122 | 17 | my @keys = @$keys; | |||||||||||||||||||||||||||||||||||||
| 123 | 17 | my $last_key = pop @keys; | |||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | 17 | local $CONTEXT = $ROOT; | |||||||||||||||||||||||||||||||||||||
| 126 | 17 | for my $k (@keys) { | |||||||||||||||||||||||||||||||||||||
| 127 | 6 | ▶ | if (exists $CONTEXT->{$k}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 128 | $CONTEXT = ref $CONTEXT->{$k} eq 'ARRAY' ? $CONTEXT->{$k}->[-1] : | ||||||||||||||||||||||||||||||||||||||
| 129 | 6 | ▶ | ref $CONTEXT->{$k} eq 'HASH' ? $CONTEXT->{$k} : | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 130 | 0 | die "invalid structure. @{[ join '.', @keys ]} cannot be `Array of table`."; | |||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $CONTEXT = $CONTEXT->{$k} ||= +{}; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$TOML::Parser::CONTEXT->{$k} ||= {}
MC/DC0%0/1
$TOML::Parser::CONTEXT->{$k} ||= {}
$TOML::Parser::CONTEXT->{$k}
Truth table0%0/2
A
A= $TOML::Parser::CONTEXT->{$k}
| |||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | 17 | ▶ | $CONTEXT->{$last_key} = [] unless exists $CONTEXT->{$last_key}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 138 | 17 | ▶ | die "invalid structure. @{[ join '.', @keys ]} cannot be `Array of table`" unless ref $CONTEXT->{$last_key} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 139 | 17 | push @{ $CONTEXT->{$last_key} } => $CONTEXT = {}; | |||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||
| 141 | 17 | $self->_parse_tokens(); | |||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||
| 144 | sub _parse_value_token { | ||||||||||||||||||||||||||||||||||||||
| 145 | 326 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_value_token: called CC=23 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||
| 146 | 326 | my $token = shift; | |||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | 326 | my ($type, $val, @args) = @$token; | |||||||||||||||||||||||||||||||||||||
| 149 | 326 | ▶ | if ($type eq TOKEN_COMMENT) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return; # pass through | |||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||
| 152 | ▶ | elsif ($type eq TOKEN_INTEGER || $type eq TOKEN_FLOAT) { | |||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$type eq "INTEGER" or $type eq "FLOAT"
MC/DC100%2/2
$type eq "INTEGER" or $type eq "FLOAT"
$type eq "INTEGER"
$type eq "FLOAT"
Truth table100%3/3
A or B
A= $type eq "INTEGER"B= $type eq "FLOAT"
| |||||||||||||||||||||||||||||||||||||||
| 153 | 98 | $val =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||
| 154 | 98 | return 0+$val; | |||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||
| 156 | elsif ($type eq TOKEN_BOOLEAN) { | ||||||||||||||||||||||||||||||||||||||
| 157 | 4 | return $self->inflate_boolean($val); | |||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||
| 159 | elsif ($type eq TOKEN_DATETIME) { | ||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return $self->inflate_datetime($val); | |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | elsif ($type eq TOKEN_STRING) { | ||||||||||||||||||||||||||||||||||||||
| 163 | 157 | my ($is_raw) = @args; | |||||||||||||||||||||||||||||||||||||
| 164 | 157 | ▶ | return $is_raw ? $val : unescape_str($val); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||
| 166 | elsif ($type eq TOKEN_MULTI_LINE_STRING_BEGIN) { | ||||||||||||||||||||||||||||||||||||||
| 167 | 20 | my ($is_raw) = @args; | |||||||||||||||||||||||||||||||||||||
| 168 | 20 | my $value = $self->_parse_value_token(shift @TOKENS); | |||||||||||||||||||||||||||||||||||||
| 169 | 20 | $value =~ s/\A(?:\r\n|[\r\n])//msg; | |||||||||||||||||||||||||||||||||||||
| 170 | 20 | $value =~ s/\\\s+//msg; | |||||||||||||||||||||||||||||||||||||
| 171 | 20 | ▶ | if (my $token = shift @TOKENS) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 172 | 20 | my ($type) = @$token; | |||||||||||||||||||||||||||||||||||||
| 173 | 20 | ▶ | return $value if $type eq TOKEN_MULTI_LINE_STRING_END; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 174 | 0 | die "Unexpected token: $type"; | |||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||
| 177 | elsif ($type eq TOKEN_INLINE_TABLE_BEGIN) { | ||||||||||||||||||||||||||||||||||||||
| 178 | 16 | my %data; | |||||||||||||||||||||||||||||||||||||
| 179 | 16 | ▶ | while (my $token = shift @TOKENS) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 180 | 62 | ▶ | last if $token->[0] eq TOKEN_INLINE_TABLE_END; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 181 | 46 | ▶ | next if $token->[0] eq TOKEN_COMMENT; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 182 | 44 | my ($key, $value) = $self->_parse_key_and_value($token); | |||||||||||||||||||||||||||||||||||||
| 183 | 44 | ▶ | die "Duplicate key. key:$key" if exists $data{$key}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 184 | 44 | $data{$key} = $value; | |||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||
| 186 | 16 | return \%data; | |||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||
| 188 | elsif ($type eq TOKEN_ARRAY_BEGIN) { | ||||||||||||||||||||||||||||||||||||||
| 189 | 29 | my @data; | |||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||
| 191 | my $last_token; | ||||||||||||||||||||||||||||||||||||||
| 192 | 29 | ▶ | while (my $token = shift @TOKENS) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 193 | 85 | ▶ | last if $token->[0] eq TOKEN_ARRAY_END; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 194 | 56 | ▶ | next if $token->[0] eq TOKEN_COMMENT; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 195 | 49 | ▶ | if ($self->{strict_mode}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 196 | 22 | ▶ | die "Unexpected token: $token->[0]" if defined $last_token && $token->[0] ne $last_token->[0]; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $last_token and $token->[0] ne $last_token->[0]
MC/DC0%0/2
defined $last_token and $token->[0] ne $last_token->[0]
defined $last_token
$token->[0] ne $last_token->[0]
Truth table66%2/3
A and B
A= defined $last_tokenB= $token->[0] ne $last_token->[0]
| |||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||
| 198 | 49 | push @data => $self->_parse_value_token($token); | |||||||||||||||||||||||||||||||||||||
| 199 | 49 | $last_token = $token; | |||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||
| 201 | 29 | return \@data; | |||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||
| 204 | 0 | die "Unexpected token: $type"; | |||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||
| 207 | sub inflate_datetime { | ||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_datetime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 209 | 2 | return $self->{inflate_datetime}->(@_); | |||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||
| 212 | sub inflate_boolean { | ||||||||||||||||||||||||||||||||||||||
| 213 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_boolean: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 214 | 4 | return $self->{inflate_boolean}->(@_); | |||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||
| 217 | 20 | 1; | |||||||||||||||||||||||||||||||||||||
| 218 | __END__ | ||||||||||||||||||||||||||||||||||||||