| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PPIx::Regexp::Token::GroupType::Assertion - Represent a look ahead or look behind 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 the parenthesized look ahead and look behind |
|
21
|
|
|
|
|
|
|
assertions. |
|
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::Token::GroupType::Assertion; |
|
31
|
|
|
|
|
|
|
|
|
32
|
9
|
|
|
9
|
|
62
|
use strict; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
261
|
|
|
33
|
9
|
|
|
9
|
|
73
|
use warnings; |
|
|
9
|
|
|
|
|
21
|
|
|
|
9
|
|
|
|
|
244
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
9
|
|
|
9
|
|
46
|
use base qw{ PPIx::Regexp::Token::GroupType }; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
3939
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
9
|
|
|
|
|
900
|
use PPIx::Regexp::Constant qw{ |
|
38
|
|
|
|
|
|
|
COOKIE_LOOKAROUND_ASSERTION |
|
39
|
|
|
|
|
|
|
@CARP_NOT |
|
40
|
9
|
|
|
9
|
|
64
|
}; |
|
|
9
|
|
|
|
|
19
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = '0.087_01'; |
|
43
|
|
|
|
|
|
|
|
|
44
|
9
|
|
|
9
|
|
60
|
use constant EXPL_NLA => 'Negative look-ahead assertion'; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
482
|
|
|
45
|
9
|
|
|
9
|
|
63
|
use constant EXPL_NLB => 'Negative look-behind assertion'; |
|
|
9
|
|
|
|
|
25
|
|
|
|
9
|
|
|
|
|
378
|
|
|
46
|
9
|
|
|
9
|
|
51
|
use constant EXPL_PLA => 'Positive look-ahead assertion'; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
371
|
|
|
47
|
9
|
|
|
9
|
|
59
|
use constant EXPL_PLB => 'Positive look-behind assertion'; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
1121
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
9
|
|
|
|
|
2160
|
use constant DEF => { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
'?!' => { |
|
52
|
|
|
|
|
|
|
expl => EXPL_NLA, |
|
53
|
|
|
|
|
|
|
look_ahead => 1, |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
'*nla:' => { |
|
56
|
|
|
|
|
|
|
expl => EXPL_NLA, |
|
57
|
|
|
|
|
|
|
intro => '5.027009', |
|
58
|
|
|
|
|
|
|
look_ahead => 1, |
|
59
|
|
|
|
|
|
|
}, |
|
60
|
|
|
|
|
|
|
'*negative_lookahead:' => { |
|
61
|
|
|
|
|
|
|
expl => EXPL_NLA, |
|
62
|
|
|
|
|
|
|
intro => '5.027009', |
|
63
|
|
|
|
|
|
|
look_ahead => 1, |
|
64
|
|
|
|
|
|
|
}, |
|
65
|
|
|
|
|
|
|
'? { |
|
66
|
|
|
|
|
|
|
expl => EXPL_NLB, |
|
67
|
|
|
|
|
|
|
intro => '5.005', |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
'*nlb:' => { |
|
70
|
|
|
|
|
|
|
expl => EXPL_NLB, |
|
71
|
|
|
|
|
|
|
intro => '5.027009', |
|
72
|
|
|
|
|
|
|
}, |
|
73
|
|
|
|
|
|
|
'*negative_lookbehind:' => { |
|
74
|
|
|
|
|
|
|
expl => EXPL_NLB, |
|
75
|
|
|
|
|
|
|
intro => '5.027009', |
|
76
|
|
|
|
|
|
|
}, |
|
77
|
|
|
|
|
|
|
'?=' => { |
|
78
|
|
|
|
|
|
|
expl => EXPL_PLA, |
|
79
|
|
|
|
|
|
|
look_ahead => 1, |
|
80
|
|
|
|
|
|
|
positive => 1, |
|
81
|
|
|
|
|
|
|
}, |
|
82
|
|
|
|
|
|
|
'*pla:' => { |
|
83
|
|
|
|
|
|
|
expl => EXPL_PLA, |
|
84
|
|
|
|
|
|
|
intro => '5.027009', |
|
85
|
|
|
|
|
|
|
look_ahead => 1, |
|
86
|
|
|
|
|
|
|
positive => 1, |
|
87
|
|
|
|
|
|
|
}, |
|
88
|
|
|
|
|
|
|
'*positive_lookahead:' => { |
|
89
|
|
|
|
|
|
|
expl => EXPL_PLA, |
|
90
|
|
|
|
|
|
|
intro => '5.027009', |
|
91
|
|
|
|
|
|
|
look_ahead => 1, |
|
92
|
|
|
|
|
|
|
positive => 1, |
|
93
|
|
|
|
|
|
|
}, |
|
94
|
|
|
|
|
|
|
'?<=' => { |
|
95
|
|
|
|
|
|
|
expl => EXPL_PLB, |
|
96
|
|
|
|
|
|
|
intro => '5.005', |
|
97
|
|
|
|
|
|
|
positive => 1, |
|
98
|
|
|
|
|
|
|
}, |
|
99
|
|
|
|
|
|
|
'*plb:' => { |
|
100
|
|
|
|
|
|
|
expl => EXPL_PLB, |
|
101
|
|
|
|
|
|
|
intro => '5.027009', |
|
102
|
|
|
|
|
|
|
positive => 1, |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
'*positive_lookbehind:' => { |
|
105
|
|
|
|
|
|
|
expl => EXPL_PLB, |
|
106
|
|
|
|
|
|
|
intro => '5.027009', |
|
107
|
|
|
|
|
|
|
positive => 1, |
|
108
|
|
|
|
|
|
|
}, |
|
109
|
9
|
|
|
9
|
|
57
|
}; |
|
|
9
|
|
|
|
|
19
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__PACKAGE__->__setup_class(); |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub __match_setup { |
|
114
|
48
|
|
|
48
|
|
157
|
my ( undef, $tokenizer ) = @_; # $class not used |
|
115
|
48
|
100
|
|
|
|
235
|
$tokenizer->__cookie_exists( COOKIE_LOOKAROUND_ASSERTION ) |
|
116
|
|
|
|
|
|
|
and return; |
|
117
|
45
|
|
|
|
|
95
|
my $nest_depth = 1; |
|
118
|
|
|
|
|
|
|
$tokenizer->cookie( COOKIE_LOOKAROUND_ASSERTION, sub { |
|
119
|
233
|
|
|
233
|
|
542
|
my ( undef, $token ) = @_; # $tokenizer not used |
|
120
|
|
|
|
|
|
|
$token |
|
121
|
|
|
|
|
|
|
and $token->isa( 'PPIx::Regexp::Token::Structure' ) |
|
122
|
|
|
|
|
|
|
and $nest_depth += ( { |
|
123
|
|
|
|
|
|
|
'(' => 1, |
|
124
|
|
|
|
|
|
|
')' => -1, |
|
125
|
233
|
100
|
100
|
|
|
1644
|
}->{ $token->content() } || 0 ); |
|
|
|
|
66
|
|
|
|
|
|
126
|
233
|
|
|
|
|
979
|
return $nest_depth; |
|
127
|
|
|
|
|
|
|
}, |
|
128
|
45
|
|
|
|
|
405
|
); |
|
129
|
45
|
|
|
|
|
117
|
return; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 is_look_ahead |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This method returns a true value if the assertion is a look-ahead |
|
135
|
|
|
|
|
|
|
assertion, or a false value if it is a look-behind assertion. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub is_look_ahead { |
|
140
|
17
|
|
|
17
|
1
|
41
|
my ( $self ) = @_; |
|
141
|
17
|
|
|
|
|
82
|
return $self->DEF->{ $self->unescaped_content() }->{look_ahead}; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 is_positive |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This method returns a true value if the assertion is a positive |
|
147
|
|
|
|
|
|
|
assertion, or a false value if it is a negative assertion. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub is_positive { |
|
152
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
153
|
0
|
|
|
|
|
|
return $self->DEF->{ $self->unescaped_content() }->{positive}; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |