/usr/share/perl5/PPI/Token/Comment.pm is in libppi-perl 1.220-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | package PPI::Token::Comment;
=pod
=head1 NAME
PPI::Token::Comment - A comment in Perl source code
=head1 INHERITANCE
PPI::Token::Comment
isa PPI::Token
isa PPI::Element
=head1 SYNOPSIS
# This is a PPI::Token::Comment
print "Hello World!"; # So it this
$string =~ s/ foo # This, unfortunately, is not :(
bar
/w;
=head1 DESCRIPTION
In PPI, comments are represented by C<PPI::Token::Comment> objects.
These come in two flavours, line comment and inline comments.
A C<line comment> is a comment that stands on its own line. These comments
hold their own newline and whitespace (both leading and trailing) as part
of the one C<PPI::Token::Comment> object.
An inline comment is a comment that appears after some code, and
continues to the end of the line. This does B<not> include whitespace,
and the terminating newlines is considered a separate
L<PPI::Token::Whitespace> token.
This is largely a convenience, simplifying a lot of normal code relating
to the common things people do with comments.
Most commonly, it means when you C<prune> or C<delete> a comment, a line
comment disappears taking the entire line with it, and an inline comment
is removed from the inside of the line, allowing the newline to drop
back onto the end of the code, as you would expect.
It also means you can move comments around in blocks much more easily.
For now, this is a suitably handy way to do things. However, I do reserve
the right to change my mind on this one if it gets dangerously
anachronistic somewhere down the line.
=head1 METHODS
Only very limited methods are available, beyond those provided by our
parent L<PPI::Token> and L<PPI::Element> classes.
=cut
use strict;
use PPI::Token ();
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.220';
@ISA = 'PPI::Token';
}
### XS -> PPI/XS.xs:_PPI_Token_Comment__significant 0.900+
sub significant() { '' }
# Most stuff goes through __TOKENIZER__commit.
# This is such a rare case, do char at a time to keep the code small
sub __TOKENIZER__on_char {
my $t = $_[1];
# Make sure not to include the trailing newline
if ( substr( $t->{line}, $t->{line_cursor}, 1 ) eq "\n" ) {
return $t->_finalize_token->__TOKENIZER__on_char( $t );
}
1;
}
sub __TOKENIZER__commit {
my $t = $_[1];
# Get the rest of the line
my $rest = substr( $t->{line}, $t->{line_cursor} );
if ( chomp $rest ) { # Include the newline separately
# Add the current token, and the newline
$t->_new_token('Comment', $rest);
$t->_new_token('Whitespace', "\n");
} else {
# Add this token only
$t->_new_token('Comment', $rest);
}
# Advance the line cursor to the end
$t->{line_cursor} = $t->{line_length} - 1;
0;
}
# Comments end at the end of the line
sub __TOKENIZER__on_line_end {
$_[1]->_finalize_token if $_[1]->{token};
1;
}
=pod
=head2 line
The C<line> accessor returns true if the C<PPI::Token::Comment> is a
line comment, or false if it is an inline comment.
=cut
sub line {
# Entire line comments have a newline at the end
$_[0]->{content} =~ /\n$/ ? 1 : 0;
}
1;
=pod
=head1 SUPPORT
See the L<support section|PPI/SUPPORT> in the main module.
=head1 AUTHOR
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
=head1 COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
|