Regexp/Token/Comment.pm

filter: Statementstmt 94.7% 18 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 4 / 4 totaltotal 93.7% 30 / 32 CC 1 SCAR 1.1
CC
1
Cov
95%
can_be_quantified
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Regexp/Structure/Replacement.pm ↑ Summary Regexp/Node/Unknown.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Token::Comment - Represent a comment.
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo(?#bar)}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Token::Comment> is a
14 L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15  
16 C<PPIx::Regexp::Token::Comment> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This class represents a comment - both parenthesized comments (i.e.
21 C<< (?# this is a comment ) >> and the /x mode end-of-line comments.
22  
23 =head1 METHODS
24  
25 This class provides no public methods beyond those provided by its
26 superclass.
27  
28 =cut
29  
30 package PPIx::Regexp::Token::Comment;
31  
32 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 9 ▶use base qw{ PPIx::Regexp::Token };
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 9 ▶use PPIx::Regexp::Constant qw{ @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 9 our $VERSION = '0.092';
40  
41 # Return true if the token can be quantified, and false otherwise
42 0 ▶sub can_be_quantified { return };
Subroutine can_be_quantified: not called CC=1 SCAR=6.9
Pod documented
43  
44 43 ▶sub significant {
Subroutine significant: called CC=1 SCAR=0.0
Pod documented
45 43 return;
46 }
47  
48 1 ▶sub comment {
Subroutine comment: called CC=1 SCAR=0.0
Pod documented
49 1 return 1;
50 }
51  
52 1 ▶sub explain {
Subroutine explain: called CC=1 SCAR=0.0
Pod documented
53 1 return 'Comment';
54 }
55  
56 # This must be implemented by tokens which do not recognize themselves.
57 # The return is a list of list references. Each list reference must
58 # contain a regular expression that recognizes the token, and optionally
59 # a reference to a hash to pass to make_token as the class-specific
60 # arguments. The regular expression MUST be anchored to the beginning of
61 # the string.
62 9 ▶sub __PPIX_TOKEN__recognize {
Subroutine __PPIX_TOKEN__recognize: called CC=1 SCAR=0.0
63 9 return ( [ qr{ \A \( \? \# [^\)]* \) }smx ] );
64 }
65  
66 # We anticipate that these tokens will be generated by other classes:
67 # PPIx::Regexp::Token::Structure for parenthesized comments, and
68 # PPIx::Regexp::Token::Literal for end-of-line /x mode comments.
69  
70 =begin comment
71  
72 sub __PPIX_TOKENIZER__regexp {
73 my ( $class, $tokenizer, $character ) = @_;
74  
75 return $character eq 'x' ? 1 : 0;
76 }
77  
78 =end comment
79  
80 =cut
81  
82 9 1;
83  
84 __END__
« Regexp/Structure/Replacement.pm ↑ Summary Regexp/Node/Unknown.pm »