| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package PRANG::Graph::Seq; |
|
3
|
|
|
|
|
|
|
$PRANG::Graph::Seq::VERSION = '0.21'; |
|
4
|
11
|
|
|
11
|
|
1799
|
use Moose; |
|
|
11
|
|
|
|
|
24
|
|
|
|
11
|
|
|
|
|
71
|
|
|
5
|
11
|
|
|
11
|
|
71907
|
use MooseX::Params::Validate; |
|
|
11
|
|
|
|
|
31
|
|
|
|
11
|
|
|
|
|
99
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'members' => |
|
8
|
|
|
|
|
|
|
is => "ro", |
|
9
|
|
|
|
|
|
|
isa => "ArrayRef[PRANG::Graph::Node]", |
|
10
|
|
|
|
|
|
|
default => sub { [] }, |
|
11
|
|
|
|
|
|
|
; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub accept { |
|
14
|
252
|
|
|
252
|
0
|
444
|
my $self = shift; |
|
15
|
252
|
|
|
|
|
1287
|
my ( $node, $ctx, $lax ) = pos_validated_list( |
|
16
|
|
|
|
|
|
|
\@_, |
|
17
|
|
|
|
|
|
|
{ isa => 'XML::LibXML::Node' }, |
|
18
|
|
|
|
|
|
|
{ isa => 'PRANG::Graph::Context' }, |
|
19
|
|
|
|
|
|
|
{ isa => 'Bool' }, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
252
|
|
|
|
|
82805
|
my $pos = $ctx->seq_pos; |
|
23
|
252
|
|
|
|
|
447
|
my ($key, $val, $x, $ns, $member); |
|
24
|
252
|
|
|
|
|
370
|
do { |
|
25
|
535
|
|
|
|
|
12432
|
$member = $self->members->[$pos-1]; |
|
26
|
|
|
|
|
|
|
|
|
27
|
535
|
100
|
|
|
|
1291
|
if (! $member) { |
|
28
|
7
|
100
|
|
|
|
44
|
$ctx->exception("unexpected element", $node) |
|
29
|
|
|
|
|
|
|
unless $lax; |
|
30
|
3
|
|
|
|
|
13
|
return; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
528
|
|
|
|
|
1667
|
($key, $val, $x, $ns) = $member->accept($node, $ctx, $lax); |
|
34
|
|
|
|
|
|
|
|
|
35
|
513
|
100
|
100
|
|
|
1885
|
if (!$key or !$member->accept_many ) { |
|
36
|
377
|
|
|
|
|
9653
|
$ctx->seq_pos(++$pos); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} until ($key); |
|
39
|
230
|
|
|
|
|
1186
|
($key, $val, $x, $ns); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub complete { |
|
43
|
99
|
|
|
99
|
0
|
261
|
my $self = shift; |
|
44
|
99
|
|
|
|
|
463
|
my ( $ctx ) = pos_validated_list( |
|
45
|
|
|
|
|
|
|
\@_, |
|
46
|
|
|
|
|
|
|
{ isa => 'PRANG::Graph::Context' }, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
99
|
|
|
|
|
17891
|
my $pos = $ctx->seq_pos; |
|
50
|
99
|
|
|
|
|
326
|
my $member; |
|
51
|
|
|
|
|
|
|
my $done; |
|
52
|
99
|
|
|
|
|
272
|
while ( !$done ) { |
|
53
|
474
|
|
|
|
|
11111
|
$member = $self->members->[$pos-1]; |
|
54
|
474
|
100
|
100
|
|
|
1885
|
if ( $member and $member->complete($ctx) ) { |
|
55
|
375
|
|
|
|
|
9295
|
$ctx->seq_pos(++$pos); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
else { |
|
58
|
99
|
|
|
|
|
284
|
$done = 1; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
99
|
|
|
|
|
174
|
my $cmp = $pos-1 <=> @{$self->members}; |
|
|
99
|
|
|
|
|
2201
|
|
|
62
|
99
|
50
|
|
|
|
325
|
if ( $cmp == 1 ) { |
|
63
|
0
|
|
|
|
|
0
|
warn "Accepted too much!!"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
99
|
|
|
|
|
440
|
return ( $cmp != -1 ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub expected { |
|
69
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
|
70
|
2
|
|
|
|
|
12
|
my ( $ctx ) = pos_validated_list( |
|
71
|
|
|
|
|
|
|
\@_, |
|
72
|
|
|
|
|
|
|
{ isa => 'PRANG::Graph::Context' }, |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
866
|
my $pos = $ctx->seq_pos; |
|
76
|
2
|
|
|
|
|
58
|
my $member = $self->members->[$pos-1]; |
|
77
|
2
|
50
|
|
|
|
10
|
if ($member) { |
|
78
|
2
|
|
|
|
|
13
|
return $member->expected($ctx); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
else { |
|
81
|
0
|
|
|
|
|
0
|
return "er... nothing?"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub output { |
|
86
|
58
|
|
|
58
|
0
|
139
|
my $self = shift; |
|
87
|
58
|
|
|
|
|
361
|
my ( $item, $node, $ctx ) = pos_validated_list( |
|
88
|
|
|
|
|
|
|
\@_, |
|
89
|
|
|
|
|
|
|
{ isa => 'Item' }, |
|
90
|
|
|
|
|
|
|
{ isa => 'XML::LibXML::Element' }, |
|
91
|
|
|
|
|
|
|
{ isa => 'PRANG::Graph::Context' }, |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
|
|
94
|
58
|
|
|
|
|
18871
|
for my $member ( @{ $self->members } ) { |
|
|
58
|
|
|
|
|
1476
|
|
|
95
|
388
|
|
|
|
|
13907
|
$member->output($item,$node,$ctx); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
with 'PRANG::Graph::Node'; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
PRANG::Graph::Seq - a sequence of graph nodes |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
See L<PRANG::Graph::Meta::Element> source and |
|
112
|
|
|
|
|
|
|
L<PRANG::Graph::Node> for examples and information. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This graph node specifies that the XML graph at this point has a |
|
117
|
|
|
|
|
|
|
sequence of text nodes, elements, element choices or quantities |
|
118
|
|
|
|
|
|
|
thereof, depending on the type of entries in the B<members> property. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Classes with only one element defined do not have one of these objects |
|
121
|
|
|
|
|
|
|
in their graph. Typically there is one members entry per element |
|
122
|
|
|
|
|
|
|
defined in the class. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B<ArrayRef[PRANG::Graph::Node] members> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The B<members> property provides the next portion of the XML Graph. |
|
131
|
|
|
|
|
|
|
Depending on the type of entry, it will accept and emit nodes in a |
|
132
|
|
|
|
|
|
|
particular way. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Entries must be one of L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>, |
|
135
|
|
|
|
|
|
|
L<PRANG::Graph::Element>, or L<PRANG::Graph::Text>. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Element>, |
|
142
|
|
|
|
|
|
|
L<PRANG::Graph::Context>, L<PRANG::Graph::Node> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Lower order L<PRANG::Graph::Node> types: |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>, |
|
147
|
|
|
|
|
|
|
L<PRANG::Graph::Element>, L<PRANG::Graph::Text> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR AND LICENCE |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Development commissioned by NZ Registry Services, and carried out by |
|
152
|
|
|
|
|
|
|
Catalyst IT - L<http://www.catalyst.net.nz/> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright 2009, 2010, NZ Registry Services. This module is licensed |
|
155
|
|
|
|
|
|
|
under the Artistic License v2.0, which permits relicensing under other |
|
156
|
|
|
|
|
|
|
Free Software licenses. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
|
159
|
|
|
|
|
|
|
|