Eyapp/_TreeregexpSupport.pm

filter: Statementstmt 77.4% 24 / 31 Branchbran 33.3% 4 / 12 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 61.6% 37 / 60 CC 10 SCAR 25.4
CC
10
Cov
63%
checknumchildren
24.4
until_first_match
4.0
BEGIN
1.0
CRAP 12.7
« Eyapp/Treeregexp.pm ↑ Summary Eyapp/Output.pm »
1 # Copyright © 2006, 2007, 2008, 2009, 2010, 2011, 2012 Casiano Rodriguez-Leon.
2 # Copyright © 2017 William N. Braswell, Jr.
3 # All Rights Reserved.
4 #
5 # Parse::Yapp is Copyright © 1998, 1999, 2000, 2001, Francois Desarmenien.
6 # Parse::Yapp is Copyright © 2017 William N. Braswell, Jr.
7 # All Rights Reserved.
8 package Parse::Eyapp::_TreeregexpSupport;
9 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 27 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 27 ▶use Parse::Eyapp::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 27 ▶use base qw (Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 27 our @EXPORT_OK = qw(until_first_match checknumchildren);
14  
15 ################### Support routines #########################
16  
17 # used whith array patterns
18 # index of the children to start
19 # $b recognizer treereg
20 # $r reference to an array where children that don't match are pushed
21 83 ▶sub until_first_match {
Subroutine until_first_match: called CC=4 SCAR=13.9
Pod undocumented
22 83 my ($father, $order, $b, $r) = @_;
23  
24 83 ▶ return undef unless UNIVERSAL::can($father, 'children');
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::can($father, "children") 0 83 83
25 83 for ($order..0+$father->children()) {
26 148 my $t = $father->child($_);
27 148 ▶ return $t if ($b->($t));
Branch: 1 branch
BranchTrueFalseTotal
if &$b($t) 21 127 148
28 127 push @$r, $t;
29 }
30 62 return undef;
31 }
32  
33 4 ▶sub checknumchildren {
Subroutine checknumchildren: called CC=7 SCAR=32.0
Pod undocumented
34 4 my ($self, $numexpected, $line, $filename, $there_are_lists, $severity) = @_;
35
36 4 my $numchildren = $self->children;
37 4 ▶ return 1 if ($numchildren == $numexpected) or ($there_are_lists and $numchildren >= $numexpected);
Branch: 1 branch
BranchTrueFalseTotal
if $numchildren == $numexpected or $there_are_lists and $numchildren >= $numexpected 4 0 4
Condition50%3/6
$numchildren == $numexpected or $there_are_lists and $numchildren >= $numexpected
l!l&&r!l&&!r
220
$there_are_lists and $numchildren >= $numexpected
!ll&&!rl&&r
002
MC/DC0%0/3
$numchildren == $numexpected or $there_are_lists and $numchildren >= $numexpected
$numchildren == $numexpected $there_are_lists $numchildren >= $numexpected
Truth table50%2/4
A or B and C
A= $numchildren == $numexpectedB= $there_are_listsC= $numchildren >= $numexpected
ABCresult
1XX1
0111
00X0
0100
38  
39 0 ▶ return 0 unless ($severity > 1);
Branch: 1 branch
BranchTrueFalseTotal
unless $severity > 1 0 0 0
40 0 my $class = ref($self);
41 0 ▶ my $clause = $there_are_lists? ' at least' : '';
Branch: 1 branch
BranchTrueFalseTotal
$there_are_lists ? : 0 0 0
42 0 my $warnmessage =<<"END_OF_WARN_MESSAGE";
43 found node $class with $numchildren children.
44 Expected$clause $numexpected children (see line $line of $filename)"
45 END_OF_WARN_MESSAGE
46 0 ▶ croak "Error! $warnmessage" if $severity > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $severity > 2 0 0 0
47 0 warn "Warning! $warnmessage";
48  
49 0 return 0;
50 }
51  
52 27 1;
53  
54  
55 __END__
« Eyapp/Treeregexp.pm ↑ Summary Eyapp/Output.pm »