| 1 | package YATT::Lite::XHF; sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 64 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 64 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 64 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 64 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 64 | our $VERSION = "0.03"; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 64 | ▶ | use constant TRACE => $ENV{TRACE_XHF_PARSER}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 64 | ▶ | use base qw(YATT::Lite::Object); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 64 | ▶ | use fields qw(FH filename string tokens | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | _fh_configured | ||||||||||||||||||||||||||||||||||||||||||
| 14 | allow_empty_name | ||||||||||||||||||||||||||||||||||||||||||
| 15 | encoding crlf | ||||||||||||||||||||||||||||||||||||||||||
| 16 | nocr subst | ||||||||||||||||||||||||||||||||||||||||||
| 17 | first_lineno | ||||||||||||||||||||||||||||||||||||||||||
| 18 | _depth | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 64 | skip_comment bytes); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 64 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 64 | our @EXPORT = qw(read_file_xhf); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 64 | our @EXPORT_OK = (@EXPORT, qw(parse_xhf $cc_name)); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 64 | ▶ | use YATT::Lite::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 64 | ▶ | use YATT::Lite::Util::Enum _ => [qw(NAME SIGIL VALUE LINENO)]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 64 | our $cc_name = qr{[0-9A-Za-z_\.\-/~!]}; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 64 | our $re_suffix= qr{\[$cc_name*\]}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 64 | our $cc_sigil = qr{[:\#,\-=\[\]\{\}]}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 64 | our $cc_tabsp = qr{[\ \t]}; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 64 | our %OPN = ('[' => \&organize_array, '{' => \&organize_hash | |||||||||||||||||||||||||||||||||||||||||
| 34 | , '=' => \&organize_expr); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 64 | our %CLO = (']' => '[', '}' => '{'); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 64 | our %NAME_LESS = (%CLO, '-' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 64 | our %ALLOW_EMPTY_NAME = (':' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 115 | ▶ | sub after_new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 115 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 115 | ▶ | $self->{skip_comment} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"skip_comment"} //= 1
MC/DC0%0/1
$self->{"skip_comment"} //= 1
$self->{"skip_comment"}
Truth table50%1/2
A
A= $self->{"skip_comment"}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 29 | ▶ | sub read_file_xhf { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file_xhf: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 29 | my ($pack, $fn, %rest) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 29 | my $method = do { | |||||||||||||||||||||||||||||||||||||||||
| 47 | 29 | my $single = delete $rest{single}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 29 | ▶ | my $all = delete $rest{all} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $rest{"all"} // 1
MC/DC0%0/1
delete $rest{"all"} // 1
delete $rest{"all"}
Truth table50%1/2
A
A= delete $rest{"all"}
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 29 | ▶ | if ($single or not $all) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$single or not $all
MC/DC0%0/2
$single or not $all
$single
not $all
Truth table33%1/3
A or not(B)
A= $singleB= not $all
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | 'read'; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 29 | 'read_all'; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 29 | MY->new(filename => $fn, encoding => 'utf8', %rest)->$method; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | sub parse_xhf { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_xhf: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | MY->new(string => @_)->read; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 64 | *configure_file = \&configure_filename; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 64 | *configure_file = \&configure_filename; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 47 | ▶ | sub configure_filename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_filename: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 47 | (my MY $self, my ($fn)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 47 | ▶ | open $self->{FH}, '<', $fn | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | or croak "Can't open file '$fn': $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 47 | $self->{_fh_configured} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 47 | $self->{filename} = $fn; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 47 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub configure_filename_for_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_filename_for_error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | (my MY $self, my ($fn)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | $self->{filename} = $fn; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | # To accept in-stream encoding spec. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # (See YATT::Lite::Test::XHFTest::load and t/lite_xhf.t) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 31 | ▶ | sub configure_encoding { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_encoding: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 31 | (my MY $self, my $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 31 | $self->{_fh_configured} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 31 | $self->{encoding} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub configure_binary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_binary: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | (my MY $self, my $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | warnings::warnif(deprecated => | |||||||||||||||||||||||||||||||||||||||||
| 89 | "XHF option 'binary' is deprecated, use 'bytes' instead"); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->{bytes} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 68 | ▶ | sub configure_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_string: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 68 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 68 | ($self->{string}) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | open $self->{FH}, '<', \ $self->{string} | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 68 | ▶ | or croak "Can't create string stream: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 68 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub trace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | (my MY $reader, my ($msg, @desc)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | print STDERR " " x $reader->{_depth}, $msg, terse_dump(@desc), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 29 | ▶ | sub read_all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_all: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 29 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 29 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 29 | ▶ | while (my @block = $self->read) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 29 | push @res, @block; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 29 | ▶ | wantarray ? @res : do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | my %dict = @res; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | \%dict; | |||||||||||||||||||||||||||||||||||||||||
| 115 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # XXX: Should I rename this to read_one()? | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 414 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 414 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 414 | ▶ | $self->cf_let(\@_, sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 414 | ▶ | if (my @tokens = $self->tokenize) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 348 | $self->organize(@tokens); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 66 | return; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 414 | }); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 414 | ▶ | sub tokenize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tokenize: called CC=10 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 414 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 414 | local $/ = ""; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 414 | my $fh = $$self{FH}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 414 | ▶ | unless ($self->{_fh_configured}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 117 | ▶ | if (not $self->{bytes} and not $self->{string} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $self->{"bytes"} || $self->{"string"} and $self->{"encoding"}
$self->{'bytes'} || $self->{'string'}
MC/DC66%2/3
not $self->{"bytes"} || $self->{"string"} and $self->{"encoding"}
$self->{'bytes'}
$self->{'string'}
$self->{"encoding"}
Truth table75%3/4
not(A || B) and C
A= $self->{'bytes'}B= $self->{'string'}C= $self->{"encoding"}
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | and $self->{encoding}) { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 31 | binmode $fh, ":encoding($self->{encoding})"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 117 | ▶ | if ($self->{crlf}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | binmode $fh, ":crlf"; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 414 | my @tokens; | |||||||||||||||||||||||||||||||||||||||||
| 145 | LOOP: { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 414 | do { | |||||||||||||||||||||||||||||||||||||||||
| 147 | 414 | ▶ | defined (my $para = <$fh>) or last LOOP; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | $para = untaint_unless_tainted | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ($self->{filename} // $self->{string} | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 360 | ▶ | , $para); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"filename"} // $self->{"string"}
MC/DC0%0/2
$self->{"filename"} // $self->{"string"}
$self->{"filename"}
$self->{"string"}
Truth table66%2/3
A // B
A= $self->{"filename"}B= $self->{"string"}
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 360 | @tokens = $self->tokenize_1($para); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 414 | ▶ | } until (not $self->{skip_comment} or @tokens); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->{"skip_comment"} or @tokens
MC/DC0%0/2
not $self->{"skip_comment"} or @tokens
not $self->{"skip_comment"}
@tokens
Truth table66%2/3
not(A) or B
A= not $self->{"skip_comment"}B= @tokens
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 414 | @tokens; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 360 | ▶ | sub tokenize_1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tokenize_1: called CC=20 SCAR=32.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 360 | my MY $reader = shift; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 360 | $_[0] =~ s{\n+$}{\n}s; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 360 | ▶ | $_[0] =~ s{\r+}{}g if $reader->{nocr}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 360 | ▶ | if (my $sub = $reader->{subst}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | local $_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | *_ = \ $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $sub->($_); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 360 | ▶ | my $lineno = $reader->{first_lineno} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$reader->{"first_lineno"} // 1
MC/DC100%1/1
$reader->{"first_lineno"} // 1
$reader->{"first_lineno"}
Truth table100%2/2
A
A= $reader->{"first_lineno"}
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 360 | my ($pos, $ncomments, @tokens, @result); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 360 | foreach my $token (@tokens = split /(?<=\n)(?=[^\ \t])/, $_[0]) { | |||||||||||||||||||||||||||||||||||||||||
| 169 | 1658 | $pos++; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 1658 | ▶ | if ($token =~ s{^(?:\#[^\n]*(?:\n|$))+}{}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 47 | $ncomments++; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 47 | ▶ | next if $token eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1611 | ▶ | unless ($token =~ s{^($cc_name*$re_suffix*) ($cc_sigil) (?:($cc_tabsp)|(\n|$))}{}x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | croak "Invalid XHF token '$token' ".$reader->fileinfo_lineno($lineno)."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 1611 | my ($name, $sigil, $tabsp, $eol) = ($1, $2, $3, $4); | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1611 | ▶ | if ($name eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | croak "Invalid XHF token(name is empty for '$token') " | ||||||||||||||||||||||||||||||||||||||||||
| 182 | .$reader->fileinfo_lineno($lineno)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 627 | ▶ | if $sigil eq ':' and not $reader->{allow_empty_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sigil eq ":" and not $reader->{"allow_empty_name"}
MC/DC0%0/2
$sigil eq ":" and not $reader->{"allow_empty_name"}
$sigil eq ":"
not $reader->{"allow_empty_name"}
Truth table33%1/3
A and not(B)
A= $sigil eq ":"B= not $reader->{"allow_empty_name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } elsif ($NAME_LESS{$sigil}) { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | croak "Invalid XHF token('$sigil' should not be prefixed by name '$name') " | |||||||||||||||||||||||||||||||||||||||||
| 186 | .$reader->fileinfo_lineno($lineno)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | # Comment fields are ignored. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 1611 | ▶ | $ncomments++, next if $sigil eq "#"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1611 | ▶ | if ($CLO{$sigil}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 231 | undef $name; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | # Line continuation. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 1611 | $token =~ s/\n[\ \t]/\n/g; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1611 | ▶ | unless (defined $eol) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | # Values are trimmed unless $eol | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 750 | $token =~ s/^\s+|\s+$//gs; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # Deny: name{ foo | ||||||||||||||||||||||||||||||||||||||||||
| 204 | # Allow: name[ foo | ||||||||||||||||||||||||||||||||||||||||||
| 205 | croak "Invalid XHF token(container with value) " | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 861 | ▶ | . join("", grep {defined $_} $name, $sigil, $tabsp, $token) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sigil eq "{" and $token ne ""
MC/DC0%0/2
$sigil eq "{" and $token ne ""
$sigil eq "{"
$token ne ""
Truth table66%2/3
A and B
A= $sigil eq "{"B= $token ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | . $reader->fileinfo_lineno($lineno)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 208 | if $sigil eq '{' and $token ne ""; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # Trim leading space for $tabsp eq "\n". | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 861 | $token =~ s/^[\ \t]//; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 1611 | push @result, [$name, $sigil, $token, $lineno]; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } continue { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 1658 | $lineno++; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # Comment only paragraph should return nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 360 | ▶ | return if $ncomments && !@result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ncomments and not @result
MC/DC100%2/2
$ncomments and not @result
$ncomments
not @result
Truth table100%3/3
A and not(B)
A= $ncommentsB= not @result
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 348 | ▶ | wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | ▶ | sub fileinfo { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileinfo: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | (my MY $reader, my $desc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 6 | $reader->fileinfo_lineno($desc->[_LINENO]); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 6 | ▶ | sub fileinfo_lineno { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileinfo_lineno: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | (my MY $reader, my $lineno) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | sprintf("at %s line %d" | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | ▶ | , $reader->{filename} // "(unknown)" | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$reader->{"filename"} // "(unknown)"
MC/DC0%0/1
$reader->{"filename"} // "(unknown)"
$reader->{"filename"}
Truth table50%1/2
A
A= $reader->{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | , $lineno); | ||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 348 | ▶ | sub organize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organize: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 348 | my MY $reader = shift; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 348 | local $reader->{_depth} = -1; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 348 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 348 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 348 | ▶ | while ($pos < @_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 976 | my $desc = $_[$pos++]; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 976 | ▶ | unless (defined $desc->[_NAME]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | croak "Invalid XHF: Field close '$desc->[_SIGIL]'" | |||||||||||||||||||||||||||||||||||||||||
| 245 | ." (line $desc->[_LINENO]) without open! " | ||||||||||||||||||||||||||||||||||||||||||
| 246 | .$reader->fileinfo($desc)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | push @result, $desc->[_NAME] if $desc->[_NAME] ne '' | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 974 | ▶ | or $ALLOW_EMPTY_NAME{$desc->[_SIGIL]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$desc->[0] ne "" or $YATT::Lite::XHF::ALLOW_EMPTY_NAME{$desc->[1]}
MC/DC50%1/2
$desc->[0] ne "" or $YATT::Lite::XHF::ALLOW_EMPTY_NAME{$desc->[1]}
$desc->[0] ne ""
$YATT::Lite::XHF::ALLOW_EMPTY_NAME{$desc->[1]}
Truth table66%2/3
A or B
A= $desc->[0] ne ""B= $YATT::Lite::XHF::ALLOW_EMPTY_NAME{$desc->[1]}
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 974 | ▶ | if (my $sub = $OPN{$desc->[_SIGIL]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | # sigil がある時、value を無視して、良いのか? | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 188 | push @result, $sub->($reader, \$pos, \@_, $desc); | |||||||||||||||||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 786 | push @result, $desc->[_VALUE]; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 342 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | @result | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 337 | } else { | |||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | my %hash = @result; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | # '[' block | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 208 | ▶ | sub organize_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organize_array: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 208 | (my MY $reader, my ($posref, $tokens, $first)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 208 | local $reader->{_depth} = $reader->{_depth} + 1; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 208 | $reader->trace("> ", $first) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 208 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 208 | ▶ | push @result, $first->[_VALUE] if defined $first and $first->[_VALUE] ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $first and $first->[2] ne ""
MC/DC0%0/2
defined $first and $first->[2] ne ""
defined $first
$first->[2] ne ""
Truth table33%1/3
A and B
A= defined $firstB= $first->[2] ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 208 | ▶ | while ($$posref < @$tokens) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 571 | my $desc = $tokens->[$$posref++]; | |||||||||||||||||||||||||||||||||||||||||
| 274 | # NAME | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 571 | ▶ | unless (defined $desc->[_NAME]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 207 | ▶ | if ($desc->[_SIGIL] ne ']') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | croak "Invalid XHF: paren mismatch. '['" | |||||||||||||||||||||||||||||||||||||||||
| 278 | ." (line $first->[_LINENO]) is closed by '$desc->[_SIGIL]' " | ||||||||||||||||||||||||||||||||||||||||||
| 279 | .$reader->fileinfo($desc)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 206 | $reader->trace("< ", $first, $desc) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 206 | return \@result; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | elsif ($desc->[_NAME] ne '') { | |||||||||||||||||||||||||||||||||||||||||
| 285 | 37 | $reader->trace("| ", $desc) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 37 | push @result, $desc->[_NAME]; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # VALUE | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 364 | ▶ | if (my $sub = $OPN{$desc->[_SIGIL]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | # sigil がある時、value があったらどうするかは、子供次第。 | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 60 | push @result, $sub->($reader, $posref, $tokens, $desc); | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 304 | $reader->trace("| ", $desc) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 304 | push @result, $desc->[_VALUE]; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | croak "Invalid XHF: Missing close ']' for '[' " | |||||||||||||||||||||||||||||||||||||||||
| 299 | .$reader->fileinfo($first)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # '{' block. | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 23 | ▶ | sub organize_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organize_hash: called CC=11 SCAR=24.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 23 | (my MY $reader, my ($posref, $tokens, $first)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 23 | ▶ | croak "Invalid XHF hash block beginning! " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $first and $first->[2] ne ""
MC/DC0%0/2
defined $first and $first->[2] ne ""
defined $first
$first->[2] ne ""
Truth table33%1/3
A and B
A= defined $firstB= $first->[2] ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | . join("", @$first).$reader->fileinfo($first)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 307 | if defined $first and $first->[_VALUE] ne ''; | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 23 | local $reader->{_depth} = $reader->{_depth} + 1; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 23 | $reader->trace("> ", $first) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 23 | my %result; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 23 | ▶ | while ($$posref < @$tokens) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 57 | my $desc = $tokens->[$$posref++]; | |||||||||||||||||||||||||||||||||||||||||
| 313 | # NAME | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 57 | ▶ | unless (defined $desc->[_NAME]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 22 | ▶ | if ($desc->[_SIGIL] ne '}') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | croak "Invalid XHF: paren mismatch. '{'" | |||||||||||||||||||||||||||||||||||||||||
| 317 | ." (line $first->[_LINENO]) is closed by '$desc->[_SIGIL]' " | ||||||||||||||||||||||||||||||||||||||||||
| 318 | .$reader->fileinfo($desc)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 21 | $reader->trace("< ", $first, $desc) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 21 | return \%result; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | elsif ($desc->[_SIGIL] eq '-') { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | # Should treat two lines as one key value pair. | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 7 | ▶ | unless ($$posref < @$tokens) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | croak "Invalid XHF hash:" | |||||||||||||||||||||||||||||||||||||||||
| 327 | ." key '- $desc->[_VALUE]' doesn't have value! " | ||||||||||||||||||||||||||||||||||||||||||
| 328 | .$reader->fileinfo($desc)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 7 | my $valdesc = $tokens->[$$posref++]; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 7 | my $value = do { | |||||||||||||||||||||||||||||||||||||||||
| 332 | 7 | ▶ | if (my $sub = $OPN{$valdesc->[_SIGIL]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | $sub->($reader, $posref, $tokens, $valdesc); | |||||||||||||||||||||||||||||||||||||||||
| 334 | } elsif ($valdesc->[_SIGIL] eq '-') { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | $valdesc->[_VALUE]; | |||||||||||||||||||||||||||||||||||||||||
| 336 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | croak "Invalid XHF hash value:" | |||||||||||||||||||||||||||||||||||||||||
| 338 | . " key '$desc->[_VALUE]' has invalid sigil '$valdesc->[_SIGIL]' " | ||||||||||||||||||||||||||||||||||||||||||
| 339 | .$reader->fileinfo($valdesc)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 7 | $reader->add_value($result{$desc->[_VALUE]}, $value); | |||||||||||||||||||||||||||||||||||||||||
| 343 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 28 | $reader->trace("| ", $desc) if TRACE; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 28 | ▶ | if (my $sub = $OPN{$desc->[_SIGIL]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | # sigil がある時、value を無視して、良いのか? | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 6 | $desc->[_VALUE] = $sub->($reader, $posref, $tokens, $desc); | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 28 | $reader->add_value($result{$desc->[_NAME]}, $desc->[_VALUE]); | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | croak "Invalid XHF: Missing close '}' for '{' " | |||||||||||||||||||||||||||||||||||||||||
| 353 | .$reader->fileinfo($first)."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | # '=' value | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 25 | ▶ | sub _undef {undef} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_undef: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 64 | our %EXPR = (null => \&_undef, 'undef' => \&_undef); | |||||||||||||||||||||||||||||||||||||||||
| 359 | 25 | ▶ | sub organize_expr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organize_expr: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 25 | (my MY $reader, my ($posref, $tokens, $first)) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 25 | ▶ | if ((my $val = $first->[_VALUE]) =~ s/^\#(\w+)\s*//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 25 | ▶ | my $sub = $EXPR{$1} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | or croak "Invalid XHF keyword: '= #$1'"; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 25 | $sub->($reader, $val, $tokens); | |||||||||||||||||||||||||||||||||||||||||
| 365 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | croak "Not yet implemented XHF token: '@$first'"; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 35 | ▶ | sub add_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_value: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 35 | my MY $reader = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 35 | ▶ | unless (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 35 | $_[0] = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } elsif (ref $_[0] ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $_[0] = [$_[0], $_[1]]; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | push @{$_[0]}, $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 64 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 64 | YATT::Lite::Breakpoint::break_load_xhf(); | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 64 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | __END__ | ||||||||||||||||||||||||||||||||||||||||||