| 1 | package Language::Expr::EvaluatorRole; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | our $DATE = '2016-07-03'; # DATE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | our $VERSION = '0.29'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | requires 'rule_pair_simple'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | requires 'rule_pair_string'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | requires 'rule_or_xor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | requires 'rule_ternary'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | requires 'rule_and'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | requires 'rule_bit_or_xor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | requires 'rule_bit_and'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | requires 'rule_comparison3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | requires 'rule_comparison'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | requires 'rule_bit_shift'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | requires 'rule_add'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | requires 'rule_mult'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | requires 'rule_unary'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | requires 'rule_power'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | requires 'rule_subscripting_var'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 13 | requires 'rule_subscripting_expr'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | requires 'rule_array'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 13 | requires 'rule_hash'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 13 | requires 'rule_undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | requires 'rule_squotestr'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 13 | requires 'rule_dquotestr'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | requires 'rule_var'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 13 | requires 'rule_func'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | requires 'rule_func_map'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 13 | requires 'rule_func_grep'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 13 | requires 'rule_func_usort'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 13 | requires 'rule_bool'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 13 | requires 'rule_num'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 13 | requires 'rule_parenthesis'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 13 | requires 'expr_preprocess'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 13 | requires 'expr_postprocess'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 114 | ▶ | sub parse_dquotestr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_dquotestr: called CC=29 SCAR=34.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 114 | my ($self, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 114 | ▶ | if (ref($parts[0]) eq 'ARRAY') { splice @parts, 0, 1, @{ $parts[0] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 114 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | my @sbuf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | #say "D:parse_dquotestr:parts = ", join(", ", @parts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #for (grep {defined} @parts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 114 | for (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 114 | my $s01 = substr($_, 0, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 114 | my $s02 = substr($_, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 114 | my $l = length(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 114 | ▶ | if ($_ eq "\\'" ) { push @sbuf, "'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 15 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | elsif ($_ eq "\\\"") { push @sbuf, '"' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | elsif ($_ eq "\\\\") { push @sbuf, "\\" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | elsif ($_ eq "\\\$") { push @sbuf, '$' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | elsif ($_ eq "\\t" ) { push @sbuf, "\t" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | elsif ($_ eq "\\n" ) { push @sbuf, "\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | elsif ($_ eq "\\f" ) { push @sbuf, "\f" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | elsif ($_ eq "\\b" ) { push @sbuf, "\b" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | elsif ($_ eq "\\a" ) { push @sbuf, "\a" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | elsif ($_ eq "\\e" ) { push @sbuf, "\e" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ▶ | elsif ($l >= 2 && $l <= 4 && $s01 eq "\\" && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition58%7/12
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0 and substr($_, 1, 1) <= 7
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0
$l >= 2 and $l <= 4 and $s01 eq "\\"
$l >= 2 and $l <= 4
MC/DC0%0/5
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0 and substr($_, 1, 1) <= 7
$l >= 2
$l <= 4
$s01 eq "\\"
substr($_, 1, 1) >= 0
substr($_, 1, 1) <= 7
Truth table50%3/6
A and B and C and D and E
A= $l >= 2B= $l <= 4C= $s01 eq "\\"D= substr($_, 1, 1) >= 0E= substr($_, 1, 1) <= 7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | substr($_, 1, 1) >= "0" && substr($_, 1, 1) <= "7") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # \000 octal escape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | push @sbuf, chr(oct(substr($_, 1))) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ▶ | elsif ($l >= 3 && $l <= 4 && $s02 eq "\\x") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$l >= 3 and $l <= 4 and $s02 eq "\\x"
$l >= 3 and $l <= 4
MC/DC0%0/3
$l >= 3 and $l <= 4 and $s02 eq "\\x"
$l >= 3
$l <= 4
$s02 eq "\\x"
Truth table75%3/4
A and B and C
A= $l >= 3B= $l <= 4C= $s02 eq "\\x"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # \xFF hex escape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @sbuf, chr(hex(substr($_, 1))) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ▶ | elsif ($l >= 5 && $l <= 8 && substr($_, 0, 3) eq "\\x{") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$l >= 5 and $l <= 8 and substr($_, 0, 3) eq "\\x{"
$l >= 5 and $l <= 8
MC/DC0%0/3
$l >= 5 and $l <= 8 and substr($_, 0, 3) eq "\\x{"
$l >= 5
$l <= 8
substr($_, 0, 3) eq "\\x{"
Truth table75%3/4
A and B and C
A= $l >= 5B= $l <= 8C= substr($_, 0, 3) eq "\\x{"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # \x{1234} wide hex escape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | push @sbuf, chr(hex(substr($_, 3, length()-4))) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ($s02 eq '${') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # ${var} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | push @res, {type=>"STR", value=>join("", @sbuf)} if @sbuf; @sbuf=(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | push @res, {type=>"VAR", value=>substr($_, 2, length()-3)} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | elsif ($s01 eq '$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # $var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | push @res, {type=>"STR", value=>join("", @sbuf)} if @sbuf; @sbuf=(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | push @res, {type=>"VAR", value=>substr($_, 1, length()-1)} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 90 | push @sbuf, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 114 | ▶ | push @res, {type=>"STR", value=>join("", grep {defined} @sbuf)} if @sbuf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 114 | \@res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 20 | ▶ | sub parse_squotestr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_squotestr: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 20 | my ($self, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 20 | ▶ | if (ref($parts[0]) eq 'ARRAY') { splice @parts, 0, 1, @{ $parts[0] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 20 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | my @sbuf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #say "D:parse_dquotestr:parts = ", join(", ", @parts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | #for (grep {defined} @parts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 20 | for (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 24 | ▶ | if ($_ eq "\\'" ) { push @sbuf, "'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | elsif ($_ eq "\\\\") { push @sbuf, "\\" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 20 | else { push @sbuf, $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 20 | ▶ | push @res, {type=>"STR", value=>join("", grep {defined} @sbuf)} if @sbuf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 20 | \@res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # ABSTRACT: Specification for Language::Expr interpreter/compiler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||