line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::PP::Ref::Parser; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw/ openhandle /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
794
|
use YAML::Parser; |
|
1
|
|
|
|
|
74315
|
|
|
1
|
|
|
|
|
71
|
|
7
|
1
|
|
|
|
|
72
|
use YAML::PP::Common qw( |
8
|
|
|
|
|
|
|
YAML_PLAIN_SCALAR_STYLE |
9
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE YAML_DOUBLE_QUOTED_SCALAR_STYLE |
10
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE |
11
|
|
|
|
|
|
|
YAML_BLOCK_SEQUENCE_STYLE YAML_FLOW_SEQUENCE_STYLE |
12
|
|
|
|
|
|
|
YAML_BLOCK_MAPPING_STYLE YAML_FLOW_MAPPING_STYLE |
13
|
1
|
|
|
1
|
|
10
|
); |
|
1
|
|
|
|
|
4
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use base 'YAML::PP::Parser'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
534
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %style_map = ( |
18
|
|
|
|
|
|
|
plain => YAML_PLAIN_SCALAR_STYLE, |
19
|
|
|
|
|
|
|
single => YAML_SINGLE_QUOTED_SCALAR_STYLE, |
20
|
|
|
|
|
|
|
double => YAML_DOUBLE_QUOTED_SCALAR_STYLE, |
21
|
|
|
|
|
|
|
literal => YAML_LITERAL_SCALAR_STYLE, |
22
|
|
|
|
|
|
|
folded => YAML_FOLDED_SCALAR_STYLE, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parse { |
26
|
4
|
|
|
4
|
0
|
10388
|
my ($self) = @_; |
27
|
4
|
|
|
|
|
42
|
my $reader = $self->reader; |
28
|
4
|
|
|
|
|
29
|
my $string; |
29
|
4
|
100
|
|
|
|
31
|
if ($reader->can('open_handle')) { |
30
|
2
|
100
|
|
|
|
13
|
if (openhandle($reader->input)) { |
31
|
1
|
|
|
|
|
9
|
$string = do { local $/; $reader->open_handle->getline }; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
6
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
1
|
|
|
1
|
|
61
|
open my $fh, '<:encoding(UTF-8)', $reader->input; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
16
|
|
35
|
1
|
|
|
|
|
1577
|
$string = do { local $/; <$fh> }; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
57
|
|
36
|
1
|
|
|
|
|
44
|
close $fh; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
2
|
|
|
|
|
9
|
$string = $reader->read; |
41
|
|
|
|
|
|
|
} |
42
|
4
|
|
|
|
|
9827
|
my $co = $self->receiver; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $cb = sub { |
45
|
51
|
|
|
51
|
|
2886261
|
my ($info) = @_; |
46
|
|
|
|
|
|
|
# Transform events becayse YAML::Parser uses something |
47
|
|
|
|
|
|
|
# very differnt from libyaml and YAML::PP |
48
|
51
|
|
|
|
|
149
|
my $event = (delete $info->{event}) . '_event'; |
49
|
51
|
100
|
|
|
|
243
|
if ($event eq 'alias_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
50
|
1
|
|
|
|
|
4
|
$info->{value} = delete $info->{name}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif ($event eq 'scalar_event') { |
53
|
16
|
|
|
|
|
48
|
my $style = $style_map{ $info->{style} }; |
54
|
16
|
|
|
|
|
33
|
$info->{style} = $style; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ($event eq 'document_start_event') { |
57
|
4
|
50
|
|
|
|
19
|
$info->{implicit} = delete $info->{explicit} ? 0 : 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif ($event eq 'document_end_event') { |
60
|
4
|
100
|
|
|
|
18
|
$info->{implicit} = delete $info->{explicit} ? 0 : 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($event eq 'sequence_start_event') { |
63
|
4
|
50
|
|
|
|
17
|
if (delete $info->{flow}) { |
64
|
4
|
|
|
|
|
41
|
$info->{style} = YAML_FLOW_SEQUENCE_STYLE; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
0
|
$info->{style} = YAML_BLOCK_SEQUENCE_STYLE; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ($event eq 'mapping_start_event') { |
71
|
5
|
100
|
|
|
|
18
|
if (delete $info->{flow}) { |
72
|
1
|
|
|
|
|
12
|
$info->{style} = YAML_FLOW_MAPPING_STYLE; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
4
|
|
|
|
|
33
|
$info->{style} = YAML_BLOCK_MAPPING_STYLE; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
51
|
|
|
|
|
152
|
$info->{name} = $event; |
79
|
51
|
50
|
|
|
|
120
|
if (ref $co eq 'CODE') { |
80
|
0
|
|
|
|
|
0
|
$co->($self, $event, $info); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else { |
83
|
51
|
|
|
|
|
221
|
return $co->$event($info); |
84
|
|
|
|
|
|
|
} |
85
|
4
|
|
|
|
|
49
|
}; |
86
|
4
|
|
|
|
|
27
|
my $refrec = PerlYamlReferenceParserReceiver->new( |
87
|
|
|
|
|
|
|
callback => $cb, |
88
|
|
|
|
|
|
|
); |
89
|
4
|
|
|
|
|
81
|
my $p = YAML::Parser->new(receiver => $refrec); |
90
|
4
|
|
|
|
|
60
|
$p->parse($string); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |