Babble/Plugin/SKT.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 92.3% 24 / 26 CC 2 SCAR 3.4
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
extend_grammar
1.0
CRAP 1.4
« Babble/Plugin/Sigify.pm ↑ Summary Babble/Plugin/PackageVersion.pm »
1 package Babble::Plugin::SKT;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶sub extend_grammar {
Subroutine extend_grammar: called CC=1 SCAR=0.0
Pod undocumented
6 1 my ($self, $g) = @_;
7 1 $g->add_rule(TryCatch =>
8 'try(?&PerlOWS)(?&PerlBlock)'
9 .'(?:(?&PerlOWS)catch(?&PerlOWS)(?&PerlBlock))?+'
10 );
11 1 $g->augment_rule(Statement => '(?&PerlTryCatch)');
12 }
13  
14 3 ▶sub transform_to_plain {
Subroutine transform_to_plain: called CC=1 SCAR=0.0
Pod undocumented
15 3 my ($self, $top) = @_;
16 3 $top->remove_use_statement('Syntax::Keyword::Try');
17 $top->each_match_within(TryCatch => [
18 'try(?&PerlOWS)', [ try_block => '(?&PerlBlock)' ],
19 '(?:(?&PerlOWS)catch(?&PerlOWS)', [ catch_block => '(?&PerlBlock)' ], ')?+'
20 3 ▶ ] => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
21 3 my ($m) = @_;
22 3 my ($try, $catch) = $m->subtexts(qw(try_block catch_block));
23 3 my $text = do {
24 3 ▶ if ($catch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($catch) { } 1 2 3
25 1 $try =~ s/\s*}$/; 1 }/;
26 1 'unless (eval '.$try.') '.$catch;
27 } else {
28 2 'eval '.$try;
29 }
30 };
31 3 $m->replace_text('{ local $@; '.$text.' }');
32 3 });
33 }
34  
35 1 1;
36 __END__
« Babble/Plugin/Sigify.pm ↑ Summary Babble/Plugin/PackageVersion.pm »