Highlife/Rule/Choice.pm

filter: Statementstmt 32.2% 10 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 2 totaltotal 28.8% 13 / 45 CC 5 SCAR 27.5
CC
5
Cov
27%
parse_from_token
30.0
new
2.0
_init
2.0
CRAP 15.7
« Highlife/Rule/Repetition.pm ↑ Summary Highlife/Rule/Sequence.pm »
1 package Parse::Highlife::Rule::Choice;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(Parse::Highlife::Rule);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Parse::Highlife::Utils qw(params);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub new
8 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my( $class, @args ) = @_;
10 0 my $self = bless Parse::Highlife::Rule->new( @args ), $class;
11 0 return $self -> _init( @args );
12 }
13  
14 sub _init
15 0 ▶{
Subroutine _init: not called CC=1 SCAR=6.9
16 0 my( $self, $choice )
17 = params( \@_,
18 -choice => [],
19 );
20 0 $self->{'choice'} = $choice;
21 0 return $self;
22 }
23  
24 sub parse_from_token
25 0 ▶{
Subroutine parse_from_token: not called CC=5 SCAR=34.0
Pod undocumented
26 0 my( $self, $parser, $tokens, $t ) = @_;
27 0 ▶ return (0,0,0) if $t >= scalar(@{$tokens});
Branch: 1 branch
BranchTrueFalseTotal
if $t >= scalar @{$tokens;} 0 0 0
28  
29 # - try to parse one sub-rule after another
30 # - return result on first success
31 # - if no success: return failure
32  
33 0 my $_t;
34 0 my ($_status, $_result);
35 0 foreach my $subrulename (@{$self->{'choice'}}) {
36 0 my $subrule = $parser->get_rule( $subrulename );
37 0 $_t = $t;
38 0 ($_t) = $self->_parse_ignored_tokens( $tokens, $_t );
39 0 ($_status, $_t, $_result) = $subrule->wrap_parse_from_token( $parser, $tokens, $_t );
40 0 ▶ last if $_status;
Branch: 1 branch
BranchTrueFalseTotal
if $_status 0 0 0
41 }
42  
43 0 ▶ if( $_status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_status) 0 0 0
44 return (
45 1,
46 $_t,
47 0 $parser->make_ast_element('group', $self->{'name'}, [ $_result ])
48 );
49 }
50 0 return (0,0,0);
51 }
52  
53 1 1;
« Highlife/Rule/Repetition.pm ↑ Summary Highlife/Rule/Sequence.pm »