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 DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils, |
2 | var DumpException, Escaper, Inline, ParseException, ParseMore, Pattern, Unescaper, Utils, |
|
3 | indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
3 | indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
|
Line 4... | Line 4... | |||
4 | |
4 | |
|
Line 5... | Line 5... | |||
5 | Pattern = require('./Pattern'); |
5 | Pattern = require('./Pattern'); |
|
Line 10... | Line 10... | |||
10 | |
10 | |
|
Line 11... | Line 11... | |||
11 | Utils = require('./Utils'); |
11 | Utils = require('./Utils'); |
|
Line -... | Line 12... | |||
- | 12 | |
||
- | 13 | ParseException = require('./Exception/ParseException'); |
||
12 | |
14 | |
|
Line 13... | Line 15... | |||
13 | ParseException = require('./Exception/ParseException'); |
15 | ParseMore = require('./Exception/ParseMore'); |
|
14 | |
16 | |
|
Line 111... | Line 113... | |||
111 | } |
113 | } |
|
112 | if (Utils.isNumeric(value)) { |
114 | if (Utils.isNumeric(value)) { |
|
113 | return (type === 'string' ? "'" + value + "'" : String(parseFloat(value))); |
115 | return (type === 'string' ? "'" + value + "'" : String(parseFloat(value))); |
|
114 | } |
116 | } |
|
115 | if (type === 'number') { |
117 | if (type === 'number') { |
|
116 | return (value === Infinity ? '.Inf' : (value === -Infinity ? '-.Inf' : (isNaN(value) ? '.NaN' : value))); |
118 | return (value === 2e308 ? '.Inf' : (value === -2e308 ? '-.Inf' : (isNaN(value) ? '.NaN' : value))); |
|
117 | } |
119 | } |
|
118 | if (Escaper.requiresDoubleQuoting(value)) { |
120 | if (Escaper.requiresDoubleQuoting(value)) { |
|
119 | return Escaper.escapeWithDoubleQuotes(value); |
121 | return Escaper.escapeWithDoubleQuotes(value); |
|
120 | } |
122 | } |
|
121 | if (Escaper.requiresSingleQuoting(value)) { |
123 | if (Escaper.requiresSingleQuoting(value)) { |
|
Line 218... | Line 220... | |||
218 | |
220 | |
|
219 | Inline.parseQuotedScalar = function(scalar, context) { |
221 | Inline.parseQuotedScalar = function(scalar, context) { |
|
220 | var i, match, output; |
222 | var i, match, output; |
|
221 | i = context.i; |
223 | i = context.i; |
|
222 | if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) { |
224 | if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) { |
|
223 | throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').'); |
225 | throw new ParseMore('Malformed inline YAML string (' + scalar.slice(i) + ').'); |
|
224 | } |
226 | } |
|
225 | output = match[0].substr(1, match[0].length - 2); |
227 | output = match[0].substr(1, match[0].length - 2); |
|
226 | if ('"' === scalar.charAt(i)) { |
228 | if ('"' === scalar.charAt(i)) { |
|
227 | output = Unescaper.unescapeDoubleQuotedString(output); |
229 | output = Unescaper.unescapeDoubleQuotedString(output); |
|
Line 232... | Line 234... | |||
232 | context.i = i; |
234 | context.i = i; |
|
233 | return output; |
235 | return output; |
|
234 | }; |
236 | }; |
|
Line 235... | Line 237... | |||
235 | |
237 | |
|
236 | Inline.parseSequence = function(sequence, context) { |
238 | Inline.parseSequence = function(sequence, context) { |
|
237 | var e, error, i, isQuoted, len, output, ref, value; |
239 | var e, i, isQuoted, len, output, ref, value; |
|
238 | output = []; |
240 | output = []; |
|
239 | len = sequence.length; |
241 | len = sequence.length; |
|
240 | i = context.i; |
242 | i = context.i; |
|
241 | i += 1; |
243 | i += 1; |
|
Line 270... | Line 272... | |||
270 | output.push(value); |
272 | output.push(value); |
|
271 | --i; |
273 | --i; |
|
272 | } |
274 | } |
|
273 | ++i; |
275 | ++i; |
|
274 | } |
276 | } |
|
275 | throw new ParseException('Malformed inline YAML string ' + sequence); |
277 | throw new ParseMore('Malformed inline YAML string ' + sequence); |
|
276 | }; |
278 | }; |
|
Line 277... | Line 279... | |||
277 | |
279 | |
|
278 | Inline.parseMapping = function(mapping, context) { |
280 | Inline.parseMapping = function(mapping, context) { |
|
279 | var done, i, key, len, output, shouldContinueWhileLoop, value; |
281 | var done, i, key, len, output, shouldContinueWhileLoop, value; |
|
Line 338... | Line 340... | |||
338 | if (done) { |
340 | if (done) { |
|
339 | break; |
341 | break; |
|
340 | } |
342 | } |
|
341 | } |
343 | } |
|
342 | } |
344 | } |
|
343 | throw new ParseException('Malformed inline YAML string ' + mapping); |
345 | throw new ParseMore('Malformed inline YAML string ' + mapping); |
|
344 | }; |
346 | }; |
|
Line 345... | Line 347... | |||
345 | |
347 | |
|
346 | Inline.evaluateScalar = function(scalar, context) { |
348 | Inline.evaluateScalar = function(scalar, context) { |
|
347 | var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar; |
349 | var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar; |
|
Line 355... | Line 357... | |||
355 | case 'true': |
357 | case 'true': |
|
356 | return true; |
358 | return true; |
|
357 | case 'false': |
359 | case 'false': |
|
358 | return false; |
360 | return false; |
|
359 | case '.inf': |
361 | case '.inf': |
|
360 | return Infinity; |
362 | return 2e308; |
|
361 | case '.nan': |
363 | case '.nan': |
|
362 | return NaN; |
364 | return 0/0; |
|
363 | case '-.inf': |
365 | case '-.inf': |
|
364 | return Infinity; |
366 | return 2e308; |
|
365 | default: |
367 | default: |
|
366 | firstChar = scalarLower.charAt(0); |
368 | firstChar = scalarLower.charAt(0); |
|
367 | switch (firstChar) { |
369 | switch (firstChar) { |
|
368 | case '!': |
370 | case '!': |
|
369 | firstSpace = scalar.indexOf(' '); |
371 | firstSpace = scalar.indexOf(' '); |