1 package PPI::Token::DashedWord;
7 PPI::Token::DashedWord - A dashed bareword token
11 PPI::Token::DashedWord
17 The "dashed bareword" token represents literal values like C<-foo>.
19 NOTE: this class is currently unused. All tokens that should be
20 PPI::Token::DashedWords are just normal PPI::Token::Word instead.
21 That actually makes sense, since there really is nothing special about
22 this class except that dashed words cannot be subroutine names or
23 keywords. As such, this class may be removed from PPI in the future.
32 use vars qw{$VERSION @ISA};
42 Returns the value of the dashed word as a string. This differs from
43 C<content> because C<-Foo'Bar> expands to C<-Foo::Bar>.
45 =begin testing literal 9
49 "-Foo::Bar", '-Foo::Bar',
50 "-Foo'Bar", '-Foo::Bar',
53 my $from = shift @pairs;
54 my $to = shift @pairs;
55 my $doc = PPI::Document->new( \"( $from => 1 );" );
56 isa_ok( $doc, 'PPI::Document' );
57 my $word = $doc->find_first('Token::DashedWord');
59 skip( "PPI::Token::DashedWord is deactivated", 2 );
60 isa_ok( $word, 'PPI::Token::DashedWord' );
61 is( $word && $word->literal, $to, "The source $from becomes $to ok" );
69 *literal = *PPI::Token::Word::literal;
73 #####################################################################
76 sub __TOKENIZER__on_char {
79 # Suck to the end of the dashed bareword
80 my $line = substr( $t->{line}, $t->{line_cursor} );
81 if ( $line =~ /^(\w+)/ ) {
82 $t->{token}->{content} .= $1;
83 $t->{line_cursor} += length $1;
86 # Are we a file test operator?
87 if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
89 $t->{class} = $t->{token}->set_class( 'Operator' );
91 # No, normal dashed bareword
92 $t->{class} = $t->{token}->set_class( 'Word' );
95 $t->_finalize_token->__TOKENIZER__on_char( $t );
104 See the L<support section|PPI/SUPPORT> in the main module.
108 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
112 Copyright 2001 - 2009 Adam Kennedy.
114 This program is free software; you can redistribute
115 it and/or modify it under the same terms as Perl itself.
117 The full text of the license can be found in the
118 LICENSE file included with this module.