File Coverage

blib/lib/PPIx/Regexp/Token/Comment.pm
Criterion Covered Total %
statement 16 17 94.1
branch n/a
condition n/a
subroutine 8 9 88.8
pod 4 4 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
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 is a
14             L.
15              
16             C 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     9   61 use strict;
  9         22  
  9         273  
33 9     9   49 use warnings;
  9         21  
  9         281  
34              
35 9     9   52 use base qw{ PPIx::Regexp::Token };
  9         29  
  9         962  
36              
37 9     9   64 use PPIx::Regexp::Constant qw{ @CARP_NOT };
  9         21  
  9         1987  
38              
39             our $VERSION = '0.088';
40              
41             # Return true if the token can be quantified, and false otherwise
42 0     0 1 0 sub can_be_quantified { return };
43              
44             sub significant {
45 43     43 1 113 return;
46             }
47              
48             sub comment {
49 1     1 1 4 return 1;
50             }
51              
52             sub explain {
53 1     1 1 4 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             sub __PPIX_TOKEN__recognize {
63 9     9   59 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             1;
83              
84             __END__