line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
27
|
|
258
|
use strict; |
|
27
|
|
|
|
|
65
|
|
|
27
|
|
|
|
|
700
|
|
10
|
27
|
|
|
27
|
|
134
|
use Carp; |
|
27
|
|
|
|
|
58
|
|
|
27
|
|
|
|
|
1194
|
|
11
|
27
|
|
|
27
|
|
156
|
use Parse::Eyapp::Node; |
|
27
|
|
|
|
|
59
|
|
|
27
|
|
|
|
|
607
|
|
12
|
27
|
|
|
27
|
|
130
|
use base qw (Exporter); |
|
27
|
|
|
|
|
60
|
|
|
27
|
|
|
|
|
8705
|
|
13
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub until_first_match { |
22
|
83
|
|
|
83
|
0
|
177
|
my ($father, $order, $b, $r) = @_; |
23
|
|
|
|
|
|
|
|
24
|
83
|
50
|
|
|
|
295
|
return undef unless UNIVERSAL::can($father, 'children'); |
25
|
83
|
|
|
|
|
229
|
for ($order..0+$father->children()) { |
26
|
148
|
|
|
|
|
383
|
my $t = $father->child($_); |
27
|
148
|
100
|
|
|
|
2649
|
return $t if ($b->($t)); |
28
|
127
|
|
|
|
|
471
|
push @$r, $t; |
29
|
|
|
|
|
|
|
} |
30
|
62
|
|
|
|
|
1249
|
return undef; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub checknumchildren { |
34
|
4
|
|
|
4
|
0
|
27
|
my ($self, $numexpected, $line, $filename, $there_are_lists, $severity) = @_; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
16
|
my $numchildren = $self->children; |
37
|
4
|
50
|
33
|
|
|
62
|
return 1 if ($numchildren == $numexpected) or ($there_are_lists and $numchildren >= $numexpected); |
|
|
|
66
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
return 0 unless ($severity > 1); |
40
|
0
|
|
|
|
|
|
my $class = ref($self); |
41
|
0
|
0
|
|
|
|
|
my $clause = $there_are_lists? ' at least' : ''; |
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
|
0
|
|
|
|
|
croak "Error! $warnmessage" if $severity > 2; |
47
|
0
|
|
|
|
|
|
warn "Warning! $warnmessage"; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |