@kubb/agent 4.33.5 → 4.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +22 -4176
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +1 -0
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +1 -0
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@stoplight/ordered-object-literal/package.json +53 -0
- package/.output/server/node_modules/@stoplight/ordered-object-literal/src/index.cjs +221 -0
- package/.output/server/node_modules/@stoplight/types/dist/index.js +129 -0
- package/.output/server/node_modules/@stoplight/types/package.json +81 -0
- package/.output/server/node_modules/@stoplight/yaml/buildJsonPath.js +41 -0
- package/.output/server/node_modules/@stoplight/yaml/dereferenceAnchor.js +38 -0
- package/.output/server/node_modules/@stoplight/yaml/getJsonPathForPosition.js +98 -0
- package/.output/server/node_modules/@stoplight/yaml/getLocationForJsonPath.js +145 -0
- package/.output/server/node_modules/@stoplight/yaml/index.js +16 -0
- package/.output/server/node_modules/@stoplight/yaml/lineForPosition.js +31 -0
- package/.output/server/node_modules/@stoplight/yaml/package.json +33 -0
- package/.output/server/node_modules/@stoplight/yaml/parse.js +5 -0
- package/.output/server/node_modules/@stoplight/yaml/parseWithPointers.js +456 -0
- package/.output/server/node_modules/@stoplight/yaml/safeStringify.js +5 -0
- package/.output/server/node_modules/@stoplight/yaml/trapAccess.js +11 -0
- package/.output/server/node_modules/@stoplight/yaml/types.js +6 -0
- package/.output/server/node_modules/@stoplight/yaml/utils.js +4 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/common.js +45 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/dumper.js +710 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/exception.js +35 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/index.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/loader.js +1414 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/mark.js +58 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/scalarInference.js +90 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/core.js +8 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_full.js +14 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_safe.js +19 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/failsafe.js +10 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/json.js +14 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema.js +77 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/binary.js +92 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/bool.js +32 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/float.js +94 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/int.js +159 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/regexp.js +64 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/undefined.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/map.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/merge.js +10 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/null.js +30 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/omap.js +46 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/pairs.js +55 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/seq.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/set.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/str.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/timestamp.js +70 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type.js +53 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/yamlAST.js +81 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/package.json +38 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +6 -1
- package/package.json +16 -16
|
@@ -0,0 +1,1414 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ast = require("./yamlAST");
|
|
4
|
+
'use strict';
|
|
5
|
+
const common = require("./common");
|
|
6
|
+
const YAMLException = require("./exception");
|
|
7
|
+
const Mark = require("./mark");
|
|
8
|
+
const DEFAULT_SAFE_SCHEMA = require("./schema/default_safe");
|
|
9
|
+
const DEFAULT_FULL_SCHEMA = require("./schema/default_full");
|
|
10
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
11
|
+
var CONTEXT_FLOW_IN = 1;
|
|
12
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
13
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
14
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
15
|
+
var CHOMPING_CLIP = 1;
|
|
16
|
+
var CHOMPING_STRIP = 2;
|
|
17
|
+
var CHOMPING_KEEP = 3;
|
|
18
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
19
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
20
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
21
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
22
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
23
|
+
function is_EOL(c) {
|
|
24
|
+
return (c === 0x0A) || (c === 0x0D);
|
|
25
|
+
}
|
|
26
|
+
function is_WHITE_SPACE(c) {
|
|
27
|
+
return (c === 0x09) || (c === 0x20);
|
|
28
|
+
}
|
|
29
|
+
function is_WS_OR_EOL(c) {
|
|
30
|
+
return (c === 0x09) ||
|
|
31
|
+
(c === 0x20) ||
|
|
32
|
+
(c === 0x0A) ||
|
|
33
|
+
(c === 0x0D);
|
|
34
|
+
}
|
|
35
|
+
function is_FLOW_INDICATOR(c) {
|
|
36
|
+
return 0x2C === c ||
|
|
37
|
+
0x5B === c ||
|
|
38
|
+
0x5D === c ||
|
|
39
|
+
0x7B === c ||
|
|
40
|
+
0x7D === c;
|
|
41
|
+
}
|
|
42
|
+
function fromHexCode(c) {
|
|
43
|
+
var lc;
|
|
44
|
+
if ((0x30 <= c) && (c <= 0x39)) {
|
|
45
|
+
return c - 0x30;
|
|
46
|
+
}
|
|
47
|
+
lc = c | 0x20;
|
|
48
|
+
if ((0x61 <= lc) && (lc <= 0x66)) {
|
|
49
|
+
return lc - 0x61 + 10;
|
|
50
|
+
}
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
function escapedHexLen(c) {
|
|
54
|
+
if (c === 0x78) {
|
|
55
|
+
return 2;
|
|
56
|
+
}
|
|
57
|
+
if (c === 0x75) {
|
|
58
|
+
return 4;
|
|
59
|
+
}
|
|
60
|
+
if (c === 0x55) {
|
|
61
|
+
return 8;
|
|
62
|
+
}
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
function fromDecimalCode(c) {
|
|
66
|
+
if ((0x30 <= c) && (c <= 0x39)) {
|
|
67
|
+
return c - 0x30;
|
|
68
|
+
}
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
function simpleEscapeSequence(c) {
|
|
72
|
+
return (c === 0x30) ? '\x00' :
|
|
73
|
+
(c === 0x61) ? '\x07' :
|
|
74
|
+
(c === 0x62) ? '\x08' :
|
|
75
|
+
(c === 0x74) ? '\x09' :
|
|
76
|
+
(c === 0x09) ? '\x09' :
|
|
77
|
+
(c === 0x6E) ? '\x0A' :
|
|
78
|
+
(c === 0x76) ? '\x0B' :
|
|
79
|
+
(c === 0x66) ? '\x0C' :
|
|
80
|
+
(c === 0x72) ? '\x0D' :
|
|
81
|
+
(c === 0x65) ? '\x1B' :
|
|
82
|
+
(c === 0x20) ? ' ' :
|
|
83
|
+
(c === 0x22) ? '\x22' :
|
|
84
|
+
(c === 0x2F) ? '/' :
|
|
85
|
+
(c === 0x5C) ? '\x5C' :
|
|
86
|
+
(c === 0x4E) ? '\x85' :
|
|
87
|
+
(c === 0x5F) ? '\xA0' :
|
|
88
|
+
(c === 0x4C) ? '\u2028' :
|
|
89
|
+
(c === 0x50) ? '\u2029' : '';
|
|
90
|
+
}
|
|
91
|
+
function charFromCodepoint(c) {
|
|
92
|
+
if (c <= 0xFFFF) {
|
|
93
|
+
return String.fromCharCode(c);
|
|
94
|
+
}
|
|
95
|
+
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, ((c - 0x010000) & 0x03FF) + 0xDC00);
|
|
96
|
+
}
|
|
97
|
+
var simpleEscapeCheck = new Array(256);
|
|
98
|
+
var simpleEscapeMap = new Array(256);
|
|
99
|
+
var customEscapeCheck = new Array(256);
|
|
100
|
+
var customEscapeMap = new Array(256);
|
|
101
|
+
for (var i = 0; i < 256; i++) {
|
|
102
|
+
customEscapeMap[i] = simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
103
|
+
simpleEscapeCheck[i] = simpleEscapeMap[i] ? 1 : 0;
|
|
104
|
+
customEscapeCheck[i] = 1;
|
|
105
|
+
if (!simpleEscapeCheck[i]) {
|
|
106
|
+
customEscapeMap[i] = '\\' + String.fromCharCode(i);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class State {
|
|
110
|
+
constructor(input, options) {
|
|
111
|
+
this.errorMap = {};
|
|
112
|
+
this.errors = [];
|
|
113
|
+
this.lines = [];
|
|
114
|
+
this.input = input;
|
|
115
|
+
this.filename = options['filename'] || null;
|
|
116
|
+
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
|
117
|
+
this.onWarning = options['onWarning'] || null;
|
|
118
|
+
this.legacy = options['legacy'] || false;
|
|
119
|
+
this.allowAnyEscape = options['allowAnyEscape'] || false;
|
|
120
|
+
this.ignoreDuplicateKeys = options['ignoreDuplicateKeys'] || false;
|
|
121
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
122
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
123
|
+
this.length = input.length;
|
|
124
|
+
this.position = 0;
|
|
125
|
+
this.line = 0;
|
|
126
|
+
this.lineStart = 0;
|
|
127
|
+
this.lineIndent = 0;
|
|
128
|
+
this.documents = [];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function generateError(state, message, isWarning = false) {
|
|
132
|
+
return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)), isWarning);
|
|
133
|
+
}
|
|
134
|
+
function throwErrorFromPosition(state, position, message, isWarning = false, toLineEnd = false) {
|
|
135
|
+
var line = positionToLine(state, position);
|
|
136
|
+
if (!line) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
var hash = message + position;
|
|
140
|
+
if (state.errorMap[hash]) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
var mark = new Mark(state.filename, state.input, position, line.line, (position - line.start));
|
|
144
|
+
if (toLineEnd) {
|
|
145
|
+
mark.toLineEnd = true;
|
|
146
|
+
}
|
|
147
|
+
var error = new YAMLException(message, mark, isWarning);
|
|
148
|
+
state.errors.push(error);
|
|
149
|
+
}
|
|
150
|
+
function throwError(state, message) {
|
|
151
|
+
var error = generateError(state, message);
|
|
152
|
+
var hash = error.message + error.mark.position;
|
|
153
|
+
if (state.errorMap[hash]) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
state.errors.push(error);
|
|
157
|
+
state.errorMap[hash] = 1;
|
|
158
|
+
var or = state.position;
|
|
159
|
+
while (true) {
|
|
160
|
+
if (state.position >= state.input.length - 1) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
var c = state.input.charAt(state.position);
|
|
164
|
+
if (c == '\n') {
|
|
165
|
+
state.position--;
|
|
166
|
+
if (state.position == or) {
|
|
167
|
+
state.position += 1;
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (c == '\r') {
|
|
172
|
+
state.position--;
|
|
173
|
+
if (state.position == or) {
|
|
174
|
+
state.position += 1;
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
state.position++;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function throwWarning(state, message) {
|
|
182
|
+
var error = generateError(state, message);
|
|
183
|
+
if (state.onWarning) {
|
|
184
|
+
state.onWarning.call(null, error);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
var directiveHandlers = {
|
|
190
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
191
|
+
var match, major, minor;
|
|
192
|
+
if (null !== state.version) {
|
|
193
|
+
throwError(state, 'duplication of %YAML directive');
|
|
194
|
+
}
|
|
195
|
+
if (1 !== args.length) {
|
|
196
|
+
throwError(state, 'YAML directive accepts exactly one argument');
|
|
197
|
+
}
|
|
198
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
199
|
+
if (null === match) {
|
|
200
|
+
throwError(state, 'ill-formed argument of the YAML directive');
|
|
201
|
+
}
|
|
202
|
+
major = parseInt(match[1], 10);
|
|
203
|
+
minor = parseInt(match[2], 10);
|
|
204
|
+
if (1 !== major) {
|
|
205
|
+
throwError(state, 'found incompatible YAML document (version 1.2 is required)');
|
|
206
|
+
}
|
|
207
|
+
state.version = args[0];
|
|
208
|
+
state.checkLineBreaks = (minor < 2);
|
|
209
|
+
if (2 !== minor) {
|
|
210
|
+
throwError(state, 'found incompatible YAML document (version 1.2 is required)');
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
214
|
+
var handle, prefix;
|
|
215
|
+
if (2 !== args.length) {
|
|
216
|
+
throwError(state, 'TAG directive accepts exactly two arguments');
|
|
217
|
+
}
|
|
218
|
+
handle = args[0];
|
|
219
|
+
prefix = args[1];
|
|
220
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
221
|
+
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
|
222
|
+
}
|
|
223
|
+
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
224
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
225
|
+
}
|
|
226
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
227
|
+
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
|
228
|
+
}
|
|
229
|
+
state.tagMap[handle] = prefix;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
function captureSegment(state, start, end, checkJson) {
|
|
233
|
+
var _position, _length, _character, _result;
|
|
234
|
+
var scalar = state.result;
|
|
235
|
+
if (scalar.startPosition == -1) {
|
|
236
|
+
scalar.startPosition = start;
|
|
237
|
+
}
|
|
238
|
+
if (start <= end) {
|
|
239
|
+
_result = state.input.slice(start, end);
|
|
240
|
+
if (checkJson) {
|
|
241
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
242
|
+
_character = _result.charCodeAt(_position);
|
|
243
|
+
if (!(0x09 === _character ||
|
|
244
|
+
0x20 <= _character && _character <= 0x10FFFF)) {
|
|
245
|
+
throwError(state, 'expected valid JSON character');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
250
|
+
throwError(state, 'the stream contains non-printable characters');
|
|
251
|
+
}
|
|
252
|
+
scalar.value += _result;
|
|
253
|
+
scalar.endPosition = end;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function mergeMappings(state, destination, source) {
|
|
257
|
+
var sourceKeys, key, index, quantity;
|
|
258
|
+
if (!common.isObject(source)) {
|
|
259
|
+
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
|
260
|
+
}
|
|
261
|
+
sourceKeys = Object.keys(source);
|
|
262
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
263
|
+
key = sourceKeys[index];
|
|
264
|
+
if (!_hasOwnProperty.call(destination, key)) {
|
|
265
|
+
destination[key] = source[key];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
|
|
270
|
+
var index, quantity;
|
|
271
|
+
if (keyNode == null) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (null === _result) {
|
|
275
|
+
_result = {
|
|
276
|
+
startPosition: keyNode.startPosition,
|
|
277
|
+
endPosition: valueNode.endPosition,
|
|
278
|
+
parent: null,
|
|
279
|
+
errors: [],
|
|
280
|
+
mappings: [], kind: ast.Kind.MAP
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
var mapping = ast.newMapping(keyNode, valueNode);
|
|
284
|
+
mapping.parent = _result;
|
|
285
|
+
keyNode.parent = mapping;
|
|
286
|
+
if (valueNode != null) {
|
|
287
|
+
valueNode.parent = mapping;
|
|
288
|
+
}
|
|
289
|
+
!state.ignoreDuplicateKeys && _result.mappings.forEach(sibling => {
|
|
290
|
+
if (sibling.key && sibling.key.value === (mapping.key && mapping.key.value)) {
|
|
291
|
+
throwErrorFromPosition(state, mapping.key.startPosition, 'duplicate key');
|
|
292
|
+
throwErrorFromPosition(state, sibling.key.startPosition, 'duplicate key');
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
_result.mappings.push(mapping);
|
|
296
|
+
_result.endPosition = valueNode ? valueNode.endPosition : keyNode.endPosition + 1;
|
|
297
|
+
return _result;
|
|
298
|
+
}
|
|
299
|
+
function readLineBreak(state) {
|
|
300
|
+
var ch;
|
|
301
|
+
ch = state.input.charCodeAt(state.position);
|
|
302
|
+
if (0x0A === ch) {
|
|
303
|
+
state.position++;
|
|
304
|
+
}
|
|
305
|
+
else if (0x0D === ch) {
|
|
306
|
+
state.position++;
|
|
307
|
+
if (0x0A === state.input.charCodeAt(state.position)) {
|
|
308
|
+
state.position++;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
throwError(state, 'a line break is expected');
|
|
313
|
+
}
|
|
314
|
+
state.line += 1;
|
|
315
|
+
state.lineStart = state.position;
|
|
316
|
+
state.lines.push({
|
|
317
|
+
start: state.lineStart,
|
|
318
|
+
line: state.line
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
class Line {
|
|
322
|
+
}
|
|
323
|
+
function positionToLine(state, position) {
|
|
324
|
+
var line;
|
|
325
|
+
for (var i = 0; i < state.lines.length; i++) {
|
|
326
|
+
if (state.lines[i].start > position) {
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
line = state.lines[i];
|
|
330
|
+
}
|
|
331
|
+
if (!line) {
|
|
332
|
+
return {
|
|
333
|
+
start: 0,
|
|
334
|
+
line: 0
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return line;
|
|
338
|
+
}
|
|
339
|
+
function readComment(state) {
|
|
340
|
+
var ch = 0, _position = state.position;
|
|
341
|
+
do {
|
|
342
|
+
ch = state.input.charCodeAt(++state.position);
|
|
343
|
+
} while (0 !== ch && !is_EOL(ch));
|
|
344
|
+
state.comments.push({
|
|
345
|
+
startPosition: _position,
|
|
346
|
+
endPosition: state.position,
|
|
347
|
+
value: state.input.slice(_position + 1, state.position)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
351
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
352
|
+
while (0 !== ch) {
|
|
353
|
+
while (is_WHITE_SPACE(ch)) {
|
|
354
|
+
if (ch === 0x09) {
|
|
355
|
+
state.errors.push(generateError(state, "Using tabs can lead to unpredictable results", true));
|
|
356
|
+
}
|
|
357
|
+
ch = state.input.charCodeAt(++state.position);
|
|
358
|
+
}
|
|
359
|
+
if (allowComments && 0x23 === ch) {
|
|
360
|
+
readComment(state);
|
|
361
|
+
ch = state.input.charCodeAt(state.position);
|
|
362
|
+
}
|
|
363
|
+
if (is_EOL(ch)) {
|
|
364
|
+
readLineBreak(state);
|
|
365
|
+
ch = state.input.charCodeAt(state.position);
|
|
366
|
+
lineBreaks++;
|
|
367
|
+
state.lineIndent = 0;
|
|
368
|
+
while (0x20 === ch) {
|
|
369
|
+
state.lineIndent++;
|
|
370
|
+
ch = state.input.charCodeAt(++state.position);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
|
|
378
|
+
throwWarning(state, 'deficient indentation');
|
|
379
|
+
}
|
|
380
|
+
return lineBreaks;
|
|
381
|
+
}
|
|
382
|
+
function testDocumentSeparator(state) {
|
|
383
|
+
var _position = state.position, ch;
|
|
384
|
+
ch = state.input.charCodeAt(_position);
|
|
385
|
+
if ((0x2D === ch || 0x2E === ch) &&
|
|
386
|
+
state.input.charCodeAt(_position + 1) === ch &&
|
|
387
|
+
state.input.charCodeAt(_position + 2) === ch) {
|
|
388
|
+
_position += 3;
|
|
389
|
+
ch = state.input.charCodeAt(_position);
|
|
390
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
function writeFoldedLines(state, scalar, count) {
|
|
397
|
+
if (1 === count) {
|
|
398
|
+
scalar.value += ' ';
|
|
399
|
+
}
|
|
400
|
+
else if (count > 1) {
|
|
401
|
+
scalar.value += common.repeat('\n', count - 1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
405
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
406
|
+
var state_result = ast.newScalar();
|
|
407
|
+
state_result.plainScalar = true;
|
|
408
|
+
state.result = state_result;
|
|
409
|
+
ch = state.input.charCodeAt(state.position);
|
|
410
|
+
if (is_WS_OR_EOL(ch) ||
|
|
411
|
+
is_FLOW_INDICATOR(ch) ||
|
|
412
|
+
0x23 === ch ||
|
|
413
|
+
0x26 === ch ||
|
|
414
|
+
0x2A === ch ||
|
|
415
|
+
0x21 === ch ||
|
|
416
|
+
0x7C === ch ||
|
|
417
|
+
0x3E === ch ||
|
|
418
|
+
0x27 === ch ||
|
|
419
|
+
0x22 === ch ||
|
|
420
|
+
0x25 === ch ||
|
|
421
|
+
0x40 === ch ||
|
|
422
|
+
0x60 === ch) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
if (0x3F === ch || 0x2D === ch) {
|
|
426
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
427
|
+
if (is_WS_OR_EOL(following) ||
|
|
428
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
state.kind = 'scalar';
|
|
433
|
+
captureStart = captureEnd = state.position;
|
|
434
|
+
hasPendingContent = false;
|
|
435
|
+
while (0 !== ch) {
|
|
436
|
+
if (0x3A === ch) {
|
|
437
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
438
|
+
if (is_WS_OR_EOL(following) ||
|
|
439
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else if (0x23 === ch) {
|
|
444
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
445
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
|
|
450
|
+
withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
else if (is_EOL(ch)) {
|
|
454
|
+
_line = state.line;
|
|
455
|
+
_lineStart = state.lineStart;
|
|
456
|
+
_lineIndent = state.lineIndent;
|
|
457
|
+
skipSeparationSpace(state, false, -1);
|
|
458
|
+
if (state.lineIndent >= nodeIndent) {
|
|
459
|
+
hasPendingContent = true;
|
|
460
|
+
ch = state.input.charCodeAt(state.position);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
state.position = captureEnd;
|
|
465
|
+
state.line = _line;
|
|
466
|
+
state.lineStart = _lineStart;
|
|
467
|
+
state.lineIndent = _lineIndent;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (hasPendingContent) {
|
|
472
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
473
|
+
writeFoldedLines(state, state_result, state.line - _line);
|
|
474
|
+
captureStart = captureEnd = state.position;
|
|
475
|
+
hasPendingContent = false;
|
|
476
|
+
}
|
|
477
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
478
|
+
captureEnd = state.position + 1;
|
|
479
|
+
}
|
|
480
|
+
ch = state.input.charCodeAt(++state.position);
|
|
481
|
+
if (state.position >= state.input.length) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
486
|
+
if (state.result.startPosition != -1) {
|
|
487
|
+
state_result.rawValue = state.input.substring(state_result.startPosition, state_result.endPosition);
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
state.kind = _kind;
|
|
491
|
+
state.result = _result;
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
495
|
+
var ch, captureStart, captureEnd;
|
|
496
|
+
ch = state.input.charCodeAt(state.position);
|
|
497
|
+
if (0x27 !== ch) {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
var scalar = ast.newScalar();
|
|
501
|
+
scalar.singleQuoted = true;
|
|
502
|
+
state.kind = 'scalar';
|
|
503
|
+
state.result = scalar;
|
|
504
|
+
scalar.startPosition = state.position;
|
|
505
|
+
state.position++;
|
|
506
|
+
captureStart = captureEnd = state.position;
|
|
507
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
508
|
+
if (0x27 === ch) {
|
|
509
|
+
captureSegment(state, captureStart, state.position, true);
|
|
510
|
+
ch = state.input.charCodeAt(++state.position);
|
|
511
|
+
scalar.endPosition = state.position;
|
|
512
|
+
if (0x27 === ch) {
|
|
513
|
+
captureStart = captureEnd = state.position;
|
|
514
|
+
state.position++;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
else if (is_EOL(ch)) {
|
|
521
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
522
|
+
writeFoldedLines(state, scalar, skipSeparationSpace(state, false, nodeIndent));
|
|
523
|
+
captureStart = captureEnd = state.position;
|
|
524
|
+
}
|
|
525
|
+
else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
526
|
+
throwError(state, 'unexpected end of the document within a single quoted scalar');
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
state.position++;
|
|
530
|
+
captureEnd = state.position;
|
|
531
|
+
scalar.endPosition = state.position;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
|
535
|
+
}
|
|
536
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
537
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, tmpEsc, ch;
|
|
538
|
+
ch = state.input.charCodeAt(state.position);
|
|
539
|
+
if (0x22 !== ch) {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
state.kind = 'scalar';
|
|
543
|
+
var scalar = ast.newScalar();
|
|
544
|
+
scalar.doubleQuoted = true;
|
|
545
|
+
state.result = scalar;
|
|
546
|
+
scalar.startPosition = state.position;
|
|
547
|
+
state.position++;
|
|
548
|
+
captureStart = captureEnd = state.position;
|
|
549
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
550
|
+
if (0x22 === ch) {
|
|
551
|
+
captureSegment(state, captureStart, state.position, true);
|
|
552
|
+
state.position++;
|
|
553
|
+
scalar.endPosition = state.position;
|
|
554
|
+
scalar.rawValue = state.input.substring(scalar.startPosition, scalar.endPosition);
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
else if (0x5C === ch) {
|
|
558
|
+
captureSegment(state, captureStart, state.position, true);
|
|
559
|
+
ch = state.input.charCodeAt(++state.position);
|
|
560
|
+
if (is_EOL(ch)) {
|
|
561
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
562
|
+
}
|
|
563
|
+
else if (ch < 256 && (state.allowAnyEscape ? customEscapeCheck[ch] : simpleEscapeCheck[ch])) {
|
|
564
|
+
scalar.value += (state.allowAnyEscape ? customEscapeMap[ch] : simpleEscapeMap[ch]);
|
|
565
|
+
state.position++;
|
|
566
|
+
}
|
|
567
|
+
else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
568
|
+
hexLength = tmp;
|
|
569
|
+
hexResult = 0;
|
|
570
|
+
for (; hexLength > 0; hexLength--) {
|
|
571
|
+
ch = state.input.charCodeAt(++state.position);
|
|
572
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
573
|
+
hexResult = (hexResult << 4) + tmp;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
throwError(state, 'expected hexadecimal character');
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
scalar.value += charFromCodepoint(hexResult);
|
|
580
|
+
state.position++;
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
throwError(state, 'unknown escape sequence');
|
|
584
|
+
}
|
|
585
|
+
captureStart = captureEnd = state.position;
|
|
586
|
+
}
|
|
587
|
+
else if (is_EOL(ch)) {
|
|
588
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
589
|
+
writeFoldedLines(state, scalar, skipSeparationSpace(state, false, nodeIndent));
|
|
590
|
+
captureStart = captureEnd = state.position;
|
|
591
|
+
}
|
|
592
|
+
else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
593
|
+
throwError(state, 'unexpected end of the document within a double quoted scalar');
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
state.position++;
|
|
597
|
+
captureEnd = state.position;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
|
601
|
+
}
|
|
602
|
+
function readFlowCollection(state, nodeIndent) {
|
|
603
|
+
var readNext = true, _line, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, keyNode, keyTag, valueNode, ch;
|
|
604
|
+
ch = state.input.charCodeAt(state.position);
|
|
605
|
+
if (ch === 0x5B) {
|
|
606
|
+
terminator = 0x5D;
|
|
607
|
+
isMapping = false;
|
|
608
|
+
_result = ast.newItems();
|
|
609
|
+
_result.startPosition = state.position;
|
|
610
|
+
}
|
|
611
|
+
else if (ch === 0x7B) {
|
|
612
|
+
terminator = 0x7D;
|
|
613
|
+
isMapping = true;
|
|
614
|
+
_result = ast.newMap();
|
|
615
|
+
_result.startPosition = state.position;
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
if (null !== state.anchor) {
|
|
621
|
+
_result.anchorId = state.anchor;
|
|
622
|
+
state.anchorMap[state.anchor] = _result;
|
|
623
|
+
}
|
|
624
|
+
ch = state.input.charCodeAt(++state.position);
|
|
625
|
+
while (0 !== ch) {
|
|
626
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
627
|
+
ch = state.input.charCodeAt(state.position);
|
|
628
|
+
if (ch === terminator) {
|
|
629
|
+
state.position++;
|
|
630
|
+
state.tag = _tag;
|
|
631
|
+
state.anchor = _anchor;
|
|
632
|
+
state.kind = isMapping ? 'mapping' : 'sequence';
|
|
633
|
+
state.result = _result;
|
|
634
|
+
_result.endPosition = state.position;
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
else if (!readNext) {
|
|
638
|
+
var p = state.position;
|
|
639
|
+
throwError(state, 'missed comma between flow collection entries');
|
|
640
|
+
state.position = p + 1;
|
|
641
|
+
}
|
|
642
|
+
keyTag = keyNode = valueNode = null;
|
|
643
|
+
isPair = isExplicitPair = false;
|
|
644
|
+
if (0x3F === ch) {
|
|
645
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
646
|
+
if (is_WS_OR_EOL(following)) {
|
|
647
|
+
isPair = isExplicitPair = true;
|
|
648
|
+
state.position++;
|
|
649
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
_line = state.line;
|
|
653
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
654
|
+
keyTag = state.tag;
|
|
655
|
+
keyNode = state.result;
|
|
656
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
657
|
+
ch = state.input.charCodeAt(state.position);
|
|
658
|
+
if ((isExplicitPair || state.line === _line) && 0x3A === ch) {
|
|
659
|
+
isPair = true;
|
|
660
|
+
ch = state.input.charCodeAt(++state.position);
|
|
661
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
662
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
663
|
+
valueNode = state.result;
|
|
664
|
+
}
|
|
665
|
+
if (isMapping) {
|
|
666
|
+
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
|
667
|
+
}
|
|
668
|
+
else if (isPair) {
|
|
669
|
+
var mp = storeMappingPair(state, null, keyTag, keyNode, valueNode);
|
|
670
|
+
mp.parent = _result;
|
|
671
|
+
_result.items.push(mp);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
if (keyNode) {
|
|
675
|
+
keyNode.parent = _result;
|
|
676
|
+
}
|
|
677
|
+
_result.items.push(keyNode);
|
|
678
|
+
}
|
|
679
|
+
_result.endPosition = state.position + 1;
|
|
680
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
681
|
+
ch = state.input.charCodeAt(state.position);
|
|
682
|
+
if (0x2C === ch) {
|
|
683
|
+
readNext = true;
|
|
684
|
+
ch = state.input.charCodeAt(++state.position);
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
readNext = false;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
throwError(state, 'unexpected end of the stream within a flow collection');
|
|
691
|
+
}
|
|
692
|
+
function readBlockScalar(state, nodeIndent) {
|
|
693
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
694
|
+
ch = state.input.charCodeAt(state.position);
|
|
695
|
+
if (ch === 0x7C) {
|
|
696
|
+
folding = false;
|
|
697
|
+
}
|
|
698
|
+
else if (ch === 0x3E) {
|
|
699
|
+
folding = true;
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
704
|
+
var sc = ast.newScalar();
|
|
705
|
+
state.kind = 'scalar';
|
|
706
|
+
state.result = sc;
|
|
707
|
+
sc.startPosition = state.position;
|
|
708
|
+
while (0 !== ch) {
|
|
709
|
+
ch = state.input.charCodeAt(++state.position);
|
|
710
|
+
if (0x2B === ch || 0x2D === ch) {
|
|
711
|
+
if (CHOMPING_CLIP === chomping) {
|
|
712
|
+
chomping = (0x2B === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
throwError(state, 'repeat of a chomping mode identifier');
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
719
|
+
if (tmp === 0) {
|
|
720
|
+
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
|
721
|
+
}
|
|
722
|
+
else if (!detectedIndent) {
|
|
723
|
+
textIndent = nodeIndent + tmp - 1;
|
|
724
|
+
detectedIndent = true;
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
throwError(state, 'repeat of an indentation width identifier');
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (is_WHITE_SPACE(ch)) {
|
|
735
|
+
do {
|
|
736
|
+
ch = state.input.charCodeAt(++state.position);
|
|
737
|
+
} while (is_WHITE_SPACE(ch));
|
|
738
|
+
if (0x23 === ch) {
|
|
739
|
+
readComment(state);
|
|
740
|
+
ch = state.input.charCodeAt(state.position);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
while (0 !== ch) {
|
|
744
|
+
readLineBreak(state);
|
|
745
|
+
state.lineIndent = 0;
|
|
746
|
+
ch = state.input.charCodeAt(state.position);
|
|
747
|
+
while ((!detectedIndent || state.lineIndent < textIndent) &&
|
|
748
|
+
(0x20 === ch)) {
|
|
749
|
+
state.lineIndent++;
|
|
750
|
+
ch = state.input.charCodeAt(++state.position);
|
|
751
|
+
}
|
|
752
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
753
|
+
textIndent = state.lineIndent;
|
|
754
|
+
}
|
|
755
|
+
if (is_EOL(ch)) {
|
|
756
|
+
emptyLines++;
|
|
757
|
+
continue;
|
|
758
|
+
}
|
|
759
|
+
if (state.lineIndent < textIndent) {
|
|
760
|
+
if (chomping === CHOMPING_KEEP) {
|
|
761
|
+
sc.value += common.repeat('\n', emptyLines);
|
|
762
|
+
}
|
|
763
|
+
else if (chomping === CHOMPING_CLIP) {
|
|
764
|
+
if (detectedIndent) {
|
|
765
|
+
sc.value += '\n';
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
if (folding) {
|
|
771
|
+
if (is_WHITE_SPACE(ch)) {
|
|
772
|
+
atMoreIndented = true;
|
|
773
|
+
sc.value += common.repeat('\n', emptyLines + 1);
|
|
774
|
+
}
|
|
775
|
+
else if (atMoreIndented) {
|
|
776
|
+
atMoreIndented = false;
|
|
777
|
+
sc.value += common.repeat('\n', emptyLines + 1);
|
|
778
|
+
}
|
|
779
|
+
else if (0 === emptyLines) {
|
|
780
|
+
if (detectedIndent) {
|
|
781
|
+
sc.value += ' ';
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
sc.value += common.repeat('\n', emptyLines);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
else if (detectedIndent) {
|
|
789
|
+
sc.value += common.repeat('\n', emptyLines + 1);
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
}
|
|
793
|
+
detectedIndent = true;
|
|
794
|
+
emptyLines = 0;
|
|
795
|
+
captureStart = state.position;
|
|
796
|
+
while (!is_EOL(ch) && (0 !== ch)) {
|
|
797
|
+
ch = state.input.charCodeAt(++state.position);
|
|
798
|
+
}
|
|
799
|
+
captureSegment(state, captureStart, state.position, false);
|
|
800
|
+
}
|
|
801
|
+
sc.endPosition = state.position;
|
|
802
|
+
var i = state.position - 1;
|
|
803
|
+
var needMinus = false;
|
|
804
|
+
while (true) {
|
|
805
|
+
var c = state.input[i];
|
|
806
|
+
if (c == '\r' || c == '\n') {
|
|
807
|
+
if (needMinus) {
|
|
808
|
+
i--;
|
|
809
|
+
}
|
|
810
|
+
break;
|
|
811
|
+
}
|
|
812
|
+
if (c != ' ' && c != '\t') {
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
i--;
|
|
816
|
+
}
|
|
817
|
+
sc.endPosition = i;
|
|
818
|
+
sc.rawValue = state.input.substring(sc.startPosition, sc.endPosition);
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
function readBlockSequence(state, nodeIndent) {
|
|
822
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = ast.newItems(), following, detected = false, ch;
|
|
823
|
+
if (null !== state.anchor) {
|
|
824
|
+
_result.anchorId = state.anchor;
|
|
825
|
+
state.anchorMap[state.anchor] = _result;
|
|
826
|
+
}
|
|
827
|
+
_result.startPosition = state.position;
|
|
828
|
+
ch = state.input.charCodeAt(state.position);
|
|
829
|
+
while (0 !== ch) {
|
|
830
|
+
if (0x2D !== ch) {
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
834
|
+
if (!is_WS_OR_EOL(following)) {
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
detected = true;
|
|
838
|
+
state.position++;
|
|
839
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
840
|
+
if (state.lineIndent <= nodeIndent) {
|
|
841
|
+
_result.items.push(null);
|
|
842
|
+
ch = state.input.charCodeAt(state.position);
|
|
843
|
+
continue;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
_line = state.line;
|
|
847
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
848
|
+
if (state.result) {
|
|
849
|
+
state.result.parent = _result;
|
|
850
|
+
_result.items.push(state.result);
|
|
851
|
+
}
|
|
852
|
+
skipSeparationSpace(state, true, -1);
|
|
853
|
+
ch = state.input.charCodeAt(state.position);
|
|
854
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
|
|
855
|
+
throwError(state, 'bad indentation of a sequence entry');
|
|
856
|
+
}
|
|
857
|
+
else if (state.lineIndent < nodeIndent) {
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
_result.endPosition = state.position;
|
|
862
|
+
if (detected) {
|
|
863
|
+
state.tag = _tag;
|
|
864
|
+
state.anchor = _anchor;
|
|
865
|
+
state.kind = 'sequence';
|
|
866
|
+
state.result = _result;
|
|
867
|
+
_result.endPosition = state.position;
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
873
|
+
var following, allowCompact, _line, _tag = state.tag, _anchor = state.anchor, _result = ast.newMap(), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
874
|
+
_result.startPosition = state.position;
|
|
875
|
+
if (null !== state.anchor) {
|
|
876
|
+
_result.anchorId = state.anchor;
|
|
877
|
+
state.anchorMap[state.anchor] = _result;
|
|
878
|
+
}
|
|
879
|
+
ch = state.input.charCodeAt(state.position);
|
|
880
|
+
while (0 !== ch) {
|
|
881
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
882
|
+
_line = state.line;
|
|
883
|
+
if ((0x3F === ch || 0x3A === ch) && is_WS_OR_EOL(following)) {
|
|
884
|
+
if (0x3F === ch) {
|
|
885
|
+
if (atExplicitKey) {
|
|
886
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
887
|
+
keyTag = keyNode = valueNode = null;
|
|
888
|
+
}
|
|
889
|
+
detected = true;
|
|
890
|
+
atExplicitKey = true;
|
|
891
|
+
allowCompact = true;
|
|
892
|
+
}
|
|
893
|
+
else if (atExplicitKey) {
|
|
894
|
+
atExplicitKey = false;
|
|
895
|
+
allowCompact = true;
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
throwError(state, 'incomplete explicit mapping pair; a key node is missed');
|
|
899
|
+
}
|
|
900
|
+
state.position += 1;
|
|
901
|
+
ch = following;
|
|
902
|
+
}
|
|
903
|
+
else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
904
|
+
if (state.line === _line) {
|
|
905
|
+
ch = state.input.charCodeAt(state.position);
|
|
906
|
+
while (is_WHITE_SPACE(ch)) {
|
|
907
|
+
ch = state.input.charCodeAt(++state.position);
|
|
908
|
+
}
|
|
909
|
+
if (0x3A === ch) {
|
|
910
|
+
ch = state.input.charCodeAt(++state.position);
|
|
911
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
912
|
+
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
|
913
|
+
}
|
|
914
|
+
if (atExplicitKey) {
|
|
915
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
916
|
+
keyTag = keyNode = valueNode = null;
|
|
917
|
+
}
|
|
918
|
+
detected = true;
|
|
919
|
+
atExplicitKey = false;
|
|
920
|
+
allowCompact = false;
|
|
921
|
+
keyTag = state.tag;
|
|
922
|
+
keyNode = state.result;
|
|
923
|
+
}
|
|
924
|
+
else if (state.position == state.lineStart && testDocumentSeparator(state)) {
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
else if (detected) {
|
|
928
|
+
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
state.tag = _tag;
|
|
932
|
+
state.anchor = _anchor;
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
else if (detected) {
|
|
937
|
+
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
|
938
|
+
while (state.position > 0) {
|
|
939
|
+
ch = state.input.charCodeAt(--state.position);
|
|
940
|
+
if (is_EOL(ch)) {
|
|
941
|
+
state.position++;
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
state.tag = _tag;
|
|
948
|
+
state.anchor = _anchor;
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
else {
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
956
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
957
|
+
if (atExplicitKey) {
|
|
958
|
+
keyNode = state.result;
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
valueNode = state.result;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (!atExplicitKey) {
|
|
965
|
+
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
|
966
|
+
keyTag = keyNode = valueNode = null;
|
|
967
|
+
}
|
|
968
|
+
skipSeparationSpace(state, true, -1);
|
|
969
|
+
ch = state.input.charCodeAt(state.position);
|
|
970
|
+
}
|
|
971
|
+
if (state.lineIndent > nodeIndent && (0 !== ch)) {
|
|
972
|
+
throwError(state, 'bad indentation of a mapping entry');
|
|
973
|
+
}
|
|
974
|
+
else if (state.lineIndent < nodeIndent) {
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
if (atExplicitKey) {
|
|
979
|
+
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
980
|
+
}
|
|
981
|
+
if (detected) {
|
|
982
|
+
state.tag = _tag;
|
|
983
|
+
state.anchor = _anchor;
|
|
984
|
+
state.kind = 'mapping';
|
|
985
|
+
state.result = _result;
|
|
986
|
+
}
|
|
987
|
+
return detected;
|
|
988
|
+
}
|
|
989
|
+
function readTagProperty(state) {
|
|
990
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
991
|
+
ch = state.input.charCodeAt(state.position);
|
|
992
|
+
if (0x21 !== ch) {
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
if (null !== state.tag) {
|
|
996
|
+
throwError(state, 'duplication of a tag property');
|
|
997
|
+
}
|
|
998
|
+
ch = state.input.charCodeAt(++state.position);
|
|
999
|
+
if (0x3C === ch) {
|
|
1000
|
+
isVerbatim = true;
|
|
1001
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1002
|
+
}
|
|
1003
|
+
else if (0x21 === ch) {
|
|
1004
|
+
isNamed = true;
|
|
1005
|
+
tagHandle = '!!';
|
|
1006
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
tagHandle = '!';
|
|
1010
|
+
}
|
|
1011
|
+
_position = state.position;
|
|
1012
|
+
if (isVerbatim) {
|
|
1013
|
+
do {
|
|
1014
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1015
|
+
} while (0 !== ch && 0x3E !== ch);
|
|
1016
|
+
if (state.position < state.length) {
|
|
1017
|
+
tagName = state.input.slice(_position, state.position);
|
|
1018
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
throwError(state, 'unexpected end of the stream within a verbatim tag');
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
1026
|
+
if (0x21 === ch) {
|
|
1027
|
+
if (!isNamed) {
|
|
1028
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1029
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1030
|
+
throwError(state, 'named tag handle cannot contain such characters');
|
|
1031
|
+
}
|
|
1032
|
+
isNamed = true;
|
|
1033
|
+
_position = state.position + 1;
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
throwError(state, 'tag suffix cannot contain exclamation marks');
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1040
|
+
}
|
|
1041
|
+
tagName = state.input.slice(_position, state.position);
|
|
1042
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1043
|
+
throwError(state, 'tag suffix cannot contain flow indicator characters');
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1047
|
+
throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
|
1048
|
+
}
|
|
1049
|
+
if (isVerbatim) {
|
|
1050
|
+
state.tag = tagName;
|
|
1051
|
+
}
|
|
1052
|
+
else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
1053
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1054
|
+
}
|
|
1055
|
+
else if ('!' === tagHandle) {
|
|
1056
|
+
state.tag = '!' + tagName;
|
|
1057
|
+
}
|
|
1058
|
+
else if ('!!' === tagHandle) {
|
|
1059
|
+
state.tag = 'tag:yaml.org,2002:' + tagName;
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1063
|
+
}
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
function readAnchorProperty(state) {
|
|
1067
|
+
var _position, ch;
|
|
1068
|
+
ch = state.input.charCodeAt(state.position);
|
|
1069
|
+
if (0x26 !== ch) {
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
if (null !== state.anchor) {
|
|
1073
|
+
throwError(state, 'duplication of an anchor property');
|
|
1074
|
+
}
|
|
1075
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1076
|
+
_position = state.position;
|
|
1077
|
+
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1078
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1079
|
+
}
|
|
1080
|
+
if (state.position === _position) {
|
|
1081
|
+
throwError(state, 'name of an anchor node must contain at least one character');
|
|
1082
|
+
}
|
|
1083
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
1084
|
+
return true;
|
|
1085
|
+
}
|
|
1086
|
+
function readAlias(state) {
|
|
1087
|
+
var _position, alias, len = state.length, input = state.input, ch;
|
|
1088
|
+
ch = state.input.charCodeAt(state.position);
|
|
1089
|
+
if (0x2A !== ch) {
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1092
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1093
|
+
_position = state.position;
|
|
1094
|
+
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1095
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1096
|
+
}
|
|
1097
|
+
if (state.position <= _position) {
|
|
1098
|
+
throwError(state, 'name of an alias node must contain at least one character');
|
|
1099
|
+
state.position = _position + 1;
|
|
1100
|
+
}
|
|
1101
|
+
alias = state.input.slice(_position, state.position);
|
|
1102
|
+
if (!state.anchorMap.hasOwnProperty(alias)) {
|
|
1103
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1104
|
+
if (state.position <= _position) {
|
|
1105
|
+
state.position = _position + 1;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
state.result = ast.newAnchorRef(alias, _position, state.position, state.anchorMap[alias]);
|
|
1109
|
+
skipSeparationSpace(state, true, -1);
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1113
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, type, flowIndent, blockIndent, _result;
|
|
1114
|
+
state.tag = null;
|
|
1115
|
+
state.anchor = null;
|
|
1116
|
+
state.kind = null;
|
|
1117
|
+
state.result = null;
|
|
1118
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
|
1119
|
+
CONTEXT_BLOCK_OUT === nodeContext ||
|
|
1120
|
+
CONTEXT_BLOCK_IN === nodeContext;
|
|
1121
|
+
if (allowToSeek) {
|
|
1122
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1123
|
+
atNewLine = true;
|
|
1124
|
+
if (state.lineIndent > parentIndent) {
|
|
1125
|
+
indentStatus = 1;
|
|
1126
|
+
}
|
|
1127
|
+
else if (state.lineIndent === parentIndent) {
|
|
1128
|
+
indentStatus = 0;
|
|
1129
|
+
}
|
|
1130
|
+
else if (state.lineIndent < parentIndent) {
|
|
1131
|
+
indentStatus = -1;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
let tagStart = state.position;
|
|
1136
|
+
let tagColumn = state.position - state.lineStart;
|
|
1137
|
+
if (1 === indentStatus) {
|
|
1138
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
1139
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1140
|
+
atNewLine = true;
|
|
1141
|
+
allowBlockCollections = allowBlockStyles;
|
|
1142
|
+
if (state.lineIndent > parentIndent) {
|
|
1143
|
+
indentStatus = 1;
|
|
1144
|
+
}
|
|
1145
|
+
else if (state.lineIndent === parentIndent) {
|
|
1146
|
+
indentStatus = 0;
|
|
1147
|
+
}
|
|
1148
|
+
else if (state.lineIndent < parentIndent) {
|
|
1149
|
+
indentStatus = -1;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
allowBlockCollections = false;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (allowBlockCollections) {
|
|
1158
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
1159
|
+
}
|
|
1160
|
+
if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1161
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1162
|
+
flowIndent = parentIndent;
|
|
1163
|
+
}
|
|
1164
|
+
else {
|
|
1165
|
+
flowIndent = parentIndent + 1;
|
|
1166
|
+
}
|
|
1167
|
+
blockIndent = state.position - state.lineStart;
|
|
1168
|
+
if (1 === indentStatus) {
|
|
1169
|
+
if (allowBlockCollections &&
|
|
1170
|
+
(readBlockSequence(state, blockIndent) ||
|
|
1171
|
+
readBlockMapping(state, blockIndent, flowIndent)) ||
|
|
1172
|
+
readFlowCollection(state, flowIndent)) {
|
|
1173
|
+
hasContent = true;
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
|
1177
|
+
readSingleQuotedScalar(state, flowIndent) ||
|
|
1178
|
+
readDoubleQuotedScalar(state, flowIndent)) {
|
|
1179
|
+
hasContent = true;
|
|
1180
|
+
}
|
|
1181
|
+
else if (readAlias(state)) {
|
|
1182
|
+
hasContent = true;
|
|
1183
|
+
if (null !== state.tag || null !== state.anchor) {
|
|
1184
|
+
throwError(state, 'alias node should not have any properties');
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1188
|
+
hasContent = true;
|
|
1189
|
+
if (null === state.tag) {
|
|
1190
|
+
state.tag = '?';
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
if (null !== state.anchor) {
|
|
1194
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1195
|
+
state.result.anchorId = state.anchor;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
else if (0 === indentStatus) {
|
|
1200
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (null !== state.tag && '!' !== state.tag) {
|
|
1204
|
+
if (state.tag == "!include") {
|
|
1205
|
+
if (!state.result) {
|
|
1206
|
+
state.result = ast.newScalar();
|
|
1207
|
+
state.result.startPosition = state.position;
|
|
1208
|
+
state.result.endPosition = state.position;
|
|
1209
|
+
throwError(state, "!include without value");
|
|
1210
|
+
}
|
|
1211
|
+
state.result.kind = ast.Kind.INCLUDE_REF;
|
|
1212
|
+
}
|
|
1213
|
+
else if ('?' === state.tag) {
|
|
1214
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1215
|
+
type = state.implicitTypes[typeIndex];
|
|
1216
|
+
var vl = state.result['value'];
|
|
1217
|
+
if (type.resolve(vl)) {
|
|
1218
|
+
state.result.valueObject = type.construct(state.result['value']);
|
|
1219
|
+
state.tag = type.tag;
|
|
1220
|
+
if (null !== state.anchor) {
|
|
1221
|
+
state.result.anchorId = state.anchor;
|
|
1222
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1223
|
+
}
|
|
1224
|
+
break;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
|
|
1229
|
+
type = state.typeMap[state.tag];
|
|
1230
|
+
if (null !== state.result && type.kind !== state.kind) {
|
|
1231
|
+
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
1232
|
+
}
|
|
1233
|
+
if (!type.resolve(state.result)) {
|
|
1234
|
+
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
state.result = type.construct(state.result);
|
|
1238
|
+
if (null !== state.anchor) {
|
|
1239
|
+
state.result.anchorId = state.anchor;
|
|
1240
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
throwErrorFromPosition(state, tagStart, 'unknown tag <' + state.tag + '>', false, true);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return null !== state.tag || null !== state.anchor || hasContent;
|
|
1249
|
+
}
|
|
1250
|
+
function readDocument(state) {
|
|
1251
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
1252
|
+
state.version = null;
|
|
1253
|
+
state.checkLineBreaks = state.legacy;
|
|
1254
|
+
state.tagMap = {};
|
|
1255
|
+
state.anchorMap = {};
|
|
1256
|
+
state.comments = [];
|
|
1257
|
+
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
1258
|
+
skipSeparationSpace(state, true, -1);
|
|
1259
|
+
ch = state.input.charCodeAt(state.position);
|
|
1260
|
+
if (state.lineIndent > 0 || 0x25 !== ch) {
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
hasDirectives = true;
|
|
1264
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1265
|
+
_position = state.position;
|
|
1266
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
1267
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1268
|
+
}
|
|
1269
|
+
directiveName = state.input.slice(_position, state.position);
|
|
1270
|
+
directiveArgs = [];
|
|
1271
|
+
if (directiveName.length < 1) {
|
|
1272
|
+
throwError(state, 'directive name must not be less than one character in length');
|
|
1273
|
+
}
|
|
1274
|
+
while (0 !== ch) {
|
|
1275
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1276
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1277
|
+
}
|
|
1278
|
+
if (0x23 === ch) {
|
|
1279
|
+
readComment(state);
|
|
1280
|
+
ch = state.input.charCodeAt(state.position);
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
if (is_EOL(ch)) {
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
_position = state.position;
|
|
1287
|
+
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
1288
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1289
|
+
}
|
|
1290
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
1291
|
+
}
|
|
1292
|
+
if (0 !== ch) {
|
|
1293
|
+
readLineBreak(state);
|
|
1294
|
+
}
|
|
1295
|
+
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
1296
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
1300
|
+
state.position++;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
skipSeparationSpace(state, true, -1);
|
|
1304
|
+
if (0 === state.lineIndent &&
|
|
1305
|
+
0x2D === state.input.charCodeAt(state.position) &&
|
|
1306
|
+
0x2D === state.input.charCodeAt(state.position + 1) &&
|
|
1307
|
+
0x2D === state.input.charCodeAt(state.position + 2)) {
|
|
1308
|
+
state.position += 3;
|
|
1309
|
+
skipSeparationSpace(state, true, -1);
|
|
1310
|
+
}
|
|
1311
|
+
else if (hasDirectives) {
|
|
1312
|
+
throwError(state, 'directives end mark is expected');
|
|
1313
|
+
}
|
|
1314
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
1315
|
+
skipSeparationSpace(state, true, -1);
|
|
1316
|
+
if (state.checkLineBreaks &&
|
|
1317
|
+
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1318
|
+
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
|
1319
|
+
}
|
|
1320
|
+
state.result.comments = state.comments;
|
|
1321
|
+
state.documents.push(state.result);
|
|
1322
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1323
|
+
if (0x2E === state.input.charCodeAt(state.position)) {
|
|
1324
|
+
state.position += 3;
|
|
1325
|
+
skipSeparationSpace(state, true, -1);
|
|
1326
|
+
}
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
if (state.position < (state.length - 1)) {
|
|
1330
|
+
throwError(state, 'end of the stream or a document separator is expected');
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function loadDocuments(input, options) {
|
|
1337
|
+
input = String(input);
|
|
1338
|
+
options = options || {};
|
|
1339
|
+
let inputLength = input.length;
|
|
1340
|
+
if (inputLength !== 0) {
|
|
1341
|
+
if (0x0A !== input.charCodeAt(inputLength - 1) &&
|
|
1342
|
+
0x0D !== input.charCodeAt(inputLength - 1)) {
|
|
1343
|
+
input += '\n';
|
|
1344
|
+
}
|
|
1345
|
+
if (input.charCodeAt(0) === 0xFEFF) {
|
|
1346
|
+
input = input.slice(1);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
var state = new State(input, options);
|
|
1350
|
+
state.input += '\0';
|
|
1351
|
+
while (0x20 === state.input.charCodeAt(state.position)) {
|
|
1352
|
+
state.lineIndent += 1;
|
|
1353
|
+
state.position += 1;
|
|
1354
|
+
}
|
|
1355
|
+
while (state.position < (state.length - 1)) {
|
|
1356
|
+
var q = state.position;
|
|
1357
|
+
readDocument(state);
|
|
1358
|
+
if (state.position <= q) {
|
|
1359
|
+
for (; state.position < state.length - 1; state.position++) {
|
|
1360
|
+
var c = state.input.charAt(state.position);
|
|
1361
|
+
if (c == '\n') {
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
let documents = state.documents;
|
|
1368
|
+
let docsCount = documents.length;
|
|
1369
|
+
if (docsCount > 0) {
|
|
1370
|
+
documents[docsCount - 1].endPosition = inputLength;
|
|
1371
|
+
}
|
|
1372
|
+
for (let x of documents) {
|
|
1373
|
+
x.errors = state.errors;
|
|
1374
|
+
if (x.startPosition > x.endPosition) {
|
|
1375
|
+
x.startPosition = x.endPosition;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return documents;
|
|
1379
|
+
}
|
|
1380
|
+
function loadAll(input, iterator, options = {}) {
|
|
1381
|
+
var documents = loadDocuments(input, options), index, length;
|
|
1382
|
+
for (index = 0, length = documents.length; index < length; index += 1) {
|
|
1383
|
+
iterator(documents[index]);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
exports.loadAll = loadAll;
|
|
1387
|
+
function load(input, options = {}) {
|
|
1388
|
+
var documents = loadDocuments(input, options), index, length;
|
|
1389
|
+
if (0 === documents.length) {
|
|
1390
|
+
return undefined;
|
|
1391
|
+
}
|
|
1392
|
+
else if (1 === documents.length) {
|
|
1393
|
+
return documents[0];
|
|
1394
|
+
}
|
|
1395
|
+
var e = new YAMLException('expected a single document in the stream, but found more');
|
|
1396
|
+
e.mark = new Mark("", "", 0, 0, 0);
|
|
1397
|
+
e.mark.position = documents[0].endPosition;
|
|
1398
|
+
documents[0].errors.push(e);
|
|
1399
|
+
return documents[0];
|
|
1400
|
+
}
|
|
1401
|
+
exports.load = load;
|
|
1402
|
+
function safeLoadAll(input, output, options = {}) {
|
|
1403
|
+
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
|
1404
|
+
}
|
|
1405
|
+
exports.safeLoadAll = safeLoadAll;
|
|
1406
|
+
function safeLoad(input, options = {}) {
|
|
1407
|
+
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
|
1408
|
+
}
|
|
1409
|
+
exports.safeLoad = safeLoad;
|
|
1410
|
+
module.exports.loadAll = loadAll;
|
|
1411
|
+
module.exports.load = load;
|
|
1412
|
+
module.exports.safeLoadAll = safeLoadAll;
|
|
1413
|
+
module.exports.safeLoad = safeLoad;
|
|
1414
|
+
//# sourceMappingURL=loader.js.map
|