line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PPI::Token::Number::Hex; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PPI::Token::Number::Hex - Token class for a binary number |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$n = 0x1234; # hexadecimal integer |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 INHERITANCE |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PPI::Token::Number::Hex |
16
|
|
|
|
|
|
|
isa PPI::Token::Number |
17
|
|
|
|
|
|
|
isa PPI::Token |
18
|
|
|
|
|
|
|
isa PPI::Element |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The C class is used for tokens that |
23
|
|
|
|
|
|
|
represent base-16 numbers. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
65
|
|
|
65
|
|
373
|
use strict; |
|
65
|
|
|
|
|
107
|
|
|
65
|
|
|
|
|
1533
|
|
30
|
65
|
|
|
65
|
|
277
|
use PPI::Token::Number (); |
|
65
|
|
|
|
|
114
|
|
|
65
|
|
|
|
|
12874
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '1.276'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our @ISA = "PPI::Token::Number"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=pod |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 base |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns the base for the number: 16. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub base() { 16 } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 literal |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Return the numeric value of this token. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub literal { |
55
|
31
|
|
|
31
|
1
|
116
|
my $self = shift; |
56
|
31
|
|
|
|
|
77
|
my $str = $self->_literal; |
57
|
31
|
|
|
|
|
48
|
my $neg = $str =~ s/^\-//; |
58
|
31
|
|
|
|
|
61
|
my $val = hex lc( $str ); # lc for compatibility with perls before 5.14 |
59
|
31
|
50
|
|
|
|
129
|
return $neg ? -$val : $val; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
##################################################################### |
67
|
|
|
|
|
|
|
# Tokenizer Methods |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub __TOKENIZER__on_char { |
70
|
111
|
|
|
111
|
|
160
|
my $class = shift; |
71
|
111
|
|
|
|
|
125
|
my $t = shift; |
72
|
111
|
|
|
|
|
175
|
my $char = substr( $t->{line}, $t->{line_cursor}, 1 ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Allow underscores straight through |
75
|
111
|
100
|
|
|
|
193
|
return 1 if $char eq '_'; |
76
|
|
|
|
|
|
|
|
77
|
100
|
100
|
|
|
|
244
|
if ( $char =~ /[[:xdigit:]]/ ) { |
78
|
53
|
|
|
|
|
115
|
return 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Doesn't fit a special case, or is after the end of the token |
82
|
|
|
|
|
|
|
# End of token. |
83
|
47
|
|
|
|
|
128
|
$t->_finalize_token->__TOKENIZER__on_char( $t ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SUPPORT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
See the L in the main module. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Chris Dolan Ecdolan@cpan.orgE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Copyright 2006 Chris Dolan. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This program is free software; you can redistribute |
103
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The full text of the license can be found in the |
106
|
|
|
|
|
|
|
LICENSE file included with this module. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |