"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.types = exports.keywords = exports.TokenType = void 0; const beforeExpr = true; const startsExpr = true; const isLoop = true; const isAssign = true; const prefix = true; const postfix = true; class TokenType { constructor(label, conf = {}) { this.label = label; this.keyword = conf.keyword; this.beforeExpr = !!conf.beforeExpr; this.startsExpr = !!conf.startsExpr; this.rightAssociative = !!conf.rightAssociative; this.isLoop = !!conf.isLoop; this.isAssign = !!conf.isAssign; this.prefix = !!conf.prefix; this.postfix = !!conf.postfix; this.binop = conf.binop != null ? conf.binop : null; this.updateContext = null; } } exports.TokenType = TokenType; const keywords = new Map(); exports.keywords = keywords; function createKeyword(name, options = {}) { options.keyword = name; const token = new TokenType(name, options); keywords.set(name, token); return token; } function createBinop(name, binop) { return new TokenType(name, { beforeExpr, binop }); } const types = { num: new TokenType("num", { startsExpr }), bigint: new TokenType("bigint", { startsExpr }), regexp: new TokenType("regexp", { startsExpr }), string: new TokenType("string", { startsExpr }), name: new TokenType("name", { startsExpr }), eof: new TokenType("eof"), bracketL: new TokenType("[", { beforeExpr, startsExpr }), bracketR: new TokenType("]"), braceL: new TokenType("{", { beforeExpr, startsExpr }), braceBarL: new TokenType("{|", { beforeExpr, startsExpr }), braceR: new TokenType("}"), braceBarR: new TokenType("|}"), parenL: new TokenType("(", { beforeExpr, startsExpr }), parenR: new TokenType(")"), comma: new TokenType(",", { beforeExpr }), semi: new TokenType(";", { beforeExpr }), colon: new TokenType(":", { beforeExpr }), doubleColon: new TokenType("::", { beforeExpr }), dot: new TokenType("."), question: new TokenType("?", { beforeExpr }), questionDot: new TokenType("?."), arrow: new TokenType("=>", { beforeExpr }), template: new TokenType("template"), ellipsis: new TokenType("...", { beforeExpr }), backQuote: new TokenType("`", { startsExpr }), dollarBraceL: new TokenType("${", { beforeExpr, startsExpr }), at: new TokenType("@"), hash: new TokenType("#", { startsExpr }), interpreterDirective: new TokenType("#!..."), eq: new TokenType("=", { beforeExpr, isAssign }), assign: new TokenType("_=", { beforeExpr, isAssign }), incDec: new TokenType("++/--", { prefix, postfix, startsExpr }), bang: new TokenType("!", { beforeExpr, prefix, startsExpr }), tilde: new TokenType("~", { beforeExpr, prefix, startsExpr }), pipeline: createBinop("|>", 0), nullishCoalescing: createBinop("??", 1), logicalOR: createBinop("||", 2), logicalAND: createBinop("&&", 3), bitwiseOR: createBinop("|", 4), bitwiseXOR: createBinop("^", 5), bitwiseAND: createBinop("&", 6), equality: createBinop("==/!=/===/!==", 7), relational: createBinop("/<=/>=", 8), bitShift: createBinop("<>/>>>", 9), plusMin: new TokenType("+/-", { beforeExpr, binop: 10, prefix, startsExpr }), modulo: new TokenType("%", { beforeExpr, binop: 11, startsExpr }), star: createBinop("*", 11), slash: createBinop("/", 11), exponent: new TokenType("**", { beforeExpr, binop: 12, rightAssociative: true }), _break: createKeyword("break"), _case: createKeyword("case", { beforeExpr }), _catch: createKeyword("catch"), _continue: createKeyword("continue"), _debugger: createKeyword("debugger"), _default: createKeyword("default", { beforeExpr }), _do: createKeyword("do", { isLoop, beforeExpr }), _else: createKeyword("else", { beforeExpr }), _finally: createKeyword("finally"), _for: createKeyword("for", { isLoop }), _function: createKeyword("function", { startsExpr }), _if: createKeyword("if"), _return: createKeyword("return", { beforeExpr }), _switch: createKeyword("switch"), _throw: createKeyword("throw", { beforeExpr, prefix, startsExpr }), _try: createKeyword("try"), _var: createKeyword("var"), _const: createKeyword("const"), _while: createKeyword("while", { isLoop }), _with: createKeyword("with"), _new: createKeyword("new", { beforeExpr, startsExpr }), _this: createKeyword("this", { startsExpr }), _super: createKeyword("super", { startsExpr }), _class: createKeyword("class", { startsExpr }), _extends: createKeyword("extends", { beforeExpr }), _export: createKeyword("export"), _import: createKeyword("import", { startsExpr }), _null: createKeyword("null", { startsExpr }), _true: createKeyword("true", { startsExpr }), _false: createKeyword("false", { startsExpr }), _in: createKeyword("in", { beforeExpr, binop: 8 }), _instanceof: createKeyword("instanceof", { beforeExpr, binop: 8 }), _typeof: createKeyword("typeof", { beforeExpr, prefix, startsExpr }), _void: createKeyword("void", { beforeExpr, prefix, startsExpr }), _delete: createKeyword("delete", { beforeExpr, prefix, startsExpr }) }; exports.types = types;