| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PPIx::Regexp::Structure::Main - Represent a regular expression proper, or a substitution |
|
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 is the parent of |
|
17
|
|
|
|
|
|
|
L and |
|
18
|
|
|
|
|
|
|
L. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This abstract class represents one of the top-level structures in the |
|
23
|
|
|
|
|
|
|
expression. Both |
|
24
|
|
|
|
|
|
|
L and |
|
25
|
|
|
|
|
|
|
L |
|
26
|
|
|
|
|
|
|
are derived from it. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This class provides the following public methods. Methods not documented |
|
31
|
|
|
|
|
|
|
here are private, and unsupported in the sense that the author reserves |
|
32
|
|
|
|
|
|
|
the right to change or remove them without notice. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package PPIx::Regexp::Structure::Main; |
|
37
|
|
|
|
|
|
|
|
|
38
|
9
|
|
|
9
|
|
64
|
use strict; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
266
|
|
|
39
|
9
|
|
|
9
|
|
43
|
use warnings; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
235
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
9
|
|
|
9
|
|
42
|
use base qw{ PPIx::Regexp::Structure }; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
905
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
9
|
|
|
9
|
|
66
|
use PPIx::Regexp::Constant qw{ @CARP_NOT }; |
|
|
9
|
|
|
|
|
36
|
|
|
|
9
|
|
|
|
|
2636
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = '0.087'; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 delimiters |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This method returns a string representing the delimiters of a regular |
|
50
|
|
|
|
|
|
|
expression or substitution string. In the case of something like |
|
51
|
|
|
|
|
|
|
C, it will return '//' for both the regular expression and |
|
52
|
|
|
|
|
|
|
the replacement. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub delimiters { |
|
57
|
152
|
|
|
152
|
1
|
357
|
my ( $self ) = @_; |
|
58
|
152
|
|
|
|
|
281
|
my @delims; |
|
59
|
152
|
|
|
|
|
312
|
foreach my $method ( qw{ start finish } ) { |
|
60
|
304
|
|
|
|
|
518
|
push @delims, undef; |
|
61
|
304
|
100
|
|
|
|
1068
|
defined ( my $obj = $self->$method() ) |
|
62
|
|
|
|
|
|
|
or next; |
|
63
|
301
|
50
|
|
|
|
763
|
defined ( my $str = $obj->content() ) |
|
64
|
|
|
|
|
|
|
or next; |
|
65
|
301
|
|
|
|
|
751
|
$delims[-1] = $str; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
152
|
100
|
|
|
|
459
|
defined ( $delims[0] ) |
|
68
|
|
|
|
|
|
|
or $delims[0] = $delims[1]; |
|
69
|
152
|
|
|
|
|
509
|
return $delims[0] . $delims[1]; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 interpolates |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This method returns true if the regular expression or replacement |
|
75
|
|
|
|
|
|
|
interpolates, and false otherwise. All it really does is to check |
|
76
|
|
|
|
|
|
|
whether the ending delimiter is a single quote. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub interpolates { |
|
81
|
3
|
|
|
3
|
1
|
9
|
my ( $self ) = @_; |
|
82
|
3
|
50
|
|
|
|
25
|
my $finish = $self->finish( 0 ) or return 1; |
|
83
|
3
|
|
|
|
|
23
|
return q<'> ne $finish->content(); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |