34: * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When
55:export default class Parser {
64:        this.mode = "math";
67:        this.gullet = new MacroExpander(input, settings, this.mode);
69:        this.settings = settings;
72:        this.nextToken = null;
80:        if (this.fetch().text !== text) {
82:                `Expected '${text}', got '${this.fetch().text}'`, this.fetch()
94:        this.nextToken = null;
102:    fetch(): Token {
103:        if (this.nextToken == null) {
104:            this.nextToken = this.gullet.expandNextToken();
106:        return this.nextToken;
113:        this.mode = newMode;
114:        this.gullet.switchMode(newMode);
121:        if (!this.settings.globalGroup) {
124:            this.gullet.beginGroup();
130:        if (this.settings.colorIsTextColor) {
131:            this.gullet.macros.set("\\color", "\\textcolor");
142:            if (!this.settings.globalGroup) {
143:                this.gullet.endGroup();
150:            this.gullet.endGroups();
160:        const oldToken = this.nextToken;
164:        this.gullet.pushToken(new Token("}"));
165:        this.gullet.pushTokens(tokens);
170:        this.nextToken = oldToken;
198:            if (this.mode === "math") {
199:                this.consumeSpaces();
201:            const lex = this.fetch();
220:        if (this.mode === "text") {
260:                numerNode = {type: "ordgroup", mode: this.mode, body: numerBody};
266:                denomNode = {type: "ordgroup", mode: this.mode, body: denomBody};
288:        const symbolToken = this.fetch();
291:        this.consumeSpaces(); // ignore spaces before sup/subscript argument
322:            mode: this.mode,
327:            mode: this.mode,
328:            color: this.settings.errorColor,
350:        if (this.mode === "text") {
360:            this.consumeSpaces();
363:            const lex = this.fetch();
