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