line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::References::FormatDereferences; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
11474
|
use 5.006001; |
|
17
|
|
|
|
|
54
|
|
4
|
17
|
|
|
17
|
|
83
|
use strict; |
|
17
|
|
|
|
|
24
|
|
|
17
|
|
|
|
|
359
|
|
5
|
17
|
|
|
17
|
|
70
|
use warnings; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
392
|
|
6
|
17
|
|
|
17
|
|
66
|
use Readonly; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
873
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
103
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
950
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
4434
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
6060
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform %x{a} to %x{'a'}}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
18
|
|
|
|
|
|
|
q{Perl6 assumes that braces are code blocks, so any content must be compilable}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
21
|
|
|
|
|
|
|
|
22
|
33
|
|
|
33
|
0
|
99
|
sub run_after { return 'Operators::FormatOperators' } |
23
|
40
|
|
|
40
|
0
|
1283
|
sub supported_parameters { return () } |
24
|
29
|
|
|
29
|
1
|
113
|
sub default_severity { return $SEVERITY_HIGHEST } |
25
|
25
|
|
|
25
|
1
|
78
|
sub default_themes { return qw(core bugs) } |
26
|
|
|
|
|
|
|
sub applies_to { |
27
|
|
|
|
|
|
|
return sub { |
28
|
65
|
0
|
33
|
65
|
|
738
|
$_[1]->isa('PPI::Token::Cast') and |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
29
|
|
|
|
|
|
|
$_[1]->next_sibling and |
30
|
|
|
|
|
|
|
$_[1]->next_sibling->isa('PPI::Structure::Block') and |
31
|
|
|
|
|
|
|
$_[1]->next_sibling->start->content eq '{' and |
32
|
|
|
|
|
|
|
$_[1]->next_sibling->finish->content eq '}' |
33
|
|
|
|
|
|
|
} |
34
|
4
|
|
|
4
|
1
|
20
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub transform { |
39
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
40
|
0
|
|
|
|
|
|
my $next = $elem->next_sibling; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$next->start->set_content('('); |
43
|
0
|
|
|
|
|
|
$next->finish->set_content(')'); |
44
|
0
|
0
|
|
|
|
|
if ( $elem->content eq '$#' ) { |
45
|
0
|
|
|
|
|
|
$elem->set_content('@'); |
46
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after( |
47
|
|
|
|
|
|
|
PPI::Token::Word->new('end') |
48
|
|
|
|
|
|
|
); |
49
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after( |
50
|
|
|
|
|
|
|
PPI::Token::Operator->new('.') |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
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::References::FormatDereferences - Transform %{$foo} to %($foo) |
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 dereferencing uses C<%()> and C<@()> because C<()> would be a code block otherwise: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
%{$foo} --> %($foo) |
81
|
|
|
|
|
|
|
%$foo --> %$foo |
82
|
|
|
|
|
|
|
@{$foo} --> @($foo) |
83
|
|
|
|
|
|
|
@$foo --> @$foo |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Transforms dereferences 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 : |