Skip to content

Commit

Permalink
Replaces Function#bind with $$.bind in Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Dec 6, 2011
1 parent 367c5d0 commit cef45f0
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions lib/js-yaml/parser.js
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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);
};

Expand All @@ -644,23 +644,23 @@ 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);
};

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);
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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);
};

Expand Down

0 comments on commit cef45f0

Please sign in to comment.