PPI::Token::DashedWord - A dashed bareword token


PPI documentation Contained in the PPI distribution.

Index


Code Index:

NAME

Top

PPI::Token::DashedWord - A dashed bareword token

INHERITANCE

Top

  PPI::Token::DashedWord
  isa PPI::Token
      isa PPI::Element

DESCRIPTION

Top

The "dashed bareword" token represents literal values like -foo.

NOTE: this class is currently unused. All tokens that should be PPI::Token::DashedWords are just normal PPI::Token::Word instead. That actually makes sense, since there really is nothing special about this class except that dashed words cannot be subroutine names or keywords. As such, this class may be removed from PPI in the future.

METHODS

Top

literal

Returns the value of the dashed word as a string. This differs from content because -Foo'Bar expands to -Foo::Bar.

SUPPORT

Top

See the support section in the main module.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>

COPYRIGHT

Top


PPI documentation Contained in the PPI distribution.
package PPI::Token::DashedWord;

use strict;
use PPI::Token ();

use vars qw{$VERSION @ISA};
BEGIN {
	$VERSION = '1.215';
	@ISA     = 'PPI::Token';
}

*literal = *PPI::Token::Word::literal;



#####################################################################
# Tokenizer Methods

sub __TOKENIZER__on_char {
	my $t = $_[1];

	# Suck to the end of the dashed bareword
	my $line = substr( $t->{line}, $t->{line_cursor} );
	if ( $line =~ /^(\w+)/ ) {
		$t->{token}->{content} .= $1;
		$t->{line_cursor} += length $1;
	}

	# Are we a file test operator?
	if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
		# File test operator
		$t->{class} = $t->{token}->set_class( 'Operator' );
	} else {
		# No, normal dashed bareword
		$t->{class} = $t->{token}->set_class( 'Word' );
	}

	$t->_finalize_token->__TOKENIZER__on_char( $t );
}

1;