| 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::List; | ||||||||||||
| 6 | |||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | with 'Erlang::Parser::Node'; | |||||||||||
| 9 | |||||||||||||
| 10 | 4 | has 'elems' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]'); | |||||||||||
| 11 | 4 | has 'cdr' => (is => 'rw', required => 1, isa => 'Maybe[Erlang::Parser::Node]'); | |||||||||||
| 12 | |||||||||||||
| 13 | sub print { | ||||||||||||
| 14 | 3360 | ▶ | my ($self, $fh, $depth) = @_; | ||||||||||
|
Subroutine
print: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||
| 15 | 3360 | ▶ | $depth ||= 0; | ||||||||||
|
Condition100%2/2
$depth ||= 0
MC/DC100%1/1
$depth ||= 0
$depth
Truth table100%2/2
A
A= $depth
| |||||||||||||
| 16 | |||||||||||||
| 17 | 3360 | print $fh '['; | |||||||||||
| 18 | 3360 | my $first = 1; | |||||||||||
| 19 | 3360 | foreach (@{$self->elems}) { | |||||||||||
| 20 | 4570 | ▶ | if ($first) { $first = 0 } else { print $fh ', ' } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 4570 | $_->print($fh, $depth); | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | 3360 | ▶ | if (defined $self->cdr) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 888 | print $fh '|'; | |||||||||||
| 26 | 888 | $self->cdr->print($fh, $depth); | |||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 3360 | print $fh ']'; | |||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 33 | |||||||||||||
| 34 | =head1 NAME | ||||||||||||
| 35 | |||||||||||||
| 36 | Erlang::Parser::Node::List - a list of values | ||||||||||||
| 37 | |||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||
| 39 | |||||||||||||
| 40 | A lisp-style cdr list. | ||||||||||||
| 41 | |||||||||||||
| 42 | =head2 Accessors | ||||||||||||
| 43 | |||||||||||||
| 44 | =over 4 | ||||||||||||
| 45 | |||||||||||||
| 46 | =item C<elems> | ||||||||||||
| 47 | |||||||||||||
| 48 | A list of L<Erlang::Parser::Node>s which comprise the list. | ||||||||||||
| 49 | |||||||||||||
| 50 | =item C<cdr> | ||||||||||||
| 51 | |||||||||||||
| 52 | An optional L<Erlang::Parser::Node> which forms the tail of the list. This | ||||||||||||
| 53 | should be another list (usually). | ||||||||||||
| 54 | |||||||||||||
| 55 | =back | ||||||||||||
| 56 | |||||||||||||
| 57 | =head2 Methods | ||||||||||||
| 58 | |||||||||||||
| 59 | =over 4 | ||||||||||||
| 60 | |||||||||||||
| 61 | =item C<print> | ||||||||||||
| 62 | |||||||||||||
| 63 | Pretty-prints the node to its filehandle argument. | ||||||||||||
| 64 | |||||||||||||
| 65 | =back | ||||||||||||
| 66 | |||||||||||||
| 67 | =head1 EXAMPLE | ||||||||||||
| 68 | |||||||||||||
| 69 | [7, 8, 9|[]] | ||||||||||||
| 70 | |||||||||||||
| 71 | =cut | ||||||||||||
| 72 | |||||||||||||
| 73 | 4 | 1; | |||||||||||
| 74 | |||||||||||||
| 75 | # vim: set sw=4 ts=4: | ||||||||||||