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