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 64     64   370 use strict;
  64         111  
  64         1450  
30 64     64   273 use PPI::Token ();
  64         112  
  64         13014  
31              
32             our $VERSION = '1.275';
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 210     210   376 my $t = $_[1];
54              
55             # Suck to the end of the dashed bareword
56 210         548 pos $t->{line} = $t->{line_cursor};
57 210 100       801 if ( $t->{line} =~ m/\G(\w+)/gc ) {
58 53         149 $t->{token}->{content} .= $1;
59 53         110 $t->{line_cursor} += length $1;
60             }
61              
62             # Are we a file test operator?
63 210 100       649 if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
64             # File test operator
65 125         406 $t->{class} = $t->{token}->set_class( 'Operator' );
66             } else {
67             # No, normal dashed bareword
68 85         208 $t->{class} = $t->{token}->set_class( 'Word' );
69             }
70              
71 210         531 $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