blib/lib/Text/APL/Translator.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 8 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 95.4% 42 / 44 SCAR 19.5
CC
7
Cov
97%
translate
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« blib/lib/Text/APL/Writer.pm ↑ Summary blib/lib/Text/APL.pm »
1 package Text::APL::Translator;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base 'Text::APL::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub translate {
9 24 ▶ my $self = shift;
Subroutine translate: called CC=7 SCAR=19.5
Pod documented
10 24 my ($tape) = @_;
11  
12 24 my $code = '';
13  
14 24 foreach my $token (@$tape) {
15 31 ▶ if ($token->{type} eq 'expr') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'type'} eq 'expr') { } 18 13 31
elsif ($token->{'type'} eq 'exec') { } 9 4 13
16 18 my $value = $token->{value};
17 18 ▶ if (exists $token->{as_is} && $token->{as_is}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $token->{'as_is'} and $token->{'as_is'}) { } 5 13 18
Condition66%2/3
exists $token->{"as_is"} and $token->{"as_is"}
!ll&&!rl&&r
1305
MC/DC50%1/2
exists $token->{"as_is"} and $token->{"as_is"}
exists $token->{"as_is"} $token->{"as_is"}
Truth table66%2/3
A and B
A= exists $token->{"as_is"}B= $token->{"as_is"}
ABresult
0X0
100
111
18 5 $code .= '__print(do {' . $value . '});';
19 }
20 else {
21 13 $code .= '__print_escaped(do {' . $value . '});';
22 }
23 }
24 elsif ($token->{type} eq 'exec') {
25 9 $code .= $token->{value};
26 9 ▶ $code .= ';' unless $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
unless $token->{"line"} 2 7 9
27 9 $code .= "\n";
28 }
29 else {
30 4 $token->{value} =~ s/}/\\}/gms;
31 4 $token->{value} =~ s/{/\\{/gms;
32 4 $code .= '__print(q{' . $token->{value} . '});';
33 }
34 }
35  
36 24 $code;
37 }
38  
39 3 1;
40 __END__
« blib/lib/Text/APL/Writer.pm ↑ Summary blib/lib/Text/APL.pm »