| 1 | # -*- mode: perl; coding: utf-8 -*- | ||||||||||||||||||||||||||||||||
| 2 | package YATT::LRXML::EntityPath; | ||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | BEGIN {require Exporter; *import = \&Exporter::import} | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 4 | our @EXPORT_OK = qw(parse_entpath is_nested_entpath); | |||||||||||||||||||||||||||||||
| 7 | 4 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | =pod | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | term ::= ( text | expr | pipeline ) ','? ; | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | pipeline ::= container? trail+ ; | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | trail ::= var | '[' term ']' ; | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | container::= '[' term* ']' | ||||||||||||||||||||||||||||||||
| 18 | | '{' ( dot_name (':' text | '=' term ) | ||||||||||||||||||||||||||||||||
| 19 | | other+ ','? | ||||||||||||||||||||||||||||||||
| 20 | )* '}' ; | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | var ::= (':'+ | '.'+) name ( '(' term* ')' )? ; | ||||||||||||||||||||||||||||||||
| 23 | name ::= \w+ ; | ||||||||||||||||||||||||||||||||
| 24 | dot_name ::= [\w\.]+ ; | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | expr ::= '=' text ; | ||||||||||||||||||||||||||||||||
| 27 | text ::= word ( group word? )* ; -- group で始まるのは、container. | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | group ::= [\(\[\{] ( text | ',' )* [\}\]\)] | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | word ::= [\w\$\-\+\*/%<>] other* ; | ||||||||||||||||||||||||||||||||
| 32 | other ::= [\w\$\-\+\*/%<>:\.!=] ; | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | # is_nested_entpath($entpath, ?head?) | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 50 | ▶ | sub is_nested_entpath { | ||||||||||||||||||||||||||||||
|
Subroutine
is_nested_entpath: called CC=7 SCAR=23.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 39 | 50 | ▶ | return unless defined $_[0] and ref $_[0] eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and ref $_[0] eq "ARRAY"
MC/DC0%0/2
defined $_[0] and ref $_[0] eq "ARRAY"
defined $_[0]
ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= defined $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 40 | 50 | my $item = shift; | |||||||||||||||||||||||||||||||
| 41 | 50 | ▶ | return unless defined $item->[0] and ref $item->[0] eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $item->[0] and ref $item->[0] eq "ARRAY"
MC/DC50%1/2
defined $item->[0] and ref $item->[0] eq "ARRAY"
defined $item->[0]
ref $item->[0] eq "ARRAY"
Truth table66%2/3
A and B
A= defined $item->[0]B= ref $item->[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | return 1 unless defined $_[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | defined $item->[0][0] and $item->[0][0] eq $_[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 4 | our ($TRANS, $NODE, $ORIG); | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | sub mydie (@) { | ||||||||||||||||||||||||||||||
|
Subroutine
mydie: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 49 | 2 | my $fmt = shift; | |||||||||||||||||||||||||||||||
| 50 | 2 | my $diag = do { | |||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | if ($TRANS and $NODE) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$YATT::LRXML::EntityPath::TRANS and $YATT::LRXML::EntityPath::NODE
MC/DC0%0/2
$YATT::LRXML::EntityPath::TRANS and $YATT::LRXML::EntityPath::NODE
$YATT::LRXML::EntityPath::TRANS
$YATT::LRXML::EntityPath::NODE
Truth table33%1/3
A and B
A= $YATT::LRXML::EntityPath::TRANSB= $YATT::LRXML::EntityPath::NODE
| |||||||||||||||||||||||||||||||||
| 52 | 2 | $TRANS->node_error($NODE, $fmt, @_); | |||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||
| 54 | 0 | sprintf $fmt, @_; | |||||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||
| 57 | 2 | die $diag; | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 272 | ▶ | sub parse_entpath { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_entpath: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 61 | 272 | my ($pack, $orig, $trans, $node) = @_; | |||||||||||||||||||||||||||||||
| 62 | 272 | ▶ | return undef unless defined $orig; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 271 | local $_ = $orig; | |||||||||||||||||||||||||||||||
| 64 | 271 | local $ORIG = $orig; | |||||||||||||||||||||||||||||||
| 65 | 271 | local $TRANS = $trans; | |||||||||||||||||||||||||||||||
| 66 | 271 | local $NODE = $node; | |||||||||||||||||||||||||||||||
| 67 | 271 | my @result; | |||||||||||||||||||||||||||||||
| 68 | 271 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | 271 | @result = &_parse_pipeline; | |||||||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||||||
| 71 | 0 | $result[0] = &_parse_pipeline; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | 270 | ▶ | if ($_ ne '') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | 1 | mydie "Unexpected token '$_' in entpath '$orig'"; | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | 269 | ▶ | wantarray ? @result : $result[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 4 | my %open_head = qw| ( call [ array { hash |; | |||||||||||||||||||||||||||||||
| 80 | 4 | my %open_rest = qw| ( call [ aref |; | |||||||||||||||||||||||||||||||
| 81 | 4 | my %close_ch = qw( ( ) [ ] { } ); | |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 4 | my $re_var = qr{[:]+ (\w+) (\()?}x; | |||||||||||||||||||||||||||||||
| 84 | 4 | my $re_other= qr{[\w\$\-\+\*/%<>\.=\@\|!:]}x; | |||||||||||||||||||||||||||||||
| 85 | 4 | my $re_word = qr{[\w\$\-\+\*/%<>\.=\@\|!] $re_other*}x; | |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 316 | ▶ | sub _parse_pipeline { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_pipeline: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||
| 88 | 316 | my @pipe; | |||||||||||||||||||||||||||||||
| 89 | 316 | ▶ | if (s/^ \[ //x) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 90 | # container | ||||||||||||||||||||||||||||||||
| 91 | 6 | push @pipe, _parse_group(['array'], ']', \&_parse_term); | |||||||||||||||||||||||||||||||
| 92 | } elsif (s/^ \{ //x) { | ||||||||||||||||||||||||||||||||
| 93 | 17 | push @pipe, &_parse_hash; | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | 316 | ▶ | while (s/^$re_var | ^(\[) | ^(\{)//x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 361 | ▶ | if ($2) { | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 97 | # '(' | ||||||||||||||||||||||||||||||||
| 98 | 96 | push @pipe, _parse_group([call => $1], ')', \&_parse_term); | |||||||||||||||||||||||||||||||
| 99 | } elsif (defined $1) { | ||||||||||||||||||||||||||||||||
| 100 | # \w+ | ||||||||||||||||||||||||||||||||
| 101 | 239 | push @pipe, [var => $1]; | |||||||||||||||||||||||||||||||
| 102 | } elsif (defined $3) { # '[' | ||||||||||||||||||||||||||||||||
| 103 | 24 | push @pipe, _parse_group(['aref'], ']', \&_parse_term, 'expr'); | |||||||||||||||||||||||||||||||
| 104 | } elsif (defined $4) { | ||||||||||||||||||||||||||||||||
| 105 | 2 | push @pipe, _parse_group(['var'], '}', \&_parse_term); | |||||||||||||||||||||||||||||||
| 106 | } else { | ||||||||||||||||||||||||||||||||
| 107 | 0 | mydie "?? $_"; | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | 315 | ▶ | wantarray ? @pipe : \@pipe; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 4 | my $re_grend = qr{ (?=[\)\]\}]) | $ }x; | |||||||||||||||||||||||||||||||
| 114 | 4 | my $re_text = qr{($re_word) # 1 | |||||||||||||||||||||||||||||||
| 115 | (?: ([\(\[\{]) # 2 | ||||||||||||||||||||||||||||||||
| 116 | | $re_grend)? | ||||||||||||||||||||||||||||||||
| 117 | | $re_grend | ||||||||||||||||||||||||||||||||
| 118 | }x; | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | 169 | ▶ | sub _parse_term { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_term: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||
| 121 | 169 | my ($literal_type) = @_; | |||||||||||||||||||||||||||||||
| 122 | 169 | ▶ | $literal_type ||= 'text'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$literal_type ||= "text"
MC/DC100%1/1
$literal_type ||= "text"
$literal_type
Truth table100%2/2
A
A= $literal_type
| |||||||||||||||||||||||||||||||||
| 123 | # :foo() [call => foo] | ||||||||||||||||||||||||||||||||
| 124 | # :foo(,) [call => foo => [text => '']] | ||||||||||||||||||||||||||||||||
| 125 | # :foo(bar) [call => foo => [text => 'bar']] | ||||||||||||||||||||||||||||||||
| 126 | # :foo(,,) [call => foo => [text => ''], [text => '']] | ||||||||||||||||||||||||||||||||
| 127 | # :foo(bar,) [call => foo => [text => 'bar'], [text => '']] | ||||||||||||||||||||||||||||||||
| 128 | # :foo(bar,,)[call => foo => [text => 'bar'], [text => '']] | ||||||||||||||||||||||||||||||||
| 129 | 169 | ▶ | if (s{^,}{}x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 8 | return [$literal_type => '']; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | 161 | ▶ | if (my $is_expr = s{^=}{}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | 12 | return &_parse_expr; | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | 149 | my @result; | |||||||||||||||||||||||||||||||
| 136 | 149 | ▶ | unless (s{^$re_text}{}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 137 | 45 | @result = &_parse_pipeline; | |||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||
| 139 | 104 | my $result = ''; | |||||||||||||||||||||||||||||||
| 140 | TEXT: { | ||||||||||||||||||||||||||||||||
| 141 | 104 | ▶ | do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 165 | ▶ | $result .= $1 if defined $1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | 165 | ▶ | $result .= $4 if defined $4; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 144 | 165 | ▶ | if (my $opn = $2 || $3) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$2 || $3
MC/DC50%1/2
$2 || $3
$2
$3
Truth table66%2/3
A || B
A= $2B= $3
| |||||||||||||||||||||||||||||||||
| 145 | # open group | ||||||||||||||||||||||||||||||||
| 146 | 4 | $result .= $opn; | |||||||||||||||||||||||||||||||
| 147 | 4 | $result .= &_parse_group_string($close_ch{$opn}); | |||||||||||||||||||||||||||||||
| 148 | ▶ | } elsif (not defined $1 and not defined $4) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $1 || defined $4
MC/DC50%1/2
defined $1 || defined $4
defined $1
defined $4
Truth table66%2/3
A || B
A= defined $1B= defined $4
| |||||||||||||||||||||||||||||||||
| 149 | 59 | last TEXT; | |||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | } while s{^(?: $re_text | ([\(\[\{]) | ([:\.]) ) }{}x; | ||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | 103 | @result = [$literal_type => $result]; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | 148 | s/^,//; | |||||||||||||||||||||||||||||||
| 156 | 148 | @result; | |||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 12 | ▶ | sub _parse_expr { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_expr: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||
| 160 | 12 | my $literal_type = 'expr'; | |||||||||||||||||||||||||||||||
| 161 | 12 | ▶ | if (s{^,}{}x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 162 | 0 | return [$literal_type => '']; | |||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | 12 | my $result = ''; | |||||||||||||||||||||||||||||||
| 165 | TEXT: | ||||||||||||||||||||||||||||||||
| 166 | 12 | ▶ | while (s{^(?: $re_text | ([\(\[\{]) | ([:\.]) ) }{}x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 167 | 27 | ▶ | $result .= $1 if defined $1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 168 | 27 | ▶ | $result .= $4 if defined $4; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 169 | 27 | ▶ | if (my $opn = $2 || $3) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$2 || $3
MC/DC100%2/2
$2 || $3
$2
$3
Truth table100%3/3
A || B
A= $2B= $3
| |||||||||||||||||||||||||||||||||
| 170 | # open group | ||||||||||||||||||||||||||||||||
| 171 | 12 | $result .= $opn; | |||||||||||||||||||||||||||||||
| 172 | 12 | $result .= &_parse_group_string($close_ch{$opn}); | |||||||||||||||||||||||||||||||
| 173 | ▶ | } elsif (not defined $1 and not defined $4) { | |||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $1 || defined $4
MC/DC100%2/2
defined $1 || defined $4
defined $1
defined $4
Truth table100%3/3
A || B
A= defined $1B= defined $4
| |||||||||||||||||||||||||||||||||
| 174 | 4 | last TEXT; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | 12 | s/^,//; | |||||||||||||||||||||||||||||||
| 178 | 12 | [$literal_type => $result]; | |||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | 128 | ▶ | sub _parse_group { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_group: called CC=8 SCAR=22.4
| |||||||||||||||||||||||||||||||||
| 182 | 128 | my ($group, $close, $sub, @rest) = @_; | |||||||||||||||||||||||||||||||
| 183 | 128 | ▶ | for (my ($len, $cnt) = length($_); $_ ne ''; $len = length($_), $cnt++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 184 | 271 | ▶ | if (s/^ ([\)\]\}])//x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 185 | 127 | ▶ | mydie "Paren mismatch: expect $close got $1 " if $1 ne $close; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | 127 | last; | |||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||
| 188 | 144 | my @pipe = $sub->(@rest); | |||||||||||||||||||||||||||||||
| 189 | 143 | ▶ | if ($cnt && $len == length($_)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cnt and $len == length $_
MC/DC0%0/2
$cnt and $len == length $_
$cnt
$len == length $_
Truth table66%2/3
A and B
A= $cntB= $len == length $_
| |||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | mydie "Can't match: $_" . (defined $close ? " for $close" : ""); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | 143 | ▶ | push @$group, @pipe <= 1 ? @pipe : \@pipe; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | 127 | $group; | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | 20 | ▶ | sub _parse_group_string { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_group_string: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||
| 198 | 20 | my ($close) = @_; | |||||||||||||||||||||||||||||||
| 199 | 20 | my $result = ''; | |||||||||||||||||||||||||||||||
| 200 | 20 | ▶ | for (my ($len, $prev) = length($_); $_ ne '' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 201 | ; $prev = $len, $len = length($_)) { | ||||||||||||||||||||||||||||||||
| 202 | 47 | ▶ | if (s/^ ([\)\]\}])//x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | 19 | ▶ | mydie "Paren mismatch: expect $close got $1 " if $1 ne $close; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 204 | 19 | $result .= $1; | |||||||||||||||||||||||||||||||
| 205 | 19 | last; | |||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||
| 207 | 28 | ▶ | if (s/^($re_word | , )//x) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 208 | 22 | $result .= $1; | |||||||||||||||||||||||||||||||
| 209 | } elsif (s/^([\(\[\{])//) { | ||||||||||||||||||||||||||||||||
| 210 | 4 | $result .= $1; | |||||||||||||||||||||||||||||||
| 211 | 4 | $result .= &_parse_group_string($close_ch{$1}); | |||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||
| 213 | 28 | ▶ | if (defined $prev and $prev == length($_)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prev and $prev == length $_
MC/DC100%2/2
defined $prev and $prev == length $_
defined $prev
$prev == length $_
Truth table100%3/3
A and B
A= defined $prevB= $prev == length $_
| |||||||||||||||||||||||||||||||||
| 214 | 1 | mydie "Can't parse entity_path group $ORIG (near $_)\n" | |||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | 19 | $result; | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 17 | ▶ | sub _parse_hash { | ||||||||||||||||||||||||||||||
|
Subroutine
_parse_hash: called CC=10 SCAR=24.4
| |||||||||||||||||||||||||||||||||
| 221 | 17 | my @hash = ('hash'); | |||||||||||||||||||||||||||||||
| 222 | 17 | ▶ | for (my ($len, $cnt) = length($_); $_ ne ''; $len = length($_), $cnt++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 223 | 42 | ▶ | if (s/^ ([\)\]\}])//x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 224 | 17 | ▶ | mydie "Paren mismatch: expect \} got $1 " if $1 ne '}'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 225 | 17 | last; | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | # {!=,:var} を許すには… | ||||||||||||||||||||||||||||||||
| 228 | 25 | ▶ | if (s/^([\w\.\-]+) [:=] //x || s/^($re_other+) ,?//x) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
s/^([\w\.\-]+) [:=] //x or s/^($re_other+) ,?//x
MC/DC0%0/2
s/^([\w\.\-]+) [:=] //x or s/^($re_other+) ,?//x
s/^([\w\.\-]+) [:=] //x
s/^($re_other+) ,?//x
Truth table66%2/3
A or B
A= s/^([\w\.\-]+) [:=] //xB= s/^($re_other+) ,?//x
| |||||||||||||||||||||||||||||||||
| 229 | # ↑ array でも許すべきか? | ||||||||||||||||||||||||||||||||
| 230 | 25 | my $str = $1; | |||||||||||||||||||||||||||||||
| 231 | 25 | ▶ | push @hash, [$str =~ s/^:// ? 'var' : 'text', $str]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||
| 233 | 25 | my @value = &_parse_term; | |||||||||||||||||||||||||||||||
| 234 | 25 | ▶ | push @hash, @value > 1 ? \@value : $value[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 25 | ▶ | unless (length($_) < $len) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 236 | 0 | mydie "Infinite loop on parse_hash: $_"; | |||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | # XXX: Give more detailed diag! | ||||||||||||||||||||||||||||||||
| 240 | 17 | ▶ | mydie "Odd number of hash elements" if (@hash - 1) % 2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 17 | \@hash; | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | 4 | 1; | |||||||||||||||||||||||||||||||