1 package PPI::Token::Number::Octal;
7 PPI::Token::Number::Octal - Token class for a binary number
11 $n = 0777; # octal integer
15 PPI::Token::Number::Octal
16 isa PPI::Token::Number
22 The C<PPI::Token::Number::Octal> class is used for tokens that
23 represent base-8 numbers.
30 use PPI::Token::Number ();
32 use vars qw{$VERSION @ISA};
35 @ISA = 'PPI::Token::Number';
42 Returns the base for the number: 8.
52 Return the numeric value of this token.
58 return if $self->{_error};
59 my $str = $self->_literal;
60 my $neg = $str =~ s/^\-//;
62 return $neg ? -$val : $val;
69 #####################################################################
72 sub __TOKENIZER__on_char {
75 my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
77 # Allow underscores straight through
78 return 1 if $char eq '_';
80 if ( $char =~ /\d/ ) {
81 # You cannot have 8s and 9s on octals
82 if ( $char eq '8' or $char eq '9' ) {
83 $t->{token}->{_error} = "Illegal character in octal number '$char'";
88 # Doesn't fit a special case, or is after the end of the token
90 $t->_finalize_token->__TOKENIZER__on_char( $t );
99 See the L<support section|PPI/SUPPORT> in the main module.
103 Chris Dolan E<lt>cdolan@cpan.orgE<gt>
107 Copyright 2006 Chris Dolan.
109 This program is free software; you can redistribute
110 it and/or modify it under the same terms as Perl itself.
112 The full text of the license can be found in the
113 LICENSE file included with this module.