| 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
| |||||||||||||||||||||||||||||
| 16 | 18 | my $value = $token->{value}; | |||||||||||||||||||||||||||
| 17 | 18 | ▶ | if (exists $token->{as_is} && $token->{as_is}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $token->{"as_is"} and $token->{"as_is"}
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"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||