| 1 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | PPIx::Regexp::Token::Whitespace - Represent whitespace | ||||||||||||||||||||||||||||||||||||
| 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<PPIx::Regexp::Token::Whitespace> is a | ||||||||||||||||||||||||||||||||||||
| 14 | L<PPIx::Regexp::Token::NoOp|PPIx::Regexp::Token::NoOp>. | ||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | C<PPIx::Regexp::Token::Whitespace> has no descendants. | ||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | This class represents whitespace. It will appear inside the regular | ||||||||||||||||||||||||||||||||||||
| 21 | expression only if the C</x> modifier is present, but it may also appear | ||||||||||||||||||||||||||||||||||||
| 22 | between the type and the opening delimiter (e.g. C<qr {foo}>) or after | ||||||||||||||||||||||||||||||||||||
| 23 | the regular expression in a bracketed substitution (e.g. C<s{foo} | ||||||||||||||||||||||||||||||||||||
| 24 | {bar}>). | ||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||
| 26 | If the C</xx> modifier is present, it can also appear inside bracketed | ||||||||||||||||||||||||||||||||||||
| 27 | character classes. This was introduced in Perl 5.25.9. | ||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||
| 29 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||
| 31 | This class provides no public methods beyond those provided by its | ||||||||||||||||||||||||||||||||||||
| 32 | superclass. | ||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||
| 36 | package PPIx::Regexp::Token::Whitespace; | ||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||
| 38 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 39 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 9 | ▶ | use base qw{ PPIx::Regexp::Token::NoOp }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | 9 | ▶ | use PPIx::Regexp::Constant qw{ | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 44 | COOKIE_REGEX_SET | ||||||||||||||||||||||||||||||||||||
| 45 | MINIMUM_PERL | ||||||||||||||||||||||||||||||||||||
| 46 | @CARP_NOT | ||||||||||||||||||||||||||||||||||||
| 47 | 9 | }; | |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | 9 | our $VERSION = '0.092'; | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | 151 | ▶ | sub __new { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__new: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||
| 52 | 151 | my ( $class, $content, %arg ) = @_; | |||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||
| 54 | defined $arg{perl_version_introduced} | ||||||||||||||||||||||||||||||||||||
| 55 | or $arg{perl_version_introduced} = | ||||||||||||||||||||||||||||||||||||
| 56 | 151 | ▶ | ( grep { 127 < ord } split qr{}, $content ) | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 57 | ? '5.021001' | ||||||||||||||||||||||||||||||||||||
| 58 | : MINIMUM_PERL; | ||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||
| 60 | 151 | return $class->SUPER::__new( $content, %arg ); | |||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | sub explain { | ||||||||||||||||||||||||||||||||||
|
Subroutine
explain: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 64 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||
| 65 | 3 | my $parent; | |||||||||||||||||||||||||||||||||||
| 66 | 3 | ▶ | if ( | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$parent = $self->parent and $parent->isa("PPIx::Regexp")
MC/DC50%1/2
$parent = $self->parent and $parent->isa("PPIx::Regexp")
$parent = $self->parent
$parent->isa("PPIx::Regexp")
Truth table66%2/3
A and B
A= $parent = $self->parentB= $parent->isa("PPIx::Regexp")
| |||||||||||||||||||||||||||||||||||||
| 67 | $parent = $self->parent() | ||||||||||||||||||||||||||||||||||||
| 68 | and $parent->isa( 'PPIx::Regexp' ) | ||||||||||||||||||||||||||||||||||||
| 69 | ) { | ||||||||||||||||||||||||||||||||||||
| 70 | 1 | return $self->SUPER::explain(); | |||||||||||||||||||||||||||||||||||
| 71 | } elsif ( $self->in_regex_set() ) { | ||||||||||||||||||||||||||||||||||||
| 72 | 1 | return q<Not significant in extended character class>; | |||||||||||||||||||||||||||||||||||
| 73 | } elsif ( my $count = $self->modifier_asserted( 'x*' ) ) { | ||||||||||||||||||||||||||||||||||||
| 74 | 1 | return q<Not significant under /> . ( 'x' x $count ); | |||||||||||||||||||||||||||||||||||
| 75 | } else { | ||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $self->SUPER::explain(); | |||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub whitespace { | ||||||||||||||||||||||||||||||||||
|
Subroutine
whitespace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 81 | 1 | return 1; | |||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||
| 84 | # Objects of this class are generated either by the tokenizer itself | ||||||||||||||||||||||||||||||||||||
| 85 | # (when scanning for delimiters) or by PPIx::Regexp::Token::Literal (if | ||||||||||||||||||||||||||||||||||||
| 86 | # it hits a match for \s and finds the regular expression has the /x | ||||||||||||||||||||||||||||||||||||
| 87 | # modifier asserted. | ||||||||||||||||||||||||||||||||||||
| 88 | # | ||||||||||||||||||||||||||||||||||||
| 89 | # sub __PPIX_TOKENIZER__regexp { | ||||||||||||||||||||||||||||||||||||
| 90 | # my ( $class, $tokenizer, $character ) = @_; | ||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||
| 92 | # return scalar $tokenizer->find_regexp( qr{ \A \s+ }smx ); | ||||||||||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||||||||||
| 94 | # } | ||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||
| 96 | 9 | 1; | |||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||||||||||||||||||