PPI/Token/Cast.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 21 / 21 CC 2 SCAR 4.1
CC
2
Cov
100%
__TOKENIZER__on_char
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« PPI/Token/ArrayIndex.pm ↑ Summary PPI/Token/QuoteLike/Words.pm »
1 package PPI::Token::Cast;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PPI::Token::Cast - A prefix which forces a value into a different context
8  
9 =head1 INHERITANCE
10  
11 PPI::Token::Cast
12 isa PPI::Token
13 isa PPI::Element
14  
15 =head1 DESCRIPTION
16  
17 A "cast" in PPI terms is one of more characters used as a prefix which force
18 a value into a different class or context.
19  
20 This includes referencing, dereferencing, and a few other minor cases.
21  
22 For expressions such as C<@$foo> or C<@{ $foo{bar} }> the C<@> in both cases
23 represents a cast. In this case, an array dereference.
24  
25 =head1 METHODS
26  
27 There are no additional methods beyond those provided by the parent
28 L<PPI::Token> and L<PPI::Element> classes.
29  
30 =cut
31  
32 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 63 ▶use PPI::Token ();
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 63 our $VERSION = '1.260'; # VERSION
36  
37 63 our @ISA = "PPI::Token";
38  
39 63 our %POSTFIX = map { $_ => 1 } (
40 qw{
41 %* @* $*
42 },
43 '$#*' # throws warnings if it's inside a qw
44 );
45  
46  
47  
48  
49 #####################################################################
50 # Tokenizer Methods
51  
52 # A cast is either % @ $ or $#
53 # and also postfix dereference are %* @* $* $#*
54 sub __TOKENIZER__on_char {
55 888 ▶ my $t = $_[1];
Subroutine __TOKENIZER__on_char: called CC=2 SCAR=6.9
56 888 my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
57  
58 # Are we still an operator if we add the next character
59 888 my $content = $t->{token}->{content};
60 888 ▶ return 1 if $POSTFIX{ $content . $char };
Branch: 1 branch
BranchTrueFalseTotal
if $PPI::Token::Cast::POSTFIX{$content . $char} 1 887 888
61  
62 887 $t->_finalize_token->__TOKENIZER__on_char( $t );
63 }
64  
65 63 1;
66  
67 =pod
68  
69 =head1 SUPPORT
70  
71 See the L<support section|PPI/SUPPORT> in the main module.
72  
73 =head1 AUTHOR
74  
75 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
76  
77 =head1 COPYRIGHT
78  
79 Copyright 2001 - 2011 Adam Kennedy.
80  
81 This program is free software; you can redistribute
82 it and/or modify it under the same terms as Perl itself.
83  
84 The full text of the license can be found in the
85 LICENSE file included with this module.
86  
87 =cut
« PPI/Token/ArrayIndex.pm ↑ Summary PPI/Token/QuoteLike/Words.pm »