From debec57bbd1c7f11c1f6a94a918cccc5c450bfa3 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 7 Dec 2015 17:16:40 +0200 Subject: [PATCH] Parse jump --- public_html/js/Parser.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/public_html/js/Parser.js b/public_html/js/Parser.js index 3f25d87..3ddb286 100644 --- a/public_html/js/Parser.js +++ b/public_html/js/Parser.js @@ -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(); };