Regexp/Token/Delimiter.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 39 / 39 CC 3 SCAR 3.4
CC
3
Cov
100%
perl_version_introduced
2.0
perl_version_removed
2.0
BEGIN
1.0
CRAP 1.4
« Regexp/Token/Backtrack.pm ↑ Summary Regexp/Constant.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Token::Delimiter - Represent the delimiters of the regular expression
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::Delimiter> is a
14 L<PPIx::Regexp::Token::Structure|PPIx::Regexp::Token::Structure>.
15  
16 C<PPIx::Regexp::Token::Delimiter> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This token represents the delimiters of the regular expression. Since
21 the tokenizer has to figure out where these are anyway, this class is
22 used to give the lexer a hint about what is going on.
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::Delimiter;
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::Token::Structure };
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 9 ▶use PPIx::Regexp::Constant qw{ MINIMUM_PERL @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 9 our $VERSION = '0.092';
41  
42 # Return true if the token can be quantified, and false otherwise
43 # sub can_be_quantified { return };
44  
45 4 ▶sub explain {
Subroutine explain: called CC=1 SCAR=0.0
Pod documented
46 4 return 'Regular expression or replacement string delimiter';
47 }
48  
49 =head2 perl_version_introduced
50  
51 Experimentation with weird delimiters shows that they did not actually
52 work until Perl 5.8.3, so we return C<'5.008003'> for such delimiters.
53  
54 =cut
55  
56 124 ▶sub perl_version_introduced {
Subroutine perl_version_introduced: called CC=2 SCAR=6.9
Pod documented
57 124 my ( $self ) = @_;
58 124 ▶ $self->content() =~ m/ \A [[:^ascii:]] \z /smx
Branch: 1 branch
BranchTrueFalseTotal
$self->content =~ / \A [[:^ascii:]] \z /msx and return "5.008003" 5 119 124
59 and return '5.008003';
60 119 return MINIMUM_PERL;
61 }
62  
63 =head2 perl_version_removed
64  
65 Perl 5.29.0 made fatal the use of non-standalone graphemes as regular
66 expression delimiters. Because non-characters and permanently unassigned
67 code points are still allowed per F<perldeprecation>, I take this to
68 mean characters that match C</\p{Mark}/> (i.e. combining diacritical
69 marks). But this regular expression does not compile under Perl 5.6.
70  
71 So:
72  
73 This method returns C<'5.029'> for such delimiters B<provided> the
74 requisite regular expression compiles. Otherwise it return C<undef>.
75  
76 =cut
77  
78 # Perl 5.29.0 disallows unassigned code points and combining code points
79 # as delimiters. Unfortunately for me non-characters and illegal
80 # characters are explicitly allowed. Still more unfortunately, these
81 # match /\p{Unassigned}/. So before I match a deprecated characer, I
82 # have to assert that the character is neither a non-character
83 # (\p{Noncharacter_code_point}) nor an illegal Unicode character
84 # (\P{Any}).
85 9 ▶use constant WEIRD_CHAR_RE => eval ## no critic (ProhibitStringyEval,RequireCheckingReturnValueOfEval)
Subroutine BEGIN: called CC=1 SCAR=0.0
86 'qr<
87 (?! [\p{Noncharacter_code_point}\P{Any}] )
88 [\p{Unassigned}\p{Mark}]
89 9 >smx';
90  
91 127 ▶sub perl_version_removed {
Subroutine perl_version_removed: called CC=2 SCAR=6.9
Pod documented
92 127 my ( $self ) = @_;
93 127 ▶ WEIRD_CHAR_RE
Branch: 1 branch
BranchTrueFalseTotal
$self->content =~ / (?! [\p{Noncharacter_code_point}\P{Any}] ) [\p{Unassigned}\p{Mark}] /msx and return "5.029" 1 126 127
94 and $self->content() =~ WEIRD_CHAR_RE
95 and return '5.029';
96 # I respectfully disagree with Perl Best Practices on the
97 # following. When this method is called in list context it MUST
98 # return undef if that's the right answer, NOT an empty list.
99 # Otherwise hash constructors have the wrong number of elements.
100 126 return undef; ## no critic (ProhibitExplicitReturnUndef)
101 }
102  
103 9 1;
104  
105 __END__
« Regexp/Token/Backtrack.pm ↑ Summary Regexp/Constant.pm »