Expr/Interpreter/default.pm

filter: Statementstmt 84.3% 237 / 281 Branchbran 60.2% 100 / 166 Conditioncond 55.8% 19 / 34 MC/DCmcdc 11.1% 2 / 18 Subroutinesub 83.7% 36 / 43 Podpod 0.0% 0 / 31 totaltotal 68.7% 394 / 573 CC 110 SCAR 37.0
CC
110
Cov
74%
rule_comparison
127.4
_map_grep_usort
42.0
rule_or_xor
13.4
CRAP 40.6
« Expr/Compiler/js.pm ↑ Summary Expr/JS.pm »
1 package Language::Expr::Interpreter::default;
2  
3 3 our $DATE = '2016-07-03'; # DATE
4 3 our $VERSION = '0.29'; # VERSION
5  
6 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Mo qw(build default);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 extends 'Language::Expr::Interpreter::Base';
13 3 with 'Language::Expr::InterpreterRole';
14 3 ▶use List::Util 'reduce';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶has vars => (is => 'rw', default => sub { {} });
Subroutine __ANON__: not called CC=1 SCAR=1.2
18 0 ▶has funcs => (is => 'rw', default => sub { {} });
Subroutine __ANON__: not called CC=1 SCAR=1.2
19 0 ▶has level => (is => 'rw', default => sub { 0 });
Subroutine __ANON__: not called CC=1 SCAR=1.2
20  
21 10 ▶sub rule_pair_simple {
Subroutine rule_pair_simple: called CC=1 SCAR=0.0
Pod undocumented
22 10 my ($self, %args) = @_;
23 10 my $match = $args{match};
24 10 [$match->{key}, $match->{value}];
25 }
26  
27 6 ▶sub rule_pair_string {
Subroutine rule_pair_string: called CC=1 SCAR=0.0
Pod undocumented
28 6 my ($self, %args) = @_;
29 6 my $match = $args{match};
30 6 [$match->{key}, $match->{value}];
31 }
32  
33 8 ▶sub rule_or_xor {
Subroutine rule_or_xor: called CC=10 SCAR=25.9
Pod undocumented
34 8 my ($self, %args) = @_;
35 8 my $match = $args{match};
36 8 my $res = shift @{$match->{operand}};
37 8 for my $term (@{$match->{operand}}) {
38 8 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
80
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
39 8 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 8 8
40 8 ▶ if ($op eq '||') { $res ||= $term }
Branch: 3 branches
BranchTrueFalseTotal
if ($op eq '||') { } 4 4 8
elsif ($op eq '//') { } 4 0 4
elsif ($op eq '^^') { } 0 0 0
Condition66%2/3
$res ||= $term
l!l&&r!l&&!r
220
MC/DC0%0/2
$res ||= $term
$res $term
Truth table66%2/3
A ||= B
A= $resB= $term
ABresult
1X1
011
000
41 4 ▶ elsif ($op eq '//') { $res //= $term }
Condition100%3/3
$res //= $term
l!l&&r!l&&!r
211
MC/DC100%2/2
$res //= $term
$res $term
Truth table100%3/3
A //= B
A= $resB= $term
ABresult
1X1
011
000
42 0 ▶ elsif ($op eq '^^') { $res = ($res xor $term) }
Condition0%0/4
$res ^^ $term
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
$res ^^ $term
$res $term
Truth table0%0/4
A ^^ B
A= $resB= $term
ABresult
110
101
011
000
43 }
44 8 $res;
45 }
46  
47 10 ▶sub rule_ternary {
Subroutine rule_ternary: called CC=2 SCAR=6.9
Pod undocumented
48 10 my ($self, %args) = @_;
49 10 my $match = $args{match};
50 10 my $opd = $match->{operand};
51 10 ▶ $opd->[0] ? $opd->[1] : $opd->[2];
Branch: 1 branch
BranchTrueFalseTotal
$opd->[0] ? : 5 5 10
52 }
53  
54 4 ▶sub rule_and {
Subroutine rule_and: called CC=7 SCAR=19.8
Pod undocumented
55 4 my ($self, %args) = @_;
56 4 my $match = $args{match};
57 4 my $res = shift @{$match->{operand}};
58 4 for my $term (@{$match->{operand}}) {
59 4 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
40
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
60 4 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 4 4
61 4 ▶ if ($op eq '&&') { $res = $res && $term || false }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "&&") 4 0 4
Condition83%5/6
$res && $term || &false()
l!l&&r!l&&!r
130
$res and $term
!ll&&!rl&&r
211
MC/DC0%0/3
$res && $term || &false()
$res $term &false()
Truth table60%3/5
A and B || C
A= $resB= $termC= &false()
ABCresult
11X1
0X11
1011
0X00
1000
62 }
63 4 $res;
64 }
65  
66 2 ▶sub rule_bit_or_xor {
Subroutine rule_bit_or_xor: called CC=6 SCAR=18.1
Pod undocumented
67 2 my ($self, %args) = @_;
68 2 my $match = $args{match};
69 2 my $res = shift @{$match->{operand}};
70 2 for my $term (@{$match->{operand}}) {
71 2 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
20
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
72 2 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 2 2
73 2 ▶ if ($op eq '|') { $res = $res+0 | $term }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq '|') { } 1 1 2
elsif ($op eq '^') { } 1 0 1
74 1 elsif ($op eq '^') { $res = $res+0 ^ $term }
75 }
76 2 $res;
77 }
78  
79 1 ▶sub rule_bit_and {
Subroutine rule_bit_and: called CC=5 SCAR=16.3
Pod undocumented
80 1 my ($self, %args) = @_;
81 1 my $match = $args{match};
82 1 my $res = shift @{$match->{operand}};
83 1 for my $term (@{$match->{operand}}) {
84 1 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
10
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
85 1 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 1 1
86 1 ▶ if ($op eq '&') { $res = $res+0 & $term }
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "&") 1 0 1
87 }
88 1 $res;
89 }
90  
91 5 ▶sub rule_comparison3 {
Subroutine rule_comparison3: called CC=7 SCAR=19.7
Pod undocumented
92 5 my ($self, %args) = @_;
93 5 my $match = $args{match};
94 5 my $res = shift @{$match->{operand}};
95 5 ▶ return $res unless @{$match->{operand}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$match->{"operand"};} 0 5 5
96 5 my $last_term = $res;
97 5 for my $term (@{$match->{operand}}) {
98 5 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
50
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
99 5 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 5 5
100 5 ▶ if ($op eq '<=>') { $res = ($last_term <=> $term) }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq '<=>') { } 4 1 5
elsif ($op eq 'cmp') { } 1 0 1
101 1 elsif ($op eq 'cmp') { $res = ($last_term cmp $term) }
102 5 $last_term = $term;
103 }
104 5 $res;
105 }
106  
107 43 ▶sub rule_comparison {
Subroutine rule_comparison: called CC=42 SCAR=48.5
Pod undocumented
108 43 my ($self, %args) = @_;
109 43 my $match = $args{match};
110 43 my $res = shift @{$match->{operand}};
111 43 ▶ return $res unless @{$match->{operand}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$match->{"operand"};} 0 43 43
112 43 my $last_term = $res;
113 43 for my $term (@{$match->{operand}}) {
114 46 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
460
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
115 46 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 46 46
116 46 ▶ if ($op eq '==' ) { return false unless $res = ($last_term == $term ? true:false) }
Branch: 14 branches
BranchTrueFalseTotal
if ($op eq '==') { } 16 30 46
elsif ($op eq '!=') { } 4 26 30
elsif ($op eq 'eq') { } 2 24 26
elsif ($op eq 'ne') { } 0 24 24
elsif ($op eq '<') { } 3 21 24
elsif ($op eq '<=') { } 3 18 21
elsif ($op eq '>') { } 13 5 18
elsif ($op eq '>=') { } 5 0 5
elsif ($op eq 'lt') { } 0 0 0
elsif ($op eq 'gt') { } 0 0 0
elsif ($op eq 'le') { } 0 0 0
elsif ($op eq 'ge') { } 0 0 0
unless $res = $last_term == $term ? &true() : &false() 7 9 16
$last_term == $term ? : 9 7 16
117 4 ▶ elsif ($op eq '!=' ) { return false unless $res = ($last_term != $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term != $term ? &true() : &false() 1 3 4
$last_term != $term ? : 3 1 4
118 2 ▶ elsif ($op eq 'eq' ) { return false unless $res = ($last_term eq $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term eq $term ? &true() : &false() 1 1 2
$last_term eq $term ? : 1 1 2
119 0 ▶ elsif ($op eq 'ne' ) { return false unless $res = ($last_term ne $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term ne $term ? &true() : &false() 0 0 0
$last_term ne $term ? : 0 0 0
120 3 ▶ elsif ($op eq '<' ) { return false unless $res = ($last_term < $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term < $term ? &true() : &false() 2 1 3
$last_term < $term ? : 1 2 3
121 3 ▶ elsif ($op eq '<=' ) { return false unless $res = ($last_term <= $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term <= $term ? &true() : &false() 1 2 3
$last_term <= $term ? : 2 1 3
122 13 ▶ elsif ($op eq '>' ) { return false unless $res = ($last_term > $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term > $term ? &true() : &false() 10 3 13
$last_term > $term ? : 3 10 13
123 5 ▶ elsif ($op eq '>=' ) { return false unless $res = ($last_term >= $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term >= $term ? &true() : &false() 1 4 5
$last_term >= $term ? : 4 1 5
124 0 ▶ elsif ($op eq 'lt' ) { return false unless $res = ($last_term lt $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term lt $term ? &true() : &false() 0 0 0
$last_term lt $term ? : 0 0 0
125 0 ▶ elsif ($op eq 'gt' ) { return false unless $res = ($last_term gt $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term gt $term ? &true() : &false() 0 0 0
$last_term gt $term ? : 0 0 0
126 0 ▶ elsif ($op eq 'le' ) { return false unless $res = ($last_term le $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term le $term ? &true() : &false() 0 0 0
$last_term le $term ? : 0 0 0
127 0 ▶ elsif ($op eq 'ge' ) { return false unless $res = ($last_term ge $term ? true:false) }
Branch: 2 branches
BranchTrueFalseTotal
unless $res = $last_term ge $term ? &true() : &false() 0 0 0
$last_term ge $term ? : 0 0 0
128 23 $last_term = $term;
129 }
130 20 ▶ $res ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$res ? : 20 0 20
131 }
132  
133 4 ▶sub rule_bit_shift {
Subroutine rule_bit_shift: called CC=6 SCAR=18.1
Pod undocumented
134 4 my ($self, %args) = @_;
135 4 my $match = $args{match};
136 4 my $res = shift @{$match->{operand}};
137 4 for my $term (@{$match->{operand}}) {
138 4 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
40
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
139 4 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 4 4
140 4 ▶ if ($op eq '>>') { $res >>= $term }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq '>>') { } 2 2 4
elsif ($op eq '<<') { } 2 0 2
141 2 elsif ($op eq '<<') { $res <<= $term }
142 }
143 4 $res;
144 }
145  
146 20 ▶sub rule_add {
Subroutine rule_add: called CC=7 SCAR=19.6
Pod undocumented
147 20 my ($self, %args) = @_;
148 20 my $match = $args{match};
149 20 my $res = shift @{$match->{operand}};
150 20 for my $term (@{$match->{operand}}) {
151 37 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
370
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
152 37 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 37 37
153 37 ▶ if ($op eq '+') { $res += $term }
Branch: 3 branches
BranchTrueFalseTotal
if ($op eq '+') { } 30 7 37
elsif ($op eq '-') { } 5 2 7
elsif ($op eq '.') { } 2 0 2
154 5 elsif ($op eq '-') { $res -= $term }
155 2 elsif ($op eq '.') { $res .= $term }
156 }
157 20 $res;
158 }
159  
160 12 ▶sub rule_mult {
Subroutine rule_mult: called CC=8 SCAR=20.9
Pod undocumented
161 12 my ($self, %args) = @_;
162 12 my $match = $args{match};
163 12 my $res = shift @{$match->{operand}};
164 12 for my $term (@{$match->{operand}}) {
165 20 ▶ my $op = shift @{$match->{op}//=[]};
Condition50%1/2
$match->{"op"} //= []
l!l
200
MC/DC0%0/1
$match->{"op"} //= []
$match->{"op"}
Truth table50%1/2
A
A= $match->{"op"}
Aresult
11
00
166 20 ▶ last unless $op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op 0 20 20
167 20 ▶ if ($op eq '*') { $res *= $term }
Branch: 4 branches
BranchTrueFalseTotal
if ($op eq '*') { } 7 13 20
elsif ($op eq '/') { } 6 7 13
elsif ($op eq '%') { } 3 4 7
elsif ($op eq 'x') { } 4 0 4
168 6 elsif ($op eq '/') { $res /= $term }
169 3 elsif ($op eq '%') { $res %= $term }
170 4 elsif ($op eq 'x') { $res x= $term }
171 }
172 12 $res;
173 }
174  
175 12 ▶sub rule_unary {
Subroutine rule_unary: called CC=7 SCAR=19.5
Pod undocumented
176 12 my ($self, %args) = @_;
177 12 my $match = $args{match};
178 12 my $res = $match->{operand};
179 12 ▶ if ($match->{op}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match->{"op"}) 12 0 12
180 12 for my $op (reverse @{$match->{op}}) {
181 17 ▶ if ($op eq '!') { $res = $res ? false : true }
Branch: 4 branches
BranchTrueFalseTotal
if ($op eq '!') { } 5 12 17
elsif ($op eq '-') { } 11 1 12
elsif ($op eq '~') { } 1 0 1
$res ? : 3 2 5
182 11 elsif ($op eq '-') { $res = -$res }
183 1 elsif ($op eq '~') { $res = ~($res+0) }
184 }
185 }
186 12 $res;
187 }
188  
189 3 ▶sub rule_power {
Subroutine rule_power: called CC=1 SCAR=0.0
Pod undocumented
190 3 my ($self, %args) = @_;
191 3 my $match = $args{match};
192 3 ▶ reduce { $b ** $a } reverse @{$match->{operand}};
Subroutine __ANON__: called CC=1 SCAR=0.0
193 }
194  
195 2 ▶sub rule_subscripting_var {
Subroutine rule_subscripting_var: called CC=1 SCAR=0.0
Pod undocumented
196 2 my ($self, %args) = @_;
197 2 $self->rule_subscripting_expr(%args);
198 }
199  
200 9 ▶sub rule_subscripting_expr {
Subroutine rule_subscripting_expr: called CC=4 SCAR=14.0
Pod undocumented
201 9 my ($self, %args) = @_;
202 9 my $match = $args{match};
203 9 my $res = $match->{operand};
204 9 for my $i (@{$match->{subscript}}) {
205 10 ▶ if (ref($res) eq 'ARRAY' ) { $res = $res->[$i] }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $res eq 'ARRAY') { } 5 5 10
elsif (ref $res eq 'HASH') { } 5 0 5
206 5 elsif (ref($res) eq 'HASH') { $res = $res->{$i} }
207 0 else { die "Invalid subscript on nonhash/nonarray" }
208 }
209 9 $res;
210 }
211  
212 7 ▶sub rule_array {
Subroutine rule_array: called CC=1 SCAR=0.0
Pod undocumented
213 7 my ($self, %args) = @_;
214 7 my $match = $args{match};
215 7 $match->{element};
216 }
217  
218 9 ▶sub rule_hash {
Subroutine rule_hash: called CC=1 SCAR=0.0
Pod undocumented
219 9 my ($self, %args) = @_;
220 9 my $match = $args{match};
221 9 return { map { $_->[0] => $_->[1] } @{ $match->{pair} } }
222 }
223  
224 5 ▶sub rule_undef {
Subroutine rule_undef: called CC=1 SCAR=0.0
Pod undocumented
225 5 my ($self, %args) = @_;
226 5 my $match = $args{match};
227 5 undef;
228 }
229  
230 10 ▶sub rule_squotestr {
Subroutine rule_squotestr: called CC=1 SCAR=0.0
Pod undocumented
231 10 my ($self, %args) = @_;
232 join("",
233 10 map { $_->{value} }
234 10 @{ $self->parse_squotestr($args{match}{part}) });
235 }
236  
237 48 ▶sub rule_dquotestr {
Subroutine rule_dquotestr: called CC=2 SCAR=6.9
Pod undocumented
238 48 my ($self, %args) = @_;
239 join("",
240 map { $_->{type} eq 'VAR' ?
241 $self->rule_var(match=>{var=>$_->{value}}) :
242 $_->{value}
243 48 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
$_->{'type'} eq 'VAR' ? : 2 46 48
244 48 @{ $self->parse_dquotestr($args{match}{part}) });
245 }
246  
247 2 ▶sub rule_bool {
Subroutine rule_bool: called CC=2 SCAR=6.9
Pod undocumented
248 2 my ($self, %args) = @_;
249 2 my $match = $args{match};
250 2 ▶ if ($match->{bool} eq 'true') { true } else { false }
Branch: 1 branch
BranchTrueFalseTotal
if ($match->{'bool'} eq 'true') { } 1 1 2
251 }
252  
253 263 ▶sub rule_num {
Subroutine rule_num: called CC=3 SCAR=12.7
Pod undocumented
254 263 my ($self, %args) = @_;
255 263 my $match = $args{match};
256 0 ▶ if ($match->{num} eq 'inf') { "Inf"+0 }
Branch: 2 branches
BranchTrueFalseTotal
if ($match->{'num'} eq 'inf') { } 0 263 263
elsif ($match->{'num'} eq 'nan') { } 0 263 263
257 0 elsif ($match->{num} eq 'nan') { "NaN"+0 }
258 263 else { $match->{num}+0 }
259 }
260  
261 9 ▶sub rule_var {
Subroutine rule_var: called CC=1 SCAR=0.0
Pod undocumented
262 9 my ($self, %args) = @_;
263 9 my $match = $args{match};
264 9 $self->vars->{ $match->{var} };
265 }
266  
267 4 ▶sub rule_func {
Subroutine rule_func: called CC=2 SCAR=7.1
Pod undocumented
268 4 my ($self, %args) = @_;
269 4 my $match = $args{match};
270 4 my $f = $match->{func_name};
271 4 my $args = $match->{args};
272 4 my $res;
273 4 ▶ if ($self->funcs->{$f}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->funcs->{$f}) { } 4 0 4
274 4 return $self->funcs->{$f}->(@$args);
275 } else {
276 0 die "Unknown function $f";
277 }
278 }
279  
280 0 ▶sub _map_grep_usort {
Subroutine _map_grep_usort: not called CC=6 SCAR=37.4
281 0 my ($self, $which, %args) = @_;
282 0 my $match = $args{match};
283 0 my $ary = $match->{array};
284 0 my $expr = $match->{expr};
285 0 ▶ die "Second argument to map/grep/usort must be an array"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ary eq "ARRAY" 0 0 0
286 unless ref($ary) eq 'ARRAY';
287 0 local $self->{level} = $self->{level}+1;
288 #print "DEBUG: _map_grep_usort: level=$self->{level}, expr=`$expr`, array=[".join(",", @$ary),"]\n";
289 0 my $res;
290 0 ▶ if ($which eq 'map') {
Branch: 3 branches
BranchTrueFalseTotal
if ($which eq 'map') { } 0 0 0
elsif ($which eq 'grep') { } 0 0 0
elsif ($which eq 'usort') { } 0 0 0
291 0 $res = [];
292 0 local $self->{vars}{_};
293 0 for (@$ary) {
294 0 $self->{vars}{_} = $_;
295 0 push @$res, Language::Expr::Parser::parse_expr($expr, $self,
296 $self->level);
297 0 push @$res, $_;
298 }
299 } elsif ($which eq 'grep') {
300 0 local $self->{vars}{_};
301 $res = [ grep {
302 0 $self->{vars}{_} = $_;
303 0 $self->Language::Expr::Parser::parse_expr($expr, $self,
304 $self->level)
305 } @$ary];
306 } elsif ($which eq 'usort') {
307 0 local $self->{vars}{a};
308 0 local $self->{vars}{b};
309 $res = [ sort {
310 0 $self->{vars}{a} = $a;
311 0 $self->{vars}{b} = $b;
312 0 Language::Expr::Parser::parse_expr($expr, $self,
313 $self->level)
314 } @$ary];
315 }
316 0 $res;
317 }
318  
319 0 ▶sub rule_func_map {
Subroutine rule_func_map: not called CC=1 SCAR=6.9
Pod undocumented
320 0 my ($self, %args) = @_;
321 0 $self->_map_grep_usort('map', %args);
322 }
323  
324 0 ▶sub rule_func_grep {
Subroutine rule_func_grep: not called CC=1 SCAR=6.9
Pod undocumented
325 0 my ($self, %args) = @_;
326 0 $self->_map_grep_usort('grep', %args);
327 }
328  
329 0 ▶sub rule_func_usort {
Subroutine rule_func_usort: not called CC=1 SCAR=6.9
Pod undocumented
330 0 my ($self, %args) = @_;
331 0 $self->_map_grep_usort('usort', %args);
332 }
333  
334 31 ▶sub rule_parenthesis {}
Subroutine rule_parenthesis: called CC=1 SCAR=0.0
Pod undocumented
335  
336 166 ▶sub expr_preprocess {}
Subroutine expr_preprocess: called CC=1 SCAR=0.0
Pod undocumented
337  
338 139 ▶sub expr_postprocess {
Subroutine expr_postprocess: called CC=1 SCAR=0.0
Pod undocumented
339 139 my ($self, %args) = @_;
340 139 my $result = $args{result};
341 139 $result;
342 }
343  
344 3 1;
345 # ABSTRACT: A default interpreter for Language::Expr
346  
347 __END__
« Expr/Compiler/js.pm ↑ Summary Expr/JS.pm »