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<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     9   54 use strict;
  9         16  
  9         286  
33 9     9   34 use warnings;
  9         12  
  9         420  
34              
35 9     9   38 use base qw{ PPIx::Regexp::Token };
  9         23  
  9         730  
36              
37 9     9   44 use PPIx::Regexp::Constant qw{ @CARP_NOT };
  9         13  
  9         2104  
38              
39             our $VERSION = '0.091';
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 83 return;
46             }
47              
48             sub comment {
49 1     1 1 2 return 1;
50             }
51              
52             sub explain {
53 1     1 1 3 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   54 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__
85              
86             =head1 SUPPORT
87              
88             Support is by the author. Please file bug reports at
89             L<https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
90             L<https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in
91             electronic mail to the author.
92              
93             =head1 AUTHOR
94              
95             Thomas R. Wyant, III F<wyant at cpan dot org>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             Copyright (C) 2009-2023, 2025 by Thomas R. Wyant, III
100              
101             This program is free software; you can redistribute it and/or modify it
102             under the same terms as Perl 5.10.0. For more details, see the full text
103             of the licenses in the directory LICENSES.
104              
105             This program is distributed in the hope that it will be useful, but
106             without any warranty; without even the implied warranty of
107             merchantability or fitness for a particular purpose.
108              
109             =cut
110              
111             # ex: set textwidth=72 :