line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::PostfixExpressions::AddWhitespace; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
788
|
use 5.006001; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
5
|
use Readonly; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
9
|
1
|
|
|
|
|
47
|
use Perl::ToPerl6::Utils::PPI qw{ |
10
|
|
|
|
|
|
|
is_ppi_token_word |
11
|
|
|
|
|
|
|
insert_trailing_whitespace |
12
|
1
|
|
|
1
|
|
113
|
}; |
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
270
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform 'if()' to 'if ()'}; |
19
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
20
|
|
|
|
|
|
|
q{if(), elsif() and unless() need whitespace in order to not be interpreted as function calls}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %map = ( |
25
|
|
|
|
|
|
|
if => 1, |
26
|
|
|
|
|
|
|
elsif => 1, |
27
|
|
|
|
|
|
|
unless => 1, |
28
|
|
|
|
|
|
|
while => 1, |
29
|
|
|
|
|
|
|
until => 1, |
30
|
|
|
|
|
|
|
for => 1, |
31
|
|
|
|
|
|
|
foreach => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
0
|
5
|
sub supported_parameters { return () } |
37
|
1
|
|
|
1
|
1
|
5
|
sub default_necessity { return $NECESSITY_HIGHEST } |
38
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
39
|
|
|
|
|
|
|
sub applies_to { |
40
|
|
|
|
|
|
|
return sub { |
41
|
0
|
0
|
|
0
|
|
|
is_ppi_token_word($_[1],%map) and |
42
|
|
|
|
|
|
|
$_[1]->next_sibling->isa('PPI::Structure::Condition') |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
0
|
1
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub transform { |
49
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
insert_trailing_whitespace($elem); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 NAME |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::CompoundStatements::AddWhitespace - Add whitespace between conditionals 'if', 'unless' &c and () |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AFFILIATION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
72
|
|
|
|
|
|
|
distribution. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
While Perl6 conditionals allow parentheses, they need whitespace between the bareword C<if> and the opening parenthesis to avoid being interpreted as a function call: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
if(1) { } elsif(){} --> if (1) { } elsif(){} |
80
|
|
|
|
|
|
|
if (1) { } elsif(){} --> if (1) { } elsif(){} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 CONFIGURATION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
95
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
############################################################################## |
100
|
|
|
|
|
|
|
# Local Variables: |
101
|
|
|
|
|
|
|
# mode: cperl |
102
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
103
|
|
|
|
|
|
|
# fill-column: 78 |
104
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
105
|
|
|
|
|
|
|
# c-indentation-style: bsd |
106
|
|
|
|
|
|
|
# End: |
107
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |