| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | PPIx::Regexp::Structure::Modifier - Represent modifying parentheses | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use PPIx::Regexp::Dumper; | ||||||||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{(?i:foo)}smx' ) | ||||||||||
| 9 | ->print(); | ||||||||||
| 10 | |||||||||||
| 11 | =head1 INHERITANCE | ||||||||||
| 12 | |||||||||||
| 13 | C<PPIx::Regexp::Structure::Modifier> is a | ||||||||||
| 14 | L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>. | ||||||||||
| 15 | |||||||||||
| 16 | C<PPIx::Regexp::Structure::Modifier> has no descendants. | ||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This class represents parentheses that apply modifiers to their contents | ||||||||||
| 21 | -- even if there are no modifiers. The latter is to say that C<(?:foo)> | ||||||||||
| 22 | also ends up as this class. | ||||||||||
| 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::Structure::Modifier; | ||||||||||
| 32 | |||||||||||
| 33 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 9 | ▶ | use base qw{ PPIx::Regexp::Structure }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 9 | ▶ | use PPIx::Regexp::Constant qw{ @CARP_NOT }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 9 | our $VERSION = '0.092'; | |||||||||
| 41 | |||||||||||
| 42 | # This is a kluge for both determining whether the object asserts | ||||||||||
| 43 | # modifiers (hence the 'ductype') and determining whether the given | ||||||||||
| 44 | # modifier is actually asserted. The signature is the invocant and the | ||||||||||
| 45 | # modifier name, which must not be undef. The return is a boolean. | ||||||||||
| 46 | 2 | ▶ | sub __ducktype_modifier_asserted { | ||||||||
|
Subroutine
__ducktype_modifier_asserted: called CC=4 SCAR=14.9
| |||||||||||
| 47 | 2 | my ( $self, $modifier ) = @_; | |||||||||
| 48 | 2 | foreach my $type ( reverse $self->type() ) { | |||||||||
| 49 | 2 | ▶ | $type->can( '__ducktype_modifier_asserted' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | or next; | ||||||||||
| 51 | 2 | ▶ | defined( my $val = $type->__ducktype_modifier_asserted( $modifier ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | or next; | ||||||||||
| 53 | 2 | return $val; | |||||||||
| 54 | } | ||||||||||
| 55 | 0 | return; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 9 | 1; | |||||||||
| 59 | |||||||||||
| 60 | __END__ | ||||||||||