Highlife/Rule.pm

filter: Statementstmt 23.2% 10 / 43 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 3 totaltotal 17.8% 13 / 73 CC 10 SCAR 36.0
CC
10
Cov
17%
wrap_parse_from_token
72.0
_parse_ignored_tokens
12.0
new
2.0
CRAP 36.5
« Highlife/Token/Delimited.pm ↑ Summary Highlife/Token/Characters.pm »
1 package Parse::Highlife::Rule;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Parse::Highlife::Utils qw(params);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Data::Dump qw(dump);
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 {}, $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, $name )
17 = params( \@_,
18 -name => '',
19 );
20 0 $self->{'name'} = $name;
21 0 return $self;
22 }
23  
24 # abstract
25 0 ▶sub parse_from_token { return (0,0,0) }
Subroutine parse_from_token: not called CC=1 SCAR=6.9
Pod undocumented
26  
27 sub wrap_parse_from_token
28 0 ▶{
Subroutine wrap_parse_from_token: not called CC=8 SCAR=42.8
Pod undocumented
29 0 my( $self, $parser, $tokens, $t ) = @_;
30 #return (0,0,0) if $t >= scalar(@{$tokens});
31
32 0 ▶ if( $parser->{'debug'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->{"debug"}) 0 0 0
33 0 my $classname = ref $self;
34 0 $classname =~ s/^.*\://g;
35 0 my $_t = $t;
36 0 ($_t) = $self->_parse_ignored_tokens( $tokens, $_t );
37 0 ▶ print ''.('| ' x $parser->{'current-indent'})."try rule <$self->{name}> as $classname from token #$_t'".($tokens->[$_t] ? $tokens->[$_t]->{'matched-substring'} : '<out-of-range>')."'\n";
Branch: 1 branch
BranchTrueFalseTotal
$tokens->[$_t] ? : 0 0 0
38 0 $parser->{'current-indent'} ++;
39 }
40
41 0 my @result = $self->parse_from_token( $parser, $tokens, $t );
42
43 0 ▶ if( $parser->{'debug'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->{"debug"}) 0 0 0
44 0 $parser->{'current-indent'} --;
45 0 ▶ print ''.('| ' x $parser->{'current-indent'}).( $result[0] ? "MATCH <$self->{name}>" : '^' )."\n";
Branch: 1 branch
BranchTrueFalseTotal
$result[0] ? : 0 0 0
46 }
47 #my $in = <STDIN>;
48  
49 0 my $ast = $result[2];
50 0 ▶ if( ref $ast eq 'HASH' && $ast->{'category'} eq 'group' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ast eq "HASH" and $ast->{"category"} eq "group") 0 0 0
Condition0%0/3
ref $ast eq "HASH" and $ast->{"category"} eq "group"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $ast eq "HASH" and $ast->{"category"} eq "group"
ref $ast eq "HASH" $ast->{"category"} eq "group"
Truth table0%0/3
A and B
A= ref $ast eq "HASH"B= $ast->{"category"} eq "group"
ABresult
0X0
100
111
51 0 foreach my $child (@{$ast->{'children'}}) {
52 0 $child->{'parent'} = $ast;
53 0 $child->{'parent-id'} = $ast->{'id'};
54 }
55 }
56 0 return @result;
57 }
58  
59 sub _parse_ignored_tokens
60 0 ▶{
Subroutine _parse_ignored_tokens: not called CC=3 SCAR=24.8
61 0 my( $self, $tokens, $offset ) = @_;
62 0 my $t = $offset;
63 0 ▶ while( $t < scalar @{$tokens} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t < scalar @{$tokens;}) 0 0 0
64 0 ▶ last unless $tokens->[$t]->{'is-ignored'};
Branch: 1 branch
BranchTrueFalseTotal
unless $tokens->[$t]{"is-ignored"} 0 0 0
65 0 $t++;
66 }
67 0 return ($t); # t = new offset after parsed stuff
68 }
69  
70 1 1;
« Highlife/Token/Delimited.pm ↑ Summary Highlife/Token/Characters.pm »