line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::BasicTypes::Integers::FormatBinaryLiterals; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
10474
|
use 5.006001; |
|
17
|
|
|
|
|
49
|
|
4
|
17
|
|
|
17
|
|
72
|
use strict; |
|
17
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
315
|
|
5
|
17
|
|
|
17
|
|
61
|
use warnings; |
|
17
|
|
|
|
|
21
|
|
|
17
|
|
|
|
|
438
|
|
6
|
17
|
|
|
17
|
|
71
|
use Readonly; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
867
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
79
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
838
|
|
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
4056
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
4569
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transforms 0b0011 into :2<0011>}; |
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Perl6 binary integers look like :2<0011>}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
40
|
|
|
40
|
0
|
1588
|
sub supported_parameters { return () } |
22
|
29
|
|
|
29
|
1
|
116
|
sub default_severity { return $SEVERITY_HIGHEST } |
23
|
25
|
|
|
25
|
1
|
85
|
sub default_themes { return qw(core bugs) } |
24
|
4
|
|
|
4
|
1
|
12
|
sub applies_to { return 'PPI::Token::Number::Binary' } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# 0b0101 --> :2<0101> |
30
|
|
|
|
|
|
|
# 0b010_101_01 --> :2<010_101_01> |
31
|
|
|
|
|
|
|
# 0b010__101_01 --> :2<010_101_01> |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
sub transform { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $old_content = $elem->content; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$old_content =~ s{^0b[_]?}{}i; |
39
|
0
|
|
|
|
|
|
$old_content =~ s{[_]$}{}; |
40
|
0
|
|
|
|
|
|
$old_content =~ s{[_]+}{_}g; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $new_content = ':2<' . $old_content . '>'; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$elem->set_content( $new_content ); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::BasicTypes::Integers::FormatBinaryLiterals - Format 0b0101 properly |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AFFILIATION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> distribution. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Perl6 binary literals have the format ':2<01_01_01_01>'. Perl6 enforces the rule that separators must occur between digits, and only one separator character at a time: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0b01 -> :2<01> |
72
|
|
|
|
|
|
|
0b0101 -> :2<0101> |
73
|
|
|
|
|
|
|
0b010_10 -> :2<010_10> |
74
|
|
|
|
|
|
|
0b_010__10_ -> :2<010_10> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Transforms binary numbers outside of comments, heredocs, strings and POD. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 CONFIGURATION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
91
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
############################################################################## |
96
|
|
|
|
|
|
|
# Local Variables: |
97
|
|
|
|
|
|
|
# mode: cperl |
98
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
99
|
|
|
|
|
|
|
# fill-column: 78 |
100
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
101
|
|
|
|
|
|
|
# c-indentation-style: bsd |
102
|
|
|
|
|
|
|
# End: |
103
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |