1 package Filter::Keyword::Filter;
4 use Filter::Keyword::Parser;
5 use Filter::Util::Call;
6 use Scalar::Util qw(weaken);
7 use B::Hooks::EndOfScope;
9 use constant DEBUG => $ENV{FILTER_KEYWORD_DEBUG};
10 use constant DEBUG_VERBOSE => DEBUG && $ENV{FILTER_KEYWORD_DEBUG} > 1;
12 has parser => (is => 'lazy');
13 has active => (is => 'rwp', default => 0);
18 Filter::Keyword::Parser->new(
19 reader => sub { $_ = ''; my $r = filter_read; ($_, $r) },
21 DEBUG_VERBOSE && print STDERR "#re-add#";
31 return if $self->active;
32 push @ACTIVE_FILTERS, $self;
33 $self->_set_active(1);
36 $self->_set_active(0);
45 my ($string, $code) = $self->parser->get_next;
47 DEBUG && print $string;