Regexp/Token/Recursion.pm

filter: Statementstmt 90.0% 27 / 30 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 88.4% 46 / 52 CC 5 SCAR 10.6
CC
5
Cov
84%
explain
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Regexp/Structure/Assertion.pm ↑ Summary Regexp/Token/Condition.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Token::Recursion - Represent a recursion
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{(foo(?1)?)}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Token::Recursion> is a
14 L<PPIx::Regexp::Token::Reference|PPIx::Regexp::Token::Reference>.
15  
16 C<PPIx::Regexp::Token::Recursion> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This class represents a recursion to a named or numbered capture.
21  
22 =head1 METHODS
23  
24 This class provides no public methods beyond those provided by its
25 superclass.
26  
27 =cut
28  
29 package PPIx::Regexp::Token::Recursion;
30  
31 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 9 ▶use base qw{ PPIx::Regexp::Token::Reference };
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 9 ▶use Carp qw{ confess };
Subroutine BEGIN: called CC=1 SCAR=0.0
37 9 ▶use PPIx::Regexp::Constant qw{ RE_CAPTURE_NAME @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 9 our $VERSION = '0.092';
40  
41 # Return true if the token can be quantified, and false otherwise
42 # sub can_be_quantified { return };
43  
44 4 ▶sub explain {
Subroutine explain: called CC=5 SCAR=18.4
Pod documented
45 4 my ( $self ) = @_;
46 4 ▶ $self->is_named()
Branch: 1 branch
BranchTrueFalseTotal
$self->is_named and return sprintf("Recurse into capture group '%s'", $self->name) 1 3 4
47 and return sprintf q<Recurse into capture group '%s'>,
48 $self->name();
49 3 ▶ if ( $self->is_relative() ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->is_relative) { } 0 3 3
elsif (my $number = $self->absolute) { } 1 2 3
50 0 my $number = $self->number();
51 0 ▶ $number >= 0
Branch: 1 branch
BranchTrueFalseTotal
$number >= 0 and return sprintf("Recurse into %s following capture group (%d in this regexp)", PPIx::Regexp::Util::__to_ordinal_en($self->number), $self->absolute) 0 0 0
52 and return sprintf
53 q<Recurse into %s following capture group (%d in this regexp)>,
54 PPIx::Regexp::Util::__to_ordinal_en( $self->number() ),
55 $self->absolute();
56 0 return sprintf
57 q<Back reference to %s previous capture group (%d in this regexp)>,
58 PPIx::Regexp::Util::__to_ordinal_en( - $self->number() ),
59 $self->absolute();
60 } elsif ( my $number = $self->absolute() ) {
61 1 return sprintf q<Recurse into capture group %d>, $number;
62 } else {
63 2 return q<Recurse to beginning of regular expression>;
64 }
65 }
66  
67 8 ▶sub perl_version_introduced {
Subroutine perl_version_introduced: called CC=1 SCAR=0.0
Pod documented
68 8 return '5.009005';
69 }
70  
71 1 ▶sub raw_width {
Subroutine raw_width: called CC=1 SCAR=0.0
Pod documented
72 1 return ( undef, undef );
73 }
74  
75 5 ▶sub width {
Subroutine width: called CC=1 SCAR=0.0
Pod documented
76 5 return ( undef, undef );
77 }
78  
79 # This must be implemented by tokens which do not recognize themselves.
80 # The return is a list of list references. Each list reference must
81 # contain a regular expression that recognizes the token, and optionally
82 # a reference to a hash to pass to make_token as the class-specific
83 # arguments. The regular expression MUST be anchored to the beginning of
84 # the string.
85 16 ▶sub __PPIX_TOKEN__recognize {
Subroutine __PPIX_TOKEN__recognize: called CC=1 SCAR=0.0
86 return (
87 16 [ qr{ \A \( \? (?: ( [-+]? [0-9]+ )) \) }smx, { is_named => 0 } ],
88 [ qr{ \A \( \? (?: R) \) }smx,
89 { is_named => 0, capture => '0' } ],
90 9 [ qr{ \A \( \? (?: & | P> ) ( @{[ RE_CAPTURE_NAME ]} ) \) }smxo,
91 { is_named => 1 } ],
92 );
93 }
94  
95 9 1;
96  
97 __END__
« Regexp/Structure/Assertion.pm ↑ Summary Regexp/Token/Condition.pm »