| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
52
|
|
|
52
|
|
156967
|
use strict; |
|
|
52
|
|
|
|
|
70
|
|
|
|
52
|
|
|
|
|
1535
|
|
|
2
|
52
|
|
|
52
|
|
173
|
use warnings; |
|
|
52
|
|
|
|
|
1599
|
|
|
|
52
|
|
|
|
|
5255
|
|
|
3
|
|
|
|
|
|
|
package YAML::PP::Lexer; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = 'v0.41.0'; # VERSION |
|
6
|
|
|
|
|
|
|
|
|
7
|
52
|
50
|
|
52
|
|
261
|
use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0; |
|
|
52
|
|
|
|
|
91
|
|
|
|
52
|
|
|
|
|
3902
|
|
|
8
|
52
|
100
|
66
|
52
|
|
1774
|
use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0; |
|
|
52
|
|
|
|
|
75
|
|
|
|
52
|
|
|
|
|
10741
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
52
|
|
|
52
|
|
27929
|
use YAML::PP::Grammar qw/ $GRAMMAR /; |
|
|
52
|
|
|
|
|
174
|
|
|
|
52
|
|
|
|
|
8170
|
|
|
11
|
52
|
|
|
52
|
|
345
|
use Carp qw/ croak /; |
|
|
52
|
|
|
|
|
78
|
|
|
|
52
|
|
|
|
|
321998
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
|
14
|
4776
|
|
|
4776
|
0
|
11158
|
my ($class, %args) = @_; |
|
15
|
|
|
|
|
|
|
my $self = bless { |
|
16
|
|
|
|
|
|
|
reader => $args{reader}, |
|
17
|
4776
|
|
|
|
|
11445
|
}, $class; |
|
18
|
4776
|
|
|
|
|
10530
|
$self->init; |
|
19
|
4776
|
|
|
|
|
15602
|
return $self; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
|
23
|
20156
|
|
|
20156
|
0
|
25701
|
my ($self) = @_; |
|
24
|
20156
|
|
|
|
|
29521
|
$self->{next_tokens} = []; |
|
25
|
20156
|
|
|
|
|
26114
|
$self->{next_line} = undef; |
|
26
|
20156
|
|
|
|
|
25013
|
$self->{line} = 0; |
|
27
|
20156
|
|
|
|
|
23531
|
$self->{offset} = 0; |
|
28
|
20156
|
|
|
|
|
29498
|
$self->{flowcontext} = 0; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
113258
|
|
|
113258
|
0
|
140957
|
sub next_line { return $_[0]->{next_line} } |
|
32
|
90058
|
|
|
90058
|
0
|
112375
|
sub set_next_line { $_[0]->{next_line} = $_[1] } |
|
33
|
51058
|
|
|
51058
|
0
|
117354
|
sub reader { return $_[0]->{reader} } |
|
34
|
7690
|
|
|
7690
|
0
|
21767
|
sub set_reader { $_[0]->{reader} = $_[1] } |
|
35
|
189900
|
|
|
189900
|
0
|
227245
|
sub next_tokens { return $_[0]->{next_tokens} } |
|
36
|
400903
|
|
|
400903
|
0
|
594450
|
sub line { return $_[0]->{line} } |
|
37
|
0
|
|
|
0
|
0
|
0
|
sub set_line { $_[0]->{line} = $_[1] } |
|
38
|
140273
|
|
|
140273
|
0
|
156796
|
sub offset { return $_[0]->{offset} } |
|
39
|
140171
|
|
|
140171
|
0
|
158977
|
sub set_offset { $_[0]->{offset} = $_[1] } |
|
40
|
39099
|
|
|
39099
|
0
|
46298
|
sub inc_line { return $_[0]->{line}++ } |
|
41
|
97786
|
|
|
97786
|
0
|
152243
|
sub context { return $_[0]->{context} } |
|
42
|
3936
|
|
|
3936
|
0
|
5141
|
sub set_context { $_[0]->{context} = $_[1] } |
|
43
|
175511
|
|
|
175511
|
0
|
323596
|
sub flowcontext { return $_[0]->{flowcontext} } |
|
44
|
5291
|
|
|
5291
|
0
|
7333
|
sub set_flowcontext { $_[0]->{flowcontext} = $_[1] } |
|
45
|
27609
|
|
|
27609
|
0
|
64326
|
sub block { return $_[0]->{block} } |
|
46
|
39179
|
|
|
39179
|
0
|
50742
|
sub set_block { $_[0]->{block} = $_[1] } |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $RE_WS = '[\t ]'; |
|
49
|
|
|
|
|
|
|
my $RE_LB = '[\r\n]'; |
|
50
|
|
|
|
|
|
|
my $RE_DOC_END = qr/\A(\.\.\.)(?=$RE_WS|$)/m; |
|
51
|
|
|
|
|
|
|
my $RE_DOC_START = qr/\A(---)(?=$RE_WS|$)/m; |
|
52
|
|
|
|
|
|
|
my $RE_EOL = qr/\A($RE_WS+#.*|$RE_WS+)\z/; |
|
53
|
|
|
|
|
|
|
#my $RE_COMMENT_EOL = qr/\A(#.*)?(?:$RE_LB|\z)/; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” |
|
56
|
|
|
|
|
|
|
my $RE_NS_WORD_CHAR = '[0-9A-Za-z-]'; |
|
57
|
|
|
|
|
|
|
my $RE_URI_CHAR = '(?:' . '%[0-9a-fA-F]{2}' .'|'. q{[0-9A-Za-z#;/?:@&=+$,_.!*'\(\)\[\]-]} . ')'; |
|
58
|
|
|
|
|
|
|
my $RE_NS_TAG_CHAR = '(?:' . '%[0-9a-fA-F]{2}' .'|'. q{[0-9A-Za-z#;/?:@&=+$_.~*'\(\)-]} . ')'; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# [#x21-#x7E] /* 8 bit */ |
|
61
|
|
|
|
|
|
|
# | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] /* 16 bit */ |
|
62
|
|
|
|
|
|
|
# | [#x10000-#x10FFFF] /* 32 bit */ |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#nb-char ::= c-printable - b-char - c-byte-order-mark |
|
65
|
|
|
|
|
|
|
#my $RE_NB_CHAR = '[\x21-\x7E]'; |
|
66
|
|
|
|
|
|
|
my $RE_ANCHOR_CAR = '[\x21-\x2B\x2D-\x5A\x5C\x5E-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $RE_PLAIN_START = '[\x21\x22\x24-\x39\x3B-\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; |
|
69
|
|
|
|
|
|
|
my $RE_PLAIN_END = '[\x21-\x39\x3B-\x7E\x85\xA0-\x{D7FF}\x{E000}-\x{FEFE}\x{FF00}-\x{FFFD}\x{10000}-\x{10FFFF}]'; |
|
70
|
|
|
|
|
|
|
my $RE_PLAIN_FIRST = '[\x24\x28-\x29\x2B\x2E-\x39\x3B-\x3D\x41-\x5A\x5C\x5E-\x5F\x61-\x7A\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $RE_PLAIN_START_FLOW = '[\x21\x22\x24-\x2B\x2D-\x39\x3B-\x5A\x5C\x5E-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; |
|
73
|
|
|
|
|
|
|
my $RE_PLAIN_END_FLOW = '[\x21-\x2B\x2D-\x39\x3B-\x5A\x5C\x5E-\x7A\x7C\x7E\x85\xA0-\x{D7FF}\x{E000}-\x{FEFE}\x{FF00}-\x{FFFD}\x{10000}-\x{10FFFF}]'; |
|
74
|
|
|
|
|
|
|
my $RE_PLAIN_FIRST_FLOW = '[\x24\x28-\x29\x2B\x2E-\x39\x3B-\x3D\x41-\x5A\x5C\x5E-\x5F\x61-\x7A\x7C\x7E\xA0-\xFF\x{100}-\x{10FFFF}]'; |
|
75
|
|
|
|
|
|
|
# c-indicators |
|
76
|
|
|
|
|
|
|
#! 21 |
|
77
|
|
|
|
|
|
|
#" 22 |
|
78
|
|
|
|
|
|
|
## 23 |
|
79
|
|
|
|
|
|
|
#% 25 |
|
80
|
|
|
|
|
|
|
#& 26 |
|
81
|
|
|
|
|
|
|
#' 27 |
|
82
|
|
|
|
|
|
|
#* 2A |
|
83
|
|
|
|
|
|
|
#, 2C FLOW |
|
84
|
|
|
|
|
|
|
#- 2D XX |
|
85
|
|
|
|
|
|
|
#: 3A XX |
|
86
|
|
|
|
|
|
|
#> 3E |
|
87
|
|
|
|
|
|
|
#? 3F XX |
|
88
|
|
|
|
|
|
|
#@ 40 |
|
89
|
|
|
|
|
|
|
#[ 5B FLOW |
|
90
|
|
|
|
|
|
|
#] 5D FLOW |
|
91
|
|
|
|
|
|
|
#` 60 |
|
92
|
|
|
|
|
|
|
#{ 7B FLOW |
|
93
|
|
|
|
|
|
|
#| 7C |
|
94
|
|
|
|
|
|
|
#} 7D FLOW |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $RE_PLAIN_WORD = "(?::+$RE_PLAIN_END|$RE_PLAIN_START)(?::+$RE_PLAIN_END|$RE_PLAIN_END)*"; |
|
98
|
|
|
|
|
|
|
my $RE_PLAIN_FIRST_WORD = "(?:[:?-]+$RE_PLAIN_END|$RE_PLAIN_FIRST)(?::+$RE_PLAIN_END|$RE_PLAIN_END)*"; |
|
99
|
|
|
|
|
|
|
my $RE_PLAIN_WORDS = "(?:$RE_PLAIN_FIRST_WORD(?:$RE_WS+$RE_PLAIN_WORD)*)"; |
|
100
|
|
|
|
|
|
|
my $RE_PLAIN_WORDS2 = "(?:$RE_PLAIN_WORD(?:$RE_WS+$RE_PLAIN_WORD)*)"; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $RE_PLAIN_WORD_FLOW = "(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_START_FLOW)(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_END_FLOW)*"; |
|
103
|
|
|
|
|
|
|
my $RE_PLAIN_FIRST_WORD_FLOW = "(?:[:?-]+$RE_PLAIN_END_FLOW|$RE_PLAIN_FIRST_FLOW)(?::+$RE_PLAIN_END_FLOW|$RE_PLAIN_END_FLOW)*"; |
|
104
|
|
|
|
|
|
|
my $RE_PLAIN_WORDS_FLOW = "(?:$RE_PLAIN_FIRST_WORD_FLOW(?:$RE_WS+$RE_PLAIN_WORD_FLOW)*)"; |
|
105
|
|
|
|
|
|
|
my $RE_PLAIN_WORDS_FLOW2 = "(?:$RE_PLAIN_WORD_FLOW(?:$RE_WS+$RE_PLAIN_WORD_FLOW)*)"; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#c-secondary-tag-handle ::= “!” “!” |
|
109
|
|
|
|
|
|
|
#c-named-tag-handle ::= “!” ns-word-char+ “!” |
|
110
|
|
|
|
|
|
|
#ns-tag-char ::= ns-uri-char - “!” - c-flow-indicator |
|
111
|
|
|
|
|
|
|
#ns-global-tag-prefix ::= ns-tag-char ns-uri-char* |
|
112
|
|
|
|
|
|
|
#c-ns-local-tag-prefix ::= “!” ns-uri-char* |
|
113
|
|
|
|
|
|
|
my $RE_TAG = "!(?:$RE_NS_WORD_CHAR*!$RE_NS_TAG_CHAR+|$RE_NS_TAG_CHAR+|<$RE_URI_CHAR+>|)"; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#c-ns-anchor-property ::= “&” ns-anchor-name |
|
116
|
|
|
|
|
|
|
#ns-char ::= nb-char - s-white |
|
117
|
|
|
|
|
|
|
#ns-anchor-char ::= ns-char - c-flow-indicator |
|
118
|
|
|
|
|
|
|
#ns-anchor-name ::= ns-anchor-char+ |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $RE_SEQSTART = qr/\A(-)(?=$RE_WS|$)/m; |
|
121
|
|
|
|
|
|
|
my $RE_COMPLEX = qr/(\?)(?=$RE_WS|$)/m; |
|
122
|
|
|
|
|
|
|
my $RE_COMPLEXCOLON = qr/\A(:)(?=$RE_WS|$)/m; |
|
123
|
|
|
|
|
|
|
my $RE_ANCHOR = "&$RE_ANCHOR_CAR+"; |
|
124
|
|
|
|
|
|
|
my $RE_ALIAS = "\\*$RE_ANCHOR_CAR+"; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my %REGEXES = ( |
|
128
|
|
|
|
|
|
|
ANCHOR => qr{($RE_ANCHOR)}, |
|
129
|
|
|
|
|
|
|
TAG => qr{($RE_TAG)}, |
|
130
|
|
|
|
|
|
|
ALIAS => qr{($RE_ALIAS)}, |
|
131
|
|
|
|
|
|
|
SINGLEQUOTED => qr{(?:''|[^'\r\n]+)*}, |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub _fetch_next_line { |
|
135
|
66827
|
|
|
66827
|
|
80133
|
my ($self) = @_; |
|
136
|
66827
|
|
|
|
|
88514
|
my $next_line = $self->next_line; |
|
137
|
66827
|
100
|
|
|
|
102672
|
if (defined $next_line ) { |
|
138
|
15769
|
|
|
|
|
21805
|
return $next_line; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
51058
|
|
|
|
|
74721
|
my $line = $self->reader->readline; |
|
142
|
51058
|
100
|
|
|
|
85205
|
unless (defined $line) { |
|
143
|
11959
|
|
|
|
|
22666
|
$self->set_next_line(undef); |
|
144
|
11959
|
|
|
|
|
18449
|
return; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
39099
|
|
|
|
|
70360
|
$self->set_block(1); |
|
147
|
39099
|
|
|
|
|
68423
|
$self->inc_line; |
|
148
|
39099
|
50
|
|
|
|
119582
|
$line =~ m/\A( *)([^\r\n]*)([\r\n]|\z)/ or die "Unexpected"; |
|
149
|
39099
|
|
|
|
|
111552
|
$next_line = [ $1, $2, $3 ]; |
|
150
|
39099
|
|
|
|
|
67561
|
$self->set_next_line($next_line); |
|
151
|
|
|
|
|
|
|
# $ESCAPE_CHAR from YAML.pm |
|
152
|
39099
|
100
|
|
|
|
68685
|
if ($line =~ tr/\x00-\x08\x0b-\x0c\x0e-\x1f//) { |
|
153
|
29
|
|
|
|
|
67
|
$self->exception("Control characters are not allowed"); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
39070
|
|
|
|
|
62975
|
return $next_line; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my %TOKEN_NAMES = ( |
|
160
|
|
|
|
|
|
|
'"' => 'DOUBLEQUOTE', |
|
161
|
|
|
|
|
|
|
"'" => 'SINGLEQUOTE', |
|
162
|
|
|
|
|
|
|
'|' => 'LITERAL', |
|
163
|
|
|
|
|
|
|
'>' => 'FOLDED', |
|
164
|
|
|
|
|
|
|
'!' => 'TAG', |
|
165
|
|
|
|
|
|
|
'*' => 'ALIAS', |
|
166
|
|
|
|
|
|
|
'&' => 'ANCHOR', |
|
167
|
|
|
|
|
|
|
':' => 'COLON', |
|
168
|
|
|
|
|
|
|
'-' => 'DASH', |
|
169
|
|
|
|
|
|
|
'?' => 'QUESTION', |
|
170
|
|
|
|
|
|
|
'[' => 'FLOWSEQ_START', |
|
171
|
|
|
|
|
|
|
']' => 'FLOWSEQ_END', |
|
172
|
|
|
|
|
|
|
'{' => 'FLOWMAP_START', |
|
173
|
|
|
|
|
|
|
'}' => 'FLOWMAP_END', |
|
174
|
|
|
|
|
|
|
',' => 'FLOW_COMMA', |
|
175
|
|
|
|
|
|
|
'---' => 'DOC_START', |
|
176
|
|
|
|
|
|
|
'...' => 'DOC_END', |
|
177
|
|
|
|
|
|
|
); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub fetch_next_tokens { |
|
181
|
41914
|
|
|
41914
|
0
|
54737
|
my ($self) = @_; |
|
182
|
41914
|
|
|
|
|
63808
|
my $next = $self->next_tokens; |
|
183
|
41914
|
100
|
|
|
|
62480
|
return $next if @$next; |
|
184
|
|
|
|
|
|
|
|
|
185
|
41103
|
|
|
|
|
61034
|
my $next_line = $self->_fetch_next_line; |
|
186
|
41074
|
100
|
|
|
|
60210
|
if (not $next_line) { |
|
187
|
7537
|
|
|
|
|
15097
|
return []; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
33537
|
|
|
|
|
44054
|
my $spaces = $next_line->[0]; |
|
191
|
33537
|
|
|
|
|
41001
|
my $yaml = \$next_line->[1]; |
|
192
|
33537
|
100
|
|
|
|
57701
|
if (not length $$yaml) { |
|
193
|
159
|
|
|
|
|
460
|
$self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); |
|
194
|
159
|
|
|
|
|
477
|
$self->set_next_line(undef); |
|
195
|
159
|
|
|
|
|
341
|
return $next; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
33378
|
100
|
|
|
|
83515
|
if (substr($$yaml, 0, 1) eq '#') { |
|
198
|
551
|
|
|
|
|
1807
|
$self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); |
|
199
|
551
|
|
|
|
|
1356
|
$self->set_next_line(undef); |
|
200
|
551
|
|
|
|
|
1314
|
return $next; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
32827
|
100
|
100
|
|
|
85415
|
if (not $spaces and substr($$yaml, 0, 1) eq "%") { |
|
203
|
326
|
|
|
|
|
1097
|
$self->_fetch_next_tokens_directive($yaml, $next_line->[2]); |
|
204
|
326
|
|
|
|
|
716
|
$self->set_context(0); |
|
205
|
326
|
|
|
|
|
603
|
$self->set_next_line(undef); |
|
206
|
326
|
|
|
|
|
881
|
return $next; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
32501
|
100
|
100
|
|
|
170370
|
if (not $spaces and $$yaml =~ s/\A(---|\.\.\.)(?=$RE_WS|\z)//) { |
|
|
|
100
|
100
|
|
|
|
|
|
209
|
4331
|
|
|
|
|
12781
|
$self->_push_tokens([ $TOKEN_NAMES{ $1 } => $1, $self->line ]); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
elsif ($self->flowcontext and $$yaml =~ m/\A[ \t]+(#.*)?\z/) { |
|
212
|
59
|
|
|
|
|
232
|
$self->_push_tokens([ EOL => join('', @$next_line), $self->line ]); |
|
213
|
59
|
|
|
|
|
144
|
$self->set_next_line(undef); |
|
214
|
59
|
|
|
|
|
436
|
return $next; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
else { |
|
217
|
28111
|
|
|
|
|
43338
|
$self->_push_tokens([ SPACE => $spaces, $self->line ]); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
32442
|
|
|
|
|
63899
|
my $partial = $self->_fetch_next_tokens($next_line); |
|
221
|
32436
|
100
|
|
|
|
51543
|
unless ($partial) { |
|
222
|
4769
|
|
|
|
|
7632
|
$self->set_next_line(undef); |
|
223
|
|
|
|
|
|
|
} |
|
224
|
32436
|
|
|
|
|
61461
|
return $next; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my %ANCHOR_ALIAS_TAG = ( '&' => 1, '*' => 1, '!' => 1 ); |
|
228
|
|
|
|
|
|
|
my %BLOCK_SCALAR = ( '|' => 1, '>' => 1 ); |
|
229
|
|
|
|
|
|
|
my %COLON_DASH_QUESTION = ( ':' => 1, '-' => 1, '?' => 1 ); |
|
230
|
|
|
|
|
|
|
my %QUOTED = ( '"' => 1, "'" => 1 ); |
|
231
|
|
|
|
|
|
|
my %FLOW = ( '{' => 1, '[' => 1, '}' => 1, ']' => 1, ',' => 1 ); |
|
232
|
|
|
|
|
|
|
my %CONTEXT = ( '"' => 1, "'" => 1, '>' => 1, '|' => 1 ); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
my $RE_ESCAPES = qr{(?: |
|
235
|
|
|
|
|
|
|
\\([ \\\/_0abefnrtvLNP\t"]) | \\x([0-9a-fA-F]{2}) |
|
236
|
|
|
|
|
|
|
| \\u([A-Fa-f0-9]{4}) | \\U([A-Fa-f0-9]{4,8}) |
|
237
|
|
|
|
|
|
|
)}x; |
|
238
|
|
|
|
|
|
|
my %CONTROL = ( |
|
239
|
|
|
|
|
|
|
'\\' => '\\', '/' => '/', n => "\n", t => "\t", r => "\r", b => "\b", |
|
240
|
|
|
|
|
|
|
'a' => "\a", 'b' => "\b", 'e' => "\e", 'f' => "\f", 'v' => "\x0b", "\t" => "\t", |
|
241
|
|
|
|
|
|
|
'P' => "\x{2029}", L => "\x{2028}", 'N' => "\x85", |
|
242
|
|
|
|
|
|
|
'0' => "\0", '_' => "\xa0", ' ' => ' ', q/"/ => q/"/, |
|
243
|
|
|
|
|
|
|
); |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub _fetch_next_tokens { |
|
246
|
56233
|
|
|
56233
|
|
57145
|
TRACE and warn __PACKAGE__.':'.__LINE__.": _fetch_next_tokens\n"; |
|
247
|
56233
|
|
|
|
|
65887
|
my ($self, $next_line) = @_; |
|
248
|
|
|
|
|
|
|
|
|
249
|
56233
|
|
|
|
|
70524
|
my $yaml = \$next_line->[1]; |
|
250
|
56233
|
|
|
|
|
61512
|
my $eol = $next_line->[2]; |
|
251
|
|
|
|
|
|
|
|
|
252
|
56233
|
|
|
|
|
56027
|
my @tokens; |
|
253
|
|
|
|
|
|
|
|
|
254
|
56233
|
|
|
|
|
52691
|
while (1) { |
|
255
|
104622
|
100
|
|
|
|
143139
|
unless (length $$yaml) { |
|
256
|
6836
|
|
|
|
|
10017
|
push @tokens, ( EOL => $eol, $self->line ); |
|
257
|
6836
|
|
|
|
|
12797
|
$self->_push_tokens(\@tokens); |
|
258
|
6836
|
|
|
|
|
15831
|
return; |
|
259
|
|
|
|
|
|
|
} |
|
260
|
97786
|
|
|
|
|
136704
|
my $first = substr($$yaml, 0, 1); |
|
261
|
97786
|
|
|
|
|
96640
|
my $plain = 0; |
|
262
|
|
|
|
|
|
|
|
|
263
|
97786
|
100
|
|
|
|
129986
|
if ($self->context) { |
|
264
|
1815
|
100
|
|
|
|
9003
|
if ($$yaml =~ s/\A($RE_WS*)://) { |
|
265
|
165
|
100
|
|
|
|
479
|
push @tokens, ( WS => $1, $self->line ) if $1; |
|
266
|
165
|
|
|
|
|
330
|
push @tokens, ( COLON => ':', $self->line ); |
|
267
|
165
|
|
|
|
|
431
|
$self->set_context(0); |
|
268
|
165
|
|
|
|
|
278
|
next; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
1650
|
100
|
|
|
|
4996
|
if ($$yaml =~ s/\A($RE_WS*(?: #.*))\z//) { |
|
271
|
10
|
|
|
|
|
47
|
push @tokens, ( EOL => $1 . $eol, $self->line ); |
|
272
|
10
|
|
|
|
|
32
|
$self->_push_tokens(\@tokens); |
|
273
|
10
|
|
|
|
|
23
|
return; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
1640
|
|
|
|
|
2340
|
$self->set_context(0); |
|
276
|
|
|
|
|
|
|
} |
|
277
|
97611
|
100
|
100
|
|
|
305221
|
if ($CONTEXT{ $first }) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
278
|
6437
|
|
|
|
|
9307
|
push @tokens, ( CONTEXT => $first, $self->line ); |
|
279
|
6437
|
|
|
|
|
12404
|
$self->_push_tokens(\@tokens); |
|
280
|
6437
|
|
|
|
|
14923
|
return 1; |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
elsif ($COLON_DASH_QUESTION{ $first }) { |
|
283
|
29408
|
|
|
|
|
41686
|
my $token_name = $TOKEN_NAMES{ $first }; |
|
284
|
29408
|
100
|
100
|
|
|
299406
|
if ($$yaml =~ s/\A\Q$first\E($RE_WS+|\z)//) { |
|
|
|
100
|
|
|
|
|
|
|
285
|
28869
|
|
|
|
|
48139
|
my $after = $1; |
|
286
|
28869
|
100
|
100
|
|
|
42519
|
if (not $self->flowcontext and not $self->block) { |
|
287
|
8
|
|
|
|
|
19
|
push @tokens, ERROR => $first . $after, $self->line; |
|
288
|
8
|
|
|
|
|
18
|
$self->_push_tokens(\@tokens); |
|
289
|
8
|
|
|
|
|
15
|
$self->exception("Tabs can not be used for indentation"); |
|
290
|
|
|
|
|
|
|
} |
|
291
|
28861
|
100
|
|
|
|
52515
|
if ($after =~ tr/\t//) { |
|
292
|
80
|
|
|
|
|
172
|
$self->set_block(0); |
|
293
|
|
|
|
|
|
|
} |
|
294
|
28861
|
|
|
|
|
36237
|
my $token_name = $TOKEN_NAMES{ $first }; |
|
295
|
28861
|
|
|
|
|
43477
|
push @tokens, ( $token_name => $first, $self->line ); |
|
296
|
28861
|
50
|
|
|
|
46565
|
if (not defined $1) { |
|
297
|
0
|
|
|
|
|
0
|
push @tokens, ( EOL => $eol, $self->line ); |
|
298
|
0
|
|
|
|
|
0
|
$self->_push_tokens(\@tokens); |
|
299
|
0
|
|
|
|
|
0
|
return; |
|
300
|
|
|
|
|
|
|
} |
|
301
|
28861
|
|
|
|
|
33256
|
my $ws = $1; |
|
302
|
28861
|
100
|
|
|
|
73987
|
if ($$yaml =~ s/\A(#.*|)\z//) { |
|
303
|
2822
|
|
|
|
|
7723
|
push @tokens, ( EOL => $ws . $1 . $eol, $self->line ); |
|
304
|
2822
|
|
|
|
|
6060
|
$self->_push_tokens(\@tokens); |
|
305
|
2822
|
|
|
|
|
8563
|
return; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
26039
|
|
|
|
|
37851
|
push @tokens, ( WS => $ws, $self->line ); |
|
308
|
26039
|
|
|
|
|
48593
|
next; |
|
309
|
|
|
|
|
|
|
} |
|
310
|
|
|
|
|
|
|
elsif ($self->flowcontext and $$yaml =~ s/\A:(?=[,\{\}\[\]])//) { |
|
311
|
7
|
|
|
|
|
19
|
push @tokens, ( $token_name => $first, $self->line ); |
|
312
|
7
|
|
|
|
|
40
|
next; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
532
|
|
|
|
|
840
|
$plain = 1; |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
elsif ($ANCHOR_ALIAS_TAG{ $first }) { |
|
317
|
5389
|
|
|
|
|
7477
|
my $token_name = $TOKEN_NAMES{ $first }; |
|
318
|
5389
|
|
|
|
|
7642
|
my $REGEX = $REGEXES{ $token_name }; |
|
319
|
5389
|
50
|
|
|
|
170692
|
if ($$yaml =~ s/\A$REGEX//) { |
|
320
|
5389
|
|
|
|
|
11577
|
push @tokens, ( $token_name => $1, $self->line ); |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
else { |
|
323
|
0
|
|
|
|
|
0
|
push @tokens, ( "Invalid $token_name" => $$yaml, $self->line ); |
|
324
|
0
|
|
|
|
|
0
|
$self->_push_tokens(\@tokens); |
|
325
|
0
|
|
|
|
|
0
|
return; |
|
326
|
|
|
|
|
|
|
} |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
elsif ($first eq ' ' or $first eq "\t") { |
|
329
|
9300
|
50
|
|
|
|
43710
|
if ($$yaml =~ s/\A($RE_WS+)//) { |
|
330
|
9300
|
|
|
|
|
13863
|
my $ws = $1; |
|
331
|
9300
|
100
|
|
|
|
27736
|
if ($$yaml =~ s/\A((?:#.*)?\z)//) { |
|
332
|
213
|
|
|
|
|
672
|
push @tokens, ( EOL => $ws . $1 . $eol, $self->line ); |
|
333
|
213
|
|
|
|
|
482
|
$self->_push_tokens(\@tokens); |
|
334
|
213
|
|
|
|
|
629
|
return; |
|
335
|
|
|
|
|
|
|
} |
|
336
|
9087
|
|
|
|
|
14468
|
push @tokens, ( WS => $ws, $self->line ); |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
elsif ($FLOW{ $first }) { |
|
340
|
7702
|
|
|
|
|
13699
|
push @tokens, ( $TOKEN_NAMES{ $first } => $first, $self->line ); |
|
341
|
7702
|
|
|
|
|
13606
|
substr($$yaml, 0, 1, ''); |
|
342
|
7702
|
|
|
|
|
10598
|
my $flowcontext = $self->flowcontext; |
|
343
|
7702
|
100
|
100
|
|
|
25932
|
if ($first eq '{' or $first eq '[') { |
|
|
|
100
|
100
|
|
|
|
|
|
344
|
2651
|
|
|
|
|
4431
|
$self->set_flowcontext(++$flowcontext); |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
elsif ($first eq '}' or $first eq ']') { |
|
347
|
2640
|
|
|
|
|
4267
|
$self->set_flowcontext(--$flowcontext); |
|
348
|
|
|
|
|
|
|
} |
|
349
|
|
|
|
|
|
|
} |
|
350
|
|
|
|
|
|
|
else { |
|
351
|
39375
|
|
|
|
|
40378
|
$plain = 1; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
62085
|
100
|
|
|
|
90609
|
if ($plain) { |
|
355
|
39907
|
|
|
|
|
53200
|
push @tokens, ( CONTEXT => '', $self->line ); |
|
356
|
39907
|
|
|
|
|
68731
|
$self->_push_tokens(\@tokens); |
|
357
|
39907
|
|
|
|
|
80756
|
return 1; |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
} |
|
361
|
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
0
|
return; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
sub fetch_plain { |
|
366
|
39868
|
|
|
39868
|
0
|
58944
|
my ($self, $indent, $context) = @_; |
|
367
|
39868
|
|
|
|
|
59560
|
my $next_line = $self->next_line; |
|
368
|
39868
|
|
|
|
|
50382
|
my $yaml = \$next_line->[1]; |
|
369
|
39868
|
|
|
|
|
43800
|
my $eol = $next_line->[2]; |
|
370
|
39868
|
|
|
|
|
43244
|
my $REGEX = $RE_PLAIN_WORDS; |
|
371
|
39868
|
100
|
|
|
|
48240
|
if ($self->flowcontext) { |
|
372
|
2914
|
|
|
|
|
3665
|
$REGEX = $RE_PLAIN_WORDS_FLOW; |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
|
|
375
|
39868
|
|
|
|
|
40578
|
my @tokens; |
|
376
|
39868
|
100
|
|
|
|
630137
|
unless ($$yaml =~ s/\A($REGEX(?:[:]+(?=\:(\s|\z)))?)//) { |
|
377
|
7
|
|
|
|
|
23
|
$self->_push_tokens(\@tokens); |
|
378
|
7
|
|
|
|
|
20
|
$self->exception("Invalid plain scalar"); |
|
379
|
|
|
|
|
|
|
} |
|
380
|
39861
|
|
|
|
|
85595
|
my $plain = $1; |
|
381
|
39861
|
|
|
|
|
67365
|
push @tokens, ( PLAIN => $plain, $self->line ); |
|
382
|
|
|
|
|
|
|
|
|
383
|
39861
|
100
|
|
|
|
181179
|
if ($$yaml =~ s/\A(?:($RE_WS+#.*)|($RE_WS*))\z//) { |
|
384
|
19391
|
100
|
|
|
|
31841
|
if (defined $1) { |
|
385
|
131
|
|
|
|
|
385
|
push @tokens, ( EOL => $1 . $eol, $self->line ); |
|
386
|
131
|
|
|
|
|
326
|
$self->_push_tokens(\@tokens); |
|
387
|
131
|
|
|
|
|
295
|
$self->set_next_line(undef); |
|
388
|
131
|
|
|
|
|
450
|
return; |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
else { |
|
391
|
19260
|
|
|
|
|
39887
|
push @tokens, ( EOL => $2. $eol, $self->line ); |
|
392
|
19260
|
|
|
|
|
32565
|
$self->set_next_line(undef); |
|
393
|
|
|
|
|
|
|
} |
|
394
|
|
|
|
|
|
|
} |
|
395
|
|
|
|
|
|
|
else { |
|
396
|
20470
|
|
|
|
|
42075
|
$self->_push_tokens(\@tokens); |
|
397
|
20470
|
|
|
|
|
31106
|
my $partial = $self->_fetch_next_tokens($next_line); |
|
398
|
20468
|
100
|
|
|
|
31281
|
if (not $partial) { |
|
399
|
3485
|
|
|
|
|
5878
|
$self->set_next_line(undef); |
|
400
|
|
|
|
|
|
|
} |
|
401
|
20468
|
|
|
|
|
50441
|
return; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
19260
|
|
|
|
|
25600
|
my $RE2 = $RE_PLAIN_WORDS2; |
|
405
|
19260
|
100
|
|
|
|
24830
|
if ($self->flowcontext) { |
|
406
|
132
|
|
|
|
|
256
|
$RE2 = $RE_PLAIN_WORDS_FLOW2; |
|
407
|
|
|
|
|
|
|
} |
|
408
|
19260
|
|
|
|
|
21211
|
my $fetch_next = 0; |
|
409
|
19260
|
|
|
|
|
28521
|
my @lines = ($plain); |
|
410
|
19260
|
|
|
|
|
20394
|
my @next; |
|
411
|
19260
|
|
|
|
|
19465
|
LOOP: while (1) { |
|
412
|
19620
|
|
|
|
|
29512
|
$next_line = $self->_fetch_next_line; |
|
413
|
19620
|
100
|
|
|
|
31180
|
if (not $next_line) { |
|
414
|
3609
|
|
|
|
|
5321
|
last LOOP; |
|
415
|
|
|
|
|
|
|
} |
|
416
|
16011
|
|
|
|
|
19450
|
my $spaces = $next_line->[0]; |
|
417
|
16011
|
|
|
|
|
19469
|
my $yaml = \$next_line->[1]; |
|
418
|
16011
|
|
|
|
|
17877
|
my $eol = $next_line->[2]; |
|
419
|
|
|
|
|
|
|
|
|
420
|
16011
|
100
|
|
|
|
23968
|
if (not length $$yaml) { |
|
421
|
104
|
|
|
|
|
231
|
push @tokens, ( EOL => $spaces . $eol, $self->line ); |
|
422
|
104
|
|
|
|
|
215
|
$self->set_next_line(undef); |
|
423
|
104
|
|
|
|
|
137
|
push @lines, ''; |
|
424
|
104
|
|
|
|
|
173
|
next LOOP; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
|
|
427
|
15907
|
100
|
100
|
|
|
48059
|
if (not $spaces and $$yaml =~ s/\A(---|\.\.\.)(?=$RE_WS|\z)//) { |
|
428
|
630
|
|
|
|
|
1799
|
push @next, $TOKEN_NAMES{ $1 } => $1, $self->line; |
|
429
|
630
|
|
|
|
|
941
|
$fetch_next = 1; |
|
430
|
630
|
|
|
|
|
1153
|
last LOOP; |
|
431
|
|
|
|
|
|
|
} |
|
432
|
15277
|
100
|
|
|
|
29233
|
if ((length $spaces) < $indent) { |
|
433
|
14869
|
|
|
|
|
26671
|
last LOOP; |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
|
|
436
|
408
|
|
|
|
|
686
|
my $ws = ''; |
|
437
|
408
|
100
|
|
|
|
2013
|
if ($$yaml =~ s/\A($RE_WS+)//) { |
|
438
|
25
|
|
|
|
|
48
|
$ws = $1; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
408
|
100
|
|
|
|
854
|
if (not length $$yaml) { |
|
441
|
11
|
|
|
|
|
34
|
push @tokens, ( EOL => $spaces . $ws . $eol, $self->line ); |
|
442
|
11
|
|
|
|
|
26
|
$self->set_next_line(undef); |
|
443
|
11
|
|
|
|
|
15
|
push @lines, ''; |
|
444
|
11
|
|
|
|
|
25
|
next LOOP; |
|
445
|
|
|
|
|
|
|
} |
|
446
|
397
|
100
|
|
|
|
1125
|
if ($$yaml =~ s/\A(#.*)\z//) { |
|
447
|
10
|
|
|
|
|
47
|
push @tokens, ( EOL => $spaces . $ws . $1 . $eol, $self->line ); |
|
448
|
10
|
|
|
|
|
30
|
$self->set_next_line(undef); |
|
449
|
10
|
|
|
|
|
24
|
last LOOP; |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
387
|
100
|
|
|
|
20479
|
if ($$yaml =~ s/\A($RE2)//) { |
|
453
|
297
|
|
|
|
|
702
|
push @tokens, INDENT => $spaces, $self->line; |
|
454
|
297
|
|
|
|
|
571
|
push @tokens, WS => $ws, $self->line; |
|
455
|
297
|
|
|
|
|
553
|
push @tokens, PLAIN => $1, $self->line; |
|
456
|
297
|
|
|
|
|
513
|
push @lines, $1; |
|
457
|
297
|
|
|
|
|
717
|
my $ws = ''; |
|
458
|
297
|
100
|
|
|
|
1200
|
if ($$yaml =~ s/\A($RE_WS+)//) { |
|
459
|
42
|
|
|
|
|
90
|
$ws = $1; |
|
460
|
|
|
|
|
|
|
} |
|
461
|
297
|
100
|
|
|
|
605
|
if (not length $$yaml) { |
|
462
|
245
|
|
|
|
|
539
|
push @tokens, EOL => $ws . $eol, $self->line; |
|
463
|
245
|
|
|
|
|
506
|
$self->set_next_line(undef); |
|
464
|
245
|
|
|
|
|
627
|
next LOOP; |
|
465
|
|
|
|
|
|
|
} |
|
466
|
|
|
|
|
|
|
|
|
467
|
52
|
100
|
|
|
|
243
|
if ($$yaml =~ s/\A(#.*)\z//) { |
|
468
|
17
|
|
|
|
|
71
|
push @tokens, EOL => $ws . $1 . $eol, $self->line; |
|
469
|
17
|
|
|
|
|
51
|
$self->set_next_line(undef); |
|
470
|
17
|
|
|
|
|
37
|
last LOOP; |
|
471
|
|
|
|
|
|
|
} |
|
472
|
|
|
|
|
|
|
else { |
|
473
|
35
|
100
|
|
|
|
103
|
push @tokens, WS => $ws, $self->line if $ws; |
|
474
|
35
|
|
|
|
|
63
|
$fetch_next = 1; |
|
475
|
|
|
|
|
|
|
} |
|
476
|
|
|
|
|
|
|
} |
|
477
|
|
|
|
|
|
|
else { |
|
478
|
90
|
|
|
|
|
272
|
push @tokens, SPACE => $spaces, $self->line; |
|
479
|
90
|
|
|
|
|
209
|
push @tokens, WS => $ws, $self->line; |
|
480
|
90
|
50
|
|
|
|
181
|
if ($self->flowcontext) { |
|
481
|
90
|
|
|
|
|
134
|
$fetch_next = 1; |
|
482
|
|
|
|
|
|
|
} |
|
483
|
|
|
|
|
|
|
else { |
|
484
|
0
|
|
|
|
|
0
|
push @tokens, ERROR => $$yaml, $self->line; |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
|
|
488
|
125
|
|
|
|
|
387
|
last LOOP; |
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
} |
|
491
|
|
|
|
|
|
|
# remove empty lines at the end |
|
492
|
19260
|
|
100
|
|
|
39545
|
while (@lines > 1 and $lines[-1] eq '') { |
|
493
|
90
|
|
|
|
|
211
|
pop @lines; |
|
494
|
|
|
|
|
|
|
} |
|
495
|
19260
|
100
|
|
|
|
28690
|
if (@lines > 1) { |
|
496
|
242
|
|
|
|
|
1114
|
my $value = YAML::PP::Render->render_multi_val(\@lines); |
|
497
|
242
|
|
|
|
|
311
|
my @eol; |
|
498
|
242
|
100
|
|
|
|
563
|
if ($tokens[-3] eq 'EOL') { |
|
499
|
207
|
|
|
|
|
538
|
@eol = splice @tokens, -3; |
|
500
|
|
|
|
|
|
|
} |
|
501
|
242
|
|
|
|
|
1009
|
$self->push_subtokens( { name => 'PLAIN_MULTI', value => $value }, \@tokens); |
|
502
|
242
|
|
|
|
|
748
|
$self->_push_tokens([ @eol, @next ]); |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
else { |
|
505
|
19018
|
|
|
|
|
49510
|
$self->_push_tokens([ @tokens, @next ]); |
|
506
|
|
|
|
|
|
|
} |
|
507
|
19260
|
|
|
|
|
41863
|
@tokens = (); |
|
508
|
19260
|
100
|
|
|
|
27893
|
if ($fetch_next) { |
|
509
|
755
|
|
|
|
|
1385
|
my $partial = $self->_fetch_next_tokens($next_line); |
|
510
|
755
|
100
|
|
|
|
1659
|
if (not $partial) { |
|
511
|
610
|
|
|
|
|
1047
|
$self->set_next_line(undef); |
|
512
|
|
|
|
|
|
|
} |
|
513
|
|
|
|
|
|
|
} |
|
514
|
19260
|
|
|
|
|
49846
|
return; |
|
515
|
|
|
|
|
|
|
} |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
sub fetch_block { |
|
518
|
1720
|
|
|
1720
|
0
|
3328
|
my ($self, $indent, $context) = @_; |
|
519
|
1720
|
|
|
|
|
3221
|
my $next_line = $self->next_line; |
|
520
|
1720
|
|
|
|
|
2777
|
my $yaml = \$next_line->[1]; |
|
521
|
1720
|
|
|
|
|
2539
|
my $eol = $next_line->[2]; |
|
522
|
|
|
|
|
|
|
|
|
523
|
1720
|
|
|
|
|
2388
|
my @tokens; |
|
524
|
1720
|
|
|
|
|
2876
|
my $token_name = $TOKEN_NAMES{ $context }; |
|
525
|
1720
|
50
|
|
|
|
18056
|
$$yaml =~ s/\A\Q$context\E// or die "Unexpected"; |
|
526
|
1720
|
|
|
|
|
4257
|
push @tokens, ( $token_name => $context, $self->line ); |
|
527
|
1720
|
|
|
|
|
2278
|
my $current_indent = $indent; |
|
528
|
1720
|
|
|
|
|
1934
|
my $started = 0; |
|
529
|
1720
|
|
|
|
|
1928
|
my $set_indent = 0; |
|
530
|
1720
|
|
|
|
|
2178
|
my $chomp = ''; |
|
531
|
1720
|
100
|
|
|
|
6606
|
if ($$yaml =~ s/\A([1-9])([+-]?)//) { |
|
|
|
100
|
|
|
|
|
|
|
532
|
215
|
|
|
|
|
389
|
push @tokens, ( BLOCK_SCALAR_INDENT => $1, $self->line ); |
|
533
|
215
|
|
|
|
|
323
|
$set_indent = $1; |
|
534
|
215
|
100
|
|
|
|
580
|
$chomp = $2 if $2; |
|
535
|
215
|
100
|
|
|
|
525
|
push @tokens, ( BLOCK_SCALAR_CHOMP => $2, $self->line ) if $2; |
|
536
|
|
|
|
|
|
|
} |
|
537
|
|
|
|
|
|
|
elsif ($$yaml =~ s/\A([+-])([1-9])?//) { |
|
538
|
409
|
|
|
|
|
917
|
push @tokens, ( BLOCK_SCALAR_CHOMP => $1, $self->line ); |
|
539
|
409
|
|
|
|
|
618
|
$chomp = $1; |
|
540
|
409
|
100
|
|
|
|
953
|
push @tokens, ( BLOCK_SCALAR_INDENT => $2, $self->line ) if $2; |
|
541
|
409
|
100
|
|
|
|
901
|
$set_indent = $2 if $2; |
|
542
|
|
|
|
|
|
|
} |
|
543
|
1720
|
100
|
|
|
|
3468
|
if ($set_indent) { |
|
544
|
224
|
|
|
|
|
280
|
$started = 1; |
|
545
|
224
|
100
|
|
|
|
428
|
$indent-- if $indent > 0; |
|
546
|
224
|
|
|
|
|
384
|
$current_indent = $indent + $set_indent; |
|
547
|
|
|
|
|
|
|
} |
|
548
|
1720
|
100
|
|
|
|
3799
|
if (not length $$yaml) { |
|
|
|
100
|
|
|
|
|
|
|
549
|
1662
|
|
|
|
|
2763
|
push @tokens, ( EOL => $eol, $self->line ); |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
elsif ($$yaml =~ s/\A($RE_WS*(?:$RE_WS#.*|))\z//) { |
|
552
|
52
|
|
|
|
|
175
|
push @tokens, ( EOL => $1 . $eol, $self->line ); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
else { |
|
555
|
6
|
|
|
|
|
22
|
$self->_push_tokens(\@tokens); |
|
556
|
6
|
|
|
|
|
15
|
$self->exception("Invalid block scalar"); |
|
557
|
|
|
|
|
|
|
} |
|
558
|
|
|
|
|
|
|
|
|
559
|
1714
|
|
|
|
|
2217
|
my @lines; |
|
560
|
1714
|
|
|
|
|
1824
|
while (1) { |
|
561
|
5254
|
|
|
|
|
9063
|
$self->set_next_line(undef); |
|
562
|
5254
|
|
|
|
|
7049
|
$next_line = $self->_fetch_next_line; |
|
563
|
5254
|
100
|
|
|
|
8280
|
if (not $next_line) { |
|
564
|
812
|
|
|
|
|
1188
|
last; |
|
565
|
|
|
|
|
|
|
} |
|
566
|
4442
|
|
|
|
|
5440
|
my $spaces = $next_line->[0]; |
|
567
|
4442
|
|
|
|
|
5307
|
my $content = $next_line->[1]; |
|
568
|
4442
|
|
|
|
|
5038
|
my $eol = $next_line->[2]; |
|
569
|
4442
|
100
|
100
|
|
|
14528
|
if (not $spaces and $content =~ m/\A(---|\.\.\.)(?=$RE_WS|\z)/) { |
|
570
|
200
|
|
|
|
|
360
|
last; |
|
571
|
|
|
|
|
|
|
} |
|
572
|
4242
|
100
|
|
|
|
8337
|
if ((length $spaces) < $current_indent) { |
|
573
|
1436
|
100
|
|
|
|
2179
|
if (length $content) { |
|
574
|
702
|
100
|
|
|
|
1752
|
if ($content =~ m/\A\t/) { |
|
575
|
2
|
|
|
|
|
6
|
$self->_push_tokens(\@tokens); |
|
576
|
2
|
|
|
|
|
4
|
$self->exception("Invalid block scalar"); |
|
577
|
|
|
|
|
|
|
} |
|
578
|
700
|
|
|
|
|
1282
|
last; |
|
579
|
|
|
|
|
|
|
} |
|
580
|
|
|
|
|
|
|
else { |
|
581
|
734
|
|
|
|
|
1090
|
push @lines, ''; |
|
582
|
734
|
|
|
|
|
3096
|
push @tokens, ( EOL => $spaces . $eol, $self->line ); |
|
583
|
734
|
|
|
|
|
1128
|
next; |
|
584
|
|
|
|
|
|
|
} |
|
585
|
|
|
|
|
|
|
} |
|
586
|
2806
|
100
|
|
|
|
4781
|
if ((length $spaces) > $current_indent) { |
|
587
|
1572
|
100
|
|
|
|
2835
|
if ($started) { |
|
588
|
372
|
|
|
|
|
1600
|
($spaces, my $more_spaces) = unpack "a${current_indent}a*", $spaces; |
|
589
|
372
|
|
|
|
|
646
|
$content = $more_spaces . $content; |
|
590
|
|
|
|
|
|
|
} |
|
591
|
|
|
|
|
|
|
} |
|
592
|
2806
|
100
|
|
|
|
4447
|
unless (length $content) { |
|
593
|
257
|
|
|
|
|
397
|
push @lines, ''; |
|
594
|
257
|
|
|
|
|
500
|
push @tokens, ( INDENT => $spaces, $self->line, EOL => $eol, $self->line ); |
|
595
|
257
|
100
|
|
|
|
531
|
unless ($started) { |
|
596
|
131
|
|
|
|
|
171
|
$current_indent = length $spaces; |
|
597
|
|
|
|
|
|
|
} |
|
598
|
257
|
|
|
|
|
409
|
next; |
|
599
|
|
|
|
|
|
|
} |
|
600
|
2549
|
100
|
|
|
|
4011
|
unless ($started) { |
|
601
|
1382
|
|
|
|
|
1798
|
$started = 1; |
|
602
|
1382
|
|
|
|
|
1664
|
$current_indent = length $spaces; |
|
603
|
|
|
|
|
|
|
} |
|
604
|
2549
|
|
|
|
|
3276
|
push @lines, $content; |
|
605
|
2549
|
|
|
|
|
4330
|
push @tokens, ( |
|
606
|
|
|
|
|
|
|
INDENT => $spaces, $self->line, |
|
607
|
|
|
|
|
|
|
BLOCK_SCALAR_CONTENT => $content, $self->line, |
|
608
|
|
|
|
|
|
|
EOL => $eol, $self->line, |
|
609
|
|
|
|
|
|
|
); |
|
610
|
|
|
|
|
|
|
} |
|
611
|
1712
|
|
|
|
|
7066
|
my $value = YAML::PP::Render->render_block_scalar($context, $chomp, \@lines); |
|
612
|
1712
|
|
|
|
|
4370
|
my @eol = splice @tokens, -3; |
|
613
|
1712
|
|
|
|
|
6679
|
$self->push_subtokens( { name => 'BLOCK_SCALAR', value => $value }, \@tokens ); |
|
614
|
1712
|
|
|
|
|
5325
|
$self->_push_tokens([ @eol ]); |
|
615
|
1712
|
|
|
|
|
7890
|
return 0; |
|
616
|
|
|
|
|
|
|
} |
|
617
|
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
sub fetch_quoted { |
|
619
|
4717
|
|
|
4717
|
0
|
7988
|
my ($self, $indent, $context) = @_; |
|
620
|
4717
|
|
|
|
|
7662
|
my $next_line = $self->next_line; |
|
621
|
4717
|
|
|
|
|
6430
|
my $yaml = \$next_line->[1]; |
|
622
|
4717
|
|
|
|
|
6421
|
my $spaces = $next_line->[0]; |
|
623
|
|
|
|
|
|
|
|
|
624
|
4717
|
|
|
|
|
6768
|
my $token_name = $TOKEN_NAMES{ $context }; |
|
625
|
4717
|
50
|
|
|
|
44330
|
$$yaml =~ s/\A\Q$context// or die "Unexpected";; |
|
626
|
4717
|
|
|
|
|
9684
|
my @tokens = ( $token_name => $context, $self->line ); |
|
627
|
|
|
|
|
|
|
|
|
628
|
4717
|
|
|
|
|
5430
|
my $start = 1; |
|
629
|
4717
|
|
|
|
|
5149
|
my @values; |
|
630
|
4717
|
|
|
|
|
5225
|
while (1) { |
|
631
|
|
|
|
|
|
|
|
|
632
|
5567
|
100
|
|
|
|
8343
|
unless ($start) { |
|
633
|
850
|
100
|
|
|
|
1381
|
$next_line = $self->_fetch_next_line or do { |
|
634
|
1
|
|
|
|
|
4
|
for (my $i = 0; $i < @tokens; $i+= 3) { |
|
635
|
3
|
|
|
|
|
5
|
my $token = $tokens[ $i + 1 ]; |
|
636
|
3
|
100
|
|
|
|
7
|
if (ref $token) { |
|
637
|
1
|
|
|
|
|
2
|
$tokens[ $i + 1 ] = $token->{orig}; |
|
638
|
|
|
|
|
|
|
} |
|
639
|
|
|
|
|
|
|
} |
|
640
|
1
|
|
|
|
|
4
|
$self->_push_tokens(\@tokens); |
|
641
|
1
|
|
|
|
|
4
|
$self->exception("Missing closing quote <$context> at EOF"); |
|
642
|
|
|
|
|
|
|
}; |
|
643
|
849
|
|
|
|
|
1031
|
$start = 0; |
|
644
|
849
|
|
|
|
|
1116
|
$spaces = $next_line->[0]; |
|
645
|
849
|
|
|
|
|
1314
|
$yaml = \$next_line->[1]; |
|
646
|
|
|
|
|
|
|
|
|
647
|
849
|
100
|
100
|
|
|
4205
|
if (not length $$yaml) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
648
|
160
|
|
|
|
|
424
|
push @tokens, ( EOL => $spaces . $next_line->[2], $self->line ); |
|
649
|
160
|
|
|
|
|
358
|
$self->set_next_line(undef); |
|
650
|
160
|
|
|
|
|
403
|
push @values, { value => '', orig => '' }; |
|
651
|
160
|
|
|
|
|
279
|
next; |
|
652
|
|
|
|
|
|
|
} |
|
653
|
|
|
|
|
|
|
elsif (not $spaces and $$yaml =~ m/\A(---|\.\.\.)(?=$RE_WS|\z)/) { |
|
654
|
3
|
|
|
|
|
10
|
for (my $i = 0; $i < @tokens; $i+= 3) { |
|
655
|
9
|
|
|
|
|
12
|
my $token = $tokens[ $i + 1 ]; |
|
656
|
9
|
100
|
|
|
|
18
|
if (ref $token) { |
|
657
|
3
|
|
|
|
|
9
|
$tokens[ $i + 1 ] = $token->{orig}; |
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
} |
|
660
|
3
|
|
|
|
|
8
|
$self->_push_tokens(\@tokens); |
|
661
|
3
|
|
|
|
|
7
|
$self->exception("Missing closing quote <$context> or invalid document marker"); |
|
662
|
|
|
|
|
|
|
} |
|
663
|
|
|
|
|
|
|
elsif ((length $spaces) < $indent) { |
|
664
|
3
|
|
|
|
|
9
|
for (my $i = 0; $i < @tokens; $i+= 3) { |
|
665
|
9
|
|
|
|
|
13
|
my $token = $tokens[ $i + 1 ]; |
|
666
|
9
|
100
|
|
|
|
18
|
if (ref $token) { |
|
667
|
3
|
|
|
|
|
9
|
$tokens[ $i + 1 ] = $token->{orig}; |
|
668
|
|
|
|
|
|
|
} |
|
669
|
|
|
|
|
|
|
} |
|
670
|
3
|
|
|
|
|
9
|
$self->_push_tokens(\@tokens); |
|
671
|
3
|
|
|
|
|
10
|
$self->exception("Wrong indendation or missing closing quote <$context>"); |
|
672
|
|
|
|
|
|
|
} |
|
673
|
|
|
|
|
|
|
|
|
674
|
683
|
100
|
|
|
|
2879
|
if ($$yaml =~ s/\A($RE_WS+)//) { |
|
675
|
95
|
|
|
|
|
186
|
$spaces .= $1; |
|
676
|
|
|
|
|
|
|
} |
|
677
|
683
|
|
|
|
|
1307
|
push @tokens, ( WS => $spaces, $self->line ); |
|
678
|
|
|
|
|
|
|
} |
|
679
|
|
|
|
|
|
|
|
|
680
|
5400
|
|
|
|
|
10778
|
my $v = $self->_read_quoted_tokens($start, $context, $yaml, \@tokens); |
|
681
|
5398
|
|
|
|
|
7204
|
push @values, $v; |
|
682
|
5398
|
100
|
|
|
|
9073
|
if ($tokens[-3] eq $token_name) { |
|
683
|
4708
|
100
|
|
|
|
6200
|
if ($start) { |
|
684
|
|
|
|
|
|
|
$self->push_subtokens( |
|
685
|
|
|
|
|
|
|
{ name => 'QUOTED', value => $v->{value} }, \@tokens |
|
686
|
4217
|
|
|
|
|
13671
|
); |
|
687
|
|
|
|
|
|
|
} |
|
688
|
|
|
|
|
|
|
else { |
|
689
|
491
|
|
|
|
|
1742
|
my $value = YAML::PP::Render->render_quoted($context, \@values); |
|
690
|
491
|
|
|
|
|
1672
|
$self->push_subtokens( |
|
691
|
|
|
|
|
|
|
{ name => 'QUOTED_MULTILINE', value => $value }, \@tokens |
|
692
|
|
|
|
|
|
|
); |
|
693
|
|
|
|
|
|
|
} |
|
694
|
4708
|
100
|
|
|
|
7692
|
$self->set_context(1) if $self->flowcontext; |
|
695
|
4708
|
100
|
|
|
|
7327
|
if (length $$yaml) { |
|
696
|
2566
|
|
|
|
|
4168
|
my $partial = $self->_fetch_next_tokens($next_line); |
|
697
|
2566
|
100
|
|
|
|
4147
|
if (not $partial) { |
|
698
|
1017
|
|
|
|
|
1793
|
$self->set_next_line(undef); |
|
699
|
|
|
|
|
|
|
} |
|
700
|
2566
|
|
|
|
|
11847
|
return 0; |
|
701
|
|
|
|
|
|
|
} |
|
702
|
|
|
|
|
|
|
else { |
|
703
|
2142
|
|
|
|
|
4509
|
@tokens = (); |
|
704
|
2142
|
|
|
|
|
3827
|
push @tokens, ( EOL => $next_line->[2], $self->line ); |
|
705
|
2142
|
|
|
|
|
4750
|
$self->_push_tokens(\@tokens); |
|
706
|
2142
|
|
|
|
|
4584
|
$self->set_next_line(undef); |
|
707
|
2142
|
|
|
|
|
10068
|
return; |
|
708
|
|
|
|
|
|
|
} |
|
709
|
|
|
|
|
|
|
} |
|
710
|
690
|
|
|
|
|
1094
|
$tokens[-2] .= $next_line->[2]; |
|
711
|
690
|
|
|
|
|
1415
|
$self->set_next_line(undef); |
|
712
|
690
|
|
|
|
|
852
|
$start = 0; |
|
713
|
|
|
|
|
|
|
} |
|
714
|
|
|
|
|
|
|
} |
|
715
|
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
sub _read_quoted_tokens { |
|
717
|
5400
|
|
|
5400
|
|
9566
|
my ($self, $start, $first, $yaml, $tokens) = @_; |
|
718
|
5400
|
|
|
|
|
6300
|
my $quoted = ''; |
|
719
|
5400
|
|
|
|
|
5915
|
my $decoded = ''; |
|
720
|
5400
|
|
|
|
|
6597
|
my $token_name = $TOKEN_NAMES{ $first }; |
|
721
|
5400
|
|
|
|
|
5937
|
my $eol = ''; |
|
722
|
5400
|
100
|
|
|
|
7980
|
if ($first eq "'") { |
|
723
|
2197
|
|
|
|
|
2817
|
my $regex = $REGEXES{SINGLEQUOTED}; |
|
724
|
2197
|
50
|
|
|
|
14025
|
if ($$yaml =~ s/\A($regex)//) { |
|
725
|
2197
|
|
|
|
|
4993
|
$quoted .= $1; |
|
726
|
2197
|
|
|
|
|
2812
|
$decoded .= $1; |
|
727
|
2197
|
|
|
|
|
3573
|
$decoded =~ s/''/'/g; |
|
728
|
|
|
|
|
|
|
} |
|
729
|
2197
|
100
|
|
|
|
4178
|
unless (length $$yaml) { |
|
730
|
88
|
100
|
|
|
|
588
|
if ($quoted =~ s/($RE_WS+)\z//) { |
|
731
|
24
|
|
|
|
|
45
|
$eol = $1; |
|
732
|
24
|
|
|
|
|
287
|
$decoded =~ s/($eol)\z//; |
|
733
|
|
|
|
|
|
|
} |
|
734
|
|
|
|
|
|
|
} |
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
else { |
|
737
|
3203
|
|
|
|
|
6137
|
($quoted, $decoded, $eol) = $self->_read_doublequoted($yaml); |
|
738
|
|
|
|
|
|
|
} |
|
739
|
5400
|
|
|
|
|
13848
|
my $value = { value => $decoded, orig => $quoted }; |
|
740
|
|
|
|
|
|
|
|
|
741
|
5400
|
100
|
|
|
|
25996
|
if ($$yaml =~ s/\A$first//) { |
|
742
|
4708
|
100
|
|
|
|
7302
|
if ($start) { |
|
743
|
4217
|
|
|
|
|
9543
|
push @$tokens, ( $token_name . 'D' => $value, $self->line ); |
|
744
|
|
|
|
|
|
|
} |
|
745
|
|
|
|
|
|
|
else { |
|
746
|
491
|
|
|
|
|
1133
|
push @$tokens, ( $token_name . 'D_LINE' => $value, $self->line ); |
|
747
|
|
|
|
|
|
|
} |
|
748
|
4708
|
|
|
|
|
7062
|
push @$tokens, ( $token_name => $first, $self->line ); |
|
749
|
4708
|
|
|
|
|
9866
|
return $value; |
|
750
|
|
|
|
|
|
|
} |
|
751
|
692
|
100
|
|
|
|
1433
|
if (length $$yaml) { |
|
752
|
2
|
|
|
|
|
7
|
push @$tokens, ( $token_name . 'D' => $value->{orig}, $self->line ); |
|
753
|
2
|
|
|
|
|
7
|
$self->_push_tokens($tokens); |
|
754
|
2
|
|
|
|
|
5
|
$self->exception("Invalid quoted <$first> string"); |
|
755
|
|
|
|
|
|
|
} |
|
756
|
|
|
|
|
|
|
|
|
757
|
690
|
|
|
|
|
1633
|
push @$tokens, ( $token_name . 'D_LINE' => $value, $self->line ); |
|
758
|
690
|
|
|
|
|
1232
|
push @$tokens, ( EOL => $eol, $self->line ); |
|
759
|
|
|
|
|
|
|
|
|
760
|
690
|
|
|
|
|
1186
|
return $value; |
|
761
|
|
|
|
|
|
|
} |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
sub _read_doublequoted { |
|
764
|
3203
|
|
|
3203
|
|
4474
|
my ($self, $yaml) = @_; |
|
765
|
3203
|
|
|
|
|
3931
|
my $quoted = ''; |
|
766
|
3203
|
|
|
|
|
3519
|
my $decoded = ''; |
|
767
|
3203
|
|
|
|
|
4086
|
my $eol = ''; |
|
768
|
3203
|
|
|
|
|
3571
|
while (1) { |
|
769
|
9367
|
|
|
|
|
8851
|
my $last = 1; |
|
770
|
9367
|
100
|
|
|
|
22951
|
if ($$yaml =~ s/\A([^"\\ \t]+)//) { |
|
771
|
5584
|
|
|
|
|
9117
|
$quoted .= $1; |
|
772
|
5584
|
|
|
|
|
6476
|
$decoded .= $1; |
|
773
|
5584
|
|
|
|
|
5664
|
$last = 0; |
|
774
|
|
|
|
|
|
|
} |
|
775
|
9367
|
100
|
|
|
|
31015
|
if ($$yaml =~ s/\A($RE_ESCAPES)//) { |
|
776
|
1475
|
|
|
|
|
2186
|
$quoted .= $1; |
|
777
|
1475
|
100
|
|
|
|
3947
|
my $dec = defined $2 ? $CONTROL{ $2 } |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
: defined $3 ? chr hex $3 |
|
779
|
|
|
|
|
|
|
: defined $4 ? chr hex $4 |
|
780
|
|
|
|
|
|
|
: chr hex $5; |
|
781
|
1475
|
|
|
|
|
1801
|
$decoded .= $dec; |
|
782
|
1475
|
|
|
|
|
1707
|
$last = 0; |
|
783
|
|
|
|
|
|
|
} |
|
784
|
9367
|
100
|
|
|
|
18303
|
if ($$yaml =~ s/\A([ \t]+)//) { |
|
785
|
2762
|
|
|
|
|
3885
|
my $spaces = $1; |
|
786
|
2762
|
100
|
|
|
|
4159
|
if (length $$yaml) { |
|
787
|
2621
|
|
|
|
|
3359
|
$quoted .= $spaces; |
|
788
|
2621
|
|
|
|
|
2733
|
$decoded .= $spaces; |
|
789
|
2621
|
|
|
|
|
3004
|
$last = 0; |
|
790
|
|
|
|
|
|
|
} |
|
791
|
|
|
|
|
|
|
else { |
|
792
|
141
|
|
|
|
|
232
|
$eol = $spaces; |
|
793
|
141
|
|
|
|
|
238
|
last; |
|
794
|
|
|
|
|
|
|
} |
|
795
|
|
|
|
|
|
|
} |
|
796
|
9226
|
100
|
|
|
|
14485
|
if ($$yaml =~ s/\A(\\)\z//) { |
|
797
|
82
|
|
|
|
|
161
|
$quoted .= $1; |
|
798
|
82
|
|
|
|
|
140
|
$decoded .= $1; |
|
799
|
82
|
|
|
|
|
110
|
last; |
|
800
|
|
|
|
|
|
|
} |
|
801
|
9144
|
100
|
|
|
|
13326
|
last if $last; |
|
802
|
|
|
|
|
|
|
} |
|
803
|
3203
|
|
|
|
|
9234
|
return ($quoted, $decoded, $eol); |
|
804
|
|
|
|
|
|
|
} |
|
805
|
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
sub _fetch_next_tokens_directive { |
|
807
|
326
|
|
|
326
|
|
666
|
my ($self, $yaml, $eol) = @_; |
|
808
|
326
|
|
|
|
|
418
|
my @tokens; |
|
809
|
|
|
|
|
|
|
|
|
810
|
326
|
|
|
|
|
520
|
my $trailing_ws = ''; |
|
811
|
326
|
|
100
|
|
|
1235
|
my $warn = $ENV{YAML_PP_RESERVED_DIRECTIVE} || 'warn'; |
|
812
|
326
|
100
|
|
|
|
5287
|
if ($$yaml =~ s/\A(\s*%YAML[ \t]+([0-9]+\.[0-9]+))//) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
813
|
163
|
|
|
|
|
294
|
my $dir = $1; |
|
814
|
163
|
|
|
|
|
274
|
my $version = $2; |
|
815
|
163
|
100
|
|
|
|
1234
|
if ($$yaml =~ s/\A($RE_WS+)//) { |
|
|
|
100
|
|
|
|
|
|
|
816
|
28
|
|
|
|
|
63
|
$trailing_ws = $1; |
|
817
|
|
|
|
|
|
|
} |
|
818
|
|
|
|
|
|
|
elsif (length $$yaml) { |
|
819
|
1
|
|
|
|
|
4
|
push @tokens, ( 'Invalid directive' => $dir.$$yaml.$eol, $self->line ); |
|
820
|
1
|
|
|
|
|
3
|
$self->_push_tokens(\@tokens); |
|
821
|
1
|
|
|
|
|
2
|
return; |
|
822
|
|
|
|
|
|
|
} |
|
823
|
162
|
100
|
|
|
|
1007
|
if ($version !~ m/^1\.[12]$/) { |
|
824
|
9
|
50
|
|
|
|
39
|
if ($warn eq 'warn') { |
|
|
|
50
|
|
|
|
|
|
|
825
|
0
|
|
|
|
|
0
|
warn "Unsupported YAML version '$dir'"; |
|
826
|
|
|
|
|
|
|
} |
|
827
|
|
|
|
|
|
|
elsif ($warn eq 'fatal') { |
|
828
|
0
|
|
|
|
|
0
|
push @tokens, ( 'Unsupported YAML version' => $dir, $self->line ); |
|
829
|
0
|
|
|
|
|
0
|
$self->_push_tokens(\@tokens); |
|
830
|
0
|
|
|
|
|
0
|
return; |
|
831
|
|
|
|
|
|
|
} |
|
832
|
|
|
|
|
|
|
} |
|
833
|
162
|
|
|
|
|
397
|
push @tokens, ( YAML_DIRECTIVE => $dir, $self->line ); |
|
834
|
|
|
|
|
|
|
} |
|
835
|
|
|
|
|
|
|
elsif ($$yaml =~ s/\A(\s*%TAG[ \t]+(!$RE_NS_WORD_CHAR*!|!)[ \t]+(tag:\S+|!$RE_URI_CHAR+))($RE_WS*)//) { |
|
836
|
118
|
|
|
|
|
329
|
push @tokens, ( TAG_DIRECTIVE => $1, $self->line ); |
|
837
|
|
|
|
|
|
|
# TODO |
|
838
|
118
|
|
|
|
|
258
|
my $tag_alias = $2; |
|
839
|
118
|
|
|
|
|
225
|
my $tag_url = $3; |
|
840
|
118
|
|
|
|
|
409
|
$trailing_ws = $4; |
|
841
|
|
|
|
|
|
|
} |
|
842
|
|
|
|
|
|
|
elsif ($$yaml =~ s/\A(\s*\A%(?:\w+).*)//) { |
|
843
|
45
|
|
|
|
|
127
|
push @tokens, ( RESERVED_DIRECTIVE => $1, $self->line ); |
|
844
|
45
|
50
|
|
|
|
169
|
if ($warn eq 'warn') { |
|
|
|
50
|
|
|
|
|
|
|
845
|
0
|
|
|
|
|
0
|
warn "Found reserved directive '$1'"; |
|
846
|
|
|
|
|
|
|
} |
|
847
|
|
|
|
|
|
|
elsif ($warn eq 'fatal') { |
|
848
|
0
|
|
|
|
|
0
|
die "Found reserved directive '$1'"; |
|
849
|
|
|
|
|
|
|
} |
|
850
|
|
|
|
|
|
|
} |
|
851
|
|
|
|
|
|
|
else { |
|
852
|
0
|
|
|
|
|
0
|
push @tokens, ( 'Invalid directive' => $$yaml, $self->line ); |
|
853
|
0
|
|
|
|
|
0
|
push @tokens, ( EOL => $eol, $self->line ); |
|
854
|
0
|
|
|
|
|
0
|
$self->_push_tokens(\@tokens); |
|
855
|
0
|
|
|
|
|
0
|
return; |
|
856
|
|
|
|
|
|
|
} |
|
857
|
325
|
100
|
66
|
|
|
1173
|
if (not length $$yaml) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
858
|
297
|
|
|
|
|
562
|
push @tokens, ( EOL => $eol, $self->line ); |
|
859
|
|
|
|
|
|
|
} |
|
860
|
|
|
|
|
|
|
elsif ($trailing_ws and $$yaml =~ s/\A(#.*)?\z//) { |
|
861
|
27
|
|
|
|
|
124
|
push @tokens, ( EOL => "$trailing_ws$1$eol", $self->line ); |
|
862
|
27
|
|
|
|
|
93
|
$self->_push_tokens(\@tokens); |
|
863
|
27
|
|
|
|
|
74
|
return; |
|
864
|
|
|
|
|
|
|
} |
|
865
|
|
|
|
|
|
|
elsif ($$yaml =~ s/\A([ \t]+#.*)?\z//) { |
|
866
|
0
|
|
|
|
|
0
|
push @tokens, ( EOL => "$1$eol", $self->line ); |
|
867
|
0
|
|
|
|
|
0
|
$self->_push_tokens(\@tokens); |
|
868
|
0
|
|
|
|
|
0
|
return; |
|
869
|
|
|
|
|
|
|
} |
|
870
|
|
|
|
|
|
|
else { |
|
871
|
1
|
|
|
|
|
3
|
push @tokens, ( 'Invalid directive' => $trailing_ws.$$yaml, $self->line ); |
|
872
|
1
|
|
|
|
|
3
|
push @tokens, ( EOL => $eol, $self->line ); |
|
873
|
|
|
|
|
|
|
} |
|
874
|
298
|
|
|
|
|
773
|
$self->_push_tokens(\@tokens); |
|
875
|
298
|
|
|
|
|
676
|
return; |
|
876
|
|
|
|
|
|
|
} |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
sub _push_tokens { |
|
879
|
133509
|
|
|
133509
|
|
169246
|
my ($self, $new_tokens) = @_; |
|
880
|
133509
|
|
|
|
|
174929
|
my $next = $self->next_tokens; |
|
881
|
133509
|
|
|
|
|
172742
|
my $line = $self->line; |
|
882
|
133509
|
|
|
|
|
179682
|
my $column = $self->offset; |
|
883
|
|
|
|
|
|
|
|
|
884
|
133509
|
|
|
|
|
219955
|
for (my $i = 0; $i < @$new_tokens; $i += 3) { |
|
885
|
231125
|
|
|
|
|
273252
|
my $value = $new_tokens->[ $i + 1 ]; |
|
886
|
231125
|
|
|
|
|
238900
|
my $name = $new_tokens->[ $i ]; |
|
887
|
231125
|
|
|
|
|
238926
|
my $line = $new_tokens->[ $i + 2 ]; |
|
888
|
231125
|
|
|
|
|
539659
|
my $push = { |
|
889
|
|
|
|
|
|
|
name => $name, |
|
890
|
|
|
|
|
|
|
line => $line, |
|
891
|
|
|
|
|
|
|
column => $column, |
|
892
|
|
|
|
|
|
|
value => $value, |
|
893
|
|
|
|
|
|
|
}; |
|
894
|
231125
|
100
|
|
|
|
365824
|
$column += length $value unless $name eq 'CONTEXT'; |
|
895
|
231125
|
|
|
|
|
246937
|
push @$next, $push; |
|
896
|
231125
|
100
|
|
|
|
438137
|
if ($name eq 'EOL') { |
|
897
|
34285
|
|
|
|
|
62468
|
$column = 0; |
|
898
|
|
|
|
|
|
|
} |
|
899
|
|
|
|
|
|
|
} |
|
900
|
133509
|
|
|
|
|
218731
|
$self->set_offset($column); |
|
901
|
133509
|
|
|
|
|
153674
|
return $next; |
|
902
|
|
|
|
|
|
|
} |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
sub push_subtokens { |
|
905
|
6662
|
|
|
6662
|
0
|
9788
|
my ($self, $token, $subtokens) = @_; |
|
906
|
6662
|
|
|
|
|
9984
|
my $next = $self->next_tokens; |
|
907
|
6662
|
|
|
|
|
9567
|
my $line = $self->line; |
|
908
|
6662
|
|
|
|
|
10352
|
my $column = $self->offset; |
|
909
|
6662
|
|
|
|
|
9810
|
$token->{column} = $column; |
|
910
|
6662
|
|
|
|
|
10840
|
$token->{subtokens} = \my @sub; |
|
911
|
|
|
|
|
|
|
|
|
912
|
6662
|
|
|
|
|
14222
|
for (my $i = 0; $i < @$subtokens; $i+=3) { |
|
913
|
29130
|
|
|
|
|
30882
|
my $name = $subtokens->[ $i ]; |
|
914
|
29130
|
|
|
|
|
35882
|
my $value = $subtokens->[ $i + 1 ]; |
|
915
|
29130
|
|
|
|
|
29872
|
my $line = $subtokens->[ $i + 2 ]; |
|
916
|
29130
|
|
|
|
|
51288
|
my $push = { |
|
917
|
|
|
|
|
|
|
name => $subtokens->[ $i ], |
|
918
|
|
|
|
|
|
|
line => $line, |
|
919
|
|
|
|
|
|
|
column => $column, |
|
920
|
|
|
|
|
|
|
}; |
|
921
|
29130
|
100
|
|
|
|
37879
|
if (ref $value eq 'HASH') { |
|
922
|
5391
|
|
|
|
|
34892
|
%$push = ( %$push, %$value ); |
|
923
|
5391
|
|
|
|
|
11861
|
$column += length $value->{orig}; |
|
924
|
|
|
|
|
|
|
} |
|
925
|
|
|
|
|
|
|
else { |
|
926
|
23739
|
|
|
|
|
29457
|
$push->{value} = $value; |
|
927
|
23739
|
|
|
|
|
26394
|
$column += length $value; |
|
928
|
|
|
|
|
|
|
} |
|
929
|
29130
|
100
|
|
|
|
40307
|
if ($push->{name} eq 'EOL') { |
|
930
|
4714
|
|
|
|
|
5243
|
$column = 0; |
|
931
|
|
|
|
|
|
|
} |
|
932
|
29130
|
|
|
|
|
52764
|
push @sub, $push; |
|
933
|
|
|
|
|
|
|
} |
|
934
|
6662
|
|
|
|
|
9844
|
$token->{line} = $sub[0]->{line}; |
|
935
|
6662
|
|
|
|
|
8466
|
push @$next, $token; |
|
936
|
6662
|
|
|
|
|
11896
|
$self->set_offset($column); |
|
937
|
6662
|
|
|
|
|
9569
|
return $next; |
|
938
|
|
|
|
|
|
|
} |
|
939
|
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
sub exception { |
|
941
|
61
|
|
|
61
|
0
|
100
|
my ($self, $msg) = @_; |
|
942
|
61
|
|
|
|
|
84
|
my $next = $self->next_tokens; |
|
943
|
61
|
|
|
|
|
96
|
$next = []; |
|
944
|
61
|
50
|
|
|
|
133
|
my $line = @$next ? $next->[0]->{line} : $self->line; |
|
945
|
61
|
|
|
|
|
353
|
my @caller = caller(0); |
|
946
|
61
|
|
|
|
|
77
|
my $yaml = ''; |
|
947
|
61
|
100
|
|
|
|
103
|
if (my $nl = $self->next_line) { |
|
948
|
60
|
|
|
|
|
154
|
$yaml = join '', @$nl; |
|
949
|
60
|
|
|
|
|
107
|
$yaml = $nl->[1]; |
|
950
|
|
|
|
|
|
|
} |
|
951
|
61
|
|
|
|
|
103
|
my $e = YAML::PP::Exception->new( |
|
952
|
|
|
|
|
|
|
line => $line, |
|
953
|
|
|
|
|
|
|
column => $self->offset + 1, |
|
954
|
|
|
|
|
|
|
msg => $msg, |
|
955
|
|
|
|
|
|
|
next => $next, |
|
956
|
|
|
|
|
|
|
where => $caller[1] . ' line ' . $caller[2], |
|
957
|
|
|
|
|
|
|
yaml => $yaml, |
|
958
|
|
|
|
|
|
|
); |
|
959
|
61
|
|
|
|
|
1387
|
croak $e; |
|
960
|
|
|
|
|
|
|
} |
|
961
|
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
1; |