use Package::Stash::PP;
use B qw(svref_2object);
use B::Hooks::EndOfScope;
+use Scalar::Util qw(set_prototype);
sub _compiling_file () {
my $depth = 0;
$self->globref_refcount(svref_2object($self->globref)->REFCNT);
}
+sub install_matcher {
+ my ($self, $post) = @_;
+ my $stash = $self->stash;
+ my $sub = sub {};
+ set_prototype(\&$sub, '*;@') unless $post eq '(';
+ { no warnings 'redefine', 'prototype'; *{$self->globref} = $sub; }
+ $self->save_refcount;
+}
+
sub have_match {
my ($self) = @_;
return 0 unless defined($self->globref_refcount);
package Filter::Keyword::Parser;
use Moo;
-use Scalar::Util qw(set_prototype);
-
has reader => (is => 'ro', required => 1);
has re_add => (is => 'ro', required => 1);
$keyword->keyword_name, qr/(\(|[A-Za-z][A-Za-z_0-9]*|{)/
)
) {
- my $sub = sub {};
- set_prototype(\&$sub, '*;@') unless $matches->[0] eq '(';
- { no warnings 'redefine'; *{$keyword->globref} = $sub; }
- $keyword->save_refcount;
+ $keyword->install_matcher($matches->[0]);
$self->current_match($matches);
$self->short_circuit(1);
return ($stripped, 1);