Add Navigable interface
This commit is contained in:
parent
3eac6863d6
commit
1367acb05f
@ -3,6 +3,7 @@ import { Variables } from "../runtime/Variables";
|
||||
import { FadeInfo } from "../view/model/FadeInfo";
|
||||
import { Menu } from "../view/model/Menu";
|
||||
import { ViewModel } from "../view/model/ViewModel";
|
||||
import { Navigable } from "../view/model/Navigable";
|
||||
import { Token } from "./Token";
|
||||
import { TokenType } from "./TokenType";
|
||||
import {
|
||||
@ -13,7 +14,7 @@ import {
|
||||
Operator
|
||||
} from "./ast";
|
||||
|
||||
export class Parser {
|
||||
export class Parser implements Navigable {
|
||||
private readonly EOF = new Token("", TokenType.EOF);
|
||||
|
||||
private tokensCount: number
|
||||
@ -43,17 +44,21 @@ export class Parser {
|
||||
this.vm = view
|
||||
}
|
||||
|
||||
public setPosition(position): void {
|
||||
public setPosition(position: number): void {
|
||||
this.position = position;
|
||||
this.next();
|
||||
}
|
||||
|
||||
public jumpLabel(label): void {
|
||||
public jumpLabel(label: string): void {
|
||||
if (label in this.labels) {
|
||||
this.position = this.labels[label];
|
||||
}
|
||||
}
|
||||
|
||||
public getLastPosition(): number {
|
||||
return this.lastPosition;
|
||||
}
|
||||
|
||||
public next(): void {
|
||||
this.lastPosition = this.position;
|
||||
|
||||
|
10
src/view/model/Navigable.ts
Normal file
10
src/view/model/Navigable.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export interface Navigable {
|
||||
|
||||
setPosition(position: number): void
|
||||
getLastPosition(): number
|
||||
|
||||
next(): void
|
||||
jumpLabel(label: string): void
|
||||
prevScene(): void
|
||||
nextScene(): void
|
||||
}
|
Loading…
Reference in New Issue
Block a user