File Coverage

blib/lib/PPI/Token/DashedWord.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 4 100.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 22 22 100.0


line stmt bran cond sub pod time code
1             package PPI::Token::DashedWord;
2              
3             =pod
4              
5             =head1 NAME
6              
7             PPI::Token::DashedWord - A dashed bareword token
8              
9             =head1 INHERITANCE
10              
11             PPI::Token::DashedWord
12             isa PPI::Token
13             isa PPI::Element
14              
15             =head1 DESCRIPTION
16              
17             The "dashed bareword" token represents literal values like C<-foo>.
18              
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.
24              
25             =head1 METHODS
26              
27             =cut
28              
29 65     65   502 use strict;
  65         138  
  65         1969  
30 65     65   345 use PPI::Token ();
  65         127  
  65         16444  
31              
32             our $VERSION = '1.277';
33              
34             our @ISA = "PPI::Token";
35              
36             =pod
37              
38             =head2 literal
39              
40             Returns the value of the dashed word as a string. This differs from
41             C because C<-Foo'Bar> expands to C<-Foo::Bar>.
42              
43             =cut
44              
45             *literal = *PPI::Token::Word::literal;
46              
47              
48              
49             #####################################################################
50             # Tokenizer Methods
51              
52             sub __TOKENIZER__on_char {
53 182     182   397 my $t = $_[1];
54              
55             # Suck to the end of the dashed bareword
56 182         701 pos $t->{line} = $t->{line_cursor};
57 182 100       940 if ( $t->{line} =~ m/\G(\w+)/gc ) {
58 43         180 $t->{token}->{content} .= $1;
59 43         145 $t->{line_cursor} += length $1;
60             }
61              
62             # Are we a file test operator?
63 182 100       776 if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
64             # File test operator
65 120         481 $t->{class} = $t->{token}->set_class( 'Operator' );
66             } else {
67             # No, normal dashed bareword
68 62         217 $t->{class} = $t->{token}->set_class( 'Word' );
69             }
70              
71 182         617 $t->_finalize_token->__TOKENIZER__on_char( $t );
72             }
73              
74             1;
75              
76             =pod
77              
78             =head1 SUPPORT
79              
80             See the L in the main module.
81              
82             =head1 AUTHOR
83              
84             Adam Kennedy Eadamk@cpan.orgE
85              
86             =head1 COPYRIGHT
87              
88             Copyright 2001 - 2011 Adam Kennedy.
89              
90             This program is free software; you can redistribute
91             it and/or modify it under the same terms as Perl itself.
92              
93             The full text of the license can be found in the
94             LICENSE file included with this module.
95              
96             =cut