lex() {
    var e = this.input, t = this.tokenRegex.lastIndex;
    if (t === e.length)
      return new S0("EOF", new u0(this, t, t));
    var r = this.tokenRegex.exec(e);
    if (r === null || r.index !== t)
      throw new G("Unexpected character: '" + e[t] + "'", new S0(e[t], new u0(this, t, t + 1)));
    var a = r[6] || r[3] || (r[2] ? "\\ " : " ");
    if (this.catcodes[a] === 14) {
      var i = e.indexOf(`
`, this.tokenRegex.lastIndex);
      return i === -1 ? (this.tokenRegex.lastIndex = e.length, this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")) : this.tokenRegex.lastIndex = i + 1, this.lex();
    }
    return new S0(a, new u0(this, t, this.tokenRegex.lastIndex));
  }
End current nested group, restoring values before the group began.