« lib/Perl/ToPerl6/Transformer/Variables/RewriteSpecialVariables.pm
↑ Summary
lib/Perl/ToPerl6/Transformer/Variables/RewriteMatchVariables.pm »
| 1 | package Perl::ToPerl6::Transformer::Regexes::StandardizeDelimiters; | ||||||||||
| 2 | |||||||||||
| 3 | 17 | ▶ | use 5.006001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 17 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 17 | ▶ | use Perl::ToPerl6::Utils qw{ :severities }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 17 | ▶ | use base 'Perl::ToPerl6::Transformer'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | #----------------------------------------------------------------------------- | ||||||||||
| 13 | |||||||||||
| 14 | 17 | Readonly::Scalar my $DESC => q{Regex delimiters can no longer be alphanumeric}; | |||||||||
| 15 | 17 | Readonly::Scalar my $EXPL => q{Regex delimiters can no longer be alphanumeric}; | |||||||||
| 16 | |||||||||||
| 17 | #----------------------------------------------------------------------------- | ||||||||||
| 18 | |||||||||||
| 19 | 38 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 20 | 27 | ▶ | sub default_necessity { return $NECESSITY_HIGHEST } | ||||||||
|
Subroutine
default_necessity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 24 | ▶ | sub default_themes { return qw( core ) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 5 | ▶ | sub applies_to { | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 78 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 24 | $_[1]->isa('PPI::Token::Regexp') and | ||||||||||
| 25 | 78 | ▶ | $_[1]->{sections}[0]{type} =~ /[a-zA-Z0-9#]/ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | 5 | } | |||||||||
| 28 | |||||||||||
| 29 | #----------------------------------------------------------------------------- | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub transform { | ||||||||
|
Subroutine
transform: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 32 | 0 | my ($self, $elem, $doc) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 0 | my @content; | |||||||||
| 35 | 0 | for ( @{ $elem->{sections} } ) { | |||||||||
| 36 | 0 | my $content = substr( $elem->content, $_->{position}, $_->{size} ); | |||||||||
| 37 | 0 | $content =~ s{/}{\\/}g; # XXX this could be a problem. | |||||||||
| 38 | 0 | $_->{position}--; # Account for the eventual lack of whitespace. | |||||||||
| 39 | 0 | $_->{type} = '//'; | |||||||||
| 40 | 0 | push @content, $content; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | my ( $operator ) = $elem->content =~ m{^(m|s|y|tr)}; | |||||||||
| 44 | 0 | my $num_modifiers = keys %{ $elem->get_modifiers }; | |||||||||
| 45 | 0 | my $modifiers = substr( $elem->content, -$num_modifiers, $num_modifiers ); | |||||||||
| 46 | |||||||||||
| 47 | 0 | my $new_content = $operator . '/' . | |||||||||
| 48 | join('/', @content) . '/' . | ||||||||||
| 49 | $modifiers; | ||||||||||
| 50 | |||||||||||
| 51 | 0 | $elem->{separator} = '/'; | |||||||||
| 52 | 0 | $elem->set_content( $new_content ); | |||||||||
| 53 | |||||||||||
| 54 | 0 | return $self->transformation( $DESC, $EXPL, $elem ); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 17 | 1; | |||||||||
| 58 | |||||||||||
| 59 | #----------------------------------------------------------------------------- | ||||||||||
| 60 | |||||||||||
| 61 | __END__ | ||||||||||