line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::CompoundStatements::RenameForeach; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
717
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use Readonly; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
9
|
1
|
|
|
1
|
|
111
|
use Perl::ToPerl6::Utils::PPI qw{ is_ppi_statement_compound }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
346
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform 'foreach' to 'for'}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{foreach() is now nmaed for()}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %map = ( |
21
|
|
|
|
|
|
|
foreach => 'for', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
0
|
5
|
sub supported_parameters { return () } |
27
|
1
|
|
|
1
|
1
|
5
|
sub default_necessity { return $NECESSITY_HIGHEST } |
28
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
29
|
|
|
|
|
|
|
sub applies_to { |
30
|
|
|
|
|
|
|
return sub { |
31
|
0
|
|
|
0
|
|
|
is_ppi_statement_compound($_[1], %map) |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
0
|
1
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub transform { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $old_content = $elem->schild(0)->content; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$elem->schild(0)->set_content($map{$old_content}); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::CompoundStatements::RenameForeach - Rename 'foreach' to 'for' |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AFFILIATION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
63
|
|
|
|
|
|
|
distribution. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Perl6 no longer uses 'foreach': |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
foreach(1) { } --> for(1) { } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 CONFIGURATION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
85
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
############################################################################## |
90
|
|
|
|
|
|
|
# Local Variables: |
91
|
|
|
|
|
|
|
# mode: cperl |
92
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
93
|
|
|
|
|
|
|
# fill-column: 78 |
94
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
95
|
|
|
|
|
|
|
# c-indentation-style: bsd |
96
|
|
|
|
|
|
|
# End: |
97
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |