Initial Commit
This commit is contained in:
117
database/perl/vendor/lib/PPI/Token/Number/Binary.pm
vendored
Normal file
117
database/perl/vendor/lib/PPI/Token/Number/Binary.pm
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
package PPI::Token::Number::Binary;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Binary - Token class for a binary number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 0b1110011; # binary integer
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Binary
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Binary> class is used for tokens that
|
||||
represent base-2 numbers.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 base
|
||||
|
||||
Returns the base for the number: 2.
|
||||
|
||||
=cut
|
||||
|
||||
sub base() { 2 }
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
return if $self->{_error};
|
||||
my $str = $self->_literal;
|
||||
my $neg = $str =~ s/^\-//;
|
||||
$str =~ s/^0[bB]//;
|
||||
my $val = 0;
|
||||
for my $bit ( $str =~ m/(.)/g ) {
|
||||
$val = $val * 2 + $bit;
|
||||
}
|
||||
return $neg ? -$val : $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# Allow underscores straight through
|
||||
return 1 if $char eq '_';
|
||||
|
||||
if ( $char =~ /[\w\d]/ ) {
|
||||
unless ( $char eq '1' or $char eq '0' ) {
|
||||
# Add a warning if it contains non-binary chars
|
||||
$t->{token}->{_error} = "Illegal character in binary number '$char'";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
146
database/perl/vendor/lib/PPI/Token/Number/Exp.pm
vendored
Normal file
146
database/perl/vendor/lib/PPI/Token/Number/Exp.pm
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
package PPI::Token::Number::Exp;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Exp - Token class for an exponential notation number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 1.0e-2;
|
||||
$n = 1e+2;
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Exp
|
||||
isa PPI::Token::Number::Float
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Exp> class is used for tokens that
|
||||
represent floating point numbers with exponential notation.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number::Float ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number::Float";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
return if $self->{_error};
|
||||
my ($mantissa, $exponent) = split m/e/i, $self->_literal;
|
||||
my $neg = $mantissa =~ s/^\-//;
|
||||
$mantissa =~ s/^\./0./;
|
||||
$exponent =~ s/^\+//;
|
||||
|
||||
# Must cast exponent as numeric type, due to string type '00' exponent
|
||||
# creating false positive condition in for() loop below, causing infinite loop
|
||||
$exponent += 0;
|
||||
|
||||
# This algorithm is reasonably close to the S_mulexp10()
|
||||
# algorithm from the Perl source code, so it should arrive
|
||||
# at the same answer as Perl most of the time.
|
||||
my $negpow = 0;
|
||||
if ($exponent < 0) {
|
||||
$negpow = 1;
|
||||
$exponent *= -1;
|
||||
}
|
||||
|
||||
my $result = 1;
|
||||
my $power = 10;
|
||||
for (my $bit = 1; $exponent; $bit = $bit << 1) {
|
||||
if ($exponent & $bit) {
|
||||
$exponent = $exponent ^ $bit;
|
||||
$result *= $power;
|
||||
}
|
||||
$power *= $power;
|
||||
}
|
||||
|
||||
my $val = $neg ? 0 - $mantissa : $mantissa;
|
||||
return $negpow ? $val / $result : $val * $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# To get here, the token must have already encountered an 'E'
|
||||
|
||||
# Allow underscores straight through
|
||||
return 1 if $char eq '_';
|
||||
|
||||
# Allow digits
|
||||
return 1 if $char =~ /\d/o;
|
||||
|
||||
# Start of exponent is special
|
||||
if ( $t->{token}->{content} =~ /e$/i ) {
|
||||
# Allow leading +/- in exponent
|
||||
return 1 if $char eq '-' || $char eq '+';
|
||||
|
||||
# Invalid character in exponent. Recover
|
||||
if ( $t->{token}->{content} =~ s/\.(e)$//i ) {
|
||||
my $word = $1;
|
||||
$t->{class} = $t->{token}->set_class('Number');
|
||||
$t->_new_token('Operator', '.');
|
||||
$t->_new_token('Word', $word);
|
||||
return $t->{class}->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
else {
|
||||
$t->{token}->{_error} = "Illegal character in exponent '$char'";
|
||||
}
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
140
database/perl/vendor/lib/PPI/Token/Number/Float.pm
vendored
Normal file
140
database/perl/vendor/lib/PPI/Token/Number/Float.pm
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
package PPI::Token::Number::Float;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Float - Token class for a floating-point number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 1.234;
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Float
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Float> class is used for tokens that
|
||||
represent floating point numbers. A float is identified by n decimal
|
||||
point. Exponential notation (the C<e> or C<E>) is handled by the
|
||||
PPI::Token::Number::Exp class.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 base
|
||||
|
||||
Returns the base for the number: 10.
|
||||
|
||||
=cut
|
||||
|
||||
sub base() { 10 }
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
my $str = $self->_literal;
|
||||
my $neg = $str =~ s/^\-//;
|
||||
$str =~ s/^\./0./;
|
||||
my $val = 0+$str;
|
||||
return $neg ? -$val : $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# Allow underscores straight through
|
||||
return 1 if $char eq '_';
|
||||
|
||||
# Allow digits
|
||||
return 1 if $char =~ /\d/o;
|
||||
|
||||
if ( $char eq '.' ) { # A second decimal point? That gets complicated.
|
||||
if ( $t->{token}{content} =~ /\.$/ ) {
|
||||
# We have a .., which is an operator. Take the . off the end of the
|
||||
# token and finish it, then make the .. operator.
|
||||
chop $t->{token}{content};
|
||||
$t->{class} = $t->{token}->set_class( 'Number' );
|
||||
$t->_new_token('Operator', '..');
|
||||
return 0;
|
||||
} elsif ( $t->{token}{content} =~ /\._/ ) {
|
||||
($t->{token}{content}, my $bareword)
|
||||
= split /\./, $t->{token}{content};
|
||||
$t->{class} = $t->{token}->set_class( 'Number' );
|
||||
$t->_new_token('Operator', '.');
|
||||
$t->_new_token('Word', $bareword);
|
||||
$t->_new_token('Operator', '.');
|
||||
return 0;
|
||||
} else {
|
||||
$t->{class} = $t->{token}->set_class( 'Number::Version' );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
# perl seems to regard pretty much anything that's not strictly an exp num
|
||||
# as float + stuff
|
||||
my $char2 = substr $t->{line}, $t->{line_cursor}+1, 1;
|
||||
if ("$char$char2" =~ /[eE][0-9+-]/) {
|
||||
$t->{class} = $t->{token}->set_class( 'Number::Exp' );
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
108
database/perl/vendor/lib/PPI/Token/Number/Hex.pm
vendored
Normal file
108
database/perl/vendor/lib/PPI/Token/Number/Hex.pm
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
package PPI::Token::Number::Hex;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Hex - Token class for a binary number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 0x1234; # hexadecimal integer
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Hex
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Hex> class is used for tokens that
|
||||
represent base-16 numbers.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 base
|
||||
|
||||
Returns the base for the number: 16.
|
||||
|
||||
=cut
|
||||
|
||||
sub base() { 16 }
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
my $str = $self->_literal;
|
||||
my $neg = $str =~ s/^\-//;
|
||||
my $val = hex lc( $str ); # lc for compatibility with perls before 5.14
|
||||
return $neg ? -$val : $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# Allow underscores straight through
|
||||
return 1 if $char eq '_';
|
||||
|
||||
if ( $char =~ /[[:xdigit:]]/ ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
113
database/perl/vendor/lib/PPI/Token/Number/Octal.pm
vendored
Normal file
113
database/perl/vendor/lib/PPI/Token/Number/Octal.pm
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
package PPI::Token::Number::Octal;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Octal - Token class for a binary number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 0777; # octal integer
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Octal
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Octal> class is used for tokens that
|
||||
represent base-8 numbers.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 base
|
||||
|
||||
Returns the base for the number: 8.
|
||||
|
||||
=cut
|
||||
|
||||
sub base() { 8 }
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
return if $self->{_error};
|
||||
my $str = $self->_literal;
|
||||
my $neg = $str =~ s/^\-//;
|
||||
my $val = oct $str;
|
||||
return $neg ? -$val : $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# Allow underscores straight through
|
||||
return 1 if $char eq '_';
|
||||
|
||||
if ( $char =~ /\d/ ) {
|
||||
# You cannot have 8s and 9s on octals
|
||||
if ( $char eq '8' or $char eq '9' ) {
|
||||
$t->{token}->{_error} = "Illegal character in octal number '$char'";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
164
database/perl/vendor/lib/PPI/Token/Number/Version.pm
vendored
Normal file
164
database/perl/vendor/lib/PPI/Token/Number/Version.pm
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
package PPI::Token::Number::Version;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PPI::Token::Number::Version - Token class for a byte-packed number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$n = 1.1.0;
|
||||
$n = 127.0.0.1;
|
||||
$n = 10_000.10_000.10_000;
|
||||
$n = v1.2.3.4
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
PPI::Token::Number::Version
|
||||
isa PPI::Token::Number
|
||||
isa PPI::Token
|
||||
isa PPI::Element
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The C<PPI::Token::Number::Version> class is used for tokens that have
|
||||
multiple decimal points. In truth, these aren't treated like numbers
|
||||
at all by Perl, but they look like numbers to a parser.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use PPI::Token::Number ();
|
||||
|
||||
our $VERSION = '1.270'; # VERSION
|
||||
|
||||
our @ISA = "PPI::Token::Number";
|
||||
|
||||
=pod
|
||||
|
||||
=head2 base
|
||||
|
||||
Returns the base for the number: 256.
|
||||
|
||||
=cut
|
||||
|
||||
sub base() { 256 }
|
||||
|
||||
=pod
|
||||
|
||||
=head2 literal
|
||||
|
||||
Return the numeric value of this token.
|
||||
|
||||
=cut
|
||||
|
||||
sub literal {
|
||||
my $self = shift;
|
||||
my $content = $self->{content};
|
||||
$content =~ s/^v//;
|
||||
return join '', map { chr $_ } ( split /\./, $content );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Tokenizer Methods
|
||||
|
||||
sub __TOKENIZER__on_char {
|
||||
my $class = shift;
|
||||
my $t = shift;
|
||||
my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
|
||||
|
||||
# Allow digits
|
||||
return 1 if $char =~ /\d/o;
|
||||
|
||||
if( $char eq '_' ) {
|
||||
return 1 if $t->{token}{content} !~ /\.$/;
|
||||
|
||||
chop $t->{token}->{content};
|
||||
$t->{class} = $t->{token}->set_class( 'Number::Float' )
|
||||
if $t->{token}{content} !~ /\..+\./;
|
||||
$t->_new_token('Operator', '.');
|
||||
$t->_new_token('Word', '_');
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Is this a second decimal point in a row? Then the '..' operator
|
||||
if ( $char eq '.' ) {
|
||||
if ( $t->{token}->{content} =~ /\.$/ ) {
|
||||
# We have a .., which is an operator.
|
||||
# Take the . off the end of the token..
|
||||
# and finish it, then make the .. operator.
|
||||
chop $t->{token}->{content};
|
||||
$t->{class} = $t->{token}->set_class( 'Number::Float' )
|
||||
if $t->{token}{content} !~ /\..+\./;
|
||||
$t->_new_token('Operator', '..');
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Doesn't fit a special case, or is after the end of the token
|
||||
# End of token.
|
||||
$t->_finalize_token->__TOKENIZER__on_char( $t );
|
||||
}
|
||||
|
||||
sub __TOKENIZER__commit {
|
||||
my $t = $_[1];
|
||||
|
||||
# Capture the rest of the token
|
||||
pos $t->{line} = $t->{line_cursor};
|
||||
# This was not a v-string after all (it's a word);
|
||||
return PPI::Token::Word->__TOKENIZER__commit($t)
|
||||
if $t->{line} !~ m/\G(v\d[_\d]*(?:\.\d[_\d]*)+|v\d[_\d]*\b)/gc;
|
||||
|
||||
my $content = $1;
|
||||
|
||||
# If there are no periods this could be a word starting with v\d
|
||||
# Forced to be a word. Done.
|
||||
return PPI::Token::Word->__TOKENIZER__commit($t)
|
||||
if $content !~ /\./ and $t->__current_token_is_forced_word($content);
|
||||
|
||||
# This is a v-string
|
||||
$t->{line_cursor} += length $content;
|
||||
$t->_new_token( 'Number::Version', $content );
|
||||
$t->_finalize_token->__TOKENIZER__on_char($t);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
- Does not handle leading minus sign correctly. Should translate to a DashedWord.
|
||||
See L<http://perlmonks.org/?node_id=574573>
|
||||
|
||||
-95.0.1.0 --> "-_\000\cA\000"
|
||||
-96.0.1.0 --> Argument "`\0^A\0" isn't numeric in negation (-)
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
See the L<support section|PPI/SUPPORT> in the main module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Chris Dolan E<lt>cdolan@cpan.orgE<gt>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2006 Chris Dolan.
|
||||
|
||||
This program is free software; you can redistribute
|
||||
it and/or modify it under the same terms as Perl itself.
|
||||
|
||||
The full text of the license can be found in the
|
||||
LICENSE file included with this module.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user