line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 is a |
14
|
|
|
|
|
|
|
L. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
C 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
|
|
|
9
|
|
66
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
290
|
|
32
|
9
|
|
|
9
|
|
54
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
274
|
|
33
|
|
|
|
|
|
|
|
34
|
9
|
|
|
9
|
|
51
|
use base qw{ PPIx::Regexp::Token::Reference }; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
842
|
|
35
|
|
|
|
|
|
|
|
36
|
9
|
|
|
9
|
|
70
|
use Carp qw{ confess }; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
517
|
|
37
|
9
|
|
|
9
|
|
95
|
use PPIx::Regexp::Constant qw{ RE_CAPTURE_NAME @CARP_NOT }; |
|
9
|
|
|
|
|
56
|
|
|
9
|
|
|
|
|
4016
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = '0.087'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Return true if the token can be quantified, and false otherwise |
42
|
|
|
|
|
|
|
# sub can_be_quantified { return }; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub explain { |
45
|
4
|
|
|
4
|
1
|
12
|
my ( $self ) = @_; |
46
|
4
|
100
|
|
|
|
23
|
$self->is_named() |
47
|
|
|
|
|
|
|
and return sprintf q, |
48
|
|
|
|
|
|
|
$self->name(); |
49
|
3
|
50
|
|
|
|
12
|
if ( $self->is_relative() ) { |
|
|
100
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
my $number = $self->number(); |
51
|
0
|
0
|
|
|
|
0
|
$number >= 0 |
52
|
|
|
|
|
|
|
and return sprintf |
53
|
|
|
|
|
|
|
q, |
54
|
|
|
|
|
|
|
PPIx::Regexp::Util::__to_ordinal_en( $self->number() ), |
55
|
|
|
|
|
|
|
$self->absolute(); |
56
|
0
|
|
|
|
|
0
|
return sprintf |
57
|
|
|
|
|
|
|
q, |
58
|
|
|
|
|
|
|
PPIx::Regexp::Util::__to_ordinal_en( - $self->number() ), |
59
|
|
|
|
|
|
|
$self->absolute(); |
60
|
|
|
|
|
|
|
} elsif ( my $number = $self->absolute() ) { |
61
|
1
|
|
|
|
|
9
|
return sprintf q, $number; |
62
|
|
|
|
|
|
|
} else { |
63
|
2
|
|
|
|
|
6
|
return q; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub perl_version_introduced { |
68
|
8
|
|
|
8
|
1
|
2034
|
return '5.009005'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub raw_width { |
72
|
1
|
|
|
1
|
1
|
4
|
return ( undef, undef ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub width { |
76
|
5
|
|
|
5
|
1
|
27
|
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
|
|
|
|
|
|
|
sub __PPIX_TOKEN__recognize { |
86
|
|
|
|
|
|
|
return ( |
87
|
16
|
|
|
16
|
|
120
|
[ qr{ \A \( \? (?: ( [-+]? [0-9]+ )) \) }smx, { is_named => 0 } ], |
88
|
|
|
|
|
|
|
[ qr{ \A \( \? (?: R) \) }smx, |
89
|
|
|
|
|
|
|
{ is_named => 0, capture => '0' } ], |
90
|
9
|
|
|
|
|
991
|
[ qr{ \A \( \? (?: & | P> ) ( @{[ RE_CAPTURE_NAME ]} ) \) }smxo, |
91
|
|
|
|
|
|
|
{ is_named => 1 } ], |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |