| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# (c) Parse::Eyapp Copyright 2006-2008 Casiano Rodriguez-Leon, all rights reserved. |
|
2
|
|
|
|
|
|
|
package Parse::Eyapp::_TreeregexpSupport; |
|
3
|
27
|
|
|
27
|
|
155
|
use strict; |
|
|
27
|
|
|
|
|
518
|
|
|
|
27
|
|
|
|
|
962
|
|
|
4
|
27
|
|
|
27
|
|
141
|
use Carp; |
|
|
27
|
|
|
|
|
56
|
|
|
|
27
|
|
|
|
|
1884
|
|
|
5
|
27
|
|
|
27
|
|
191
|
use Parse::Eyapp::Node; |
|
|
27
|
|
|
|
|
60
|
|
|
|
27
|
|
|
|
|
701
|
|
|
6
|
27
|
|
|
27
|
|
171
|
use base qw (Exporter); |
|
|
27
|
|
|
|
|
59
|
|
|
|
27
|
|
|
|
|
12998
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(until_first_match checknumchildren); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
################### Support routines ######################### |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# used whith array patterns |
|
12
|
|
|
|
|
|
|
# index of the children to start |
|
13
|
|
|
|
|
|
|
# $b recognizer treereg |
|
14
|
|
|
|
|
|
|
# $r reference to an array where children that don't match are pushed |
|
15
|
|
|
|
|
|
|
sub until_first_match { |
|
16
|
83
|
|
|
83
|
0
|
152
|
my ($father, $order, $b, $r) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
83
|
50
|
|
|
|
362
|
return undef unless UNIVERSAL::can($father, 'children'); |
|
19
|
83
|
|
|
|
|
258
|
for ($order..0+$father->children()) { |
|
20
|
148
|
|
|
|
|
438
|
my $t = $father->child($_); |
|
21
|
148
|
100
|
|
|
|
4042
|
return $t if ($b->($t)); |
|
22
|
127
|
|
|
|
|
351
|
push @$r, $t; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
62
|
|
|
|
|
1968
|
return undef; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub checknumchildren { |
|
28
|
4
|
|
|
4
|
0
|
21
|
my ($self, $numexpected, $line, $filename, $there_are_lists, $severity) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
15
|
my $numchildren = $self->children; |
|
31
|
4
|
50
|
33
|
|
|
84
|
return 1 if ($numchildren == $numexpected) or ($there_are_lists and $numchildren >= $numexpected); |
|
|
|
|
66
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
return 0 unless ($severity > 1); |
|
34
|
0
|
|
|
|
|
|
my $class = ref($self); |
|
35
|
0
|
0
|
|
|
|
|
my $clause = $there_are_lists? ' at least' : ''; |
|
36
|
0
|
|
|
|
|
|
my $warnmessage =<<"END_OF_WARN_MESSAGE"; |
|
37
|
|
|
|
|
|
|
found node $class with $numchildren children. |
|
38
|
|
|
|
|
|
|
Expected$clause $numexpected children (see line $line of $filename)" |
|
39
|
|
|
|
|
|
|
END_OF_WARN_MESSAGE |
|
40
|
0
|
0
|
|
|
|
|
croak "Error! $warnmessage" if $severity > 2; |
|
41
|
0
|
|
|
|
|
|
warn "Warning! $warnmessage"; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return 0; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |