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