line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::BasicTypes::Strings::FormatRegexp; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
10424
|
use 5.006001; |
|
17
|
|
|
|
|
46
|
|
4
|
17
|
|
|
17
|
|
75
|
use strict; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
332
|
|
5
|
17
|
|
|
17
|
|
61
|
use warnings; |
|
17
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
791
|
|
6
|
17
|
|
|
17
|
|
65
|
use Readonly; |
|
17
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
796
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
74
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
825
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
4134
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
4091
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{qr{...} is now rx{...} - Does not alter the contents of qr{...}}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
18
|
|
|
|
|
|
|
q{qr{...} is now written as rx{...} - The contents are not rewritten}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
21
|
|
|
|
|
|
|
|
22
|
40
|
|
|
40
|
0
|
1329
|
sub supported_parameters { return () } |
23
|
29
|
|
|
29
|
1
|
122
|
sub default_severity { return $SEVERITY_HIGHEST } |
24
|
25
|
|
|
25
|
1
|
81
|
sub default_themes { return qw(core bugs) } |
25
|
4
|
|
|
4
|
1
|
10
|
sub applies_to { return 'PPI::Token::QuoteLike::Regexp' } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# Note to the reader: |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# A PPI::Token::QuoteLike::Regexp object contains a single string which has the |
33
|
|
|
|
|
|
|
# entire 'qr{...}' token. Therefore we can't add a Token::Whitespace between |
34
|
|
|
|
|
|
|
# the 'qr' and '{..}' like we can with loops and conditionals. |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# qr{...} --> rx{...} |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
sub transform { |
41
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $content = $elem->content; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$content =~ s{^qr}{rx}; |
46
|
0
|
|
|
|
|
|
$content =~ s{^rx\(}{rx (}; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$elem->set_content( $content ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::BasicTypes::Strings::FormatRegexp - Format regexps correctly |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AFFILIATION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
69
|
|
|
|
|
|
|
distribution. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Perl6 regexps now use rx{} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
qr{} --> rx{} |
77
|
|
|
|
|
|
|
qr() --> rx () |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Transforms qr{} outside of comments, heredocs, strings and POD. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 CONFIGURATION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
94
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
############################################################################## |
99
|
|
|
|
|
|
|
# Local Variables: |
100
|
|
|
|
|
|
|
# mode: cperl |
101
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
102
|
|
|
|
|
|
|
# fill-column: 78 |
103
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
104
|
|
|
|
|
|
|
# c-indentation-style: bsd |
105
|
|
|
|
|
|
|
# End: |
106
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |