diff options
Diffstat (limited to 'dist/yaml.js')
-rw-r--r-- | dist/yaml.js | 116 |
1 files changed, 74 insertions, 42 deletions
diff --git a/dist/yaml.js b/dist/yaml.js index 86ac1cf..0d4f0dd 100644 --- a/dist/yaml.js +++ b/dist/yaml.js @@ -53,7 +53,7 @@ Dumper = (function() { module.exports = Dumper; -},{"./Inline":5,"./Utils":9}],2:[function(require,module,exports){ +},{"./Inline":6,"./Utils":10}],2:[function(require,module,exports){ var Escaper, Pattern; Pattern = require('./Pattern'); @@ -111,7 +111,7 @@ Escaper = (function() { module.exports = Escaper; -},{"./Pattern":7}],3:[function(require,module,exports){ +},{"./Pattern":8}],3:[function(require,module,exports){ var DumpException, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; @@ -170,7 +170,36 @@ module.exports = ParseException; },{}],5:[function(require,module,exports){ -var DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils, +var ParseMore, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + +ParseMore = (function(superClass) { + extend(ParseMore, superClass); + + function ParseMore(message, parsedLine, snippet) { + this.message = message; + this.parsedLine = parsedLine; + this.snippet = snippet; + } + + ParseMore.prototype.toString = function() { + if ((this.parsedLine != null) && (this.snippet != null)) { + return '<ParseMore> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')'; + } else { + return '<ParseMore> ' + this.message; + } + }; + + return ParseMore; + +})(Error); + +module.exports = ParseMore; + + +},{}],6:[function(require,module,exports){ +var DumpException, Escaper, Inline, ParseException, ParseMore, Pattern, Unescaper, Utils, 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; }; Pattern = require('./Pattern'); @@ -183,6 +212,8 @@ Utils = require('./Utils'); ParseException = require('./Exception/ParseException'); +ParseMore = require('./Exception/ParseMore'); + DumpException = require('./Exception/DumpException'); Inline = (function() { @@ -391,7 +422,7 @@ Inline = (function() { var i, match, output; i = context.i; if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) { - throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').'); + throw new ParseMore('Malformed inline YAML string (' + scalar.slice(i) + ').'); } output = match[0].substr(1, match[0].length - 2); if ('"' === scalar.charAt(i)) { @@ -443,7 +474,7 @@ Inline = (function() { } ++i; } - throw new ParseException('Malformed inline YAML string ' + sequence); + throw new ParseMore('Malformed inline YAML string ' + sequence); }; Inline.parseMapping = function(mapping, context) { @@ -511,7 +542,7 @@ Inline = (function() { } } } - throw new ParseException('Malformed inline YAML string ' + mapping); + throw new ParseMore('Malformed inline YAML string ' + mapping); }; Inline.evaluateScalar = function(scalar, context) { @@ -654,8 +685,8 @@ Inline = (function() { module.exports = Inline; -},{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Pattern":7,"./Unescaper":8,"./Utils":9}],6:[function(require,module,exports){ -var Inline, ParseException, Parser, Pattern, Utils; +},{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Pattern":8,"./Unescaper":9,"./Utils":10}],7:[function(require,module,exports){ +var Inline, ParseException, ParseMore, Parser, Pattern, Utils; Inline = require('./Inline'); @@ -665,6 +696,8 @@ Utils = require('./Utils'); ParseException = require('./Exception/ParseException'); +ParseMore = require('./Exception/ParseMore'); + Parser = (function() { Parser.prototype.PATTERN_FOLDED_SCALAR_ALL = new Pattern('^(?:(?<type>![^\\|>]*)\\s+)?(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$'); @@ -684,13 +717,13 @@ Parser = (function() { Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$'); - Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n'); + Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n', 'm'); - Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+'); + Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+', 'm'); - Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n'); + Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n', 'm'); - Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$'); + Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$', 'm'); Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION = {}; @@ -979,18 +1012,16 @@ Parser = (function() { if (indent === newIndent) { removeComments = !removeCommentsPattern.test(this.currentLine); } - if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) { - this.moveToPreviousLine(); - break; + if (removeComments && this.isCurrentLineComment()) { + continue; } if (this.isCurrentLineBlank()) { data.push(this.currentLine.slice(newIndent)); continue; } - if (removeComments && this.isCurrentLineComment()) { - if (indent === newIndent) { - continue; - } + if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) { + this.moveToPreviousLine(); + break; } if (indent >= newIndent) { data.push(this.currentLine.slice(newIndent)); @@ -1019,7 +1050,7 @@ Parser = (function() { }; Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) { - var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val; + var e, error, foldedIndent, matches, modifiers, pos, ref, ref1, val; if (0 === value.indexOf('*')) { pos = value.indexOf('#'); if (pos !== -1) { @@ -1046,25 +1077,26 @@ Parser = (function() { return val; } } - try { - return Inline.parse(value, exceptionOnInvalidType, objectDecoder); - } catch (error) { - e = error; - if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) { - value += "\n" + this.getNextEmbedBlock(); + if ((ref1 = value.charAt(0)) === '[' || ref1 === '{' || ref1 === '"' || ref1 === "'") { + while (true) { try { return Inline.parse(value, exceptionOnInvalidType, objectDecoder); - } catch (error1) { - e = error1; - e.parsedLine = this.getRealCurrentLineNb() + 1; - e.snippet = this.currentLine; - throw e; + } catch (error) { + e = error; + if (e instanceof ParseMore && this.moveToNextLine()) { + value += "\n" + Utils.trim(this.currentLine, ' '); + } else { + e.parsedLine = this.getRealCurrentLineNb() + 1; + e.snippet = this.currentLine; + throw e; + } } - } else { - e.parsedLine = this.getRealCurrentLineNb() + 1; - e.snippet = this.currentLine; - throw e; } + } else { + if (this.isNextLineIndented()) { + value += "\n" + this.getNextEmbedBlock(); + } + return Inline.parse(value, exceptionOnInvalidType, objectDecoder); } }; @@ -1258,7 +1290,7 @@ Parser = (function() { module.exports = Parser; -},{"./Exception/ParseException":4,"./Inline":5,"./Pattern":7,"./Utils":9}],7:[function(require,module,exports){ +},{"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Inline":6,"./Pattern":8,"./Utils":10}],8:[function(require,module,exports){ var Pattern; Pattern = (function() { @@ -1366,7 +1398,7 @@ Pattern = (function() { count = 0; while (this.regex.test(str) && (limit === 0 || count < limit)) { this.regex.lastIndex = 0; - str = str.replace(this.regex, ''); + str = str.replace(this.regex, replacement); count++; } return [str, count]; @@ -1379,7 +1411,7 @@ Pattern = (function() { module.exports = Pattern; -},{}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ var Pattern, Unescaper, Utils; Utils = require('./Utils'); @@ -1464,7 +1496,7 @@ Unescaper = (function() { module.exports = Unescaper; -},{"./Pattern":7,"./Utils":9}],9:[function(require,module,exports){ +},{"./Pattern":8,"./Utils":10}],10:[function(require,module,exports){ var Pattern, Utils, hasProp = {}.hasOwnProperty; @@ -1680,7 +1712,7 @@ Utils = (function() { } date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); if (tz_offset) { - date.setTime(date.getTime() + tz_offset); + date.setTime(date.getTime() - tz_offset); } return date; }; @@ -1764,7 +1796,7 @@ Utils = (function() { module.exports = Utils; -},{"./Pattern":7}],10:[function(require,module,exports){ +},{"./Pattern":8}],11:[function(require,module,exports){ var Dumper, Parser, Utils, Yaml; Parser = require('./Parser'); @@ -1870,4 +1902,4 @@ if (typeof window === "undefined" || window === null) { module.exports = Yaml; -},{"./Dumper":1,"./Parser":6,"./Utils":9}]},{},[10]); +},{"./Dumper":1,"./Parser":7,"./Utils":10}]},{},[11]); |