File Coverage

blib/lib/Erlang/Parser/Node/Atom.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition 5 5 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 21 21 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::Atom;
6              
7 3     3   11 use Moose;
  3         3  
  3         19  
8             with 'Erlang::Parser::Node';
9              
10             has 'atom' => (is => 'rw', required => 1, isa => 'Str');
11              
12             sub print {
13 13512     13512 1 13759 my ($self, $fh, $depth) = @_;
14 13512   100     21169 $depth ||= 0;
15              
16 13512 100 100     302910 if (not $self->atom =~ /^[^a-z]|[^a-zA-Z_0-9]/
17             and not $self->atom =~ /^(case|receive|after|of|end|fun|when|div|bs[lr]|bx?or|band|rem|try|catch|andalso|and|orelse|or|begin|not|if)$/) {
18 13252         289857 print $fh $self->atom;
19             } else {
20 260         5940 my $atom = $self->atom;
21 260         349 $atom =~ s/\\/\\\\/g;
22 260         289 $atom =~ s/'/\\'/g;
23              
24 260         842 print $fh "'$atom'";
25             }
26             }
27              
28             __PACKAGE__->meta->make_immutable;
29              
30             =head1 NAME
31              
32             Erlang::Parser::Node::Atom - a plain atom
33              
34             =head1 DESCRIPTION
35              
36             The basic symbol unit in Erlang.
37              
38             =head2 Accessors
39              
40             =over 4
41              
42             =item C<atom>
43              
44             The string representation of the atom>
45              
46             =back
47              
48             =head2 Methods
49              
50             =over 4
51              
52             =item C<print>
53              
54             Pretty-prints the node to its filehandle argument.
55              
56             =back
57              
58             =head1 EXAMPLE
59              
60             my.atom@is.long.
61              
62             =cut
63              
64             1;
65              
66             # vim: set sw=4 ts=4: