line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::Regexes::StandardizeDelimiters; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
12227
|
use 5.006001; |
|
17
|
|
|
|
|
54
|
|
4
|
17
|
|
|
17
|
|
83
|
use strict; |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
455
|
|
5
|
17
|
|
|
17
|
|
75
|
use warnings; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
480
|
|
6
|
17
|
|
|
17
|
|
78
|
use Readonly; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
970
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
100
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
1032
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
4677
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
8431
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Regex delimiters can no longer be alphanumeric}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Regex delimiters can no longer be alphanumeric}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
40
|
|
|
40
|
0
|
1190
|
sub supported_parameters { return () } |
22
|
29
|
|
|
29
|
1
|
116
|
sub default_severity { return $SEVERITY_HIGHEST } |
23
|
25
|
|
|
25
|
1
|
93
|
sub default_themes { return qw(core bugs) } |
24
|
|
|
|
|
|
|
sub applies_to { |
25
|
|
|
|
|
|
|
return sub { |
26
|
|
|
|
|
|
|
$_[1]->isa('PPI::Token::Regexp') and |
27
|
61
|
50
|
|
61
|
|
735
|
$_[1]->{sections}[0]{type} =~ /[a-zA-Z0-9#]/ |
28
|
|
|
|
|
|
|
} |
29
|
4
|
|
|
4
|
1
|
19
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub transform { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @content; |
37
|
0
|
|
|
|
|
|
for ( @{ $elem->{sections} } ) { |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $content = substr( $elem->content, $_->{position}, $_->{size} ); |
39
|
0
|
|
|
|
|
|
$content =~ s{/}{\\/}g; # XXX this could be a problem. |
40
|
0
|
|
|
|
|
|
$_->{position}--; # Account for the eventual lack of whitespace. |
41
|
0
|
|
|
|
|
|
$_->{type} = '//'; |
42
|
0
|
|
|
|
|
|
push @content, $content; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my ( $operator ) = $elem->content =~ m{^(m|s|y|tr)}; |
46
|
0
|
|
|
|
|
|
my $num_modifiers = keys %{ $elem->get_modifiers }; |
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $modifiers = substr( $elem->content, -$num_modifiers, $num_modifiers ); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $new_content = $operator . '/' . |
50
|
|
|
|
|
|
|
join('/', @content) . '/' . |
51
|
|
|
|
|
|
|
$modifiers; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$elem->{separator} = '/'; |
54
|
0
|
|
|
|
|
|
$elem->set_content( $new_content ); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::Regexp::StandardizeDelimiters - Regexen can no longer have alphanumeric delimiters |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AFFILIATION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
75
|
|
|
|
|
|
|
distribution. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Perl6 regular expression delimiters can no longer be alphanumeric: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
m mfoom --> m/foo/ |
83
|
|
|
|
|
|
|
m mf/oom --> m/f\/oo/ # Escape the new delimiter |
84
|
|
|
|
|
|
|
m f\foof --> m/\foo/ # Otherwise do not alter the contents. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Transforms regular expressions outside of comments, heredocs, strings and POD. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 CONFIGURATION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
101
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
############################################################################## |
106
|
|
|
|
|
|
|
# Local Variables: |
107
|
|
|
|
|
|
|
# mode: cperl |
108
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
109
|
|
|
|
|
|
|
# fill-column: 78 |
110
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
111
|
|
|
|
|
|
|
# c-indentation-style: bsd |
112
|
|
|
|
|
|
|
# End: |
113
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |