Subject: | Regexp::Grammars does not clear RULE_HANDLER properly after match fails |
#!/usr/bin/env perl
use v5.20;
package MyAction {
sub new {
return bless {}, shift;
}
sub text {
my ($self, $result) = @_;
warn "\n-->auto action is called";
return $result;
}
}
my $test_grammar = do {
use Regexp::Grammars;
qr{
<text>
<rule: text> \w+
}x;
};
say "auto action should be called";
"abc_test" =~ $test_grammar->with_actions(MyAction->new);
say;
say "no auto action provided, so auto action will not ba called";
"abc_test" =~ $test_grammar;
say;
say "match fail, so auto action should not ba called";
'$$$' =~ $test_grammar->with_actions(MyAction->new);
say;
say "no auto action provided, so auto action should not ba called";
say "However, becuase the RULE_HANLDLER is not cleared, after match, auto action is called";
"abc_test" =~ $test_grammar
__DATA__
perl -v
This is perl 5, version 20, subversion 0 (v5.20.0) built for x86_64-linux
perl -MRegexp::Grammars -E 'say $Regexp::Grammars::VERSION'
1.036