line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Babble::Plugin::SKT; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
69500
|
use Moo; |
|
1
|
|
|
|
|
7204
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub extend_grammar { |
6
|
1
|
|
|
1
|
0
|
1685
|
my ($self, $g) = @_; |
7
|
1
|
|
|
|
|
4
|
$g->add_rule(TryCatch => |
8
|
|
|
|
|
|
|
'try(?&PerlOWS)(?&PerlBlock)' |
9
|
|
|
|
|
|
|
.'(?:(?&PerlOWS)catch(?&PerlOWS)(?&PerlBlock))?+' |
10
|
|
|
|
|
|
|
); |
11
|
1
|
|
|
|
|
13
|
$g->augment_rule(Statement => '(?&PerlTryCatch)'); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub transform_to_plain { |
15
|
3
|
|
|
3
|
0
|
1715
|
my ($self, $top) = @_; |
16
|
3
|
|
|
|
|
16
|
$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
|
|
|
|
|
|
|
] => sub { |
21
|
3
|
|
|
3
|
|
11
|
my ($m) = @_; |
22
|
3
|
|
|
|
|
20
|
my ($try, $catch) = $m->subtexts(qw(try_block catch_block)); |
23
|
3
|
|
|
|
|
8
|
my $text = do { |
24
|
3
|
100
|
|
|
|
12
|
if ($catch) { |
25
|
1
|
|
|
|
|
7
|
$try =~ s/\s*}$/; 1 }/; |
26
|
1
|
|
|
|
|
6
|
'unless (eval '.$try.') '.$catch; |
27
|
|
|
|
|
|
|
} else { |
28
|
2
|
|
|
|
|
10
|
'eval '.$try; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
}; |
31
|
3
|
|
|
|
|
63
|
$m->replace_text('{ local $@; '.$text.' }'); |
32
|
3
|
|
|
|
|
68
|
}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Babble::Plugin::SKT - Plugin to convert Syntax::Keyword::Try to eval |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SEE ALSO |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L<Syntax::Keyword::Try> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |