File Coverage

blib/lib/Erlang/Parser/Node/BinOp.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition 2 2 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 17 17 100.0


line stmt bran cond sub pod time code
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::BinOp;
6              
7 3     3   10 use Moose;
  3         5  
  3         15  
8             with 'Erlang::Parser::Node';
9              
10             has 'op' => (is => 'rw', required => 1, isa => 'Str');
11             has 'a' => (is => 'rw', required => 1, does => 'Erlang::Parser::Node');
12             has 'b' => (is => 'rw', required => 1, does => 'Erlang::Parser::Node');
13              
14             sub print {
15 5406     5406 1 5029 my ($self, $fh, $depth) = @_;
16 5406   100     9079 $depth ||= 0;
17              
18 5406         5383 print $fh '(';
19 5406         123135 $self->a->print($fh, $depth);
20              
21 5406         5379 print $fh ' ';
22 5406         121275 print $fh $self->op;
23 5406         4849 print $fh ' ';
24              
25 5406         120035 $self->b->print($fh, $depth);
26 5406         10436 print $fh ')';
27             }
28              
29             __PACKAGE__->meta->make_immutable;
30              
31             =head1 NAME
32              
33             Erlang::Parser::Node::BinOp - a binary operation
34              
35             =head1 DESCRIPTION
36              
37             An infix binary operation.
38              
39             =head2 Accessors
40              
41             =over 4
42              
43             =item C<op>
44              
45             The operation as a string (i.e. '+' for addition, '--' for list difference).
46              
47             =item C<a>, C<b>
48              
49             The first and second L<Erlang::Parser::Node> arguments to the operation.
50              
51             =back
52              
53             =head2 Methods
54              
55             =over 4
56              
57             =item C<print>
58              
59             Pretty-prints the node to its filehandle argument.
60              
61             =back
62              
63             =head1 EXAMPLE
64              
65             1 + 1
66              
67             =cut
68              
69             1;
70              
71             # vim: set sw=4 ts=4: