line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::Variables::FormatMatchVariables; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
11063
|
use 5.006001; |
|
17
|
|
|
|
|
52
|
|
4
|
17
|
|
|
17
|
|
106
|
use strict; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
470
|
|
5
|
17
|
|
|
17
|
|
82
|
use warnings; |
|
17
|
|
|
|
|
1227
|
|
|
17
|
|
|
|
|
568
|
|
6
|
17
|
|
|
17
|
|
81
|
use Readonly; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
867
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
80
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
879
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
4254
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
5882
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform $1..$n to $0..$n-1}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Transform $1..$n to $0..$n-1}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# '$1' => '$0', # And so on, make sure they don't get modified twice |
22
|
|
|
|
|
|
|
# '$2' => '$1', |
23
|
|
|
|
|
|
|
# '$3' => '$2', |
24
|
|
|
|
|
|
|
# '$4' => '$1', |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# Make sure this is run *after* Variables::FormatSpecialVariables. |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
|
31
|
34
|
|
|
34
|
0
|
114
|
sub run_after { 'Variables::FormatSpecialVariables' } |
32
|
41
|
|
|
41
|
0
|
1159
|
sub supported_parameters { return () } |
33
|
29
|
|
|
29
|
1
|
108
|
sub default_severity { return $SEVERITY_HIGHEST } |
34
|
25
|
|
|
25
|
1
|
82
|
sub default_themes { return qw(core bugs) } |
35
|
|
|
|
|
|
|
sub applies_to { |
36
|
|
|
|
|
|
|
return sub { |
37
|
61
|
50
|
|
61
|
|
696
|
$_[1]->isa('PPI::Token::Magic') and |
38
|
|
|
|
|
|
|
$_[1]->content =~ / ^ \$ \d+ $ /x |
39
|
|
|
|
|
|
|
} |
40
|
4
|
|
|
4
|
1
|
17
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub transform { |
45
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
46
|
0
|
|
|
|
|
|
my $old_content = $elem->content; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$old_content =~ m/ ^ \$ (\d+) $ /x; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
return if $1 <= 0; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $new_content = q{$} . ($1 - 1); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$elem->set_content( $new_content ); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::Variables::FormatMatchVariables - Renumber match variables |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AFFILIATION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
75
|
|
|
|
|
|
|
distribution. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Perl6 renumbers match variables so that they start at C<$0>. If you're wondering |
81
|
|
|
|
|
|
|
what happened to C<$0>, it's now C<$*PROGRAM-NAME>: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$1 --> $0 |
84
|
|
|
|
|
|
|
$2 --> $1 |
85
|
|
|
|
|
|
|
$99 --> $98 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Transforms match values outside of comments, heredocs, strings and POD. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 CONFIGURATION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
102
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
############################################################################## |
107
|
|
|
|
|
|
|
# Local Variables: |
108
|
|
|
|
|
|
|
# mode: cperl |
109
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
110
|
|
|
|
|
|
|
# fill-column: 78 |
111
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
112
|
|
|
|
|
|
|
# c-indentation-style: bsd |
113
|
|
|
|
|
|
|
# End: |
114
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |