scratch – Diff between revs 75 and 125
?pathlinks?
Rev 75 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | // Generated by CoffeeScript 1.10.0 |
1 | // Generated by CoffeeScript 1.12.4 |
|
2 | var Inline, ParseException, Parser, Pattern, Utils; |
2 | var Inline, ParseException, ParseMore, Parser, Pattern, Utils; |
|
Line 3... | Line 3... | |||
3 | |
3 | |
|
Line 4... | Line 4... | |||
4 | Inline = require('./Inline'); |
4 | Inline = require('./Inline'); |
|
Line 5... | Line 5... | |||
5 | |
5 | |
|
Line 6... | Line 6... | |||
6 | Pattern = require('./Pattern'); |
6 | Pattern = require('./Pattern'); |
|
Line -... | Line 7... | |||
- | 7 | |
||
- | 8 | Utils = require('./Utils'); |
||
7 | |
9 | |
|
8 | Utils = require('./Utils'); |
10 | ParseException = require('./Exception/ParseException'); |
|
Line 9... | Line 11... | |||
9 | |
11 | |
|
Line 26... | Line 28... | |||
26 | |
28 | |
|
Line 27... | Line 29... | |||
27 | Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +'); |
29 | Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +'); |
|
Line 28... | Line 30... | |||
28 | |
30 | |
|
Line 29... | Line 31... | |||
29 | Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$'); |
31 | Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$'); |
|
Line 30... | Line 32... | |||
30 | |
32 | |
|
Line 31... | Line 33... | |||
31 | Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n'); |
33 | Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n', 'm'); |
|
Line 32... | Line 34... | |||
32 | |
34 | |
|
Line 33... | Line 35... | |||
33 | Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+'); |
35 | Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+', 'm'); |
|
Line 51... | Line 53... | |||
51 | this.currentLine = ''; |
53 | this.currentLine = ''; |
|
52 | this.refs = {}; |
54 | this.refs = {}; |
|
53 | } |
55 | } |
|
Line 54... | Line 56... | |||
54 | |
56 | |
|
55 | Parser.prototype.parse = function(value, exceptionOnInvalidType, objectDecoder) { |
57 | Parser.prototype.parse = function(value, exceptionOnInvalidType, objectDecoder) { |
|
56 | var alias, allowOverwrite, block, c, context, data, e, error, error1, error2, first, i, indent, isRef, j, k, key, l, lastKey, len, len1, len2, len3, lineCount, m, matches, mergeNode, n, name, parsed, parsedItem, parser, ref, ref1, ref2, refName, refValue, val, values; |
58 | var alias, allowOverwrite, block, c, context, data, e, first, i, indent, isRef, j, k, key, l, lastKey, len, len1, len2, len3, lineCount, m, matches, mergeNode, n, name, parsed, parsedItem, parser, ref, ref1, ref2, refName, refValue, val, values; |
|
57 | if (exceptionOnInvalidType == null) { |
59 | if (exceptionOnInvalidType == null) { |
|
58 | exceptionOnInvalidType = false; |
60 | exceptionOnInvalidType = false; |
|
59 | } |
61 | } |
|
60 | if (objectDecoder == null) { |
62 | if (objectDecoder == null) { |
|
Line 228... | Line 230... | |||
228 | } else { |
230 | } else { |
|
229 | lineCount = this.lines.length; |
231 | lineCount = this.lines.length; |
|
230 | if (1 === lineCount || (2 === lineCount && Utils.isEmpty(this.lines[1]))) { |
232 | if (1 === lineCount || (2 === lineCount && Utils.isEmpty(this.lines[1]))) { |
|
231 | try { |
233 | try { |
|
232 | value = Inline.parse(this.lines[0], exceptionOnInvalidType, objectDecoder); |
234 | value = Inline.parse(this.lines[0], exceptionOnInvalidType, objectDecoder); |
|
233 | } catch (error1) { |
235 | } catch (error) { |
|
234 | e = error1; |
236 | e = error; |
|
235 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
237 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
|
236 | e.snippet = this.currentLine; |
238 | e.snippet = this.currentLine; |
|
237 | throw e; |
239 | throw e; |
|
238 | } |
240 | } |
|
239 | if (typeof value === 'object') { |
241 | if (typeof value === 'object') { |
|
Line 256... | Line 258... | |||
256 | } |
258 | } |
|
257 | return value; |
259 | return value; |
|
258 | } else if ((ref2 = Utils.ltrim(value).charAt(0)) === '[' || ref2 === '{') { |
260 | } else if ((ref2 = Utils.ltrim(value).charAt(0)) === '[' || ref2 === '{') { |
|
259 | try { |
261 | try { |
|
260 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
262 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
|
261 | } catch (error2) { |
263 | } catch (error) { |
|
262 | e = error2; |
264 | e = error; |
|
263 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
265 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
|
264 | e.snippet = this.currentLine; |
266 | e.snippet = this.currentLine; |
|
265 | throw e; |
267 | throw e; |
|
266 | } |
268 | } |
|
267 | } |
269 | } |
|
Line 321... | Line 323... | |||
321 | while (this.moveToNextLine()) { |
323 | while (this.moveToNextLine()) { |
|
322 | indent = this.getCurrentLineIndentation(); |
324 | indent = this.getCurrentLineIndentation(); |
|
323 | if (indent === newIndent) { |
325 | if (indent === newIndent) { |
|
324 | removeComments = !removeCommentsPattern.test(this.currentLine); |
326 | removeComments = !removeCommentsPattern.test(this.currentLine); |
|
325 | } |
327 | } |
|
326 | if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) { |
- | ||
327 | this.moveToPreviousLine(); |
328 | if (removeComments && this.isCurrentLineComment()) { |
|
328 | break; |
329 | continue; |
|
329 | } |
330 | } |
|
330 | if (this.isCurrentLineBlank()) { |
331 | if (this.isCurrentLineBlank()) { |
|
331 | data.push(this.currentLine.slice(newIndent)); |
332 | data.push(this.currentLine.slice(newIndent)); |
|
332 | continue; |
333 | continue; |
|
333 | } |
334 | } |
|
334 | if (removeComments && this.isCurrentLineComment()) { |
335 | if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) { |
|
335 | if (indent === newIndent) { |
336 | this.moveToPreviousLine(); |
|
336 | continue; |
- | ||
337 | } |
337 | break; |
|
338 | } |
338 | } |
|
339 | if (indent >= newIndent) { |
339 | if (indent >= newIndent) { |
|
340 | data.push(this.currentLine.slice(newIndent)); |
340 | data.push(this.currentLine.slice(newIndent)); |
|
341 | } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') { |
341 | } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') { |
|
Line 361... | Line 361... | |||
361 | Parser.prototype.moveToPreviousLine = function() { |
361 | Parser.prototype.moveToPreviousLine = function() { |
|
362 | this.currentLine = this.lines[--this.currentLineNb]; |
362 | this.currentLine = this.lines[--this.currentLineNb]; |
|
363 | }; |
363 | }; |
|
Line 364... | Line 364... | |||
364 | |
364 | |
|
365 | Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) { |
365 | Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) { |
|
366 | var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val; |
366 | var e, foldedIndent, matches, modifiers, pos, ref, ref1, val; |
|
367 | if (0 === value.indexOf('*')) { |
367 | if (0 === value.indexOf('*')) { |
|
368 | pos = value.indexOf('#'); |
368 | pos = value.indexOf('#'); |
|
369 | if (pos !== -1) { |
369 | if (pos !== -1) { |
|
370 | value = value.substr(1, pos - 2); |
370 | value = value.substr(1, pos - 2); |
|
Line 388... | Line 388... | |||
388 | return Inline.parseScalar(matches.type + ' ' + val); |
388 | return Inline.parseScalar(matches.type + ' ' + val); |
|
389 | } else { |
389 | } else { |
|
390 | return val; |
390 | return val; |
|
391 | } |
391 | } |
|
392 | } |
392 | } |
|
393 | try { |
- | ||
394 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
393 | if ((ref1 = value.charAt(0)) === '[' || ref1 === '{' || ref1 === '"' || ref1 === "'") { |
|
395 | } catch (error) { |
394 | while (true) { |
|
396 | e = error; |
- | ||
397 | if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) { |
- | ||
398 | value += "\n" + this.getNextEmbedBlock(); |
- | ||
399 | try { |
395 | try { |
|
400 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
396 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
|
401 | } catch (error1) { |
397 | } catch (error) { |
|
402 | e = error1; |
398 | e = error; |
|
- | 399 | if (e instanceof ParseMore && this.moveToNextLine()) { |
||
- | 400 | value += "\n" + Utils.trim(this.currentLine, ' '); |
||
- | 401 | } else { |
||
403 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
402 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
|
404 | e.snippet = this.currentLine; |
403 | e.snippet = this.currentLine; |
|
405 | throw e; |
404 | throw e; |
|
- | 405 | } |
||
406 | } |
406 | } |
|
407 | } else { |
- | ||
408 | e.parsedLine = this.getRealCurrentLineNb() + 1; |
- | ||
409 | e.snippet = this.currentLine; |
- | ||
410 | throw e; |
- | ||
411 | } |
407 | } |
|
- | 408 | } else { |
||
- | 409 | if (this.isNextLineIndented()) { |
||
- | 410 | value += "\n" + this.getNextEmbedBlock(); |
||
- | 411 | } |
||
- | 412 | return Inline.parse(value, exceptionOnInvalidType, objectDecoder); |
||
412 | } |
413 | } |
|
413 | }; |
414 | }; |
|
Line 414... | Line 415... | |||
414 | |
415 | |
|
415 | Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) { |
416 | Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) { |