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
|
|
57
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
245
|
|
39
|
9
|
|
|
9
|
|
74
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
248
|
|
40
|
|
|
|
|
|
|
|
41
|
9
|
|
|
9
|
|
65
|
use base qw{ PPIx::Regexp::Structure }; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
833
|
|
42
|
|
|
|
|
|
|
|
43
|
9
|
|
|
9
|
|
63
|
use PPIx::Regexp::Constant qw{ @CARP_NOT }; |
|
9
|
|
|
|
|
45
|
|
|
9
|
|
|
|
|
2526
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = '0.087_01'; |
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
|
348
|
my ( $self ) = @_; |
58
|
152
|
|
|
|
|
247
|
my @delims; |
59
|
152
|
|
|
|
|
347
|
foreach my $method ( qw{ start finish } ) { |
60
|
304
|
|
|
|
|
522
|
push @delims, undef; |
61
|
304
|
100
|
|
|
|
977
|
defined ( my $obj = $self->$method() ) |
62
|
|
|
|
|
|
|
or next; |
63
|
301
|
50
|
|
|
|
719
|
defined ( my $str = $obj->content() ) |
64
|
|
|
|
|
|
|
or next; |
65
|
301
|
|
|
|
|
696
|
$delims[-1] = $str; |
66
|
|
|
|
|
|
|
} |
67
|
152
|
100
|
|
|
|
434
|
defined ( $delims[0] ) |
68
|
|
|
|
|
|
|
or $delims[0] = $delims[1]; |
69
|
152
|
|
|
|
|
559
|
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
|
10
|
my ( $self ) = @_; |
82
|
3
|
50
|
|
|
|
22
|
my $finish = $self->finish( 0 ) or return 1; |
83
|
3
|
|
|
|
|
15
|
return q<'> ne $finish->content(); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |