Parse jump

This commit is contained in:
Victor 2015-12-07 17:16:40 +02:00
parent 4a7f2a8f88
commit debec57bbd

View File

@ -19,6 +19,12 @@ Parser.prototype.getInstance = function () {
return this;
};
Parser.prototype.jumpLabel = function (label) {
if (label in this.labels) {
this.position = this.labels[label];
}
};
Parser.prototype.next = function () {
this.lastPosition = this.position;
@ -63,7 +69,7 @@ Parser.prototype.statement = function() {
if (this.match(token, TokenType.SHOW)) return this.show();
if (this.match(token, TokenType.HIDE)) return this.hide();
// if (this.match(token, TokenType.JUMP)) return this.jump();
if (this.match(token, TokenType.JUMP)) return this.jump();
// if (this.match(token, TokenType.IF)) return this.ifStatement();
/*if (this.lookMatch(1, TokenType.COLON)) {
@ -317,6 +323,12 @@ Parser.prototype.playAmbience = function() {
return false;
};
Parser.prototype.jump = function() {
var labelName = this.consume(TokenType.WORD).getText();
this.jumpLabel(labelName);
return false;
};
Parser.prototype.expression = function() {
return this.orTest();
};