Blatte/Syntax.pm

filter: Statementstmt 87.4% 223 / 255 Branchbran 76.9% 20 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 89.0% 65 / 73 Podpod 0.0% 0 / 2 totaltotal 86.5% 308 / 356 CC 18 SCAR 8.0
CC
18
Cov
86%
make_sub
8.0
transform
6.0
transform
4.0
CRAP 2.2
« Blatte.pm ↑ Summary Blatte/Ws.pm »
1 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Blatte::Syntax;
4  
5 343 ▶sub transform {
Subroutine transform: called CC=2 SCAR=7.1
Pod undocumented
6 343 my($obj, $column) = @_;
7 343 ▶ return $obj unless ref($obj);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $obj 0 343 343
8 343 $obj->transform($column);
9 }
10  
11 5 ▶sub make_sub {
Subroutine make_sub: called CC=8 SCAR=20.8
Pod undocumented
12 5 my($params, $exprs, $column) = @_;
13  
14 5 my @positional;
15 my @named;
16 5 my $rest;
17  
18 5 foreach my $param (@$params) {
19 8 ▶ if ($param->isa('Blatte::Syntax::Param::Positional')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($param->isa('Blatte::Syntax::Param::Positional')) { } 5 3 8
elsif ($param->isa('Blatte::Syntax::Param::Named')) { } 2 1 3
elsif ($param->isa('Blatte::Syntax::Param::Rest')) { } 1 0 1
20 5 push(@positional, $param->name());
21 } elsif ($param->isa('Blatte::Syntax::Param::Named')) {
22 2 push(@named, $param->name());
23 } elsif ($param->isa('Blatte::Syntax::Param::Rest')) {
24 1 $rest = $param->name();
25 }
26 }
27  
28 5 my $indent = (' ' x $column);
29  
30 5 my $result = "sub {\n";
31 5 $result .= sprintf("%s my \$_named = shift;\n", $indent);
32 5 ▶ if (@positional) {
Branch: 1 branch
BranchTrueFalseTotal
if (@positional) 4 1 5
33 $result .= sprintf("%s my(%s) = map {\n",
34 $indent,
35 join(sprintf(",\n%s ", $indent),
36 4 map { sprintf('$%s', $_) } @positional));
37 4 $result .= sprintf("%s &Blatte::unwrapws(\$_);\n",
38 $indent);
39 4 $result .= sprintf("%s } splice(\@_, 0, %d);\n",
40 $indent,
41 scalar(@positional));
42 }
43 5 foreach my $named (@named) {
44 2 $result .= sprintf("%s my \$%s = \$_named->{%s};\n",
45 $indent, $named, $named);
46 }
47 5 ▶ if (defined($rest)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rest) 1 4 5
48 1 $result .= sprintf("%s my \$%s = [\@_];\n", $indent, $rest);
49 }
50 $result .= sprintf("%s %s;\n",
51 $indent,
52 join(sprintf(";\n%s ", $indent),
53 5 map { &Blatte::Syntax::transform($_, $column + 2) } @$exprs));
54 5 $result .= sprintf("%s}", $indent);
55  
56 5 $result;
57 }
58  
59 ############################################################
60  
61 package Blatte::Syntax::List;
62  
63 35 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
64 35 my $type = shift;
65 35 bless [@_], $type;
66 }
67  
68 35 ▶sub transform {
Subroutine transform: called CC=6 SCAR=17.9
69 35 my($self, $column) = @_;
70  
71 35 ▶ return '[]' unless @$self;
Branch: 1 branch
BranchTrueFalseTotal
unless @$self 4 31 35
72  
73 31 my @exprs;
74 my @assignments;
75  
76 31 foreach my $subexpr (@$self) {
77 100 ▶ if (UNIVERSAL::isa($subexpr, 'Blatte::Syntax::Assignment')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($subexpr, 'Blatte::Syntax::Assignment')) { } 2 98 100
78 2 push(@assignments, $subexpr);
79 } else {
80 98 push(@exprs, $subexpr);
81 }
82 }
83  
84 31 my $first = shift(@exprs);
85  
86 31 my $indent = (' ' x $column);
87 31 my $result = "do {\n";
88 31 $result .= sprintf("%s my \$_first = %s;\n",
89 $indent,
90 &Blatte::Syntax::transform($first, $column + 15));
91 $result .= sprintf("%s my \@_rest = (%s);\n",
92 $indent,
93 join(sprintf(",\n%s ", $indent),
94 map {
95 31 my $result =
96 sprintf("&Blatte::wrapws('%s',\n",
97 &Blatte::wsof($_));
98 67 $result .=
99 sprintf("%s%s%s%s)",
100 $indent,
101 (' ' x 15),
102 (' ' x 16),
103 &Blatte::Syntax::transform($_,
104 $column + 31));
105 67 $result;
106 } @exprs));
107 31 $result .= sprintf("%s if (ref(\$_first) eq 'CODE') {\n", $indent);
108 $result .= sprintf("%s &\$_first({%s}",
109 $indent,
110 join(sprintf(",\n%s ", $indent),
111 map {
112 31 sprintf('%s => %s',
113 $_->name(),
114 &Blatte::Syntax::transform($_->expr(),
115 $column + 16));
116 } @assignments));
117 31 ▶ if (@exprs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exprs) 31 0 31
118 31 $result .= sprintf(",\n%s &Blatte::unwrapws(\$_rest[0])",
119 $indent);
120 31 ▶ if (@exprs > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exprs > 1) 20 11 31
121 20 $result .= sprintf(",\n%s \@_rest[1 .. \$#_rest]",
122 $indent);
123 }
124 }
125 31 $result .= ");\n";
126 31 $result .= sprintf("%s } else {\n", $indent);
127 31 $result .= sprintf("%s [\$_first, \@_rest];\n", $indent);
128 31 $result .= sprintf("%s }\n", $indent);
129 31 $result .= sprintf("%s}", $indent);
130  
131 31 $result;
132 }
133  
134 ############################################################
135  
136 package Blatte::Syntax::Assignment;
137  
138 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
139 2 my($type, $name, $expr) = @_;
140 2 bless [$name, $expr], $type;
141 }
142  
143 2 ▶sub name { $_[0]->[0] }
Subroutine name: called CC=1 SCAR=0.0
144 2 ▶sub expr { $_[0]->[1] }
Subroutine expr: called CC=1 SCAR=0.0
145  
146 ############################################################
147  
148 package Blatte::Syntax::VarRef;
149  
150 42 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
151 42 my($type, $name) = @_;
152 42 bless \$name, $type;
153 }
154  
155 42 ▶sub name { $ {$_[0]} }
Subroutine name: called CC=1 SCAR=0.0
156  
157 42 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
158 42 my($self, $column) = @_;
159 42 sprintf('$%s', $self->name());
160 }
161  
162 ############################################################
163  
164 package Blatte::Syntax::Literal;
165  
166 95 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
167 95 my($type, $str) = @_;
168 95 bless \$str, $type;
169 }
170  
171 95 ▶sub str { $ {$_[0]} }
Subroutine str: called CC=1 SCAR=0.0
172  
173 95 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
174 95 my($self, $column) = @_;
175 95 my $str = $self->str();
176 95 $str =~ s/([\\\'])/\\$1/g;
177 95 sprintf("'%s'", $str);
178 }
179  
180 ############################################################
181  
182 package Blatte::Syntax::DefineVar;
183  
184 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
185 3 my($type, $name, $expr) = @_;
186 3 bless [$name, $expr], $type;
187 }
188  
189 6 ▶sub name { $_[0]->[0] }
Subroutine name: called CC=1 SCAR=0.0
190 3 ▶sub expr { $_[0]->[1] }
Subroutine expr: called CC=1 SCAR=0.0
191  
192 3 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
193 3 my($self, $column) = @_;
194  
195 3 my $indent = (' ' x $column);
196  
197 3 my $result = "do {\n";
198 3 $result .= sprintf("%s use vars '\$%s';\n", $indent, $self->name());
199 3 $result .= sprintf("%s \$%s = %s;\n",
200 $indent,
201 $self->name(),
202 &Blatte::Syntax::transform($self->expr(), $column + 4));
203 3 $result .= sprintf("%s [];\n", $indent);
204 3 $result .= sprintf("%s}", $indent);
205  
206 3 $result;
207 }
208  
209 ############################################################
210  
211 package Blatte::Syntax::DefineFn;
212  
213 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
214 4 my($type, $name, $params, $exprs) = @_;
215 4 bless [$name, $params, $exprs], $type;
216 }
217  
218 8 ▶sub name { $_[0]->[0] }
Subroutine name: called CC=1 SCAR=0.0
219 4 ▶sub params { $_[0]->[1] }
Subroutine params: called CC=1 SCAR=0.0
220 4 ▶sub exprs { $_[0]->[2] }
Subroutine exprs: called CC=1 SCAR=0.0
221  
222 4 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
223 4 my($self, $column) = @_;
224  
225 4 my $indent = (' ' x $column);
226  
227 4 my $result = "do {\n";
228 4 $result .= sprintf("%s use vars '\$%s';\n", $indent, $self->name());
229 4 $result .= sprintf("%s \$%s = %s;\n",
230 $indent,
231 $self->name(),
232 &Blatte::Syntax::make_sub($self->params(),
233 $self->exprs(),
234 $column + 4));
235 4 $result .= sprintf("%s [];\n", $indent);
236 4 $result .= sprintf("%s}", $indent);
237  
238 4 $result;
239 }
240  
241 ############################################################
242  
243 package Blatte::Syntax::SetVar;
244  
245 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
246 1 my($type, $name, $expr) = @_;
247 1 bless [$name, $expr], $type;
248 }
249  
250 1 ▶sub name { $_[0]->[0] }
Subroutine name: called CC=1 SCAR=0.0
251 1 ▶sub expr { $_[0]->[1] }
Subroutine expr: called CC=1 SCAR=0.0
252  
253 1 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
254 1 my($self, $column) = @_;
255  
256 1 sprintf("\$%s = %s",
257 $self->name(),
258 &Blatte::Syntax::transform($self->expr(), $column + 2));
259 }
260  
261 ############################################################
262  
263 package Blatte::Syntax::Lambda;
264  
265 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
266 1 my($type, $params, $exprs) = @_;
267 1 bless [$params, $exprs], $type;
268 }
269  
270 1 ▶sub params { $_[0]->[0] }
Subroutine params: called CC=1 SCAR=0.0
271 1 ▶sub exprs { $_[0]->[1] }
Subroutine exprs: called CC=1 SCAR=0.0
272  
273 1 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
274 1 my($self, $column) = @_;
275 1 &Blatte::Syntax::make_sub($self->params(), $self->exprs(), $column);
276 }
277  
278 ############################################################
279  
280 package Blatte::Syntax::Param::Positional;
281  
282 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
283 5 my($type, $name) = @_;
284 5 bless \$name, $type;
285 }
286  
287 5 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
288 5 $ {$_[0]};
289 }
290  
291 ############################################################
292  
293 package Blatte::Syntax::Param::Named;
294  
295 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
296 2 my($type, $name) = @_;
297 2 bless \$name, $type;
298 }
299  
300 2 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
301 2 $ {$_[0]};
302 }
303  
304 ############################################################
305  
306 package Blatte::Syntax::Param::Rest;
307  
308 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
309 1 my($type, $name) = @_;
310 1 bless \$name, $type;
311 }
312  
313 1 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
314 1 $ {$_[0]};
315 }
316  
317 ############################################################
318  
319 package Blatte::Syntax::Let;
320  
321 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
322 4 my($type, $clauses, $exprs) = @_;
323 4 bless [$clauses, $exprs], $type;
324 }
325  
326 8 ▶sub clauses { @{$_[0]->[0]} }
Subroutine clauses: called CC=1 SCAR=0.0
327 4 ▶sub exprs { @{$_[0]->[1]} }
Subroutine exprs: called CC=1 SCAR=0.0
328  
329 4 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
330 4 my($self, $column) = @_;
331  
332 4 my $indent = (' ' x $column);
333  
334 4 my $result = "do {\n";
335 $result .= sprintf("%s my(%s) =\n",
336 $indent,
337 join(sprintf(",\n%s ", $indent),
338 map {
339 4 sprintf('$%s', $_->name());
340 } $self->clauses()));
341 $result .= sprintf("%s (%s);\n",
342 $indent,
343 join(sprintf(",\n%s ", $indent),
344 map {
345 4 sprintf('(%s)',
346 &Blatte::Syntax::transform($_->expr(),
347 $column + 6));
348 } $self->clauses()));
349 $result .= sprintf("%s %s;\n",
350 $indent,
351 join(sprintf(";\n%s ", $indent),
352 map {
353 4 &Blatte::Syntax::transform($_, $column + 2);
354 } $self->exprs()));
355 4 $result .= sprintf("%s}", $indent);
356  
357 4 $result;
358 }
359  
360 ############################################################
361  
362 package Blatte::Syntax::LetStar;
363  
364 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
365 2 my($type, $clauses, $exprs) = @_;
366 2 bless [$clauses, $exprs], $type;
367 }
368  
369 2 ▶sub clauses { @{$_[0]->[0]} }
Subroutine clauses: called CC=1 SCAR=0.0
370 2 ▶sub exprs { @{$_[0]->[1]} }
Subroutine exprs: called CC=1 SCAR=0.0
371  
372 2 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
373 2 my($self, $column) = @_;
374  
375 2 my $indent = (' ' x $column);
376  
377 2 my $result = "do {\n";
378 $result .= sprintf("%s %s;\n",
379 $indent,
380 join(sprintf(";\n%s ", $indent),
381 map {
382 2 sprintf('my $%s = %s;',
383 $_->name(),
384 &Blatte::Syntax::transform($_->expr(),
385 $column + 7));
386 } $self->clauses()));
387 $result .= sprintf("%s %s;\n",
388 $indent,
389 join(sprintf(";\n%s ", $indent),
390 map {
391 2 &Blatte::Syntax::transform($_, $column + 2);
392 } $self->exprs()));
393 2 $result .= sprintf("%s}", $indent);
394  
395 2 $result;
396 }
397  
398 ############################################################
399  
400 package Blatte::Syntax::Letrec;
401  
402 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
403 0 my($type, $clauses, $exprs) = @_;
404 0 bless [$clauses, $exprs], $type;
405 }
406  
407 0 ▶sub clauses { @{$_[0]->[0]} }
Subroutine clauses: not called CC=1 SCAR=6.9
408 0 ▶sub exprs { @{$_[0]->[1]} }
Subroutine exprs: not called CC=1 SCAR=6.9
409  
410 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
411 0 my($self, $column) = @_;
412  
413 0 my $indent = (' ' x $column);
414  
415 0 my $result = "do {\n";
416 $result .= sprintf("%s my(%s);\n",
417 $indent,
418 join(sprintf(",\n%s ", $indent),
419 map {
420 0 sprintf('$%s', $_->name());
421 } $self->clauses()));
422 $result .= sprintf("%s %s;\n",
423 $indent,
424 join(sprintf(";\n%s ", $indent),
425 map {
426 0 sprintf('$%s = %s;',
427 $_->name(),
428 &Blatte::Syntax::transform($_->expr(),
429 $column + 4));
430 } $self->clauses()));
431 $result .= sprintf("%s %s;\n",
432 $indent,
433 join(sprintf(";\n%s ", $indent),
434 map {
435 0 &Blatte::Syntax::transform($_, $column + 2);
436 } $self->exprs()));
437 0 $result .= sprintf("%s}", $indent);
438  
439 0 $result;
440 }
441  
442 ############################################################
443  
444 package Blatte::Syntax::LetClause;
445  
446 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
447 9 my($type, $name, $expr) = @_;
448 9 bless [$name, $expr], $type;
449 }
450  
451 9 ▶sub name { $_[0]->[0] }
Subroutine name: called CC=1 SCAR=0.0
452 9 ▶sub expr { $_[0]->[1] }
Subroutine expr: called CC=1 SCAR=0.0
453  
454 ############################################################
455  
456 package Blatte::Syntax::If;
457  
458 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
459 2 my($type, $test, $consequent, @alternates) = @_;
460 2 bless [$test, $consequent, @alternates], $type;
461 }
462  
463 2 ▶sub test { $_[0]->[0] }
Subroutine test: called CC=1 SCAR=0.0
464 2 ▶sub consequent { $_[0]->[1] }
Subroutine consequent: called CC=1 SCAR=0.0
465 4 ▶sub alternates { @{$_[0]}[2 .. $#{$_[0]}] }
Subroutine alternates: called CC=1 SCAR=0.0
466  
467 2 ▶sub transform {
Subroutine transform: called CC=2 SCAR=6.9
468 2 my($self, $column) = @_;
469  
470 2 my $indent = (' ' x $column);
471  
472 2 my $result = "do {\n";
473 2 $result .= sprintf("%s if (&Blatte::true(%s)) {\n",
474 $indent,
475 &Blatte::Syntax::transform($self->test(),
476 $column + 20));
477 2 $result .= sprintf("%s %s;\n",
478 $indent,
479 &Blatte::Syntax::transform($self->consequent(),
480 $column + 4));
481 2 $result .= sprintf("%s } else {\n",
482 $indent);
483 $result .= sprintf("%s %s;\n",
484 $indent,
485 ($self->alternates() ?
486 join(sprintf(";\n%s ", $indent),
487 map {
488 2 ▶ &Blatte::Syntax::transform($_, $column + 4);
Branch: 1 branch
BranchTrueFalseTotal
$self->alternates ? : 2 0 2
489 } $self->alternates()) :
490 'undef'));
491 2 $result .= sprintf("%s }\n", $indent);
492 2 $result .= sprintf("%s}", $indent);
493  
494 2 $result;
495 }
496  
497 ############################################################
498  
499 package Blatte::Syntax::Cond;
500  
501 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
502 2 my $type = shift;
503 2 bless [@_], $type;
504 }
505  
506 2 ▶sub clauses { @{$_[0]} }
Subroutine clauses: called CC=1 SCAR=0.0
507  
508 2 ▶sub transform {
Subroutine transform: called CC=4 SCAR=13.9
509 2 my($self, $column) = @_;
510  
511 2 my $indent = (' ' x $column);
512  
513 2 my $result = "do {\n";
514  
515 2 my @clauses = $self->clauses();
516 2 my $first_clause = shift(@clauses);
517  
518 2 $result .= sprintf("%s if (&Blatte::true(%s)) {\n",
519 $indent,
520 &Blatte::Syntax::transform($first_clause->test(),
521 $column + 20));
522 $result .= sprintf("%s %s;\n",
523 $indent,
524 ($first_clause->actions() ?
525 join(sprintf(";\n%s ", $indent),
526 $indent,
527 map {
528 2 ▶ &Blatte::Syntax::transform($_, $column + 4);
Branch: 1 branch
BranchTrueFalseTotal
$first_clause->actions ? : 2 0 2
529 } $first_clause->actions()) :
530 'undef'));
531 2 foreach my $clause (@clauses) {
532 5 $result .= sprintf("%s } elsif (&Blatte::true(%s)) {\n",
533 $indent,
534 &Blatte::Syntax::transform($clause->test(),
535 $column + 25));
536 $result .= sprintf("%s %s;\n",
537 $indent,
538 ($clause->actions() ?
539 join(sprintf(";\n%s ", $indent),
540 $indent,
541 map {
542 5 ▶ &Blatte::Syntax::transform($_, $column + 4);
Branch: 1 branch
BranchTrueFalseTotal
$clause->actions ? : 5 0 5
543 } $clause->actions()) :
544 'undef'));
545 }
546 2 $result .= sprintf("%s }\n", $indent);
547 2 $result .= sprintf("%s}", $indent);
548  
549 2 $result;
550 }
551  
552 ############################################################
553  
554 package Blatte::Syntax::CondClause;
555  
556 7 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
557 7 my($type, $test, @actions) = @_;
558 7 bless [$test, @actions], $type;
559 }
560  
561 7 ▶sub test { $_[0]->[0] }
Subroutine test: called CC=1 SCAR=0.0
562 14 ▶sub actions { @{$_[0]}[1 .. $#{$_[0]}] }
Subroutine actions: called CC=1 SCAR=0.0
563  
564 ############################################################
565  
566 package Blatte::Syntax::While;
567  
568 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
569 0 my($type, $test, @exprs) = @_;
570 0 bless [$test, @exprs], $type;
571 }
572  
573 0 ▶sub test { $_[0]->[0] }
Subroutine test: not called CC=1 SCAR=6.9
574 0 ▶sub exprs { @{$_[0]}[1 .. $#{$_[0]}] }
Subroutine exprs: not called CC=1 SCAR=6.9
575  
576 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
577 0 my($self, $column) = @_;
578  
579 0 my $indent = (' ' x $column);
580  
581 0 my $result = "do {\n";
582 0 $result .= sprintf("%s while (&Blatte::true(%s)) {\n",
583 $indent,
584 &Blatte::Syntax::transform($self->test(), $column + 23));
585 $result .= sprintf("%s %s;\n",
586 $indent,
587 join(sprintf(";\n%s ",
588 map {
589 0 &Blatte::Syntax::transform($_,
590 $column + 4);
591 } $self->exprs())));
592 0 $result .= sprintf("%s }\n", $indent);
593 0 $result .= sprintf("%s}", $indent);
594  
595 0 $result;
596 }
597  
598 ############################################################
599  
600 package Blatte::Syntax::And;
601  
602 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
603 1 my $type = shift;
604 1 bless [@_], $type;
605 }
606  
607 1 ▶sub exprs { @{$_[0]} }
Subroutine exprs: called CC=1 SCAR=0.0
608  
609 1 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
610 1 my($self, $column) = @_;
611  
612 1 my $indent = (' ' x $column);
613  
614 sprintf('(%s)',
615 join(sprintf("\n%s && ", $indent),
616 map {
617 1 sprintf('&Blatte::true(%s)',
618 &Blatte::Syntax::transform($_, $column + 18));
619 } $self->exprs()));
620 }
621  
622 ############################################################
623  
624 package Blatte::Syntax::Or;
625  
626 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
627 2 my $type = shift;
628 2 bless [@_], $type;
629 }
630  
631 2 ▶sub exprs { @{$_[0]} }
Subroutine exprs: called CC=1 SCAR=0.0
632  
633 2 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
634 2 my($self, $column) = @_;
635  
636 2 my $indent = (' ' x $column);
637  
638 sprintf('(%s)',
639 join(sprintf("\n%s || ", $indent),
640 map {
641 2 sprintf('&Blatte::true(%s)',
642 &Blatte::Syntax::transform($_, $column + 18));
643 } $self->exprs()));
644 }
645  
646 12 1;
647  
648 __END__
« Blatte.pm ↑ Summary Blatte/Ws.pm »