line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::BasicTypes::Strings::FormatHereDocs; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
10773
|
use 5.006001; |
|
17
|
|
|
|
|
47
|
|
4
|
17
|
|
|
17
|
|
76
|
use strict; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
327
|
|
5
|
17
|
|
|
17
|
|
947
|
use warnings; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
373
|
|
6
|
17
|
|
|
17
|
|
68
|
use Readonly; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
798
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
75
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
932
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
3995
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
5736
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform <<EOF to q:to/EOF/}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Perl6 heredocs now have more flexibility}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
40
|
|
|
40
|
0
|
1631
|
sub supported_parameters { return () } |
22
|
29
|
|
|
29
|
1
|
122
|
sub default_severity { return $SEVERITY_HIGHEST } |
23
|
25
|
|
|
25
|
1
|
81
|
sub default_themes { return qw(core bugs) } |
24
|
4
|
|
|
4
|
1
|
10
|
sub applies_to { return 'PPI::Token::HereDoc' } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# <<EOF --> q:to/EOF/ |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
sub transform { |
32
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $content = $elem->content; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ( $content =~ s{<<(\w+)}{q:to/$1/} ) { |
|
|
0
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
# XXX This breaks PPI::Token::HereDoc encapsulation. |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
elsif ( $content =~ s{<<'(\s*(\w+))'}{q:to/$2/} ) { |
43
|
0
|
|
|
|
|
|
my $heredoc = $1; |
44
|
0
|
|
|
|
|
|
my $stripped = $2; |
45
|
0
|
|
|
|
|
|
for my $line ( @{ $elem->{_heredoc} } ) { |
|
0
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
next unless $line =~ /$heredoc$/; |
47
|
0
|
|
|
|
|
|
$line = $stripped; |
48
|
0
|
|
|
|
|
|
last; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
$elem->{_terminator} = $1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$elem->set_content( $content ); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::BasicTypes::Strings::FormatHereDocs - Format <<EOF constructs correctly |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AFFILIATION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
74
|
|
|
|
|
|
|
distribution. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Perl6 heredocs now no longer need to be quoted, and the indentation rules differ from perl5. Specifically the old workaround of C<< <<' EOF' >> will have surprising results, because your entire heredoc will be indented by the whitespace amount: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
<<EOF; --> q:to/EOF/; |
82
|
|
|
|
|
|
|
EOF --> EOF |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
<<' EOF'; --> q:to/EOF/; |
85
|
|
|
|
|
|
|
EOF --> EOF |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Transforms only heredocs, not POD or comments. |
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 : |