Add prevScene, nextScene navigation
This commit is contained in:
parent
3237a17535
commit
2fa63256eb
@ -51,6 +51,26 @@ Parser.prototype.next = function () {
|
||||
} while (!terminal);
|
||||
};
|
||||
|
||||
Parser.prototype.prevScene = function() {
|
||||
// Для перехода к предыдущей сцене, следует два раза найти токен SCENE,
|
||||
// т.к. при первом поиске мы найдём лишь текущую.
|
||||
var currentScene = this.find(TokenType.SCENE, -1);
|
||||
var pos = this.findFrom(currentScene, TokenType.SCENE, -1);
|
||||
// Если не нашли - перематываем на начало.
|
||||
if (pos == this.position) this.position = 0;
|
||||
else this.position = pos;
|
||||
this.next();
|
||||
};
|
||||
|
||||
Parser.prototype.nextScene = function() {
|
||||
this.position = this.find(TokenType.SCENE, 1);
|
||||
this.next();
|
||||
};
|
||||
|
||||
Parser.prototype.find = function(which, step) {
|
||||
return this.findFrom(this.position, which, step);
|
||||
};
|
||||
|
||||
Parser.prototype.findFrom = function(from, which, step) {
|
||||
var pos = from;
|
||||
while (true) {
|
||||
|
Loading…
Reference in New Issue
Block a user