line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PPIx::Regexp::Structure::Assertion - Represent a parenthesized assertion |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use PPIx::Regexp::Dumper; |
8
|
|
|
|
|
|
|
PPIx::Regexp::Dumper->new( 'qr{(?<=foo)bar}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 one of the parenthesized assertions, either look |
21
|
|
|
|
|
|
|
ahead or look behind, and either positive or negative. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This class provides the following public methods beyond those provided |
26
|
|
|
|
|
|
|
by its superclass. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package PPIx::Regexp::Structure::Assertion; |
31
|
|
|
|
|
|
|
|
32
|
9
|
|
|
9
|
|
65
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
279
|
|
33
|
9
|
|
|
9
|
|
106
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
264
|
|
34
|
|
|
|
|
|
|
|
35
|
9
|
|
|
9
|
|
46
|
use base qw{ PPIx::Regexp::Structure }; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
796
|
|
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
9
|
|
66
|
use Carp qw{ confess }; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
478
|
|
38
|
9
|
|
|
9
|
|
84
|
use List::Util qw{ max }; |
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
722
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '0.087_01'; |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
4134
|
use PPIx::Regexp::Constant qw{ |
43
|
|
|
|
|
|
|
LITERAL_LEFT_CURLY_ALLOWED |
44
|
|
|
|
|
|
|
VARIABLE_LENGTH_LOOK_BEHIND_INTRODUCED |
45
|
|
|
|
|
|
|
@CARP_NOT |
46
|
9
|
|
|
9
|
|
62
|
}; |
|
9
|
|
|
|
|
27
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 is_look_ahead |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This method returns a true value if the assertion is a look-ahead |
51
|
|
|
|
|
|
|
assertion, or a false value if it is a look-behind assertion. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub is_look_ahead { |
56
|
17
|
|
|
17
|
1
|
38
|
my ( $self ) = @_; |
57
|
17
|
|
|
|
|
48
|
return $self->_get_type()->is_look_ahead(); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 is_positive |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This method returns a true value if the assertion is a positive |
63
|
|
|
|
|
|
|
assertion, or a false value if it is a negative assertion. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub is_positive { |
68
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
69
|
0
|
|
|
|
|
0
|
return $self->_get_type()->is_positive(); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub perl_version_introduced { |
73
|
13
|
|
|
13
|
1
|
29
|
my ( $self ) = @_; |
74
|
|
|
|
|
|
|
return( $self->{perl_version_introduced} ||= |
75
|
13
|
|
33
|
|
|
51
|
$self->_perl_version_introduced() ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _perl_version_introduced { |
79
|
13
|
|
|
13
|
|
25
|
my ( $self ) = @_; |
80
|
13
|
|
|
|
|
34
|
my $ver = max( map { $_->perl_version_introduced() } |
|
29
|
|
|
|
|
109
|
|
81
|
|
|
|
|
|
|
$self->children() ); |
82
|
13
|
100
|
100
|
|
|
63
|
if ( $ver < VARIABLE_LENGTH_LOOK_BEHIND_INTRODUCED && |
83
|
|
|
|
|
|
|
! $self->is_look_ahead() |
84
|
|
|
|
|
|
|
) { |
85
|
2
|
|
|
|
|
24
|
my ( $wid_min, $wid_max ) = $self->raw_width(); |
86
|
2
|
50
|
66
|
|
|
14
|
defined $wid_min |
|
|
|
66
|
|
|
|
|
87
|
|
|
|
|
|
|
and defined $wid_max |
88
|
|
|
|
|
|
|
and $wid_min < $wid_max |
89
|
|
|
|
|
|
|
and $ver = max( $ver, VARIABLE_LENGTH_LOOK_BEHIND_INTRODUCED ); |
90
|
|
|
|
|
|
|
} |
91
|
13
|
|
|
|
|
54
|
return $ver; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub width { |
95
|
5
|
|
|
5
|
1
|
11
|
return ( 0, 0 ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# An un-escaped literal left curly bracket can always follow this |
99
|
|
|
|
|
|
|
# element. |
100
|
|
|
|
|
|
|
sub __following_literal_left_curly_disallowed_in { |
101
|
1
|
|
|
1
|
|
5
|
return LITERAL_LEFT_CURLY_ALLOWED; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _get_type { |
105
|
17
|
|
|
17
|
|
36
|
my ( $self ) = @_; |
106
|
17
|
50
|
|
|
|
69
|
my $type = $self->type() |
107
|
|
|
|
|
|
|
or confess 'Programming error - no type object'; |
108
|
17
|
50
|
|
|
|
71
|
$type->isa( 'PPIx::Regexp::Token::GroupType::Assertion' ) |
109
|
|
|
|
|
|
|
or confess 'Programming error - type object is ', ref $type, |
110
|
|
|
|
|
|
|
' not PPIx::Regexp::Token::GroupType::Assertion'; |
111
|
17
|
|
|
|
|
67
|
return $type; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |