line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PPIx::Regexp::Token::GroupType::NamedCapture - Represent a named capture |
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 is a |
14
|
|
|
|
|
|
|
L. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
C has no descendants. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class represents a named capture specification. Its content will be |
21
|
|
|
|
|
|
|
something like one of the following: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
? |
24
|
|
|
|
|
|
|
?'NAME' |
25
|
|
|
|
|
|
|
?P |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This class provides the following public methods. Methods not documented |
30
|
|
|
|
|
|
|
here are private, and unsupported in the sense that the author reserves |
31
|
|
|
|
|
|
|
the right to change or remove them without notice. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package PPIx::Regexp::Token::GroupType::NamedCapture; |
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
9
|
|
69
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
267
|
|
38
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
233
|
|
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
9
|
|
45
|
use base qw{ PPIx::Regexp::Token::GroupType }; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
699
|
|
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
9
|
|
55
|
use Carp qw{ confess }; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
484
|
|
43
|
|
|
|
|
|
|
|
44
|
9
|
|
|
9
|
|
53
|
use PPIx::Regexp::Constant qw{ RE_CAPTURE_NAME @CARP_NOT }; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
861
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = '0.087_01'; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
9
|
|
61
|
use constant TOKENIZER_ARGUMENT_REQUIRED => 1; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
2774
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub __new { |
51
|
34
|
|
|
34
|
|
180
|
my ( $class, $content, %arg ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
defined $arg{perl_version_introduced} |
54
|
34
|
50
|
|
|
|
199
|
or $arg{perl_version_introduced} = '5.009005'; |
55
|
|
|
|
|
|
|
|
56
|
34
|
|
|
|
|
215
|
my $self = $class->SUPER::__new( $content, %arg ); |
57
|
|
|
|
|
|
|
|
58
|
34
|
|
|
|
|
236
|
foreach my $name ( $arg{tokenizer}->capture() ) { |
59
|
34
|
50
|
|
|
|
178
|
defined $name or next; |
60
|
34
|
|
|
|
|
140
|
$self->{name} = $name; |
61
|
34
|
|
|
|
|
146
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
confess 'Programming error - can not figure out capture name'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Return true if the token can be quantified, and false otherwise |
68
|
|
|
|
|
|
|
# sub can_be_quantified { return }; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub explain { |
71
|
1
|
|
|
1
|
1
|
3
|
my ( $self ) = @_; |
72
|
1
|
|
|
|
|
5
|
return sprintf q, $self->name(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 name |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This method returns the name of the capture. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub name { |
82
|
33
|
|
|
33
|
1
|
98
|
my ( $self ) = @_; |
83
|
33
|
|
|
|
|
184
|
return $self->{name}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub __make_group_type_matcher { |
87
|
|
|
|
|
|
|
return { |
88
|
9
|
|
|
9
|
|
120
|
'' => [ |
89
|
6
|
|
|
|
|
527
|
qr/ \A [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, |
90
|
6
|
|
|
|
|
388
|
qr/ \A [?] ' ( @{[ RE_CAPTURE_NAME ]} ) ' /smxo, |
91
|
|
|
|
|
|
|
], |
92
|
|
|
|
|
|
|
'?' => [ |
93
|
6
|
|
|
|
|
340
|
qr/ \A \\ [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, |
94
|
6
|
|
|
|
|
372
|
qr/ \A \\ [?] ' ( @{[ RE_CAPTURE_NAME ]} ) ' /smxo, |
95
|
|
|
|
|
|
|
], |
96
|
|
|
|
|
|
|
q{'} => [ |
97
|
6
|
|
|
|
|
381
|
qr/ \A [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, |
98
|
6
|
|
|
|
|
353
|
qr/ \A [?] \\ ' ( @{[ RE_CAPTURE_NAME ]} ) \\ ' /smxo, |
99
|
|
|
|
|
|
|
], |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |