diff --git a/lib/js-yaml/parser.js b/lib/js-yaml/parser.js index 3649be98..44e087bf 100644 --- a/lib/js-yaml/parser.js +++ b/lib/js-yaml/parser.js @@ -87,7 +87,7 @@ function Parser(self) { this.tagHandles = {}; this.states = []; this.marks = []; - this.state = this.parseStreamStart.bind(this); + this.state = $$.bind(this.parseStreamStart, this); } @@ -152,7 +152,7 @@ Parser.prototype.parseStreamStart = function parseStreamStart() { token.encoding); // Prepare the next state. - this.state = this.parseImplicitDocumentStart.bind(this); + this.state = $$.bind(this.parseImplicitDocumentStart, this); return event; }; @@ -169,8 +169,8 @@ Parser.prototype.parseImplicitDocumentStart = function parseImplicitDocumentStar event = new _events.DocumentStartEvent(token.startMark, token.startMark, false); // Prepare the next state. - this.states.push(this.parseDocumentEnd.bind(this)); - this.state = this.parseBlockNode.bind(this); + this.states.push($$.bind(this.parseDocumentEnd, this)); + this.state = $$.bind(this.parseBlockNode, this); return event; }; @@ -217,8 +217,8 @@ Parser.prototype.parseDocumentStart = function parseDocumentStart() { token = this.getToken(); event = new _events.DocumentStartEvent(startMark, token.endMark, true, version, tags); - this.states.push(this.parseDocumentEnd.bind(this)); - this.state = this.parseDocumentContent.bind(this); + this.states.push($$.bind(this.parseDocumentEnd, this)); + this.state = $$.bind(this.parseDocumentContent, this); return event; }; @@ -240,7 +240,7 @@ Parser.prototype.parseDocumentEnd = function parseDocumentEnd() { event = new _events.DocumentEndEvent(startMark, endMark, explicit); // Prepare the next state. - this.state = this.parseDocumentStart.bind(this); + this.state = $$.bind(this.parseDocumentStart, this); return event; }; @@ -260,7 +260,7 @@ Parser.prototype.parseDocumentContent = function parseDocumentContent() { }; Parser.prototype.processDirectives = function processDirectives() { - var token, handle, prefix, value; + var self = this, token, handle, prefix, value; this.yamlVersion = null; this.tagHandles = {}; @@ -299,15 +299,15 @@ Parser.prototype.processDirectives = function processDirectives() { } else { value = [this.yamlVersion, {}]; Object.getOwnPropertyNames(this.tagHandles).forEach(function (key) { - value[1][key] = this.tagHandles[key]; - }.bind(this)); + value[1][key] = self.tagHandles[key]; + }); } Object.getOwnPropertyNames(DEFAULT_TAGS).forEach(function (key) { - if (undefined === this.tagHandles[key]) { - this.tagHandles[key] = DEFAULT_TAGS[key]; + if (undefined === self.tagHandles[key]) { + self.tagHandles[key] = DEFAULT_TAGS[key]; } - }.bind(this)); + }); return value; }; @@ -393,7 +393,7 @@ Parser.prototype.parseNode = function parseNode(block, indentlessSequence) { endMark = this.peekToken().endMark; event = new _events.SequenceStartEvent(anchor, tag, implicit, startMark, endMark); - this.state = this.parseIndentlessSequenceEntry.bind(this); + this.state = $$.bind(this.parseIndentlessSequenceEntry, this); } else { if (this.checkToken(_tokens.ScalarToken)) { token = this.getToken(); @@ -414,22 +414,22 @@ Parser.prototype.parseNode = function parseNode(block, indentlessSequence) { endMark = this.peekToken().endMark; event = new _events.SequenceStartEvent(anchor, tag, implicit, startMark, endMark, true); - this.state = this.parseFlowSequenceFirstEntry.bind(this); + this.state = $$.bind(this.parseFlowSequenceFirstEntry, this); } else if (this.checkToken(_tokens.FlowMappingStartToken)) { endMark = this.peekToken().endMark; event = new _events.MappingStartEvent(anchor, tag, implicit, startMark, endMark, true); - this.state = this.parseFlowMappingFirstKey.bind(this); + this.state = $$.bind(this.parseFlowMappingFirstKey, this); } else if (block && this.checkToken(_tokens.BlockSequenceStartToken)) { endMark = this.peekToken().startMark; event = new _events.SequenceStartEvent(anchor, tag, implicit, startMark, endMark, false); - this.state = this.parseBlockSequenceFirstEntry.bind(this); + this.state = $$.bind(this.parseBlockSequenceFirstEntry, this); } else if (block && this.checkToken(_tokens.BlockMappingStartToken)) { endMark = this.peekToken().startMark; event = new _events.MappingStartEvent(anchor, tag, implicit, startMark, endMark, false); - this.state = this.parseBlockMappingFirstKey.bind(this); + this.state = $$.bind(this.parseBlockMappingFirstKey, this); } else if (null !== anchor || null !== tag) { // Empty scalars are allowed even if a tag or an anchor is // specified. @@ -462,11 +462,11 @@ Parser.prototype.parseBlockSequenceEntry = function parseBlockSequenceEntry() { token = this.getToken(); if (!this.checkToken(_tokens.BlockEntryToken, _tokens.BlockEndToken)) { - this.states.push(this.parseBlockSequenceEntry.bind(this)); + this.states.push($$.bind(this.parseBlockSequenceEntry, this)); return this.parseBlockNode(); } - this.state = this.parseBlockSequenceEntry.bind(this); + this.state = $$.bind(this.parseBlockSequenceEntry, this); return this.processEmptyScalar(token.endMark); } @@ -494,11 +494,11 @@ Parser.prototype.parseIndentlessSequenceEntry = function parseIndentlessSequence if (!this.checkToken(_tokens.BlockEntryToken, _tokens.KeyToken, _tokens.ValueToken, _tokens.BlockEndToken)) { - this.states.push(this.parseIndentlessSequenceEntry.bind(this)); + this.states.push($$.bind(this.parseIndentlessSequenceEntry, this)); return this.parseBlockNode(); } - this.state = this.parseIndentlessSequenceEntry.bind(this); + this.state = $$.bind(this.parseIndentlessSequenceEntry, this); return this.processEmptyScalar(token.endMark); } @@ -526,11 +526,11 @@ Parser.prototype.parseBlockMappingKey = function parseBlockMappingKey() { token = this.getToken(); if (!this.checkToken(_tokens.KeyToken, _tokens.ValueToken, _tokens.BlockEndToken)) { - this.states.push(this.parseBlockMappingValue.bind(this)); + this.states.push($$.bind(this.parseBlockMappingValue, this)); return this.parseBlockNodeOrIndentlessSequence(); } - this.state = this.parseBlockMappingValue.bind(this); + this.state = $$.bind(this.parseBlockMappingValue, this); return this.processEmptyScalar(token.endMark); } @@ -557,15 +557,15 @@ Parser.prototype.parseBlockMappingValue = function parseBlockMappingValue() { token = this.getToken(); if (!this.checkToken(_tokens.KeyToken, _tokens.ValueToken, _tokens.BlockEndToken)) { - this.states.push(this.parseBlockMappingKey.bind(this)); + this.states.push($$.bind(this.parseBlockMappingKey, this)); return this.parseBlockNodeOrIndentlessSequence(); } - this.state = this.parseBlockMappingKey.bind(this); + this.state = $$.bind(this.parseBlockMappingKey, this); return this.processEmptyScalar(token.endMark); } - this.state = this.parseBlockMappingKey.bind(this); + this.state = $$.bind(this.parseBlockMappingKey, this); token = this.peekToken(); return this.processEmptyScalar(token.startMark); @@ -608,10 +608,10 @@ Parser.prototype.parseFlowSequenceEntry = function parseFlowSequenceEntry(first) token = this.peekToken(); event = new _events.MappingStartEvent(null, null, true, token.startMark, token.endMark, true); - this.state = this.parseFlowSequenceEntryMappingKey.bind(this); + this.state = $$.bind(this.parseFlowSequenceEntryMappingKey, this); return event; } else if (!this.checkToken(_tokens.FlowSequenceEndToken)) { - this.states.push(this.parseFlowSequenceEntry.bind(this)); + this.states.push($$.bind(this.parseFlowSequenceEntry, this)); return this.parseFlowNode(); } } @@ -629,11 +629,11 @@ Parser.prototype.parseFlowSequenceEntryMappingKey = function parseFlowSequenceEn var token = this.getToken(); if (!this.checkToken(_tokens.ValueToken, _tokens.FlowEntryToken, _tokens.FlowSequenceEndToken)) { - this.states.push(this.parseFlowSequenceEntryMappingValue.bind(this)); + this.states.push($$.bind(this.parseFlowSequenceEntryMappingValue, this)); return this.parseFlowNode(); } - this.state = this.parseFlowSequenceEntryMappingValue.bind(this); + this.state = $$.bind(this.parseFlowSequenceEntryMappingValue, this); return this.processEmptyScalar(token.endMark); }; @@ -644,15 +644,15 @@ Parser.prototype.parseFlowSequenceEntryMappingValue = function parseFlowSequence token = this.getToken(); if (!this.checkToken(_tokens.FlowEntryToken, _tokens.FlowSequenceEndToken)) { - this.states.push(this.parseFlowSequenceEntryMappingEnd.bind(this)); + this.states.push($$.bind(this.parseFlowSequenceEntryMappingEnd, this)); return this.parseFlowNode(); } - this.state = this.parseFlowSequenceEntryMappingEnd.bind(this); + this.state = $$.bind(this.parseFlowSequenceEntryMappingEnd, this); return this.processEmptyScalar(token.endMark); } - this.state = this.parseFlowSequenceEntryMappingEnd.bind(this); + this.state = $$.bind(this.parseFlowSequenceEntryMappingEnd, this); token = this.peekToken(); return this.processEmptyScalar(token.startMark); }; @@ -660,7 +660,7 @@ Parser.prototype.parseFlowSequenceEntryMappingValue = function parseFlowSequence Parser.prototype.parseFlowSequenceEntryMappingEnd = function parseFlowSequenceEntryMappingEnd() { var token; - this.state = this.parseFlowSequenceEntry.bind(this); + this.state = $$.bind(this.parseFlowSequenceEntry, this); token = this.peekToken(); return new _events.MappingEndEvent(token.startMark, token.startMark); @@ -698,14 +698,14 @@ Parser.prototype.parseFlowMappingKey = function parseFlowMappingKey(first) { token = this.getToken(); if (!this.checkToken(_tokens.ValueToken, _tokens.FlowEntryToken, _tokens.FlowMappingEndToken)) { - this.states.push(this.parseFlowMappingValue.bind(this)); + this.states.push($$.bind(this.parseFlowMappingValue, this)); return this.parseFlowNode(); } - this.state = this.parseFlowMappingValue.bind(this); + this.state = $$.bind(this.parseFlowMappingValue, this); return this.processEmptyScalar(token.endMark); } else if (!this.checkToken(_tokens.FlowMappingEndToken)) { - this.states.push(this.parseFlowMappingEmptyValue.bind(this)); + this.states.push($$.bind(this.parseFlowMappingEmptyValue, this)); return this.parseFlowNode(); } } @@ -726,21 +726,21 @@ Parser.prototype.parseFlowMappingValue = function parseFlowMappingValue() { token = this.getToken(); if (!this.checkToken(_tokens.FlowEntryToken, _tokens.FlowMappingEndToken)) { - this.states.push(this.parseFlowMappingKey.bind(this)); + this.states.push($$.bind(this.parseFlowMappingKey, this)); return this.parseFlowNode(); } - this.state = this.parseFlowMappingKey.bind(this); + this.state = $$.bind(this.parseFlowMappingKey, this); return this.processEmptyScalar(token.endMark); } - this.state = this.parseFlowMappingKey.bind(this); + this.state = $$.bind(this.parseFlowMappingKey, this); token = this.peekToken(); return this.processEmptyScalar(token.startMark); }; Parser.prototype.parseFlowMappingEmptyValue = function parseFlowMappingEmptyValue() { - this.state = this.parseFlowMappingKey.bind(this); + this.state = $$.bind(this.parseFlowMappingKey, this); return this.processEmptyScalar(this.peekToken().startMark); };