line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: YAML Parser |
2
|
42
|
|
|
42
|
|
359761
|
use strict; |
|
42
|
|
|
|
|
119
|
|
|
42
|
|
|
|
|
1191
|
|
3
|
42
|
|
|
42
|
|
208
|
use warnings; |
|
42
|
|
|
|
|
79
|
|
|
42
|
|
|
|
|
2487
|
|
4
|
|
|
|
|
|
|
package YAML::PP::Parser; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.036_001'; # TRIAL VERSION |
7
|
|
|
|
|
|
|
|
8
|
42
|
50
|
|
42
|
|
245
|
use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0; |
|
42
|
|
|
|
|
126
|
|
|
42
|
|
|
|
|
3715
|
|
9
|
42
|
100
|
66
|
42
|
|
281
|
use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0; |
|
42
|
|
|
|
|
91
|
|
|
42
|
|
|
|
|
3167
|
|
10
|
|
|
|
|
|
|
|
11
|
42
|
|
|
|
|
2660
|
use YAML::PP::Common qw/ |
12
|
|
|
|
|
|
|
YAML_PLAIN_SCALAR_STYLE YAML_SINGLE_QUOTED_SCALAR_STYLE |
13
|
|
|
|
|
|
|
YAML_DOUBLE_QUOTED_SCALAR_STYLE |
14
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE |
15
|
|
|
|
|
|
|
YAML_FLOW_SEQUENCE_STYLE YAML_FLOW_MAPPING_STYLE |
16
|
42
|
|
|
42
|
|
2650
|
/; |
|
42
|
|
|
|
|
86
|
|
17
|
42
|
|
|
42
|
|
17128
|
use YAML::PP::Render; |
|
42
|
|
|
|
|
121
|
|
|
42
|
|
|
|
|
1215
|
|
18
|
42
|
|
|
42
|
|
20667
|
use YAML::PP::Lexer; |
|
42
|
|
|
|
|
134
|
|
|
42
|
|
|
|
|
1864
|
|
19
|
42
|
|
|
42
|
|
334
|
use YAML::PP::Grammar qw/ $GRAMMAR /; |
|
42
|
|
|
|
|
91
|
|
|
42
|
|
|
|
|
3599
|
|
20
|
42
|
|
|
42
|
|
18312
|
use YAML::PP::Exception; |
|
42
|
|
|
|
|
111
|
|
|
42
|
|
|
|
|
1290
|
|
21
|
42
|
|
|
42
|
|
16432
|
use YAML::PP::Reader; |
|
42
|
|
|
|
|
102
|
|
|
42
|
|
|
|
|
1311
|
|
22
|
42
|
|
|
42
|
|
264
|
use Carp qw/ croak /; |
|
42
|
|
|
|
|
95
|
|
|
42
|
|
|
|
|
36830
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
4658
|
|
|
4658
|
0
|
3396241
|
my ($class, %args) = @_; |
27
|
4658
|
|
33
|
|
|
20772
|
my $reader = delete $args{reader} || YAML::PP::Reader->new; |
28
|
4658
|
|
|
|
|
8860
|
my $default_yaml_version = delete $args{default_yaml_version}; |
29
|
4658
|
|
100
|
|
|
21143
|
my $self = bless { |
30
|
|
|
|
|
|
|
default_yaml_version => $default_yaml_version || '1.2', |
31
|
|
|
|
|
|
|
lexer => YAML::PP::Lexer->new( |
32
|
|
|
|
|
|
|
reader => $reader, |
33
|
|
|
|
|
|
|
), |
34
|
|
|
|
|
|
|
}, $class; |
35
|
4658
|
|
|
|
|
8864
|
my $receiver = delete $args{receiver}; |
36
|
4658
|
100
|
|
|
|
10208
|
if ($receiver) { |
37
|
3911
|
|
|
|
|
8291
|
$self->set_receiver($receiver); |
38
|
|
|
|
|
|
|
} |
39
|
4658
|
|
|
|
|
35073
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub clone { |
43
|
9
|
|
|
9
|
0
|
16
|
my ($self) = @_; |
44
|
9
|
|
|
|
|
21
|
my $clone = { |
45
|
|
|
|
|
|
|
default_yaml_version => $self->default_yaml_version, |
46
|
|
|
|
|
|
|
lexer => YAML::PP::Lexer->new(), |
47
|
|
|
|
|
|
|
}; |
48
|
9
|
|
|
|
|
44
|
return bless $clone, ref $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
747
|
|
|
747
|
0
|
2211
|
sub receiver { return $_[0]->{receiver} } |
52
|
|
|
|
|
|
|
sub set_receiver { |
53
|
4667
|
|
|
4667
|
0
|
7995
|
my ($self, $receiver) = @_; |
54
|
4667
|
|
|
|
|
6141
|
my $callback; |
55
|
4667
|
100
|
|
|
|
11202
|
if (ref $receiver eq 'CODE') { |
56
|
3911
|
|
|
|
|
5507
|
$callback = $receiver; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
$callback = sub { |
60
|
21726
|
|
|
21726
|
|
37090
|
my ($self, $event, $info) = @_; |
61
|
21726
|
|
|
|
|
65899
|
return $receiver->$event($info); |
62
|
756
|
|
|
|
|
3534
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
4667
|
|
|
|
|
8282
|
$self->{callback} = $callback; |
65
|
4667
|
|
|
|
|
8435
|
$self->{receiver} = $receiver; |
66
|
|
|
|
|
|
|
} |
67
|
4
|
|
|
4
|
0
|
11
|
sub reader { return $_[0]->lexer->{reader} } |
68
|
|
|
|
|
|
|
sub set_reader { |
69
|
7571
|
|
|
7571
|
0
|
12354
|
my ($self, $reader) = @_; |
70
|
7571
|
|
|
|
|
13912
|
$self->lexer->set_reader($reader); |
71
|
|
|
|
|
|
|
} |
72
|
116689
|
|
|
116689
|
0
|
321443
|
sub lexer { return $_[0]->{lexer} } |
73
|
83573
|
|
|
83573
|
0
|
222117
|
sub callback { return $_[0]->{callback} } |
74
|
0
|
|
|
0
|
0
|
0
|
sub set_callback { $_[0]->{callback} = $_[1] } |
75
|
19356
|
|
|
19356
|
0
|
26524
|
sub level { return $#{ $_[0]->{offset} } } |
|
19356
|
|
|
|
|
58410
|
|
76
|
105220
|
|
|
105220
|
0
|
179702
|
sub offset { return $_[0]->{offset} } |
77
|
7571
|
|
|
7571
|
0
|
13446
|
sub set_offset { $_[0]->{offset} = $_[1] } |
78
|
160976
|
|
|
160976
|
0
|
270222
|
sub events { return $_[0]->{events} } |
79
|
7571
|
|
|
7571
|
0
|
12723
|
sub set_events { $_[0]->{events} = $_[1] } |
80
|
46595
|
|
|
46595
|
0
|
98198
|
sub new_node { return $_[0]->{new_node} } |
81
|
69533
|
|
|
69533
|
0
|
127290
|
sub set_new_node { $_[0]->{new_node} = $_[1] } |
82
|
2846
|
|
|
2846
|
0
|
6592
|
sub tagmap { return $_[0]->{tagmap} } |
83
|
15576
|
|
|
15576
|
0
|
35665
|
sub set_tagmap { $_[0]->{tagmap} = $_[1] } |
84
|
26257
|
|
|
26257
|
0
|
43185
|
sub tokens { return $_[0]->{tokens} } |
85
|
7571
|
|
|
7571
|
0
|
33349
|
sub set_tokens { $_[0]->{tokens} = $_[1] } |
86
|
104422
|
|
|
104422
|
0
|
165230
|
sub event_stack { return $_[0]->{event_stack} } |
87
|
7571
|
|
|
7571
|
0
|
13020
|
sub set_event_stack { $_[0]->{event_stack} = $_[1] } |
88
|
7580
|
|
|
7580
|
0
|
18787
|
sub default_yaml_version { return $_[0]->{default_yaml_version} } |
89
|
8232
|
|
|
8232
|
0
|
20981
|
sub yaml_version { return $_[0]->{yaml_version} } |
90
|
7729
|
|
|
7729
|
0
|
13248
|
sub set_yaml_version { $_[0]->{yaml_version} = $_[1] } |
91
|
8353
|
|
|
8353
|
0
|
13343
|
sub yaml_version_directive { return $_[0]->{yaml_version_directive} } |
92
|
15923
|
|
|
15923
|
0
|
26413
|
sub set_yaml_version_directive { $_[0]->{yaml_version_directive} = $_[1] } |
93
|
|
|
|
|
|
|
|
94
|
24429
|
|
|
24429
|
0
|
50549
|
sub rule { return $_[0]->{rule} } |
95
|
|
|
|
|
|
|
sub set_rule { |
96
|
141908
|
|
|
141908
|
0
|
246688
|
my ($self, $name) = @_; |
97
|
42
|
|
|
42
|
|
352
|
no warnings 'uninitialized'; |
|
42
|
|
|
|
|
103
|
|
|
42
|
|
|
|
|
390703
|
|
98
|
141908
|
|
|
|
|
174560
|
DEBUG and $self->info("set_rule($name)"); |
99
|
141908
|
|
|
|
|
234467
|
$self->{rule} = $name; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub init { |
103
|
7571
|
|
|
7571
|
0
|
12000
|
my ($self) = @_; |
104
|
7571
|
|
|
|
|
19260
|
$self->set_offset([]); |
105
|
7571
|
|
|
|
|
17596
|
$self->set_events([]); |
106
|
7571
|
|
|
|
|
17116
|
$self->set_new_node(0); |
107
|
7571
|
|
|
|
|
22059
|
$self->set_tagmap({ |
108
|
|
|
|
|
|
|
'!!' => "tag:yaml.org,2002:", |
109
|
|
|
|
|
|
|
}); |
110
|
7571
|
|
|
|
|
18221
|
$self->set_tokens([]); |
111
|
7571
|
|
|
|
|
17850
|
$self->set_rule(undef); |
112
|
7571
|
|
|
|
|
17607
|
$self->set_event_stack([]); |
113
|
7571
|
|
|
|
|
14019
|
$self->set_yaml_version($self->default_yaml_version); |
114
|
7571
|
|
|
|
|
18039
|
$self->set_yaml_version_directive(undef); |
115
|
7571
|
|
|
|
|
13068
|
$self->lexer->init; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub parse_string { |
119
|
5383
|
|
|
5383
|
0
|
74507
|
my ($self, $yaml) = @_; |
120
|
5383
|
|
|
|
|
13107
|
$self->set_reader(YAML::PP::Reader->new( input => $yaml )); |
121
|
5383
|
|
|
|
|
11065
|
$self->parse(); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub parse_file { |
125
|
0
|
|
|
0
|
0
|
0
|
my ($self, $file) = @_; |
126
|
0
|
|
|
|
|
0
|
$self->set_reader(YAML::PP::Reader::File->new( input => $file )); |
127
|
0
|
|
|
|
|
0
|
$self->parse(); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my %nodetypes = ( |
131
|
|
|
|
|
|
|
MAPVALUE => 'NODETYPE_COMPLEX', |
132
|
|
|
|
|
|
|
MAP => 'NODETYPE_MAP', |
133
|
|
|
|
|
|
|
# IMAP => 'NODETYPE_SEQ', |
134
|
|
|
|
|
|
|
SEQ => 'NODETYPE_SEQ', |
135
|
|
|
|
|
|
|
SEQ0 => 'NODETYPE_SEQ', |
136
|
|
|
|
|
|
|
FLOWMAP => 'NODETYPE_FLOWMAP', |
137
|
|
|
|
|
|
|
FLOWMAPVALUE => 'NODETYPE_FLOWMAPVALUE', |
138
|
|
|
|
|
|
|
FLOWSEQ => 'NODETYPE_FLOWSEQ', |
139
|
|
|
|
|
|
|
FLOWSEQ_NEXT => 'FLOWSEQ_NEXT', |
140
|
|
|
|
|
|
|
DOC => 'FULLNODE', |
141
|
|
|
|
|
|
|
DOC_END => 'DOCUMENT_END', |
142
|
|
|
|
|
|
|
STR => 'STREAM', |
143
|
|
|
|
|
|
|
END_FLOW => 'END_FLOW', |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub parse { |
147
|
7571
|
|
|
7571
|
0
|
12728
|
my ($self) = @_; |
148
|
7571
|
|
|
|
|
10506
|
TRACE and warn "=== parse()\n"; |
149
|
7571
|
|
|
|
|
10182
|
TRACE and $self->debug_yaml; |
150
|
7571
|
|
|
|
|
18256
|
$self->init; |
151
|
7571
|
|
|
|
|
13540
|
$self->lexer->init; |
152
|
7571
|
|
|
|
|
11400
|
eval { |
153
|
7571
|
|
|
|
|
18185
|
$self->start_stream; |
154
|
7571
|
|
|
|
|
28753
|
$self->set_rule( 'STREAM' ); |
155
|
|
|
|
|
|
|
|
156
|
7571
|
|
|
|
|
17932
|
$self->parse_tokens(); |
157
|
|
|
|
|
|
|
|
158
|
7416
|
|
|
|
|
14969
|
$self->end_stream; |
159
|
|
|
|
|
|
|
}; |
160
|
7571
|
100
|
|
|
|
28218
|
if (my $error = $@) { |
161
|
155
|
100
|
|
|
|
409
|
if (ref $error) { |
162
|
124
|
|
|
|
|
351
|
croak "$error\n "; |
163
|
|
|
|
|
|
|
} |
164
|
31
|
|
|
|
|
2696
|
croak $error; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
7416
|
|
|
|
|
9932
|
DEBUG and $self->highlight_yaml; |
168
|
7416
|
|
|
|
|
14856
|
TRACE and $self->debug_tokens; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub lex_next_tokens { |
172
|
31900
|
|
|
31900
|
0
|
51387
|
my ($self) = @_; |
173
|
|
|
|
|
|
|
|
174
|
31900
|
|
|
|
|
39642
|
DEBUG and $self->info("----------------> lex_next_tokens"); |
175
|
31900
|
|
|
|
|
44173
|
TRACE and $self->debug_events; |
176
|
|
|
|
|
|
|
|
177
|
31900
|
|
|
|
|
53110
|
my $indent = $self->offset->[-1]; |
178
|
31900
|
|
|
|
|
53795
|
my $event_types = $self->events; |
179
|
31900
|
|
|
|
|
59279
|
my $next_tokens = $self->lexer->fetch_next_tokens($indent); |
180
|
31865
|
100
|
|
|
|
75310
|
return unless @$next_tokens; |
181
|
|
|
|
|
|
|
|
182
|
24440
|
|
|
|
|
37229
|
my $next = $next_tokens->[0]; |
183
|
|
|
|
|
|
|
|
184
|
24440
|
100
|
|
|
|
60578
|
return 1 if ($next->{name} ne 'SPACE'); |
185
|
18371
|
|
|
|
|
36567
|
my $flow = $event_types->[-1] =~ m/^FLOW/; |
186
|
18371
|
|
|
|
|
34342
|
my $space = length $next->{value}; |
187
|
18371
|
|
|
|
|
38651
|
my $tokens = $self->tokens; |
188
|
|
|
|
|
|
|
|
189
|
18371
|
100
|
|
|
|
35522
|
if (not $space) { |
190
|
13988
|
|
|
|
|
21253
|
shift @$next_tokens; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
else { |
193
|
4383
|
|
|
|
|
8399
|
push @$tokens, shift @$next_tokens; |
194
|
|
|
|
|
|
|
} |
195
|
18371
|
100
|
|
|
|
34569
|
if ($flow) { |
196
|
678
|
100
|
|
|
|
1694
|
if ($space >= $indent) { |
197
|
675
|
|
|
|
|
1985
|
return 1; |
198
|
|
|
|
|
|
|
} |
199
|
3
|
|
|
|
|
37
|
$self->exception("Bad indendation in " . $self->events->[-1]); |
200
|
|
|
|
|
|
|
} |
201
|
17693
|
|
|
|
|
39060
|
$next = $next_tokens->[0]; |
202
|
17693
|
100
|
|
|
|
36185
|
if ($space > $indent ) { |
203
|
7856
|
100
|
|
|
|
24281
|
return 1 if $indent < 0; |
204
|
1823
|
100
|
|
|
|
3765
|
unless ($self->new_node) { |
205
|
4
|
|
|
|
|
14
|
$self->exception("Bad indendation in " . $self->events->[-1]); |
206
|
|
|
|
|
|
|
} |
207
|
1819
|
|
|
|
|
4745
|
return 1; |
208
|
|
|
|
|
|
|
} |
209
|
9837
|
100
|
|
|
|
19255
|
if ($self->new_node) { |
210
|
1287
|
100
|
|
|
|
2842
|
if ($space < $indent) { |
211
|
437
|
|
|
|
|
1796
|
$self->scalar_event({ style => YAML_PLAIN_SCALAR_STYLE, value => '' }); |
212
|
437
|
|
|
|
|
1038
|
$self->remove_nodes($space); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
else { |
215
|
|
|
|
|
|
|
# unindented sequence starts |
216
|
850
|
|
|
|
|
1779
|
my $exp = $self->events->[-1]; |
217
|
850
|
|
|
|
|
1681
|
my $seq_start = $next->{name} eq 'DASH'; |
218
|
850
|
100
|
100
|
|
|
3957
|
if ( $seq_start and ($exp eq 'MAPVALUE' or $exp eq 'MAP')) { |
|
|
|
100
|
|
|
|
|
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
else { |
221
|
289
|
|
|
|
|
1158
|
$self->scalar_event({ style => YAML_PLAIN_SCALAR_STYLE, value => '' }); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
else { |
226
|
8550
|
100
|
|
|
|
17698
|
if ($space < $indent) { |
227
|
1905
|
|
|
|
|
4350
|
$self->remove_nodes($space); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
9837
|
|
|
|
|
18818
|
my $exp = $self->events->[-1]; |
232
|
|
|
|
|
|
|
|
233
|
9837
|
100
|
100
|
|
|
25101
|
if ($exp eq 'SEQ0' and $next->{name} ne 'DASH') { |
234
|
240
|
|
|
|
|
472
|
TRACE and $self->info("In unindented sequence"); |
235
|
240
|
|
|
|
|
751
|
$self->end_sequence; |
236
|
240
|
|
|
|
|
535
|
$exp = $self->events->[-1]; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
9837
|
100
|
|
|
|
17493
|
if ($self->offset->[-1] != $space) { |
240
|
4
|
|
|
|
|
12
|
$self->exception("Expected " . $self->events->[-1]); |
241
|
|
|
|
|
|
|
} |
242
|
9833
|
|
|
|
|
25238
|
return 1; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
my %next_event = ( |
246
|
|
|
|
|
|
|
MAP => 'MAPVALUE', |
247
|
|
|
|
|
|
|
IMAP => 'IMAPVALUE', |
248
|
|
|
|
|
|
|
MAPVALUE => 'MAP', |
249
|
|
|
|
|
|
|
IMAPVALUE => 'IMAP', |
250
|
|
|
|
|
|
|
SEQ => 'SEQ', |
251
|
|
|
|
|
|
|
SEQ0 => 'SEQ0', |
252
|
|
|
|
|
|
|
DOC => 'DOC_END', |
253
|
|
|
|
|
|
|
STR => 'STR', |
254
|
|
|
|
|
|
|
FLOWSEQ => 'FLOWSEQ_NEXT', |
255
|
|
|
|
|
|
|
FLOWSEQ_NEXT => 'FLOWSEQ', |
256
|
|
|
|
|
|
|
FLOWMAP => 'FLOWMAPVALUE', |
257
|
|
|
|
|
|
|
FLOWMAPVALUE => 'FLOWMAP', |
258
|
|
|
|
|
|
|
); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
my %event_to_method = ( |
261
|
|
|
|
|
|
|
MAP => 'mapping', |
262
|
|
|
|
|
|
|
IMAP => 'mapping', |
263
|
|
|
|
|
|
|
FLOWMAP => 'mapping', |
264
|
|
|
|
|
|
|
SEQ => 'sequence', |
265
|
|
|
|
|
|
|
SEQ0 => 'sequence', |
266
|
|
|
|
|
|
|
FLOWSEQ => 'sequence', |
267
|
|
|
|
|
|
|
DOC => 'document', |
268
|
|
|
|
|
|
|
STR => 'stream', |
269
|
|
|
|
|
|
|
VAL => 'scalar', |
270
|
|
|
|
|
|
|
ALI => 'alias', |
271
|
|
|
|
|
|
|
MAPVALUE => 'mapping', |
272
|
|
|
|
|
|
|
IMAPVALUE => 'mapping', |
273
|
|
|
|
|
|
|
); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#sub process_events { |
276
|
|
|
|
|
|
|
# my ($self, $res) = @_; |
277
|
|
|
|
|
|
|
# |
278
|
|
|
|
|
|
|
# my $event_stack = $self->event_stack; |
279
|
|
|
|
|
|
|
# return unless @$event_stack; |
280
|
|
|
|
|
|
|
# |
281
|
|
|
|
|
|
|
# if (@$event_stack == 1 and $event_stack->[0]->[0] eq 'properties') { |
282
|
|
|
|
|
|
|
# return; |
283
|
|
|
|
|
|
|
# } |
284
|
|
|
|
|
|
|
# |
285
|
|
|
|
|
|
|
# my $event_types = $self->events; |
286
|
|
|
|
|
|
|
# my $properties; |
287
|
|
|
|
|
|
|
# my @send_events; |
288
|
|
|
|
|
|
|
# for my $event (@$event_stack) { |
289
|
|
|
|
|
|
|
# TRACE and warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\$event], ['event']); |
290
|
|
|
|
|
|
|
# my ($type, $info) = @$event; |
291
|
|
|
|
|
|
|
# if ($type eq 'properties') { |
292
|
|
|
|
|
|
|
# $properties = $info; |
293
|
|
|
|
|
|
|
# } |
294
|
|
|
|
|
|
|
# elsif ($type eq 'scalar') { |
295
|
|
|
|
|
|
|
# $info->{name} = 'scalar_event'; |
296
|
|
|
|
|
|
|
# $event_types->[-1] = $next_event{ $event_types->[-1] }; |
297
|
|
|
|
|
|
|
# push @send_events, $info; |
298
|
|
|
|
|
|
|
# } |
299
|
|
|
|
|
|
|
# elsif ($type eq 'begin') { |
300
|
|
|
|
|
|
|
# my $name = $info->{name}; |
301
|
|
|
|
|
|
|
# $info->{name} = $event_to_method{ $name } . '_start_event'; |
302
|
|
|
|
|
|
|
# push @{ $event_types }, $name; |
303
|
|
|
|
|
|
|
# push @{ $self->offset }, $info->{offset}; |
304
|
|
|
|
|
|
|
# push @send_events, $info; |
305
|
|
|
|
|
|
|
# } |
306
|
|
|
|
|
|
|
# elsif ($type eq 'end') { |
307
|
|
|
|
|
|
|
# my $name = $info->{name}; |
308
|
|
|
|
|
|
|
# $info->{name} = $event_to_method{ $name } . '_end_event'; |
309
|
|
|
|
|
|
|
# $self->$type($name, $info); |
310
|
|
|
|
|
|
|
# push @send_events, $info; |
311
|
|
|
|
|
|
|
# if (@$event_types) { |
312
|
|
|
|
|
|
|
# $event_types->[-1] = $next_event{ $event_types->[-1] }; |
313
|
|
|
|
|
|
|
# } |
314
|
|
|
|
|
|
|
# } |
315
|
|
|
|
|
|
|
# elsif ($type eq 'alias') { |
316
|
|
|
|
|
|
|
# if ($properties) { |
317
|
|
|
|
|
|
|
# $self->exception("Parse error: Alias not allowed in this context"); |
318
|
|
|
|
|
|
|
# } |
319
|
|
|
|
|
|
|
# $info->{name} = 'alias_event'; |
320
|
|
|
|
|
|
|
# $event_types->[-1] = $next_event{ $event_types->[-1] }; |
321
|
|
|
|
|
|
|
# push @send_events, $info; |
322
|
|
|
|
|
|
|
# } |
323
|
|
|
|
|
|
|
# } |
324
|
|
|
|
|
|
|
# @$event_stack = (); |
325
|
|
|
|
|
|
|
# for my $info (@send_events) { |
326
|
|
|
|
|
|
|
# DEBUG and $self->debug_event( $info ); |
327
|
|
|
|
|
|
|
# $self->callback->($self, $info->{name}, $info); |
328
|
|
|
|
|
|
|
# } |
329
|
|
|
|
|
|
|
#} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
my %fetch_method = ( |
332
|
|
|
|
|
|
|
'"' => 'fetch_quoted', |
333
|
|
|
|
|
|
|
"'" => 'fetch_quoted', |
334
|
|
|
|
|
|
|
'|' => 'fetch_block', |
335
|
|
|
|
|
|
|
'>' => 'fetch_block', |
336
|
|
|
|
|
|
|
'' => 'fetch_plain', |
337
|
|
|
|
|
|
|
); |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub parse_tokens { |
340
|
7571
|
|
|
7571
|
0
|
12144
|
my ($self) = @_; |
341
|
7571
|
|
|
|
|
12396
|
my $event_types = $self->events; |
342
|
7571
|
|
|
|
|
13118
|
my $offsets = $self->offset; |
343
|
7571
|
|
|
|
|
13320
|
my $tokens = $self->tokens; |
344
|
7571
|
|
|
|
|
12801
|
my $next_tokens = $self->lexer->next_tokens; |
345
|
|
|
|
|
|
|
|
346
|
7571
|
100
|
|
|
|
14550
|
unless ($self->lex_next_tokens) { |
347
|
69
|
|
|
|
|
235
|
$self->end_document(1); |
348
|
69
|
|
|
|
|
181
|
return 0; |
349
|
|
|
|
|
|
|
} |
350
|
7468
|
50
|
|
|
|
16344
|
unless ($self->new_node) { |
351
|
7468
|
50
|
|
|
|
14088
|
if ($self->level > 0) { |
352
|
0
|
0
|
|
|
|
0
|
my $new_rule = $nodetypes{ $event_types->[-1] } |
353
|
|
|
|
|
|
|
or die "Did not find '$event_types->[-1]'"; |
354
|
0
|
|
|
|
|
0
|
$self->set_rule( $new_rule ); |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
7468
|
|
|
|
|
14683
|
my $rule_name = $self->rule; |
359
|
7468
|
|
|
|
|
10708
|
DEBUG and $self->info("----------------> parse_tokens($rule_name)"); |
360
|
7468
|
50
|
|
|
|
18946
|
my $rule = $GRAMMAR->{ $rule_name } |
361
|
|
|
|
|
|
|
or die "Could not find rule $rule_name"; |
362
|
|
|
|
|
|
|
|
363
|
7468
|
|
|
|
|
9685
|
TRACE and $self->debug_rules($rule); |
364
|
7468
|
|
|
|
|
9381
|
TRACE and $self->debug_yaml; |
365
|
7468
|
|
|
|
|
9720
|
DEBUG and $self->debug_next_line; |
366
|
|
|
|
|
|
|
|
367
|
7468
|
|
|
|
|
13969
|
RULE: while ($rule_name) { |
368
|
201668
|
|
|
|
|
246689
|
DEBUG and $self->info("RULE: $rule_name"); |
369
|
201668
|
|
|
|
|
230420
|
TRACE and $self->debug_tokens($next_tokens); |
370
|
|
|
|
|
|
|
|
371
|
201668
|
50
|
|
|
|
340204
|
unless (@$next_tokens) { |
372
|
0
|
|
|
|
|
0
|
$self->exception("No more tokens"); |
373
|
|
|
|
|
|
|
} |
374
|
201668
|
|
|
|
|
239224
|
TRACE and warn __PACKAGE__.':'.__LINE__.$".Data::Dumper->Dump([\$next_tokens->[0]], ['next_token']); |
375
|
201668
|
|
|
|
|
293508
|
my $got = $next_tokens->[0]->{name}; |
376
|
201668
|
100
|
|
|
|
341045
|
if ($got eq 'CONTEXT') { |
377
|
26958
|
|
|
|
|
40881
|
my $context = shift @$next_tokens; |
378
|
26958
|
|
|
|
|
40937
|
my $indent = $offsets->[-1]; |
379
|
26958
|
100
|
|
|
|
50327
|
$indent++ unless $self->lexer->flowcontext; |
380
|
26958
|
|
|
|
|
57418
|
my $method = $fetch_method{ $context->{value} }; |
381
|
26958
|
|
|
|
|
45991
|
my $partial = $self->lexer->$method($indent, $context->{value}); |
382
|
26932
|
|
|
|
|
92441
|
next RULE; |
383
|
|
|
|
|
|
|
} |
384
|
174710
|
|
|
|
|
278617
|
my $def = $rule->{ $got }; |
385
|
174710
|
100
|
|
|
|
307802
|
if ($def) { |
|
|
100
|
|
|
|
|
|
386
|
113618
|
|
|
|
|
196710
|
push @$tokens, shift @$next_tokens; |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
elsif ($def = $rule->{DEFAULT}) { |
389
|
61044
|
|
|
|
|
84553
|
$got = 'DEFAULT'; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
else { |
392
|
48
|
|
|
|
|
242
|
$self->expected( |
393
|
|
|
|
|
|
|
expected => [keys %$rule], |
394
|
|
|
|
|
|
|
got => $next_tokens->[0], |
395
|
|
|
|
|
|
|
); |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
174662
|
|
|
|
|
218515
|
DEBUG and $self->got("---got $got"); |
399
|
174662
|
100
|
|
|
|
343502
|
if (my $sub = $def->{match}) { |
400
|
83020
|
|
|
|
|
98844
|
DEBUG and $self->info("CALLBACK $sub"); |
401
|
83020
|
100
|
|
|
|
247167
|
$self->$sub(@$tokens ? $tokens->[-1] : ()); |
402
|
|
|
|
|
|
|
} |
403
|
174636
|
|
|
|
|
266235
|
my $eol = $got eq 'EOL'; |
404
|
174636
|
|
|
|
|
253866
|
my $new = $def->{new}; |
405
|
174636
|
100
|
|
|
|
326260
|
if ($new) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
406
|
93139
|
|
|
|
|
111689
|
DEBUG and $self->got("NEW: $new"); |
407
|
93139
|
|
|
|
|
131622
|
$rule_name = $new; |
408
|
93139
|
|
|
|
|
170834
|
$self->set_rule($rule_name); |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
elsif ($eol) { |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
elsif ($def->{return}) { |
413
|
6344
|
50
|
|
|
|
16634
|
$rule_name = $nodetypes{ $event_types->[-1] } |
414
|
|
|
|
|
|
|
or die "Unexpected event type $event_types->[-1]"; |
415
|
6344
|
|
|
|
|
11582
|
$self->set_rule($rule_name); |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
else { |
418
|
58355
|
|
|
|
|
113943
|
$rule_name .= " - $got"; # for debugging |
419
|
58355
|
|
|
|
|
76325
|
$rule = $def; |
420
|
58355
|
|
|
|
|
135381
|
next RULE; |
421
|
|
|
|
|
|
|
} |
422
|
116281
|
100
|
|
|
|
198079
|
if ($eol) { |
423
|
24329
|
100
|
|
|
|
48137
|
unless ($self->lex_next_tokens) { |
424
|
7356
|
100
|
|
|
|
15225
|
if ($rule_name eq 'DIRECTIVE') { |
425
|
1
|
|
|
|
|
5
|
$self->exception("Directive needs document start"); |
426
|
|
|
|
|
|
|
} |
427
|
7355
|
|
|
|
|
18366
|
$self->end_document(1); |
428
|
7347
|
|
|
|
|
17083
|
return 0; |
429
|
|
|
|
|
|
|
} |
430
|
16961
|
100
|
|
|
|
31181
|
unless ($self->new_node) { |
431
|
11888
|
100
|
|
|
|
21273
|
if ($self->level > 0) { |
432
|
11011
|
50
|
|
|
|
30425
|
$rule_name = $nodetypes{ $event_types->[-1] } |
433
|
|
|
|
|
|
|
or die "Did not find '$event_types->[-1]'"; |
434
|
11011
|
|
|
|
|
21781
|
$self->set_rule( $rule_name ); |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
} |
437
|
16961
|
|
|
|
|
31639
|
$rule_name = $self->rule; |
438
|
|
|
|
|
|
|
} |
439
|
108913
|
50
|
|
|
|
305667
|
$rule = $GRAMMAR->{ $rule_name } |
440
|
|
|
|
|
|
|
or die "Unexpected rule $rule_name"; |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
0
|
die "Unexpected"; |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub end_sequence { |
448
|
240
|
|
|
240
|
0
|
564
|
my ($self) = @_; |
449
|
240
|
|
|
|
|
519
|
my $event_types = $self->events; |
450
|
240
|
|
|
|
|
348
|
pop @{ $event_types }; |
|
240
|
|
|
|
|
394
|
|
451
|
240
|
|
|
|
|
367
|
pop @{ $self->offset }; |
|
240
|
|
|
|
|
472
|
|
452
|
240
|
|
|
|
|
630
|
my $info = { name => 'sequence_end_event' }; |
453
|
240
|
|
|
|
|
623
|
$self->callback->($self, $info->{name} => $info ); |
454
|
240
|
|
|
|
|
978
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
sub remove_nodes { |
458
|
10894
|
|
|
10894
|
0
|
18350
|
my ($self, $space) = @_; |
459
|
10894
|
|
|
|
|
19126
|
my $offset = $self->offset; |
460
|
10894
|
|
|
|
|
18519
|
my $event_types = $self->events; |
461
|
|
|
|
|
|
|
|
462
|
10894
|
|
|
|
|
17961
|
my $exp = $event_types->[-1]; |
463
|
10894
|
|
|
|
|
22646
|
while (@$offset) { |
464
|
19139
|
100
|
|
|
|
35899
|
if ($offset->[ -1 ] <= $space) { |
465
|
10887
|
|
|
|
|
17217
|
last; |
466
|
|
|
|
|
|
|
} |
467
|
8252
|
100
|
|
|
|
14873
|
if ($exp eq 'MAPVALUE') { |
468
|
51
|
|
|
|
|
313
|
$self->scalar_event({ style => YAML_PLAIN_SCALAR_STYLE, value => '' }); |
469
|
51
|
|
|
|
|
139
|
$exp = 'MAP'; |
470
|
|
|
|
|
|
|
} |
471
|
8252
|
|
|
|
|
17205
|
my $info = { name => $exp }; |
472
|
8252
|
|
|
|
|
20476
|
$info->{name} = $event_to_method{ $exp } . '_end_event'; |
473
|
8252
|
|
|
|
|
11014
|
pop @{ $event_types }; |
|
8252
|
|
|
|
|
11906
|
|
474
|
8252
|
|
|
|
|
11252
|
pop @{ $offset }; |
|
8252
|
|
|
|
|
10645
|
|
475
|
8252
|
|
|
|
|
17476
|
$self->callback->($self, $info->{name} => $info ); |
476
|
8245
|
|
|
|
|
26347
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
477
|
8245
|
|
|
|
|
19172
|
$exp = $event_types->[-1]; |
478
|
|
|
|
|
|
|
} |
479
|
10887
|
|
|
|
|
17900
|
return $exp; |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
sub start_stream { |
483
|
7571
|
|
|
7571
|
0
|
12125
|
my ($self) = @_; |
484
|
7571
|
|
|
|
|
10193
|
push @{ $self->events }, 'STR'; |
|
7571
|
|
|
|
|
12984
|
|
485
|
7571
|
|
|
|
|
12113
|
push @{ $self->offset }, -1; |
|
7571
|
|
|
|
|
12712
|
|
486
|
7571
|
|
|
|
|
19064
|
$self->callback->($self, 'stream_start_event', { |
487
|
|
|
|
|
|
|
name => 'stream_start_event', |
488
|
|
|
|
|
|
|
}); |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
sub start_document { |
492
|
8194
|
|
|
8194
|
0
|
13909
|
my ($self, $implicit) = @_; |
493
|
8194
|
|
|
|
|
11112
|
push @{ $self->events }, 'DOC'; |
|
8194
|
|
|
|
|
15506
|
|
494
|
8194
|
|
|
|
|
12390
|
push @{ $self->offset }, -1; |
|
8194
|
|
|
|
|
14316
|
|
495
|
8194
|
|
|
|
|
15763
|
my $directive = $self->yaml_version_directive; |
496
|
8194
|
|
|
|
|
12164
|
my %directive; |
497
|
8194
|
100
|
|
|
|
15339
|
if ($directive) { |
498
|
154
|
|
|
|
|
488
|
my ($major, $minor) = split m/\./, $self->yaml_version; |
499
|
154
|
|
|
|
|
864
|
%directive = ( version_directive => { major => $major, minor => $minor } ); |
500
|
|
|
|
|
|
|
} |
501
|
8194
|
|
|
|
|
28306
|
$self->callback->($self, 'document_start_event', { |
502
|
|
|
|
|
|
|
name => 'document_start_event', |
503
|
|
|
|
|
|
|
implicit => $implicit, |
504
|
|
|
|
|
|
|
%directive, |
505
|
|
|
|
|
|
|
}); |
506
|
8194
|
|
|
|
|
32169
|
$self->set_yaml_version_directive(undef); |
507
|
8194
|
|
|
|
|
18376
|
$self->set_rule( 'FULLNODE' ); |
508
|
8194
|
|
|
|
|
15473
|
$self->set_new_node(1); |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
sub start_sequence { |
512
|
3222
|
|
|
3222
|
0
|
5785
|
my ($self, $offset) = @_; |
513
|
3222
|
|
|
|
|
5498
|
my $offsets = $self->offset; |
514
|
3222
|
100
|
|
|
|
6711
|
if ($offsets->[-1] == $offset) { |
515
|
561
|
|
|
|
|
937
|
push @{ $self->events }, 'SEQ0'; |
|
561
|
|
|
|
|
1202
|
|
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
else { |
518
|
2661
|
|
|
|
|
3950
|
push @{ $self->events }, 'SEQ'; |
|
2661
|
|
|
|
|
4733
|
|
519
|
|
|
|
|
|
|
} |
520
|
3222
|
|
|
|
|
4859
|
push @{ $offsets }, $offset; |
|
3222
|
|
|
|
|
4988
|
|
521
|
3222
|
|
|
|
|
6051
|
my $event_stack = $self->event_stack; |
522
|
3222
|
|
|
|
|
6933
|
my $info = { name => 'sequence_start_event' }; |
523
|
3222
|
100
|
66
|
|
|
8405
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
524
|
227
|
|
|
|
|
495
|
my $properties = pop @$event_stack; |
525
|
227
|
|
|
|
|
650
|
$self->node_properties($properties->[1], $info); |
526
|
|
|
|
|
|
|
} |
527
|
3222
|
|
|
|
|
6604
|
$self->callback->($self, 'sequence_start_event', $info); |
528
|
|
|
|
|
|
|
} |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub start_flow_sequence { |
531
|
1361
|
|
|
1361
|
0
|
2349
|
my ($self, $offset) = @_; |
532
|
1361
|
|
|
|
|
2563
|
my $offsets = $self->offset; |
533
|
1361
|
|
|
|
|
2221
|
my $new_offset = $offsets->[-1]; |
534
|
1361
|
|
|
|
|
2428
|
my $event_types = $self->events; |
535
|
1361
|
100
|
|
|
|
3513
|
if ($new_offset < 0) { |
|
|
100
|
|
|
|
|
|
536
|
153
|
|
|
|
|
345
|
$new_offset = 0; |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
elsif ($self->new_node) { |
539
|
1149
|
100
|
|
|
|
3293
|
if ($event_types->[-1] !~ m/^FLOW/) { |
540
|
982
|
|
|
|
|
1438
|
$new_offset++; |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
} |
543
|
1361
|
|
|
|
|
2011
|
push @{ $self->events }, 'FLOWSEQ'; |
|
1361
|
|
|
|
|
2316
|
|
544
|
1361
|
|
|
|
|
1959
|
push @{ $offsets }, $new_offset; |
|
1361
|
|
|
|
|
2178
|
|
545
|
|
|
|
|
|
|
|
546
|
1361
|
|
|
|
|
2699
|
my $event_stack = $self->event_stack; |
547
|
1361
|
|
|
|
|
3880
|
my $info = { style => YAML_FLOW_SEQUENCE_STYLE, name => 'sequence_start_event' }; |
548
|
1361
|
100
|
66
|
|
|
3561
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
549
|
38
|
|
|
|
|
175
|
$self->fetch_inline_properties($event_stack, $info); |
550
|
|
|
|
|
|
|
} |
551
|
1361
|
|
|
|
|
2832
|
$self->callback->($self, 'sequence_start_event', $info); |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
sub start_flow_mapping { |
555
|
1118
|
|
|
1118
|
0
|
2477
|
my ($self, $offset, $implicit_flowseq_map) = @_; |
556
|
1118
|
|
|
|
|
2162
|
my $offsets = $self->offset; |
557
|
1118
|
|
|
|
|
1859
|
my $new_offset = $offsets->[-1]; |
558
|
1118
|
|
|
|
|
2141
|
my $event_types = $self->events; |
559
|
1118
|
100
|
|
|
|
3041
|
if ($new_offset < 0) { |
|
|
100
|
|
|
|
|
|
560
|
372
|
|
|
|
|
672
|
$new_offset = 0; |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
elsif ($self->new_node) { |
563
|
648
|
100
|
|
|
|
1946
|
if ($event_types->[-1] !~ m/^FLOW/) { |
564
|
570
|
|
|
|
|
994
|
$new_offset++; |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
} |
567
|
1118
|
100
|
|
|
|
1639
|
push @{ $self->events }, $implicit_flowseq_map ? 'IMAP' : 'FLOWMAP'; |
|
1118
|
|
|
|
|
1946
|
|
568
|
1118
|
|
|
|
|
1648
|
push @{ $offsets }, $new_offset; |
|
1118
|
|
|
|
|
1683
|
|
569
|
|
|
|
|
|
|
|
570
|
1118
|
|
|
|
|
2234
|
my $event_stack = $self->event_stack; |
571
|
1118
|
|
|
|
|
3264
|
my $info = { name => 'mapping_start_event', style => YAML_FLOW_MAPPING_STYLE }; |
572
|
1118
|
100
|
66
|
|
|
3231
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
573
|
69
|
|
|
|
|
206
|
$self->fetch_inline_properties($event_stack, $info); |
574
|
|
|
|
|
|
|
} |
575
|
1118
|
|
|
|
|
2370
|
$self->callback->($self, 'mapping_start_event', $info); |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
sub end_flow_sequence { |
579
|
1349
|
|
|
1349
|
0
|
2352
|
my ($self) = @_; |
580
|
1349
|
|
|
|
|
2417
|
my $event_types = $self->events; |
581
|
1349
|
|
|
|
|
1873
|
pop @{ $event_types }; |
|
1349
|
|
|
|
|
2098
|
|
582
|
1349
|
|
|
|
|
1967
|
pop @{ $self->offset }; |
|
1349
|
|
|
|
|
2399
|
|
583
|
1349
|
|
|
|
|
3197
|
my $info = { name => 'sequence_end_event' }; |
584
|
1349
|
|
|
|
|
2985
|
$self->callback->($self, $info->{name}, $info); |
585
|
1349
|
100
|
|
|
|
6454
|
if ($event_types->[-1] =~ m/^FLOW|^IMAP/) { |
586
|
226
|
|
|
|
|
636
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
else { |
589
|
1123
|
|
|
|
|
2660
|
push @$event_types, 'END_FLOW'; |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
sub end_flow_mapping { |
594
|
1116
|
|
|
1116
|
0
|
1956
|
my ($self) = @_; |
595
|
1116
|
|
|
|
|
2053
|
my $event_types = $self->events; |
596
|
1116
|
|
|
|
|
1583
|
pop @{ $event_types }; |
|
1116
|
|
|
|
|
1701
|
|
597
|
1116
|
|
|
|
|
1530
|
pop @{ $self->offset }; |
|
1116
|
|
|
|
|
2058
|
|
598
|
1116
|
|
|
|
|
3137
|
my $info = { name => 'mapping_end_event' }; |
599
|
1116
|
|
|
|
|
2543
|
$self->callback->($self, $info->{name}, $info); |
600
|
1108
|
100
|
|
|
|
5492
|
if ($event_types->[-1] =~ m/^FLOW|^IMAP/) { |
601
|
176
|
|
|
|
|
483
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
602
|
|
|
|
|
|
|
} |
603
|
|
|
|
|
|
|
else { |
604
|
932
|
|
|
|
|
1994
|
push @$event_types, 'END_FLOW'; |
605
|
|
|
|
|
|
|
} |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
sub cb_end_outer_flow { |
609
|
2049
|
|
|
2049
|
0
|
3622
|
my ($self) = @_; |
610
|
2049
|
|
|
|
|
3653
|
my $event_types = $self->events; |
611
|
2049
|
|
|
|
|
3173
|
pop @$event_types; |
612
|
2049
|
|
|
|
|
4327
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
sub start_mapping { |
616
|
5353
|
|
|
5353
|
0
|
9491
|
my ($self, $offset) = @_; |
617
|
5353
|
|
|
|
|
9689
|
my $offsets = $self->offset; |
618
|
5353
|
|
|
|
|
7873
|
push @{ $self->events }, 'MAP'; |
|
5353
|
|
|
|
|
9222
|
|
619
|
5353
|
|
|
|
|
7344
|
push @{ $offsets }, $offset; |
|
5353
|
|
|
|
|
8076
|
|
620
|
5353
|
|
|
|
|
9218
|
my $event_stack = $self->event_stack; |
621
|
5353
|
|
|
|
|
11686
|
my $info = { name => 'mapping_start_event' }; |
622
|
5353
|
100
|
66
|
|
|
13812
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
623
|
492
|
|
|
|
|
883
|
my $properties = pop @$event_stack; |
624
|
492
|
|
|
|
|
1227
|
$self->node_properties($properties->[1], $info); |
625
|
|
|
|
|
|
|
} |
626
|
5353
|
|
|
|
|
10880
|
$self->callback->($self, 'mapping_start_event', $info); |
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
sub end_document { |
630
|
8553
|
|
|
8553
|
0
|
14521
|
my ($self, $implicit) = @_; |
631
|
|
|
|
|
|
|
|
632
|
8553
|
|
|
|
|
13999
|
my $event_types = $self->events; |
633
|
8553
|
100
|
|
|
|
22083
|
if ($event_types->[-1] =~ m/FLOW/) { |
634
|
1
|
|
|
|
|
8
|
die "Unexpected end of flow context"; |
635
|
|
|
|
|
|
|
} |
636
|
8552
|
100
|
|
|
|
16437
|
if ($self->new_node) { |
637
|
499
|
|
|
|
|
2062
|
$self->scalar_event({ style => YAML_PLAIN_SCALAR_STYLE, value => '' }); |
638
|
|
|
|
|
|
|
} |
639
|
8552
|
|
|
|
|
21362
|
$self->remove_nodes(-1); |
640
|
|
|
|
|
|
|
|
641
|
8545
|
100
|
|
|
|
17986
|
if ($event_types->[-1] eq 'STR') { |
642
|
467
|
|
|
|
|
948
|
return; |
643
|
|
|
|
|
|
|
} |
644
|
8078
|
|
|
|
|
10866
|
my $last = pop @{ $event_types }; |
|
8078
|
|
|
|
|
12679
|
|
645
|
8078
|
50
|
33
|
|
|
30352
|
if ($last ne 'DOC' and $last ne 'DOC_END') { |
646
|
0
|
|
|
|
|
0
|
$self->exception("Unexpected event type $last"); |
647
|
|
|
|
|
|
|
} |
648
|
8078
|
|
|
|
|
11034
|
pop @{ $self->offset }; |
|
8078
|
|
|
|
|
14355
|
|
649
|
8078
|
|
|
|
|
24058
|
$self->callback->($self, 'document_end_event', { |
650
|
|
|
|
|
|
|
name => 'document_end_event', |
651
|
|
|
|
|
|
|
implicit => $implicit, |
652
|
|
|
|
|
|
|
}); |
653
|
8078
|
100
|
|
|
|
26259
|
if ($self->yaml_version eq '1.2') { |
654
|
|
|
|
|
|
|
# In YAML 1.2, directives are only for the following |
655
|
|
|
|
|
|
|
# document. In YAML 1.1, they are global |
656
|
8005
|
|
|
|
|
20648
|
$self->set_tagmap({ '!!' => "tag:yaml.org,2002:" }); |
657
|
|
|
|
|
|
|
} |
658
|
8078
|
|
|
|
|
17660
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
659
|
8078
|
|
|
|
|
15907
|
$self->set_rule('STREAM'); |
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
sub end_stream { |
663
|
7416
|
|
|
7416
|
0
|
11689
|
my ($self) = @_; |
664
|
7416
|
|
|
|
|
9953
|
my $last = pop @{ $self->events }; |
|
7416
|
|
|
|
|
12423
|
|
665
|
7416
|
50
|
|
|
|
16796
|
$self->exception("Unexpected event type $last") unless $last eq 'STR'; |
666
|
7416
|
|
|
|
|
9585
|
pop @{ $self->offset }; |
|
7416
|
|
|
|
|
12406
|
|
667
|
7416
|
|
|
|
|
18431
|
$self->callback->($self, 'stream_end_event', { |
668
|
|
|
|
|
|
|
name => 'stream_end_event', |
669
|
|
|
|
|
|
|
}); |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
sub fetch_inline_properties { |
673
|
3424
|
|
|
3424
|
0
|
6319
|
my ($self, $stack, $info) = @_; |
674
|
3424
|
|
|
|
|
5221
|
my $properties = $stack->[-1]; |
675
|
|
|
|
|
|
|
|
676
|
3424
|
|
|
|
|
5279
|
$properties = $properties->[1]; |
677
|
3424
|
|
|
|
|
4715
|
my $property_offset; |
678
|
3424
|
50
|
|
|
|
6630
|
if ($properties) { |
679
|
3424
|
|
|
|
|
4658
|
for my $p (@{ $properties->{inline} }) { |
|
3424
|
|
|
|
|
7818
|
|
680
|
3472
|
|
|
|
|
5751
|
my $type = $p->{type}; |
681
|
3472
|
50
|
|
|
|
6938
|
if (exists $info->{ $type }) { |
682
|
0
|
|
|
|
|
0
|
$self->exception("A node can only have one $type"); |
683
|
|
|
|
|
|
|
} |
684
|
3472
|
|
|
|
|
6797
|
$info->{ $type } = $p->{value}; |
685
|
3472
|
100
|
|
|
|
7391
|
unless (defined $property_offset) { |
686
|
3032
|
|
|
|
|
4887
|
$property_offset = $p->{offset}; |
687
|
3032
|
|
|
|
|
6427
|
$info->{offset} = $p->{offset}; |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
} |
690
|
3424
|
|
|
|
|
9076
|
delete $properties->{inline}; |
691
|
3424
|
100
|
|
|
|
8133
|
undef $properties unless $properties->{newline}; |
692
|
|
|
|
|
|
|
} |
693
|
|
|
|
|
|
|
|
694
|
3424
|
100
|
|
|
|
8268
|
unless ($properties) { |
695
|
2895
|
|
|
|
|
5036
|
pop @$stack; |
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
} |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
sub node_properties { |
700
|
1164
|
|
|
1164
|
0
|
2340
|
my ($self, $properties, $info) = @_; |
701
|
1164
|
50
|
|
|
|
2597
|
if ($properties) { |
702
|
1164
|
|
|
|
|
1664
|
for my $p (@{ $properties->{newline} }) { |
|
1164
|
|
|
|
|
2518
|
|
703
|
1336
|
|
|
|
|
2187
|
my $type = $p->{type}; |
704
|
1336
|
100
|
|
|
|
2725
|
if (exists $info->{ $type }) { |
705
|
1
|
|
|
|
|
4
|
$self->exception("A node can only have one $type"); |
706
|
|
|
|
|
|
|
} |
707
|
1335
|
|
|
|
|
3573
|
$info->{ $type } = $p->{value}; |
708
|
|
|
|
|
|
|
} |
709
|
1163
|
|
|
|
|
4476
|
undef $properties; |
710
|
|
|
|
|
|
|
} |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
sub scalar_event { |
714
|
29756
|
|
|
29756
|
0
|
48963
|
my ($self, $info) = @_; |
715
|
29756
|
|
|
|
|
52874
|
my $event_types = $self->events; |
716
|
29756
|
|
|
|
|
50651
|
my $event_stack = $self->event_stack; |
717
|
29756
|
100
|
66
|
|
|
65939
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
718
|
445
|
|
|
|
|
746
|
my $properties = pop @$event_stack; |
719
|
445
|
|
|
|
|
1101
|
$properties = $self->node_properties($properties->[1], $info); |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
29755
|
|
|
|
|
51158
|
$info->{name} = 'scalar_event'; |
723
|
29755
|
|
|
|
|
55565
|
$self->callback->($self, 'scalar_event', $info); |
724
|
29746
|
|
|
|
|
107253
|
$self->set_new_node(0); |
725
|
29746
|
|
|
|
|
67362
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
sub alias_event { |
729
|
550
|
|
|
550
|
0
|
1087
|
my ($self, $info) = @_; |
730
|
550
|
|
|
|
|
1019
|
my $event_stack = $self->event_stack; |
731
|
550
|
100
|
66
|
|
|
1433
|
if (@$event_stack and $event_stack->[-1]->[0] eq 'properties') { |
732
|
2
|
|
|
|
|
7
|
$self->exception("Parse error: Alias not allowed in this context"); |
733
|
|
|
|
|
|
|
} |
734
|
548
|
|
|
|
|
1037
|
my $event_types = $self->events; |
735
|
548
|
|
|
|
|
1068
|
$info->{name} = 'alias_event'; |
736
|
548
|
|
|
|
|
1174
|
$self->callback->($self, 'alias_event', $info); |
737
|
545
|
|
|
|
|
2054
|
$self->set_new_node(0); |
738
|
545
|
|
|
|
|
1483
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
sub yaml_to_tokens { |
742
|
5
|
|
|
5
|
0
|
6127
|
my ($class, $type, $input) = @_; |
743
|
5
|
|
|
38
|
|
32
|
my $yp = YAML::PP::Parser->new( receiver => sub {} ); |
744
|
5
|
|
|
|
|
10
|
my @docs = eval { |
745
|
5
|
50
|
|
|
|
18
|
$type eq 'string' ? $yp->parse_string($input) : $yp->parse_file($input); |
746
|
|
|
|
|
|
|
}; |
747
|
5
|
|
|
|
|
12
|
my $error = $@; |
748
|
|
|
|
|
|
|
|
749
|
5
|
|
|
|
|
11
|
my $tokens = $yp->tokens; |
750
|
5
|
100
|
|
|
|
13
|
if ($error) { |
751
|
1
|
|
|
|
|
5
|
my $remaining_tokens = $yp->_remaining_tokens; |
752
|
1
|
|
|
|
|
3
|
push @$tokens, map { +{ %$_, name => 'ERROR' } } @$remaining_tokens; |
|
1
|
|
|
|
|
7
|
|
753
|
|
|
|
|
|
|
} |
754
|
5
|
|
|
|
|
73
|
return $error, $tokens; |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
sub _remaining_tokens { |
758
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
759
|
1
|
|
|
|
|
2
|
my @tokens; |
760
|
1
|
|
|
|
|
3
|
my $next = $self->lexer->next_tokens; |
761
|
1
|
|
|
|
|
3
|
push @tokens, @$next; |
762
|
1
|
|
|
|
|
2
|
my $next_line = $self->lexer->next_line; |
763
|
1
|
|
|
|
|
3
|
my $remaining = ''; |
764
|
1
|
50
|
|
|
|
3
|
if ($next_line) { |
765
|
1
|
50
|
|
|
|
2
|
if ($self->lexer->offset > 0) { |
766
|
1
|
|
|
|
|
3
|
$remaining = $next_line->[1] . $next_line->[2]; |
767
|
|
|
|
|
|
|
} |
768
|
|
|
|
|
|
|
else { |
769
|
0
|
|
|
|
|
0
|
$remaining = join '', @$next_line; |
770
|
|
|
|
|
|
|
} |
771
|
|
|
|
|
|
|
} |
772
|
1
|
|
|
|
|
4
|
$remaining .= $self->reader->read; |
773
|
1
|
50
|
|
|
|
6
|
$remaining = '' unless defined $remaining; |
774
|
1
|
|
|
|
|
5
|
push @tokens, { name => "ERROR", value => $remaining }; |
775
|
1
|
|
|
|
|
3
|
return \@tokens; |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
# deprecated |
779
|
|
|
|
|
|
|
sub event_to_test_suite { |
780
|
|
|
|
|
|
|
# uncoverable subroutine |
781
|
0
|
|
|
0
|
0
|
0
|
my ($self, $event) = @_; # uncoverable statement |
782
|
0
|
0
|
|
|
|
0
|
if (ref $event eq 'ARRAY') { # uncoverable statement |
783
|
0
|
|
|
|
|
0
|
return YAML::PP::Common::event_to_test_suite($event->[1]); # uncoverable statement |
784
|
|
|
|
|
|
|
} |
785
|
0
|
|
|
|
|
0
|
return YAML::PP::Common::event_to_test_suite($event); # uncoverable statement |
786
|
|
|
|
|
|
|
} |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
sub debug_events { |
789
|
|
|
|
|
|
|
# uncoverable subroutine |
790
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; # uncoverable statement |
791
|
|
|
|
|
|
|
$self->note("EVENTS: (" # uncoverable statement |
792
|
0
|
|
|
|
|
0
|
. join (' | ', @{ $_[0]->events }) . ')' # uncoverable statement |
|
0
|
|
|
|
|
0
|
|
793
|
|
|
|
|
|
|
); |
794
|
0
|
|
|
|
|
0
|
$self->debug_offset; # uncoverable statement |
795
|
|
|
|
|
|
|
} |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
sub debug_offset { |
798
|
|
|
|
|
|
|
# uncoverable subroutine |
799
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; # uncoverable statement |
800
|
|
|
|
|
|
|
$self->note( |
801
|
|
|
|
|
|
|
qq{OFFSET: (} |
802
|
|
|
|
|
|
|
# uncoverable statement count:1 |
803
|
|
|
|
|
|
|
# uncoverable statement count:2 |
804
|
|
|
|
|
|
|
# uncoverable statement count:3 |
805
|
0
|
0
|
|
|
|
0
|
. join (' | ', map { defined $_ ? sprintf "%-3d", $_ : '?' } @{ $_[0]->offset }) |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
806
|
|
|
|
|
|
|
# uncoverable statement |
807
|
0
|
|
|
|
|
0
|
. qq/) level=@{[ $_[0]->level ]}]}/ |
808
|
|
|
|
|
|
|
); |
809
|
|
|
|
|
|
|
} |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
sub debug_yaml { |
812
|
|
|
|
|
|
|
# uncoverable subroutine |
813
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; # uncoverable statement |
814
|
0
|
|
|
|
|
0
|
my $line = $self->lexer->line; # uncoverable statement |
815
|
0
|
|
|
|
|
0
|
$self->note("LINE NUMBER: $line"); # uncoverable statement |
816
|
0
|
|
|
|
|
0
|
my $next_tokens = $self->lexer->next_tokens; # uncoverable statement |
817
|
0
|
0
|
|
|
|
0
|
if (@$next_tokens) { # uncoverable statement |
818
|
0
|
|
|
|
|
0
|
$self->debug_tokens($next_tokens); # uncoverable statement |
819
|
|
|
|
|
|
|
} |
820
|
|
|
|
|
|
|
} |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
sub debug_next_line { |
823
|
1
|
|
|
1
|
0
|
4
|
my ($self) = @_; |
824
|
1
|
|
50
|
|
|
3
|
my $next_line = $self->lexer->next_line || []; |
825
|
1
|
|
|
|
|
3
|
my $line = $next_line->[0]; |
826
|
1
|
50
|
|
|
|
10
|
$line = '' unless defined $line; |
827
|
1
|
|
|
|
|
3
|
$line =~ s/( +)$/'·' x length $1/e; |
|
0
|
|
|
|
|
0
|
|
828
|
1
|
|
|
|
|
2
|
$line =~ s/\t/â–¸/g; |
829
|
1
|
|
|
|
|
5
|
$self->note("NEXT LINE: >>$line<<"); |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
sub note { |
833
|
1
|
|
|
1
|
0
|
3
|
my ($self, $msg) = @_; |
834
|
1
|
|
|
|
|
5
|
$self->_colorize_warn(["yellow"], "============ $msg"); |
835
|
|
|
|
|
|
|
} |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
sub info { |
838
|
28
|
|
|
28
|
0
|
45
|
my ($self, $msg) = @_; |
839
|
28
|
|
|
|
|
82
|
$self->_colorize_warn(["cyan"], "============ $msg"); |
840
|
|
|
|
|
|
|
} |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
sub got { |
843
|
14
|
|
|
14
|
0
|
21
|
my ($self, $msg) = @_; |
844
|
14
|
|
|
|
|
36
|
$self->_colorize_warn(["green"], "============ $msg"); |
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
sub _colorize_warn { |
848
|
|
|
|
|
|
|
# uncoverable subroutine |
849
|
0
|
|
|
0
|
|
0
|
my ($self, $colors, $text) = @_; # uncoverable statement |
850
|
0
|
|
|
|
|
0
|
require Term::ANSIColor; # uncoverable statement |
851
|
0
|
|
|
|
|
0
|
warn Term::ANSIColor::colored($colors, $text), "\n"; # uncoverable statement |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
sub debug_event { |
855
|
|
|
|
|
|
|
# uncoverable subroutine |
856
|
0
|
|
|
0
|
0
|
0
|
my ($self, $event) = @_; # uncoverable statement |
857
|
0
|
|
|
|
|
0
|
my $str = YAML::PP::Common::event_to_test_suite($event); # uncoverable statement |
858
|
0
|
|
|
|
|
0
|
require Term::ANSIColor; # uncoverable statement |
859
|
0
|
|
|
|
|
0
|
warn Term::ANSIColor::colored(["magenta"], "============ $str"), "\n"; # uncoverable statement |
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
sub debug_rules { |
863
|
|
|
|
|
|
|
# uncoverable subroutine |
864
|
0
|
|
|
0
|
0
|
0
|
my ($self, $rules) = @_; # uncoverable statement |
865
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Maxdepth = 2; # uncoverable statement |
866
|
0
|
|
|
|
|
0
|
$self->note("RULES:"); # uncoverable statement |
867
|
0
|
|
|
|
|
0
|
for my $rule ($rules) { # uncoverable statement |
868
|
0
|
0
|
|
|
|
0
|
if (ref $rule eq 'ARRAY') { # uncoverable statement |
869
|
0
|
|
|
|
|
0
|
my $first = $rule->[0]; # uncoverable statement |
870
|
0
|
0
|
|
|
|
0
|
if (ref $first eq 'SCALAR') { # uncoverable statement |
871
|
0
|
|
|
|
|
0
|
$self->info("-> $$first"); # uncoverable statement |
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
else { # uncoverable statement |
874
|
0
|
0
|
|
|
|
0
|
if (ref $first eq 'ARRAY') { # uncoverable statement |
875
|
0
|
|
|
|
|
0
|
$first = $first->[0]; # uncoverable statement |
876
|
|
|
|
|
|
|
} |
877
|
0
|
|
|
|
|
0
|
$self->info("TYPE $first"); # uncoverable statement |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
} |
880
|
|
|
|
|
|
|
else { # uncoverable statement |
881
|
0
|
|
|
|
|
0
|
eval { # uncoverable statement |
882
|
0
|
|
|
|
|
0
|
my @keys = sort keys %$rule; # uncoverable statement |
883
|
0
|
|
|
|
|
0
|
$self->info("@keys"); # uncoverable statement |
884
|
|
|
|
|
|
|
}; |
885
|
|
|
|
|
|
|
} |
886
|
|
|
|
|
|
|
} |
887
|
|
|
|
|
|
|
} |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
sub debug_tokens { |
890
|
|
|
|
|
|
|
# uncoverable subroutine |
891
|
0
|
|
|
0
|
0
|
0
|
my ($self, $tokens) = @_; # uncoverable statement |
892
|
0
|
|
0
|
|
|
0
|
$tokens ||= $self->tokens; # uncoverable statement |
893
|
0
|
|
|
|
|
0
|
require Term::ANSIColor; # uncoverable statement |
894
|
0
|
|
|
|
|
0
|
for my $token (@$tokens) { # uncoverable statement |
895
|
|
|
|
|
|
|
my $type = Term::ANSIColor::colored(["green"], # uncoverable statement |
896
|
|
|
|
|
|
|
sprintf "%-22s L %2d C %2d ", # uncoverable statement |
897
|
0
|
|
|
|
|
0
|
$token->{name}, $token->{line}, $token->{column} + 1 # uncoverable statement |
898
|
|
|
|
|
|
|
); |
899
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Useqq = 1; # uncoverable statement |
900
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Terse = 1; # uncoverable statement |
901
|
0
|
|
|
|
|
0
|
require Data::Dumper; # uncoverable statement |
902
|
0
|
|
|
|
|
0
|
my $str = Data::Dumper->Dump([$token->{value}], ['str']); # uncoverable statement |
903
|
0
|
|
|
|
|
0
|
chomp $str; # uncoverable statement |
904
|
0
|
|
|
|
|
0
|
$str =~ s/(^.|.$)/Term::ANSIColor::colored(['blue'], $1)/ge; # uncoverable statement |
|
0
|
|
|
|
|
0
|
|
905
|
0
|
|
|
|
|
0
|
warn "$type$str\n"; # uncoverable statement |
906
|
|
|
|
|
|
|
} |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
sub highlight_yaml { |
911
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
912
|
0
|
|
|
|
|
0
|
require YAML::PP::Highlight; |
913
|
0
|
|
|
|
|
0
|
my $tokens = $self->tokens; |
914
|
0
|
|
|
|
|
0
|
my $highlighted = YAML::PP::Highlight->ansicolored($tokens); |
915
|
0
|
|
|
|
|
0
|
warn $highlighted; |
916
|
|
|
|
|
|
|
} |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
sub exception { |
919
|
63
|
|
|
63
|
0
|
184
|
my ($self, $msg, %args) = @_; |
920
|
63
|
|
|
|
|
128
|
my $next = $self->lexer->next_tokens; |
921
|
63
|
100
|
|
|
|
148
|
my $line = @$next ? $next->[0]->{line} : $self->lexer->line; |
922
|
63
|
100
|
|
|
|
122
|
my $offset = @$next ? $next->[0]->{column} : $self->lexer->offset; |
923
|
63
|
|
|
|
|
79
|
$offset++; |
924
|
63
|
|
|
|
|
114
|
my $next_line = $self->lexer->next_line; |
925
|
63
|
|
|
|
|
105
|
my $remaining = ''; |
926
|
63
|
100
|
|
|
|
125
|
if ($next_line) { |
927
|
38
|
100
|
|
|
|
67
|
if ($self->lexer->offset > 0) { |
928
|
36
|
|
|
|
|
68
|
$remaining = $next_line->[1] . $next_line->[2]; |
929
|
|
|
|
|
|
|
} |
930
|
|
|
|
|
|
|
else { |
931
|
2
|
|
|
|
|
9
|
$remaining = join '', @$next_line; |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
} |
934
|
63
|
|
100
|
|
|
269
|
my $caller = $args{caller} || [ caller(0) ]; |
935
|
|
|
|
|
|
|
my $e = YAML::PP::Exception->new( |
936
|
|
|
|
|
|
|
got => $args{got}, |
937
|
|
|
|
|
|
|
expected => $args{expected}, |
938
|
63
|
|
|
|
|
367
|
line => $line, |
939
|
|
|
|
|
|
|
column => $offset, |
940
|
|
|
|
|
|
|
msg => $msg, |
941
|
|
|
|
|
|
|
next => $next, |
942
|
|
|
|
|
|
|
where => $caller->[1] . ' line ' . $caller->[2], |
943
|
|
|
|
|
|
|
yaml => $remaining, |
944
|
|
|
|
|
|
|
); |
945
|
63
|
|
|
|
|
1360
|
croak $e; |
946
|
|
|
|
|
|
|
} |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
sub expected { |
949
|
48
|
|
|
48
|
0
|
144
|
my ($self, %args) = @_; |
950
|
48
|
|
|
|
|
79
|
my $expected = $args{expected}; |
951
|
48
|
|
|
|
|
95
|
@$expected = sort grep { m/^[A-Z_]+$/ } @$expected; |
|
222
|
|
|
|
|
821
|
|
952
|
48
|
|
|
|
|
101
|
my $got = $args{got}->{name}; |
953
|
48
|
|
|
|
|
381
|
my @caller = caller(0); |
954
|
|
|
|
|
|
|
$self->exception("Expected (@$expected), but got $got", |
955
|
|
|
|
|
|
|
caller => \@caller, |
956
|
|
|
|
|
|
|
expected => $expected, |
957
|
|
|
|
|
|
|
got => $args{got}, |
958
|
48
|
|
|
|
|
283
|
); |
959
|
|
|
|
|
|
|
} |
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
sub cb_tag { |
962
|
2729
|
|
|
2729
|
0
|
4913
|
my ($self, $token) = @_; |
963
|
2729
|
|
|
|
|
5342
|
my $stack = $self->event_stack; |
964
|
2729
|
100
|
66
|
|
|
8821
|
if (! @$stack or $stack->[-1]->[0] ne 'properties') { |
965
|
2229
|
|
|
|
|
5484
|
push @$stack, [ properties => {} ]; |
966
|
|
|
|
|
|
|
} |
967
|
2729
|
|
|
|
|
4712
|
my $last = $stack->[-1]->[1]; |
968
|
2729
|
|
|
|
|
5818
|
my $tag = $self->_read_tag($token->{value}, $self->tagmap); |
969
|
2727
|
|
100
|
|
|
12796
|
$last->{inline} ||= []; |
970
|
2727
|
|
|
|
|
10779
|
push @{ $last->{inline} }, { |
971
|
|
|
|
|
|
|
type => 'tag', |
972
|
|
|
|
|
|
|
value => $tag, |
973
|
|
|
|
|
|
|
offset => $token->{column}, |
974
|
2727
|
|
|
|
|
4004
|
}; |
975
|
|
|
|
|
|
|
} |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
sub _read_tag { |
978
|
2729
|
|
|
2729
|
|
5669
|
my ($self, $tag, $map) = @_; |
979
|
2729
|
100
|
|
|
|
18968
|
if ($tag eq '!') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
980
|
75
|
|
|
|
|
180
|
return "!"; |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
elsif ($tag =~ m/^!<(.*)>/) { |
983
|
133
|
|
|
|
|
561
|
return $1; |
984
|
|
|
|
|
|
|
} |
985
|
|
|
|
|
|
|
elsif ($tag =~ m/^(![^!]*!|!)(.+)/) { |
986
|
2521
|
|
|
|
|
6310
|
my $alias = $1; |
987
|
2521
|
|
|
|
|
4344
|
my $name = $2; |
988
|
2521
|
|
|
|
|
5584
|
$name =~ s/%([0-9a-fA-F]{2})/chr hex $1/eg; |
|
18
|
|
|
|
|
129
|
|
989
|
2521
|
100
|
|
|
|
6190
|
if (exists $map->{ $alias }) { |
990
|
2289
|
|
|
|
|
6454
|
$tag = $map->{ $alias }. $name; |
991
|
|
|
|
|
|
|
} |
992
|
|
|
|
|
|
|
else { |
993
|
232
|
100
|
66
|
|
|
782
|
if ($alias ne '!' and $alias ne '!!') { |
994
|
2
|
|
|
|
|
22
|
die "Found undefined tag handle '$alias'"; |
995
|
|
|
|
|
|
|
} |
996
|
230
|
|
|
|
|
566
|
$tag = "!$name"; |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
} |
999
|
|
|
|
|
|
|
else { |
1000
|
0
|
|
|
|
|
0
|
die "Invalid tag"; |
1001
|
|
|
|
|
|
|
} |
1002
|
2519
|
|
|
|
|
5431
|
return $tag; |
1003
|
|
|
|
|
|
|
} |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
sub cb_anchor { |
1006
|
2089
|
|
|
2089
|
0
|
4071
|
my ($self, $token) = @_; |
1007
|
2089
|
|
|
|
|
3741
|
my $anchor = $token->{value}; |
1008
|
2089
|
|
|
|
|
5989
|
$anchor = substr($anchor, 1); |
1009
|
2089
|
|
|
|
|
4493
|
my $stack = $self->event_stack; |
1010
|
2089
|
100
|
66
|
|
|
6342
|
if (! @$stack or $stack->[-1]->[0] ne 'properties') { |
1011
|
1840
|
|
|
|
|
4476
|
push @$stack, [ properties => {} ]; |
1012
|
|
|
|
|
|
|
} |
1013
|
2089
|
|
|
|
|
3507
|
my $last = $stack->[-1]->[1]; |
1014
|
2089
|
|
100
|
|
|
9345
|
$last->{inline} ||= []; |
1015
|
2089
|
|
|
|
|
8901
|
push @{ $last->{inline} }, { |
1016
|
|
|
|
|
|
|
type => 'anchor', |
1017
|
|
|
|
|
|
|
value => $anchor, |
1018
|
|
|
|
|
|
|
offset => $token->{column}, |
1019
|
2089
|
|
|
|
|
3018
|
}; |
1020
|
|
|
|
|
|
|
} |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
sub cb_property_eol { |
1023
|
1191
|
|
|
1191
|
0
|
2614
|
my ($self, $res) = @_; |
1024
|
1191
|
|
|
|
|
2283
|
my $stack = $self->event_stack; |
1025
|
1191
|
|
|
|
|
1995
|
my $last = $stack->[-1]->[1]; |
1026
|
1191
|
50
|
|
|
|
4175
|
my $inline = delete $last->{inline} or return; |
1027
|
1191
|
|
100
|
|
|
4707
|
my $newline = $last->{newline} ||= []; |
1028
|
1191
|
|
|
|
|
3244
|
push @$newline, @$inline; |
1029
|
|
|
|
|
|
|
} |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
sub cb_mapkey { |
1032
|
3892
|
|
|
3892
|
0
|
7248
|
my ($self, $token) = @_; |
1033
|
3892
|
|
|
|
|
7591
|
my $stack = $self->event_stack; |
1034
|
|
|
|
|
|
|
my $info = { |
1035
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1036
|
|
|
|
|
|
|
value => $token->{value}, |
1037
|
|
|
|
|
|
|
offset => $token->{column}, |
1038
|
3892
|
|
|
|
|
13458
|
}; |
1039
|
3892
|
100
|
66
|
|
|
10516
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1040
|
72
|
|
|
|
|
205
|
$self->fetch_inline_properties($stack, $info); |
1041
|
|
|
|
|
|
|
} |
1042
|
3892
|
|
|
|
|
5312
|
push @{ $stack }, [ scalar => $info ]; |
|
3892
|
|
|
|
|
9169
|
|
1043
|
|
|
|
|
|
|
} |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
sub cb_send_mapkey { |
1046
|
4263
|
|
|
4263
|
0
|
7764
|
my ($self, $res) = @_; |
1047
|
4263
|
|
|
|
|
5603
|
my $last = pop @{ $self->event_stack }; |
|
4263
|
|
|
|
|
7408
|
|
1048
|
4263
|
|
|
|
|
12347
|
$self->scalar_event($last->[1]); |
1049
|
4263
|
|
|
|
|
8358
|
$self->set_new_node(1); |
1050
|
|
|
|
|
|
|
} |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
sub cb_send_scalar { |
1053
|
17727
|
|
|
17727
|
0
|
31607
|
my ($self, $res) = @_; |
1054
|
17727
|
|
|
|
|
23414
|
my $last = pop @{ $self->event_stack }; |
|
17727
|
|
|
|
|
29834
|
|
1055
|
17727
|
100
|
|
|
|
36016
|
return unless $last; |
1056
|
17018
|
|
|
|
|
45828
|
$self->scalar_event($last->[1]); |
1057
|
17008
|
|
|
|
|
28959
|
my $e = $self->events; |
1058
|
17008
|
100
|
|
|
|
55277
|
if ($e->[-1] eq 'IMAP') { |
1059
|
9
|
|
|
|
|
21
|
$self->end_flow_mapping; |
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
sub cb_empty_mapkey { |
1064
|
113
|
|
|
113
|
0
|
280
|
my ($self, $token) = @_; |
1065
|
113
|
|
|
|
|
251
|
my $stack = $self->event_stack; |
1066
|
|
|
|
|
|
|
my $info = { |
1067
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1068
|
|
|
|
|
|
|
value => '', |
1069
|
|
|
|
|
|
|
offset => $token->{column}, |
1070
|
113
|
|
|
|
|
429
|
}; |
1071
|
113
|
100
|
66
|
|
|
441
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1072
|
9
|
|
|
|
|
27
|
$self->fetch_inline_properties($stack, $info); |
1073
|
|
|
|
|
|
|
} |
1074
|
113
|
|
|
|
|
335
|
$self->scalar_event($info); |
1075
|
113
|
|
|
|
|
303
|
$self->set_new_node(1); |
1076
|
|
|
|
|
|
|
} |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
sub cb_send_flow_alias { |
1079
|
17
|
|
|
17
|
0
|
46
|
my ($self, $token) = @_; |
1080
|
17
|
|
|
|
|
54
|
my $alias = substr($token->{value}, 1); |
1081
|
17
|
|
|
|
|
68
|
$self->alias_event({ value => $alias }); |
1082
|
|
|
|
|
|
|
} |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
sub cb_send_alias { |
1085
|
291
|
|
|
291
|
0
|
653
|
my ($self, $token) = @_; |
1086
|
291
|
|
|
|
|
921
|
my $alias = substr($token->{value}, 1); |
1087
|
291
|
|
|
|
|
1996
|
$self->alias_event({ value => $alias }); |
1088
|
|
|
|
|
|
|
} |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
sub cb_send_alias_key { |
1091
|
62
|
|
|
62
|
0
|
139
|
my ($self, $token) = @_; |
1092
|
62
|
|
|
|
|
187
|
my $alias = substr($token->{value}, 1); |
1093
|
62
|
|
|
|
|
264
|
$self->alias_event({ value => $alias }); |
1094
|
61
|
|
|
|
|
421
|
$self->set_new_node(1); |
1095
|
|
|
|
|
|
|
} |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
sub cb_send_alias_from_stack { |
1098
|
143
|
|
|
143
|
0
|
386
|
my ($self, $token) = @_; |
1099
|
143
|
|
|
|
|
272
|
my $last = pop @{ $self->event_stack }; |
|
143
|
|
|
|
|
297
|
|
1100
|
143
|
|
|
|
|
392
|
$self->alias_event($last->[1]); |
1101
|
|
|
|
|
|
|
} |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
sub cb_alias { |
1104
|
180
|
|
|
180
|
0
|
382
|
my ($self, $token) = @_; |
1105
|
180
|
|
|
|
|
469
|
my $alias = substr($token->{value}, 1); |
1106
|
180
|
|
|
|
|
384
|
push @{ $self->event_stack }, [ alias => { |
1107
|
|
|
|
|
|
|
value => $alias, |
1108
|
|
|
|
|
|
|
offset => $token->{column}, |
1109
|
180
|
|
|
|
|
310
|
}]; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
sub cb_question { |
1113
|
173
|
|
|
173
|
0
|
469
|
my ($self, $res) = @_; |
1114
|
173
|
|
|
|
|
432
|
$self->set_new_node(1); |
1115
|
|
|
|
|
|
|
} |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
sub cb_flow_question { |
1118
|
93
|
|
|
93
|
0
|
193
|
my ($self, $res) = @_; |
1119
|
93
|
|
|
|
|
204
|
$self->set_new_node(2); |
1120
|
|
|
|
|
|
|
} |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
sub cb_empty_complexvalue { |
1123
|
54
|
|
|
54
|
0
|
152
|
my ($self, $res) = @_; |
1124
|
54
|
|
|
|
|
235
|
$self->scalar_event({ style => YAML_PLAIN_SCALAR_STYLE, value => '' }); |
1125
|
|
|
|
|
|
|
} |
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
sub cb_questionstart { |
1128
|
339
|
|
|
339
|
0
|
794
|
my ($self, $token) = @_; |
1129
|
339
|
|
|
|
|
963
|
$self->start_mapping($token->{column}); |
1130
|
|
|
|
|
|
|
} |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
sub cb_complexcolon { |
1133
|
405
|
|
|
405
|
0
|
893
|
my ($self, $res) = @_; |
1134
|
405
|
|
|
|
|
988
|
$self->set_new_node(1); |
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
sub cb_seqstart { |
1138
|
3222
|
|
|
3222
|
0
|
5960
|
my ($self, $token) = @_; |
1139
|
3222
|
|
|
|
|
5212
|
my $column = $token->{column}; |
1140
|
3222
|
|
|
|
|
8073
|
$self->start_sequence($column); |
1141
|
3222
|
|
|
|
|
10929
|
$self->set_new_node(1); |
1142
|
|
|
|
|
|
|
} |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
sub cb_seqitem { |
1145
|
4235
|
|
|
4235
|
0
|
8047
|
my ($self, $res) = @_; |
1146
|
4235
|
|
|
|
|
8554
|
$self->set_new_node(1); |
1147
|
|
|
|
|
|
|
} |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
sub cb_take_quoted { |
1150
|
3990
|
|
|
3990
|
0
|
7339
|
my ($self, $token) = @_; |
1151
|
3990
|
|
|
|
|
6241
|
my $subtokens = $token->{subtokens}; |
1152
|
3990
|
|
|
|
|
7762
|
my $stack = $self->event_stack; |
1153
|
|
|
|
|
|
|
my $info = { |
1154
|
|
|
|
|
|
|
style => $subtokens->[0]->{value} eq '"' |
1155
|
|
|
|
|
|
|
? YAML_DOUBLE_QUOTED_SCALAR_STYLE |
1156
|
|
|
|
|
|
|
: YAML_SINGLE_QUOTED_SCALAR_STYLE, |
1157
|
|
|
|
|
|
|
value => $token->{value}, |
1158
|
|
|
|
|
|
|
offset => $token->{column}, |
1159
|
3990
|
100
|
|
|
|
16625
|
}; |
1160
|
3990
|
100
|
66
|
|
|
11017
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1161
|
236
|
|
|
|
|
695
|
$self->fetch_inline_properties($stack, $info); |
1162
|
|
|
|
|
|
|
} |
1163
|
3990
|
|
|
|
|
5514
|
push @{ $stack }, [ scalar => $info ]; |
|
3990
|
|
|
|
|
9697
|
|
1164
|
|
|
|
|
|
|
} |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
sub cb_quoted_multiline { |
1167
|
484
|
|
|
484
|
0
|
1064
|
my ($self, $token) = @_; |
1168
|
484
|
|
|
|
|
883
|
my $subtokens = $token->{subtokens}; |
1169
|
484
|
|
|
|
|
1075
|
my $stack = $self->event_stack; |
1170
|
|
|
|
|
|
|
my $info = { |
1171
|
|
|
|
|
|
|
style => $subtokens->[0]->{value} eq '"' |
1172
|
|
|
|
|
|
|
? YAML_DOUBLE_QUOTED_SCALAR_STYLE |
1173
|
|
|
|
|
|
|
: YAML_SINGLE_QUOTED_SCALAR_STYLE, |
1174
|
|
|
|
|
|
|
value => $token->{value}, |
1175
|
|
|
|
|
|
|
offset => $token->{column}, |
1176
|
484
|
100
|
|
|
|
2398
|
}; |
1177
|
484
|
100
|
66
|
|
|
1559
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1178
|
16
|
|
|
|
|
49
|
$self->fetch_inline_properties($stack, $info); |
1179
|
|
|
|
|
|
|
} |
1180
|
484
|
|
|
|
|
736
|
push @{ $stack }, [ scalar => $info ]; |
|
484
|
|
|
|
|
1231
|
|
1181
|
484
|
|
|
|
|
1129
|
$self->cb_send_scalar; |
1182
|
|
|
|
|
|
|
} |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
sub cb_take_quoted_key { |
1185
|
375
|
|
|
375
|
0
|
720
|
my ($self, $token) = @_; |
1186
|
375
|
|
|
|
|
978
|
$self->cb_take_quoted($token); |
1187
|
375
|
|
|
|
|
954
|
$self->cb_send_mapkey; |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
sub cb_send_plain_multi { |
1191
|
241
|
|
|
241
|
0
|
947
|
my ($self, $token) = @_; |
1192
|
241
|
|
|
|
|
528
|
my $stack = $self->event_stack; |
1193
|
|
|
|
|
|
|
my $info = { |
1194
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1195
|
|
|
|
|
|
|
value => $token->{value}, |
1196
|
|
|
|
|
|
|
offset => $token->{column}, |
1197
|
241
|
|
|
|
|
1052
|
}; |
1198
|
241
|
100
|
66
|
|
|
831
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1199
|
9
|
|
|
|
|
34
|
$self->fetch_inline_properties($stack, $info); |
1200
|
|
|
|
|
|
|
} |
1201
|
241
|
|
|
|
|
430
|
push @{ $stack }, [ scalar => $info ]; |
|
241
|
|
|
|
|
696
|
|
1202
|
241
|
|
|
|
|
649
|
$self->cb_send_scalar; |
1203
|
|
|
|
|
|
|
} |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
sub cb_start_plain { |
1206
|
15525
|
|
|
15525
|
0
|
26377
|
my ($self, $token) = @_; |
1207
|
15525
|
|
|
|
|
30082
|
my $stack = $self->event_stack; |
1208
|
|
|
|
|
|
|
my $info = { |
1209
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1210
|
|
|
|
|
|
|
value => $token->{value}, |
1211
|
|
|
|
|
|
|
offset => $token->{column}, |
1212
|
15525
|
|
|
|
|
50704
|
}; |
1213
|
15525
|
100
|
66
|
|
|
43733
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1214
|
2212
|
|
|
|
|
5456
|
$self->fetch_inline_properties($stack, $info); |
1215
|
|
|
|
|
|
|
} |
1216
|
15525
|
|
|
|
|
21420
|
push @{ $stack }, [ scalar => $info ]; |
|
15525
|
|
|
|
|
36005
|
|
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
sub cb_start_flowseq { |
1220
|
1361
|
|
|
1361
|
0
|
2591
|
my ($self, $token) = @_; |
1221
|
1361
|
|
|
|
|
3451
|
$self->start_flow_sequence($token->{column}); |
1222
|
|
|
|
|
|
|
} |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
sub cb_start_flowmap { |
1225
|
1109
|
|
|
1109
|
0
|
2284
|
my ($self, $token) = @_; |
1226
|
1109
|
|
|
|
|
2994
|
$self->start_flow_mapping($token->{column}); |
1227
|
|
|
|
|
|
|
} |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
sub cb_end_flowseq { |
1230
|
1349
|
|
|
1349
|
0
|
2709
|
my ($self, $res) = @_; |
1231
|
1349
|
|
|
|
|
3303
|
$self->cb_send_scalar; |
1232
|
1349
|
|
|
|
|
3922
|
$self->end_flow_sequence; |
1233
|
1349
|
|
|
|
|
2755
|
$self->set_new_node(0); |
1234
|
|
|
|
|
|
|
} |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
sub cb_flow_comma { |
1237
|
2340
|
|
|
2340
|
0
|
4389
|
my ($self) = @_; |
1238
|
2340
|
|
|
|
|
4279
|
my $event_types = $self->events; |
1239
|
2340
|
|
|
|
|
5582
|
$self->set_new_node(0); |
1240
|
2340
|
100
|
|
|
|
9055
|
if ($event_types->[-1] =~ m/^FLOWSEQ/) { |
1241
|
1682
|
|
|
|
|
4418
|
$self->cb_send_scalar; |
1242
|
1682
|
|
|
|
|
3815
|
$event_types->[-1] = $next_event{ $event_types->[-1] }; |
1243
|
|
|
|
|
|
|
} |
1244
|
|
|
|
|
|
|
} |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
sub cb_flow_colon { |
1247
|
1101
|
|
|
1101
|
0
|
2167
|
my ($self) = @_; |
1248
|
1101
|
|
|
|
|
2101
|
$self->set_new_node(1); |
1249
|
|
|
|
|
|
|
} |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
sub cb_empty_flow_mapkey { |
1252
|
402
|
|
|
402
|
0
|
938
|
my ($self, $token) = @_; |
1253
|
402
|
|
|
|
|
730
|
my $stack = $self->event_stack; |
1254
|
|
|
|
|
|
|
my $info = { |
1255
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1256
|
|
|
|
|
|
|
value => '', |
1257
|
|
|
|
|
|
|
offset => $token->{column}, |
1258
|
402
|
|
|
|
|
2295
|
}; |
1259
|
402
|
100
|
66
|
|
|
1675
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1260
|
243
|
|
|
|
|
558
|
$self->fetch_inline_properties($stack, $info); |
1261
|
|
|
|
|
|
|
} |
1262
|
402
|
|
|
|
|
1035
|
$self->scalar_event($info); |
1263
|
|
|
|
|
|
|
} |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
sub cb_end_flowmap { |
1266
|
1001
|
|
|
1001
|
0
|
1966
|
my ($self, $res) = @_; |
1267
|
1001
|
|
|
|
|
2782
|
$self->end_flow_mapping; |
1268
|
993
|
|
|
|
|
2069
|
$self->set_new_node(0); |
1269
|
|
|
|
|
|
|
} |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
sub cb_end_flowmap_empty { |
1272
|
106
|
|
|
106
|
0
|
236
|
my ($self, $res) = @_; |
1273
|
106
|
|
|
|
|
326
|
$self->cb_empty_flowmap_value; |
1274
|
106
|
|
|
|
|
386
|
$self->end_flow_mapping; |
1275
|
106
|
|
|
|
|
265
|
$self->set_new_node(0); |
1276
|
|
|
|
|
|
|
} |
1277
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
sub cb_flowkey_plain { |
1279
|
938
|
|
|
938
|
0
|
1956
|
my ($self, $token) = @_; |
1280
|
938
|
|
|
|
|
1968
|
my $stack = $self->event_stack; |
1281
|
|
|
|
|
|
|
my $info = { |
1282
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1283
|
|
|
|
|
|
|
value => $token->{value}, |
1284
|
|
|
|
|
|
|
offset => $token->{column}, |
1285
|
938
|
|
|
|
|
3501
|
}; |
1286
|
938
|
100
|
66
|
|
|
2686
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1287
|
21
|
|
|
|
|
60
|
$self->fetch_inline_properties($stack, $info); |
1288
|
|
|
|
|
|
|
} |
1289
|
938
|
|
|
|
|
2277
|
$self->scalar_event($info); |
1290
|
|
|
|
|
|
|
} |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
sub cb_flowkey_quoted { |
1293
|
139
|
|
|
139
|
0
|
343
|
my ($self, $token) = @_; |
1294
|
139
|
|
|
|
|
309
|
my $stack = $self->event_stack; |
1295
|
139
|
|
|
|
|
316
|
my $subtokens = $token->{subtokens}; |
1296
|
|
|
|
|
|
|
my $info = { |
1297
|
|
|
|
|
|
|
style => $subtokens->[0]->{value} eq '"' |
1298
|
|
|
|
|
|
|
? YAML_DOUBLE_QUOTED_SCALAR_STYLE |
1299
|
|
|
|
|
|
|
: YAML_SINGLE_QUOTED_SCALAR_STYLE, |
1300
|
|
|
|
|
|
|
value => $token->{value}, |
1301
|
|
|
|
|
|
|
offset => $token->{column}, |
1302
|
139
|
100
|
|
|
|
702
|
}; |
1303
|
139
|
100
|
66
|
|
|
481
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1304
|
2
|
|
|
|
|
6
|
$self->fetch_inline_properties($stack, $info); |
1305
|
|
|
|
|
|
|
} |
1306
|
139
|
|
|
|
|
371
|
$self->scalar_event($info); |
1307
|
|
|
|
|
|
|
} |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
sub cb_empty_flowmap_key_value { |
1310
|
136
|
|
|
136
|
0
|
274
|
my ($self, $token) = @_; |
1311
|
136
|
|
|
|
|
391
|
$self->cb_empty_flow_mapkey($token); |
1312
|
136
|
|
|
|
|
388
|
$self->cb_empty_flowmap_value; |
1313
|
136
|
|
|
|
|
331
|
$self->cb_flow_comma; |
1314
|
|
|
|
|
|
|
} |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
sub cb_end_empty_flowmap_key_value { |
1317
|
124
|
|
|
124
|
0
|
262
|
my ($self, $token) = @_; |
1318
|
124
|
|
|
|
|
352
|
$self->cb_empty_flow_mapkey($token); |
1319
|
124
|
|
|
|
|
390
|
$self->cb_empty_flowmap_value; |
1320
|
124
|
|
|
|
|
356
|
$self->cb_flow_comma; |
1321
|
124
|
|
|
|
|
362
|
$self->cb_end_flowmap; |
1322
|
|
|
|
|
|
|
} |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
sub cb_empty_flowmap_value { |
1325
|
569
|
|
|
569
|
0
|
1082
|
my ($self, $token) = @_; |
1326
|
569
|
|
|
|
|
1042
|
my $stack = $self->event_stack; |
1327
|
|
|
|
|
|
|
my $info = { |
1328
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1329
|
|
|
|
|
|
|
value => '', |
1330
|
|
|
|
|
|
|
offset => $token->{column}, |
1331
|
569
|
|
|
|
|
1889
|
}; |
1332
|
569
|
100
|
66
|
|
|
1872
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1333
|
167
|
|
|
|
|
373
|
$self->fetch_inline_properties($stack, $info); |
1334
|
|
|
|
|
|
|
} |
1335
|
569
|
|
|
|
|
1213
|
$self->scalar_event($info); |
1336
|
|
|
|
|
|
|
} |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
sub cb_empty_flowseq_comma { |
1339
|
90
|
|
|
90
|
0
|
168
|
my ($self, $token) = @_; |
1340
|
90
|
|
|
|
|
252
|
$self->cb_empty_flowmap_value($token); |
1341
|
90
|
|
|
|
|
220
|
$self->cb_flow_comma; |
1342
|
|
|
|
|
|
|
} |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
sub cb_empty_flowseq_end { |
1345
|
72
|
|
|
72
|
0
|
154
|
my ($self, $token) = @_; |
1346
|
72
|
|
|
|
|
191
|
$self->cb_empty_flowmap_value($token); |
1347
|
72
|
|
|
|
|
164
|
$self->cb_end_flowseq; |
1348
|
|
|
|
|
|
|
} |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
sub cb_insert_map_alias { |
1351
|
37
|
|
|
37
|
0
|
81
|
my ($self, $res) = @_; |
1352
|
37
|
|
|
|
|
72
|
my $stack = $self->event_stack; |
1353
|
37
|
|
|
|
|
73
|
my $scalar = pop @$stack; |
1354
|
37
|
|
|
|
|
66
|
my $info = $scalar->[1]; |
1355
|
37
|
|
|
|
|
106
|
$self->start_mapping($info->{offset}); |
1356
|
37
|
|
|
|
|
191
|
$self->alias_event($info); |
1357
|
37
|
|
|
|
|
77
|
$self->set_new_node(1); |
1358
|
|
|
|
|
|
|
} |
1359
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
sub cb_insert_map { |
1361
|
4547
|
|
|
4547
|
0
|
8233
|
my ($self, $res) = @_; |
1362
|
4547
|
|
|
|
|
8097
|
my $stack = $self->event_stack; |
1363
|
4547
|
|
|
|
|
7426
|
my $scalar = pop @$stack; |
1364
|
4547
|
|
|
|
|
6939
|
my $info = $scalar->[1]; |
1365
|
4547
|
|
|
|
|
12377
|
$self->start_mapping($info->{offset}); |
1366
|
4547
|
|
|
|
|
17589
|
$self->scalar_event($info); |
1367
|
4547
|
|
|
|
|
8297
|
$self->set_new_node(1); |
1368
|
|
|
|
|
|
|
} |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
sub cb_insert_implicit_flowseq_map { |
1371
|
7
|
|
|
7
|
0
|
23
|
my ($self, $res) = @_; |
1372
|
7
|
|
|
|
|
16
|
my $stack = $self->event_stack; |
1373
|
7
|
|
|
|
|
19
|
my $scalar = pop @$stack; |
1374
|
7
|
|
|
|
|
14
|
my $info = $scalar->[1]; |
1375
|
7
|
|
|
|
|
24
|
$self->start_flow_mapping($info->{offset}, 1); |
1376
|
7
|
|
|
|
|
24
|
$self->scalar_event($info); |
1377
|
7
|
|
|
|
|
14
|
$self->set_new_node(1); |
1378
|
|
|
|
|
|
|
} |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
sub cb_insert_empty_implicit_flowseq_map { |
1381
|
2
|
|
|
2
|
0
|
5
|
my ($self, $res) = @_; |
1382
|
2
|
|
|
|
|
6
|
my $stack = $self->event_stack; |
1383
|
2
|
|
|
|
|
5
|
my $scalar = pop @$stack; |
1384
|
2
|
|
|
|
|
3
|
my $info = $scalar->[1]; |
1385
|
2
|
|
|
|
|
9
|
$self->start_flow_mapping($info->{offset}, 1); |
1386
|
2
|
|
|
|
|
9
|
$self->cb_empty_flowmap_value; |
1387
|
2
|
|
|
|
|
5
|
$self->set_new_node(2); |
1388
|
|
|
|
|
|
|
} |
1389
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
sub cb_insert_empty_map { |
1391
|
430
|
|
|
430
|
0
|
836
|
my ($self, $token) = @_; |
1392
|
430
|
|
|
|
|
899
|
my $stack = $self->event_stack; |
1393
|
|
|
|
|
|
|
my $info = { |
1394
|
|
|
|
|
|
|
style => YAML_PLAIN_SCALAR_STYLE, |
1395
|
|
|
|
|
|
|
value => '', |
1396
|
|
|
|
|
|
|
offset => $token->{column}, |
1397
|
430
|
|
|
|
|
1494
|
}; |
1398
|
430
|
100
|
66
|
|
|
1677
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1399
|
248
|
|
|
|
|
571
|
$self->fetch_inline_properties($stack, $info); |
1400
|
|
|
|
|
|
|
} |
1401
|
430
|
|
|
|
|
1371
|
$self->start_mapping($info->{offset}); |
1402
|
430
|
|
|
|
|
1701
|
$self->scalar_event($info); |
1403
|
430
|
|
|
|
|
832
|
$self->set_new_node(1); |
1404
|
|
|
|
|
|
|
} |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
sub cb_send_block_scalar { |
1407
|
1712
|
|
|
1712
|
0
|
3927
|
my ($self, $token) = @_; |
1408
|
1712
|
|
|
|
|
3394
|
my $type = $token->{subtokens}->[0]->{value}; |
1409
|
1712
|
|
|
|
|
3489
|
my $stack = $self->event_stack; |
1410
|
|
|
|
|
|
|
my $info = { |
1411
|
|
|
|
|
|
|
style => $type eq '|' |
1412
|
|
|
|
|
|
|
? YAML_LITERAL_SCALAR_STYLE |
1413
|
|
|
|
|
|
|
: YAML_FOLDED_SCALAR_STYLE, |
1414
|
|
|
|
|
|
|
value => $token->{value}, |
1415
|
|
|
|
|
|
|
offset => $token->{column}, |
1416
|
1712
|
100
|
|
|
|
7259
|
}; |
1417
|
1712
|
100
|
66
|
|
|
5117
|
if (@$stack and $stack->[-1]->[0] eq 'properties') { |
1418
|
82
|
|
|
|
|
227
|
$self->fetch_inline_properties($stack, $info); |
1419
|
|
|
|
|
|
|
} |
1420
|
1712
|
|
|
|
|
2572
|
push @{ $self->event_stack }, [ scalar => $info ]; |
|
1712
|
|
|
|
|
3032
|
|
1421
|
1712
|
|
|
|
|
3915
|
$self->cb_send_scalar; |
1422
|
|
|
|
|
|
|
} |
1423
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
sub cb_end_document { |
1425
|
575
|
|
|
575
|
0
|
1291
|
my ($self, $token) = @_; |
1426
|
575
|
|
|
|
|
1394
|
$self->end_document(0); |
1427
|
|
|
|
|
|
|
} |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
sub cb_end_document_empty { |
1430
|
30
|
|
|
30
|
0
|
116
|
my ($self, $token) = @_; |
1431
|
30
|
|
|
|
|
97
|
$self->end_document(0); |
1432
|
|
|
|
|
|
|
} |
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
sub cb_doc_start_implicit { |
1435
|
3910
|
|
|
3910
|
0
|
8116
|
my ($self, $token) = @_; |
1436
|
3910
|
|
|
|
|
8735
|
$self->start_document(1); |
1437
|
|
|
|
|
|
|
} |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
sub cb_doc_start_explicit { |
1440
|
3760
|
|
|
3760
|
0
|
7176
|
my ($self, $token) = @_; |
1441
|
3760
|
|
|
|
|
8349
|
$self->start_document(0); |
1442
|
|
|
|
|
|
|
} |
1443
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
sub cb_end_doc_start_document { |
1445
|
524
|
|
|
524
|
0
|
1091
|
my ($self, $token) = @_; |
1446
|
524
|
|
|
|
|
1454
|
$self->end_document(1); |
1447
|
524
|
|
|
|
|
1197
|
$self->start_document(0); |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
|
1450
|
|
|
|
|
|
|
sub cb_tag_directive { |
1451
|
117
|
|
|
117
|
0
|
374
|
my ($self, $token) = @_; |
1452
|
117
|
|
|
|
|
568
|
my ($name, $tag_alias, $tag_url) = split ' ', $token->{value}; |
1453
|
117
|
|
|
|
|
357
|
$self->tagmap->{ $tag_alias } = $tag_url; |
1454
|
|
|
|
|
|
|
} |
1455
|
|
|
|
|
|
|
|
1456
|
|
|
|
45
|
0
|
|
sub cb_reserved_directive { |
1457
|
|
|
|
|
|
|
} |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
sub cb_set_yaml_version_directive { |
1460
|
159
|
|
|
159
|
0
|
431
|
my ($self, $token) = @_; |
1461
|
159
|
100
|
|
|
|
388
|
if ($self->yaml_version_directive) { |
1462
|
1
|
|
|
|
|
93
|
croak "Found duplicate YAML directive"; |
1463
|
|
|
|
|
|
|
} |
1464
|
158
|
|
|
|
|
981
|
my ($version) = $token->{value} =~ m/^%YAML[ \t]+(1\.[12])/; |
1465
|
158
|
|
100
|
|
|
684
|
$self->set_yaml_version($version || '1.2'); |
1466
|
158
|
|
|
|
|
383
|
$self->set_yaml_version_directive(1); |
1467
|
|
|
|
|
|
|
} |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
1; |