line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PPI::Token::Number::Octal; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PPI::Token::Number::Octal - Token class for a binary number |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$n = 0777; # octal integer |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 INHERITANCE |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PPI::Token::Number::Octal |
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-8 numbers. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
65
|
|
|
65
|
|
476
|
use strict; |
|
65
|
|
|
|
|
137
|
|
|
65
|
|
|
|
|
1920
|
|
30
|
65
|
|
|
65
|
|
333
|
use PPI::Token::Number (); |
|
65
|
|
|
|
|
137
|
|
|
65
|
|
|
|
|
18277
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '1.277'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our @ISA = "PPI::Token::Number"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=pod |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 base |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns the base for the number: 8. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub base() { 8 } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 literal |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Return the numeric value of this token. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub literal { |
55
|
8
|
|
|
8
|
1
|
79
|
my $self = shift; |
56
|
8
|
100
|
|
|
|
35
|
return if $self->{_error}; |
57
|
4
|
|
|
|
|
13
|
my $str = $self->_literal; |
58
|
4
|
|
|
|
|
15
|
my $neg = $str =~ s/^\-//; |
59
|
4
|
|
|
|
|
15
|
my $val = oct $str; |
60
|
4
|
50
|
|
|
|
13
|
return $neg ? -$val : $val; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
##################################################################### |
68
|
|
|
|
|
|
|
# Tokenizer Methods |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub __TOKENIZER__on_char { |
71
|
51
|
|
|
51
|
|
129
|
my $class = shift; |
72
|
51
|
|
|
|
|
78
|
my $t = shift; |
73
|
51
|
|
|
|
|
153
|
my $char = substr( $t->{line}, $t->{line_cursor}, 1 ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Allow underscores straight through |
76
|
51
|
100
|
|
|
|
143
|
return 1 if $char eq '_'; |
77
|
|
|
|
|
|
|
|
78
|
50
|
100
|
|
|
|
165
|
if ( $char =~ /\d/ ) { |
79
|
|
|
|
|
|
|
# You cannot have 8s and 9s on octals |
80
|
10
|
100
|
100
|
|
|
58
|
if ( $char eq '8' or $char eq '9' ) { |
81
|
5
|
|
|
|
|
20
|
$t->{token}->{_error} = "Illegal character in octal number '$char'"; |
82
|
|
|
|
|
|
|
} |
83
|
10
|
|
|
|
|
30
|
return 1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Doesn't fit a special case, or is after the end of the token |
87
|
|
|
|
|
|
|
# End of token. |
88
|
40
|
|
|
|
|
110
|
$t->_finalize_token->__TOKENIZER__on_char( $t ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SUPPORT |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See the L in the main module. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Chris Dolan Ecdolan@cpan.orgE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2006 Chris Dolan. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is free software; you can redistribute |
108
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The full text of the license can be found in the |
111
|
|
|
|
|
|
|
LICENSE file included with this module. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |