« lib/Perl/ToPerl6/TransformerParameter/Behavior.pm
↑ Summary
lib/Perl/ToPerl6/Transformer/BasicTypes/Integers/RewriteOctalNumbers.pm »
| 1 | package Perl::ToPerl6::Transformer::BasicTypes::Integers::RewriteBinaryNumbers; | ||
| 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{Transforms 0b0011 into :2<0011>}; | |
| 15 | 17 | Readonly::Scalar my $EXPL => q{Perl6 binary integers look like :2<0011>}; | |
| 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 { return 'PPI::Token::Number::Binary' } |
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | |||
| 24 | #----------------------------------------------------------------------------- | ||
| 25 | |||
| 26 | 0 | ▶ | sub transform { |
|
Subroutine
transform: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 27 | 0 | my ($self, $elem, $doc) = @_; | |
| 28 | |||
| 29 | 0 | my $old_content = $elem->content; | |
| 30 | |||
| 31 | 0 | $old_content =~ s{^0b[_]?}{}i; | |
| 32 | 0 | $old_content =~ s{[_]$}{}; | |
| 33 | 0 | $old_content =~ s{[_]+}{_}g; | |
| 34 | |||
| 35 | 0 | my $new_content = ':2<' . $old_content . '>'; | |
| 36 | |||
| 37 | 0 | $elem->set_content( $new_content ); | |
| 38 | |||
| 39 | 0 | return $self->transformation( $DESC, $EXPL, $elem ); | |
| 40 | } | ||
| 41 | |||
| 42 | 17 | 1; | |
| 43 | |||
| 44 | #----------------------------------------------------------------------------- | ||
| 45 | |||
| 46 | __END__ | ||