blib/lib/PPIx/Regexp/Token/Greediness.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 91.3% 42 / 46 CC 4 SCAR 5.7
CC
4
Cov
94%
__PPIX_TOKENIZER__regexp
3.0
perl_version_introduced
2.1
can_be_quantified
2.0
CRAP 1.8
« blib/lib/PPIx/Regexp/Token/GroupType/Assertion.pm ↑ Summary blib/lib/PPIx/Regexp/Token/GroupType/Modifier.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Token::Greediness - Represent a greediness qualifier.
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo*+}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Token::Greediness> is a
14 L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15  
16 C<PPIx::Regexp::Token::Greediness> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This class represents a greediness qualifier for the preceding
21 quantifier.
22  
23 =head1 METHODS
24  
25 This class provides the following public methods. Methods not documented
26 here are private, and unsupported in the sense that the author reserves
27 the right to change or remove them without notice.
28  
29 =cut
30  
31 package PPIx::Regexp::Token::Greediness;
32  
33 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 9 ▶use base qw{ PPIx::Regexp::Token };
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 9 ▶use PPIx::Regexp::Constant qw{ MINIMUM_PERL @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 9 our $VERSION = '0.091_01';
41  
42 # Return true if the token can be quantified, and false otherwise
43 0 ▶sub can_be_quantified { return };
Subroutine can_be_quantified: not called CC=1 SCAR=6.9
Pod documented
44  
45 {
46  
47 9 my %explanation = (
48 '+' => 'match longest string and give nothing back',
49 '?' => 'match shortest string first',
50 );
51  
52 sub __explanation {
53 2 ▶ return \%explanation;
Subroutine __explanation: called CC=1 SCAR=0.0
54 }
55  
56 }
57  
58 9 my %greediness = (
59 '?' => MINIMUM_PERL,
60 '+' => '5.009005',
61 );
62  
63 =head2 could_be_greediness
64  
65 PPIx::Regexp::Token::Greediness->could_be_greediness( '?' );
66  
67 This method returns true if the given string could be a greediness
68 indicator; that is, if it is '+' or '?'.
69  
70 =cut
71  
72 sub could_be_greediness {
73 2 ▶ my ( undef, $string ) = @_; # Invocant unused
Subroutine could_be_greediness: called CC=1 SCAR=0.0
Pod documented
74 2 return $greediness{$string};
75 }
76  
77 sub perl_version_introduced {
78 4 ▶ my ( $self ) = @_;
Subroutine perl_version_introduced: called CC=2 SCAR=7.2
Pod documented
79 4 ▶ return $greediness{ $self->content() } || MINIMUM_PERL;
Condition50%1/2
$greediness{$self->content} || '5.000'
l!l
40
MC/DC0%0/1
$greediness{$self->content} || '5.000'
$greediness{$self->content}
Truth table50%1/2
A
A= $greediness{$self->content}
Aresult
11
00
80 }
81  
82 sub __PPIX_TOKENIZER__regexp {
83 1098 ▶ my ( undef, $tokenizer, $character ) = @_; # Invocant, $char_type unused
Subroutine __PPIX_TOKENIZER__regexp: called CC=3 SCAR=11.0
84  
85 1098 ▶ $tokenizer->prior_significant_token( 'is_quantifier' )
Branch: 1 branch
BranchTrueFalseTotal
$tokenizer->prior_significant_token("is_quantifier") or return 1054 44 1098
86 or return;
87  
88 44 ▶ $greediness{$character} or return;
Branch: 1 branch
BranchTrueFalseTotal
$greediness{$character} or return 29 15 44
89  
90 15 return length $character;
91 }
92  
93 9 1;
94  
95 __END__
« blib/lib/PPIx/Regexp/Token/GroupType/Assertion.pm ↑ Summary blib/lib/PPIx/Regexp/Token/GroupType/Modifier.pm »