line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::RewriteSpecialLiterals; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4219
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
4
|
use Readonly; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
183
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
598
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform '__END__' etc.}; |
15
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{__END__ and __DATA__ are now POD markers}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %map = ( |
20
|
|
|
|
|
|
|
'__END__' => '=finish', |
21
|
|
|
|
|
|
|
'__FILE__' => '$?FILE', |
22
|
|
|
|
|
|
|
'__LINE__' => '$?LINE', |
23
|
|
|
|
|
|
|
'__PACKAGE__' => '$?PACKAGE', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
0
|
3
|
sub supported_parameters { return () } |
29
|
1
|
|
|
1
|
1
|
6
|
sub default_necessity { return $NECESSITY_HIGHEST } |
30
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
31
|
|
|
|
|
|
|
sub applies_to { |
32
|
|
|
|
|
|
|
return sub { |
33
|
|
|
|
|
|
|
( $_[1]->isa('PPI::Token::Separator') or |
34
|
|
|
|
|
|
|
$_[1]->isa('PPI::Token::End') or |
35
|
|
|
|
|
|
|
$_[1]->isa('PPI::Token::Word') ) and |
36
|
0
|
0
|
0
|
0
|
|
|
exists $map{$_[1]->content} |
|
|
|
0
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
0
|
1
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub transform { |
43
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ( $elem->isa('PPI::Token::Word') ) { |
|
|
0
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $new_content = $elem->content; |
47
|
0
|
|
|
|
|
|
$elem->set_content($map{$new_content}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( $elem->isa('PPI::Token::Separator') ) { |
50
|
0
|
|
|
|
|
|
my $new_content = $elem->content; |
51
|
0
|
|
|
|
|
|
$elem->set_content($map{$new_content}); |
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::RewriteSpecialLiterals - Format __END__, __LINE__ &c |
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
|
|
|
|
|
|
|
__END__ is replaced with the POD marker '=finish', and you can read beyond this boundary with the filehandle C<$*FINISH>: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ --> =finish |
80
|
|
|
|
|
|
|
__LINE__ --> $?LINE |
81
|
|
|
|
|
|
|
__FILE__ --> $?FILE |
82
|
|
|
|
|
|
|
__PACKAGE__ --> $?PACKAGE |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 CONFIGURATION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
97
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
############################################################################## |
102
|
|
|
|
|
|
|
# Local Variables: |
103
|
|
|
|
|
|
|
# mode: cperl |
104
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
105
|
|
|
|
|
|
|
# fill-column: 78 |
106
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
107
|
|
|
|
|
|
|
# c-indentation-style: bsd |
108
|
|
|
|
|
|
|
# End: |
109
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |