| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 83 | for ($order..0+$father->children()) { | |||||||||||||||||||||||||||||||||||||||||
| 26 | 148 | my $t = $father->child($_); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 148 | ▶ | return $t if ($b->($t)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%3/6
$numchildren == $numexpected or $there_are_lists and $numchildren >= $numexpected
$there_are_lists and $numchildren >= $numexpected
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
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return 0 unless ($severity > 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $clause = $there_are_lists? ' at least' : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | warn "Warning! $warnmessage"; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||||||||||||||||