line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 is a |
14
|
|
|
|
|
|
|
L. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
C 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
|
|
|
9
|
|
73
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
332
|
|
34
|
9
|
|
|
9
|
|
53
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
308
|
|
35
|
|
|
|
|
|
|
|
36
|
9
|
|
|
9
|
|
46
|
use base qw{ PPIx::Regexp::Token }; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
922
|
|
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
9
|
|
71
|
use PPIx::Regexp::Constant qw{ MINIMUM_PERL @CARP_NOT }; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
2787
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '0.087'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Return true if the token can be quantified, and false otherwise |
43
|
0
|
|
|
0
|
1
|
0
|
sub can_be_quantified { return }; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %explanation = ( |
48
|
|
|
|
|
|
|
'+' => 'match longest string and give nothing back', |
49
|
|
|
|
|
|
|
'?' => 'match shortest string first', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub __explanation { |
53
|
2
|
|
|
2
|
|
8
|
return \%explanation; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
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
|
|
|
2
|
1
|
15
|
my ( undef, $string ) = @_; # Invocant unused |
74
|
2
|
|
|
|
|
15
|
return $greediness{$string}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub perl_version_introduced { |
78
|
4
|
|
|
4
|
1
|
687
|
my ( $self ) = @_; |
79
|
4
|
|
50
|
|
|
26
|
return $greediness{ $self->content() } || MINIMUM_PERL; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub __PPIX_TOKENIZER__regexp { |
83
|
1098
|
|
|
1098
|
|
2634
|
my ( undef, $tokenizer, $character ) = @_; # Invocant, $char_type unused |
84
|
|
|
|
|
|
|
|
85
|
1098
|
100
|
|
|
|
2660
|
$tokenizer->prior_significant_token( 'is_quantifier' ) |
86
|
|
|
|
|
|
|
or return; |
87
|
|
|
|
|
|
|
|
88
|
44
|
100
|
|
|
|
262
|
$greediness{$character} or return; |
89
|
|
|
|
|
|
|
|
90
|
15
|
|
|
|
|
51
|
return length $character; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |