| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PPIx::Regexp::Token::Condition - Represent the condition of a switch |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use PPIx::Regexp::Dumper; |
|
8
|
|
|
|
|
|
|
PPIx::Regexp::Dumper->new( 'qr{(?(1)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 condition portion of a switch or conditional |
|
21
|
|
|
|
|
|
|
expression, provided that condition is reasonably represented as a |
|
22
|
|
|
|
|
|
|
token. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This class provides no public methods beyond those provided by its |
|
27
|
|
|
|
|
|
|
superclass. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package PPIx::Regexp::Token::Condition; |
|
32
|
|
|
|
|
|
|
|
|
33
|
9
|
|
|
9
|
|
66
|
use strict; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
280
|
|
|
34
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
|
9
|
|
|
|
|
39
|
|
|
|
9
|
|
|
|
|
267
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
9
|
|
|
9
|
|
68
|
use base qw{ PPIx::Regexp::Token::Reference }; |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
831
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
9
|
|
|
9
|
|
85
|
use PPIx::Regexp::Constant qw{ RE_CAPTURE_NAME @CARP_NOT }; |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
5802
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '0.087'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my %explanation = ( |
|
45
|
|
|
|
|
|
|
'(DEFINE)' => 'Define a group to be recursed into', |
|
46
|
|
|
|
|
|
|
'(R)' => 'True if recursing', |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub explain { |
|
50
|
6
|
|
|
6
|
1
|
12
|
my ( $self ) = @_; |
|
51
|
6
|
|
|
|
|
24
|
my $content = $self->content(); |
|
52
|
6
|
100
|
|
|
|
21
|
if ( defined( my $expl = $explanation{$content} ) ) { |
|
53
|
2
|
|
|
|
|
7
|
return $expl; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
4
|
100
|
|
|
|
34
|
if ( $content =~ m/ \A [(] R /smx ) { # ) |
|
56
|
2
|
100
|
|
|
|
8
|
$self->is_named() |
|
57
|
|
|
|
|
|
|
and return sprintf |
|
58
|
|
|
|
|
|
|
q, |
|
59
|
|
|
|
|
|
|
$self->name(); |
|
60
|
1
|
|
|
|
|
5
|
return sprintf |
|
61
|
|
|
|
|
|
|
q, |
|
62
|
|
|
|
|
|
|
$self->absolute(); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
$self->is_named() |
|
65
|
2
|
100
|
|
|
|
16
|
and return sprintf |
|
66
|
|
|
|
|
|
|
q, |
|
67
|
|
|
|
|
|
|
$self->name(); |
|
68
|
1
|
|
|
|
|
7
|
return sprintf |
|
69
|
|
|
|
|
|
|
q, |
|
70
|
|
|
|
|
|
|
$self->absolute(); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub perl_version_introduced { |
|
76
|
19
|
|
|
19
|
1
|
2463
|
my ( $self ) = @_; |
|
77
|
19
|
100
|
|
|
|
77
|
$self->content() =~ m/ \A [(] [0-9]+ [)] \z /smx |
|
78
|
|
|
|
|
|
|
and return '5.005'; |
|
79
|
13
|
|
|
|
|
41
|
return '5.009005'; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my @recognize = ( |
|
83
|
|
|
|
|
|
|
[ qr{ \A \( (?: ( [0-9]+ ) | R ( [0-9]+ ) ) \) }smx, |
|
84
|
|
|
|
|
|
|
{ is_named => 0 } ], |
|
85
|
|
|
|
|
|
|
[ qr{ \A \( R \) }smx, |
|
86
|
|
|
|
|
|
|
{ is_named => 0, capture => '0' } ], |
|
87
|
|
|
|
|
|
|
[ qr{ \A \( (?: < ( @{[ RE_CAPTURE_NAME ]} ) > | |
|
88
|
|
|
|
|
|
|
' ( @{[ RE_CAPTURE_NAME ]} ) ' | |
|
89
|
|
|
|
|
|
|
R & ( @{[ RE_CAPTURE_NAME ]} ) ) \) }smxo, |
|
90
|
|
|
|
|
|
|
{ is_named => 1} ], |
|
91
|
|
|
|
|
|
|
[ qr{ \A \( DEFINE \) }smx, |
|
92
|
|
|
|
|
|
|
{ is_named => 0, capture => '0' } ], |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# This must be implemented by tokens which do not recognize themselves. |
|
96
|
|
|
|
|
|
|
# The return is a list of list references. Each list reference must |
|
97
|
|
|
|
|
|
|
# contain a regular expression that recognizes the token, and optionally |
|
98
|
|
|
|
|
|
|
# a reference to a hash to pass to make_token as the class-specific |
|
99
|
|
|
|
|
|
|
# arguments. The regular expression MUST be anchored to the beginning of |
|
100
|
|
|
|
|
|
|
# the string. |
|
101
|
|
|
|
|
|
|
sub __PPIX_TOKEN__recognize { |
|
102
|
8
|
|
|
8
|
|
25
|
return @recognize; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Return true if the token can be quantified, and false otherwise |
|
106
|
|
|
|
|
|
|
# sub can_be_quantified { return }; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub __PPIX_TOKENIZER__regexp { |
|
109
|
32
|
|
|
32
|
|
96
|
my ( undef, $tokenizer ) = @_; # Invocant, $character unused |
|
110
|
|
|
|
|
|
|
|
|
111
|
32
|
|
|
|
|
97
|
foreach ( @recognize ) { |
|
112
|
78
|
|
|
|
|
165
|
my ( $re, $arg ) = @{ $_ }; |
|
|
78
|
|
|
|
|
238
|
|
|
113
|
78
|
100
|
|
|
|
214
|
my $accept = $tokenizer->find_regexp( $re ) or next; |
|
114
|
26
|
|
|
|
|
143
|
return $tokenizer->make_token( $accept, __PACKAGE__, $arg ); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
6
|
|
|
|
|
21
|
return; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |