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::WhenList; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
10
|
use Moose; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
14
|
|
8
|
|
|
|
|
|
|
with 'Erlang::Parser::Node'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'groups' => (is => 'rw', default => sub {[]}, isa => 'ArrayRef[ArrayRef[Erlang::Parser::Node]]'); |
11
|
|
|
|
|
|
|
has 'exprs' => (is => 'rw', default => sub {[]}, isa => 'ArrayRef[Erlang::Parser::Node]'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _append { |
14
|
766
|
|
|
766
|
|
1209
|
my ($self, $expr) = @_; |
15
|
766
|
|
|
|
|
809
|
push @{$self->exprs}, $expr; |
|
766
|
|
|
|
|
19966
|
|
16
|
766
|
|
|
|
|
1436
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _group () { |
20
|
4912
|
|
|
4912
|
|
5408
|
my $self = shift; |
21
|
4912
|
100
|
|
|
|
3734
|
push @{$self->groups}, $self->exprs if @{$self->exprs}; |
|
598
|
|
|
|
|
15442
|
|
|
4912
|
|
|
|
|
139897
|
|
22
|
4912
|
|
|
|
|
119070
|
$self->exprs([]); |
23
|
4912
|
|
|
|
|
12279
|
$self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub print { |
27
|
4870
|
|
|
4870
|
1
|
4389
|
my ($self, $fh, $depth) = @_; |
28
|
4870
|
|
50
|
|
|
6310
|
$depth ||= 0; |
29
|
|
|
|
|
|
|
|
30
|
4870
|
100
|
|
|
|
3401
|
if (@{$self->groups}) { |
|
4870
|
|
|
|
|
120837
|
|
31
|
556
|
|
|
|
|
856
|
print $fh 'when '; |
32
|
556
|
|
|
|
|
534
|
my $first = 1; |
33
|
556
|
|
|
|
|
485
|
foreach (@{$self->groups}) { |
|
556
|
|
|
|
|
13975
|
|
34
|
598
|
100
|
|
|
|
979
|
if ($first) { $first = 0 } else { print $fh '; ' } |
|
556
|
|
|
|
|
635
|
|
|
42
|
|
|
|
|
65
|
|
35
|
|
|
|
|
|
|
|
36
|
598
|
|
|
|
|
613
|
my $infirst = 1; |
37
|
598
|
|
|
|
|
954
|
foreach (@$_) { |
38
|
766
|
100
|
|
|
|
1025
|
if ($infirst) { $infirst = 0 } else { print $fh ', ' } |
|
598
|
|
|
|
|
629
|
|
|
168
|
|
|
|
|
209
|
|
39
|
766
|
|
|
|
|
1970
|
$_->print($fh, $depth); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
556
|
|
|
|
|
1282
|
print $fh ' '; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Erlang::Parser::Node::WhenList - a guard sequence |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Used to restrict the circumstances under which a pattern match will match; |
55
|
|
|
|
|
|
|
comprised of guards separated by semi-colons, each which is comprised of |
56
|
|
|
|
|
|
|
several guard expressions separated by commas. The guard sequence as a whole |
57
|
|
|
|
|
|
|
passes if all guard expressions in any guard pass. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Accessors |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item C<groups> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
A list of a list of L<Erlang::Parser::Node>s; each individual list of nodes is |
66
|
|
|
|
|
|
|
a guard (and each node a guard expression). |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item C<exprs> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Used only during construction of the guard sequence; should be empty after |
71
|
|
|
|
|
|
|
parsing is complete. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 Methods |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item C<print> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Pretty-prints the node to its filehandle argument. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 EXAMPLE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
when is_bool(X), is_bool(Y); X < Y |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# vim: set sw=4 ts=4: |