PPI/Token/DashedWord.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 31 / 31 CC 3 SCAR 6.2
CC
3
Cov
100%
__TOKENIZER__on_char
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« PPI/Token/Number/Hex.pm ↑ Summary PPI/Token/Prototype.pm »
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 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 62 ▶use PPI::Token ();
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 62 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
33 BEGIN {
34 62 ▶ $VERSION = '1.236';
Subroutine BEGIN: called CC=1 SCAR=0.0
35 62 @ISA = 'PPI::Token';
36 }
37  
38 =pod
39  
40 =head2 literal
41  
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>.
44  
45 =cut
46  
47 62 *literal = *PPI::Token::Word::literal;
48  
49  
50  
51 #####################################################################
52 # Tokenizer Methods
53  
54 sub __TOKENIZER__on_char {
55 205 ▶ my $t = $_[1];
Subroutine __TOKENIZER__on_char: called CC=3 SCAR=11.0
56  
57 # Suck to the end of the dashed bareword
58 205 pos $t->{line} = $t->{line_cursor};
59 205 ▶ if ( $t->{line} =~ m/\G(\w+)/gc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->{"line"} =~ /\G(\w+)/cg) 55 150 205
60 55 $t->{token}->{content} .= $1;
61 55 $t->{line_cursor} += length $1;
62 }
63  
64 # Are we a file test operator?
65 205 ▶ if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->{'token'}{'content'} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/) { } 124 81 205
66 # File test operator
67 124 $t->{class} = $t->{token}->set_class( 'Operator' );
68 } else {
69 # No, normal dashed bareword
70 81 $t->{class} = $t->{token}->set_class( 'Word' );
71 }
72  
73 205 $t->_finalize_token->__TOKENIZER__on_char( $t );
74 }
75  
76 62 1;
77  
78 =pod
79  
80 =head1 SUPPORT
81  
82 See the L<support section|PPI/SUPPORT> in the main module.
83  
84 =head1 AUTHOR
85  
86 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
87  
88 =head1 COPYRIGHT
89  
90 Copyright 2001 - 2011 Adam Kennedy.
91  
92 This program is free software; you can redistribute
93 it and/or modify it under the same terms as Perl itself.
94  
95 The full text of the license can be found in the
96 LICENSE file included with this module.
97  
98 =cut
« PPI/Token/Number/Hex.pm ↑ Summary PPI/Token/Prototype.pm »