/usr/share/perl5/PPIx/Regexp/Token/GroupType.pm is in libppix-regexp-perl 0.036-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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | =head1 NAME
PPIx::Regexp::Token::GroupType - Represent a grouping parenthesis type.
=head1 SYNOPSIS
use PPIx::Regexp::Dumper;
PPIx::Regexp::Dumper->new( 'qr{(?i:foo)}smx' )
->print();
=head1 INHERITANCE
C<PPIx::Regexp::Token::GroupType> is a
L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
C<PPIx::Regexp::Token::GroupType> is the parent of
L<PPIx::Regexp::Token::GroupType::Assertion|PPIx::Regexp::Token::GroupType::Assertion>,
L<PPIx::Regexp::Token::GroupType::BranchReset|PPIx::Regexp::Token::GroupType::BranchReset>,
L<PPIx::Regexp::Token::GroupType::Code|PPIx::Regexp::Token::GroupType::Code>,
L<PPIx::Regexp::Token::GroupType::Modifier|PPIx::Regexp::Token::GroupType::Modifier>,
L<PPIx::Regexp::Token::GroupType::NamedCapture|PPIx::Regexp::Token::GroupType::NamedCapture>,
L<PPIx::Regexp::Token::GroupType::Subexpression|PPIx::Regexp::Token::GroupType::Subexpression>
and
L<PPIx::Regexp::Token::GroupType::Switch|PPIx::Regexp::Token::GroupType::Switch>.
=head1 DESCRIPTION
This class represents any of the magic sequences of characters that can
follow an open parenthesis. This particular class is intended to be
abstract.
=head1 METHODS
This class provides no public methods beyond those provided by its
superclass.
=cut
package PPIx::Regexp::Token::GroupType;
use strict;
use warnings;
use base qw{ PPIx::Regexp::Token };
our $VERSION = '0.036';
# Return true if the token can be quantified, and false otherwise
sub can_be_quantified { return };
=head2 __defining_string
my $string = $class->__defining_string();
This method is private to the C<PPIx-Regexp> package, and is documented
for the author's benefit only. It may be changed or revoked without
notice.
This method returns an array of strings that define the specific group
type. These strings will normally start with C<'?'>.
Optionally, the first returned item may be a hash reference. The only
supported key is C<{suffix}>, which is a string to be suffixed to each
of the regular expressions made by C<__make_group_type_matcher()> out of
the defining strings, inside a C<(?= ... )>, so that it is not included
in the match.
This method B<must> be overridden, unless C<__make_group_type_matcher()>
is.
=cut
sub __defining_string {
require Carp;
Carp::confess(
'Programming error - __defining_string() must be overridden' );
}
=head2 __make_group_type_matcher
my $hash_ref = $class->__make_group_type_matcher();
This method is private to the C<PPIx-Regexp> package, and is documented
for the author's benefit only. It may be changed or revoked without
notice.
This method returns a reference to a hash. The keys are regexp delimiter
characters which appear in the defining strings for the group type. For
each key, the value is a reference to an array of C<Regexp> objects,
properly escaped for the key character. Key C<''> provides the regular
expressions to be used if the regexp delimiter does not appear in any of
the defining strings.
If this method is overridden by the subclass, method
C<__defining_string()> need not be, unless the overridden
C<__make_group_type_matcher()> calls C<__defining_string()>.
=cut
sub __make_group_type_matcher {
my ( $class ) = @_;
my @defs = $class->__defining_string();
my $opt = ref $defs[0] ? shift @defs : {};
my $suffix = defined $opt->{suffix} ?
qr/ (?= \Q$opt->{suffix}\E ) /smx :
'';
my %rslt;
foreach my $str ( $class->__defining_string() ) {
my %seen;
my @chars = grep { ! $seen{$_}++ } split qr{}smx, $str;
push @{ $rslt{''} ||= [] }, qr{ \A \Q$str\E $suffix }smx;
foreach my $chr ( @chars ) {
( my $expr = $str ) =~ s/ (?= \Q$chr\E ) /\\/smxg;
push @{ $rslt{$chr} ||= [] }, qr{ \A \Q$expr\E $suffix }smx;
}
}
return \%rslt;
}
=head2 __match_setup
$class->__match_setup( $tokenizer );
This method is private to the C<PPIx-Regexp> package, and is documented
for the author's benefit only. It may be changed or revoked without
notice.
This method performs whatever setup is needed once it is determined that
the given group type has been detected. This method is called only if
the class matched at the current position in the string being parsed. It
must perform whatever extra setup is needed for the match. It returns
nothing.
This method need not be overridden. The default does nothing.
=cut
sub __match_setup {
return;
}
my %matcher;
sub __PPIX_TOKENIZER__regexp {
my ( $class, $tokenizer, $character ) = @_;
my $mtch = $matcher{$class} ||= $class->__make_group_type_matcher();
my $re_list = $mtch->{ $tokenizer->get_start_delimiter() } ||
$mtch->{''};
foreach my $re ( @{ $re_list } ) {
my $accept = $tokenizer->find_regexp( $re )
or next;
$class->__match_setup( $tokenizer );
return $accept;
}
return;
}
1;
__END__
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<http://rt.cpan.org>, or in electronic mail to the author.
=head1 AUTHOR
Thomas R. Wyant, III F<wyant at cpan dot org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009-2014 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
# ex: set textwidth=72 :
|