« blib/lib/Erlang/Parser/Node/Comprehension.pm
↑ Summary
blib/lib/Erlang/Parser/Node/FunLocalCase.pm »
| 1 | # Copyright 2011-2012 Yuki Izumi. ( anneli AT cpan DOT org ) | ||||||||||||
| 2 | # This is free software; you can redistribute it and/or modify it under the | ||||||||||||
| 3 | # same terms as Perl itself. | ||||||||||||
| 4 | |||||||||||||
| 5 | package Erlang::Parser::Node::IfExpr; | ||||||||||||
| 6 | |||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | with 'Erlang::Parser::Node'; | |||||||||||
| 9 | |||||||||||||
| 10 | 4 | has 'seq' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]'); | |||||||||||
| 11 | 4 | has 'stmts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]'); | |||||||||||
| 12 | |||||||||||||
| 13 | sub print { | ||||||||||||
| 14 | 8 | ▶ | my ($self, $fh, $depth) = @_; | ||||||||||
|
Subroutine
print: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||
| 15 | 8 | ▶ | $depth ||= 0; | ||||||||||
|
Condition50%1/2
$depth ||= 0
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
| |||||||||||||
| 16 | |||||||||||||
| 17 | 8 | my $first = 1; | |||||||||||
| 18 | 8 | foreach (@{$self->seq}) { | |||||||||||
| 19 | 10 | ▶ | if ($first) { $first = 0 } else { print $fh ', ' } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 10 | $_->print($fh, $depth); | |||||||||||
| 21 | } | ||||||||||||
| 22 | 8 | print $fh " ->\n"; | |||||||||||
| 23 | |||||||||||||
| 24 | 8 | $depth++; | |||||||||||
| 25 | 8 | print $fh "\t" x $depth; | |||||||||||
| 26 | |||||||||||||
| 27 | 8 | $first = 1; | |||||||||||
| 28 | 8 | foreach (@{$self->stmts}) { | |||||||||||
| 29 | 18 | ▶ | if ($first) { $first = 0 } else { print $fh ",\n", "\t" x $depth } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 18 | $_->print($fh, $depth); | |||||||||||
| 31 | } | ||||||||||||
| 32 | 8 | $depth--; | |||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 36 | |||||||||||||
| 37 | =head1 NAME | ||||||||||||
| 38 | |||||||||||||
| 39 | Erlang::Parser::Node::IfExpr - a case in an if statement | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 DESCRIPTION | ||||||||||||
| 42 | |||||||||||||
| 43 | A block of statements; a glorified parenthesis. | ||||||||||||
| 44 | |||||||||||||
| 45 | =head2 Accessors | ||||||||||||
| 46 | |||||||||||||
| 47 | =over 4 | ||||||||||||
| 48 | |||||||||||||
| 49 | =item C<seq> | ||||||||||||
| 50 | |||||||||||||
| 51 | The guard sequence; a list of L<Erlang::Parser::Node>s. | ||||||||||||
| 52 | |||||||||||||
| 53 | =item C<exprs> | ||||||||||||
| 54 | |||||||||||||
| 55 | The body of L<Erlang::Parser::Node>s to be executed if C<seq> evalutes true. | ||||||||||||
| 56 | |||||||||||||
| 57 | =back | ||||||||||||
| 58 | |||||||||||||
| 59 | =head2 Methods | ||||||||||||
| 60 | |||||||||||||
| 61 | =over 4 | ||||||||||||
| 62 | |||||||||||||
| 63 | =item C<print> | ||||||||||||
| 64 | |||||||||||||
| 65 | Pretty-prints the node to its filehandle argument. | ||||||||||||
| 66 | |||||||||||||
| 67 | =back | ||||||||||||
| 68 | |||||||||||||
| 69 | =head1 EXAMPLE | ||||||||||||
| 70 | |||||||||||||
| 71 | X>Y -> | ||||||||||||
| 72 | true | ||||||||||||
| 73 | |||||||||||||
| 74 | =cut | ||||||||||||
| 75 | |||||||||||||
| 76 | 4 | 1; | |||||||||||
| 77 | |||||||||||||
| 78 | # vim: set sw=4 ts=4: | ||||||||||||