| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 44 | 0 | $parser->{'current-indent'} --; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | print ''.('| ' x $parser->{'current-indent'}).( $result[0] ? "MATCH <$self->{name}>" : '^' )."\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
ref $ast eq "HASH" and $ast->{"category"} eq "group"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | last unless $tokens->[$t]->{'is-ignored'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | $t++; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | return ($t); # t = new offset after parsed stuff | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | 1; | |||||||||||||||||||||||||||