"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lexer = void 0;
class Lexer {
    constructor(input) {
        this.pos = 0;
        this.input = input;
    }
    getPosition() {
        return this.pos;
    }
    setPosition(pos) {
        this.pos = pos;
    }
    fwd(len) {
        this.pos += len;
    }
    peek(n = 0) {
        let p = this.pos + n;
        return p < this.input.length ? this.input.charAt(p) : "$";
    }
    substring(from, to) {
        if (to !== undefined && to > this.input.length) {
            to = this.input.length;
        }
        return this.input.substring(from, to);
    }
    isDone() {
        return this.pos > this.input.length;
    }
    isAtEnd(fwd = 0) {
        return this.pos + fwd === this.input.length;
    }
    toString() {
        return this.input.substring(0, this.pos) + " -- " + this.input.substring(this.pos);
    }
}
exports.Lexer = Lexer;
//# sourceMappingURL=Lexer.js.map