1 |
|
2 |
|
3 |
|
4 |
|
5 | export var TokenType; (function (TokenType) {
|
6 |
|
7 | const PRECEDENCE_MASK = 0xf; TokenType[TokenType["PRECEDENCE_MASK"] = PRECEDENCE_MASK] = "PRECEDENCE_MASK";
|
8 | const IS_KEYWORD = 1 << 4; TokenType[TokenType["IS_KEYWORD"] = IS_KEYWORD] = "IS_KEYWORD";
|
9 | const IS_ASSIGN = 1 << 5; TokenType[TokenType["IS_ASSIGN"] = IS_ASSIGN] = "IS_ASSIGN";
|
10 | const IS_RIGHT_ASSOCIATIVE = 1 << 6; TokenType[TokenType["IS_RIGHT_ASSOCIATIVE"] = IS_RIGHT_ASSOCIATIVE] = "IS_RIGHT_ASSOCIATIVE";
|
11 | const IS_PREFIX = 1 << 7; TokenType[TokenType["IS_PREFIX"] = IS_PREFIX] = "IS_PREFIX";
|
12 | const IS_POSTFIX = 1 << 8; TokenType[TokenType["IS_POSTFIX"] = IS_POSTFIX] = "IS_POSTFIX";
|
13 |
|
14 | const num = 0; TokenType[TokenType["num"] = num] = "num";
|
15 | const bigint = 512; TokenType[TokenType["bigint"] = bigint] = "bigint";
|
16 | const regexp = 1024; TokenType[TokenType["regexp"] = regexp] = "regexp";
|
17 | const string = 1536; TokenType[TokenType["string"] = string] = "string";
|
18 | const name = 2048; TokenType[TokenType["name"] = name] = "name";
|
19 | const eof = 2560; TokenType[TokenType["eof"] = eof] = "eof";
|
20 | const bracketL = 3072; TokenType[TokenType["bracketL"] = bracketL] = "bracketL";
|
21 | const bracketR = 3584; TokenType[TokenType["bracketR"] = bracketR] = "bracketR";
|
22 | const braceL = 4096; TokenType[TokenType["braceL"] = braceL] = "braceL";
|
23 | const braceBarL = 4608; TokenType[TokenType["braceBarL"] = braceBarL] = "braceBarL";
|
24 | const braceR = 5120; TokenType[TokenType["braceR"] = braceR] = "braceR";
|
25 | const braceBarR = 5632; TokenType[TokenType["braceBarR"] = braceBarR] = "braceBarR";
|
26 | const parenL = 6144; TokenType[TokenType["parenL"] = parenL] = "parenL";
|
27 | const parenR = 6656; TokenType[TokenType["parenR"] = parenR] = "parenR";
|
28 | const comma = 7168; TokenType[TokenType["comma"] = comma] = "comma";
|
29 | const semi = 7680; TokenType[TokenType["semi"] = semi] = "semi";
|
30 | const colon = 8192; TokenType[TokenType["colon"] = colon] = "colon";
|
31 | const doubleColon = 8704; TokenType[TokenType["doubleColon"] = doubleColon] = "doubleColon";
|
32 | const dot = 9216; TokenType[TokenType["dot"] = dot] = "dot";
|
33 | const question = 9728; TokenType[TokenType["question"] = question] = "question";
|
34 | const questionDot = 10240; TokenType[TokenType["questionDot"] = questionDot] = "questionDot";
|
35 | const arrow = 10752; TokenType[TokenType["arrow"] = arrow] = "arrow";
|
36 | const template = 11264; TokenType[TokenType["template"] = template] = "template";
|
37 | const ellipsis = 11776; TokenType[TokenType["ellipsis"] = ellipsis] = "ellipsis";
|
38 | const backQuote = 12288; TokenType[TokenType["backQuote"] = backQuote] = "backQuote";
|
39 | const dollarBraceL = 12800; TokenType[TokenType["dollarBraceL"] = dollarBraceL] = "dollarBraceL";
|
40 | const at = 13312; TokenType[TokenType["at"] = at] = "at";
|
41 | const hash = 13824; TokenType[TokenType["hash"] = hash] = "hash";
|
42 | const eq = 14368; TokenType[TokenType["eq"] = eq] = "eq";
|
43 | const assign = 14880; TokenType[TokenType["assign"] = assign] = "assign";
|
44 | const preIncDec = 15744; TokenType[TokenType["preIncDec"] = preIncDec] = "preIncDec";
|
45 | const postIncDec = 16256; TokenType[TokenType["postIncDec"] = postIncDec] = "postIncDec";
|
46 | const bang = 16512; TokenType[TokenType["bang"] = bang] = "bang";
|
47 | const tilde = 17024; TokenType[TokenType["tilde"] = tilde] = "tilde";
|
48 | const pipeline = 17409; TokenType[TokenType["pipeline"] = pipeline] = "pipeline";
|
49 | const nullishCoalescing = 17922; TokenType[TokenType["nullishCoalescing"] = nullishCoalescing] = "nullishCoalescing";
|
50 | const logicalOR = 18434; TokenType[TokenType["logicalOR"] = logicalOR] = "logicalOR";
|
51 | const logicalAND = 18947; TokenType[TokenType["logicalAND"] = logicalAND] = "logicalAND";
|
52 | const bitwiseOR = 19460; TokenType[TokenType["bitwiseOR"] = bitwiseOR] = "bitwiseOR";
|
53 | const bitwiseXOR = 19973; TokenType[TokenType["bitwiseXOR"] = bitwiseXOR] = "bitwiseXOR";
|
54 | const bitwiseAND = 20486; TokenType[TokenType["bitwiseAND"] = bitwiseAND] = "bitwiseAND";
|
55 | const equality = 20999; TokenType[TokenType["equality"] = equality] = "equality";
|
56 | const lessThan = 21512; TokenType[TokenType["lessThan"] = lessThan] = "lessThan";
|
57 | const greaterThan = 22024; TokenType[TokenType["greaterThan"] = greaterThan] = "greaterThan";
|
58 | const relationalOrEqual = 22536; TokenType[TokenType["relationalOrEqual"] = relationalOrEqual] = "relationalOrEqual";
|
59 | const bitShift = 23049; TokenType[TokenType["bitShift"] = bitShift] = "bitShift";
|
60 | const plus = 23690; TokenType[TokenType["plus"] = plus] = "plus";
|
61 | const minus = 24202; TokenType[TokenType["minus"] = minus] = "minus";
|
62 | const modulo = 24587; TokenType[TokenType["modulo"] = modulo] = "modulo";
|
63 | const star = 25099; TokenType[TokenType["star"] = star] = "star";
|
64 | const slash = 25611; TokenType[TokenType["slash"] = slash] = "slash";
|
65 | const exponent = 26188; TokenType[TokenType["exponent"] = exponent] = "exponent";
|
66 | const jsxName = 26624; TokenType[TokenType["jsxName"] = jsxName] = "jsxName";
|
67 | const jsxText = 27136; TokenType[TokenType["jsxText"] = jsxText] = "jsxText";
|
68 | const jsxTagStart = 27648; TokenType[TokenType["jsxTagStart"] = jsxTagStart] = "jsxTagStart";
|
69 | const jsxTagEnd = 28160; TokenType[TokenType["jsxTagEnd"] = jsxTagEnd] = "jsxTagEnd";
|
70 | const typeParameterStart = 28672; TokenType[TokenType["typeParameterStart"] = typeParameterStart] = "typeParameterStart";
|
71 | const nonNullAssertion = 29184; TokenType[TokenType["nonNullAssertion"] = nonNullAssertion] = "nonNullAssertion";
|
72 | const _break = 29712; TokenType[TokenType["_break"] = _break] = "_break";
|
73 | const _case = 30224; TokenType[TokenType["_case"] = _case] = "_case";
|
74 | const _catch = 30736; TokenType[TokenType["_catch"] = _catch] = "_catch";
|
75 | const _continue = 31248; TokenType[TokenType["_continue"] = _continue] = "_continue";
|
76 | const _debugger = 31760; TokenType[TokenType["_debugger"] = _debugger] = "_debugger";
|
77 | const _default = 32272; TokenType[TokenType["_default"] = _default] = "_default";
|
78 | const _do = 32784; TokenType[TokenType["_do"] = _do] = "_do";
|
79 | const _else = 33296; TokenType[TokenType["_else"] = _else] = "_else";
|
80 | const _finally = 33808; TokenType[TokenType["_finally"] = _finally] = "_finally";
|
81 | const _for = 34320; TokenType[TokenType["_for"] = _for] = "_for";
|
82 | const _function = 34832; TokenType[TokenType["_function"] = _function] = "_function";
|
83 | const _if = 35344; TokenType[TokenType["_if"] = _if] = "_if";
|
84 | const _return = 35856; TokenType[TokenType["_return"] = _return] = "_return";
|
85 | const _switch = 36368; TokenType[TokenType["_switch"] = _switch] = "_switch";
|
86 | const _throw = 37008; TokenType[TokenType["_throw"] = _throw] = "_throw";
|
87 | const _try = 37392; TokenType[TokenType["_try"] = _try] = "_try";
|
88 | const _var = 37904; TokenType[TokenType["_var"] = _var] = "_var";
|
89 | const _let = 38416; TokenType[TokenType["_let"] = _let] = "_let";
|
90 | const _const = 38928; TokenType[TokenType["_const"] = _const] = "_const";
|
91 | const _while = 39440; TokenType[TokenType["_while"] = _while] = "_while";
|
92 | const _with = 39952; TokenType[TokenType["_with"] = _with] = "_with";
|
93 | const _new = 40464; TokenType[TokenType["_new"] = _new] = "_new";
|
94 | const _this = 40976; TokenType[TokenType["_this"] = _this] = "_this";
|
95 | const _super = 41488; TokenType[TokenType["_super"] = _super] = "_super";
|
96 | const _class = 42000; TokenType[TokenType["_class"] = _class] = "_class";
|
97 | const _extends = 42512; TokenType[TokenType["_extends"] = _extends] = "_extends";
|
98 | const _export = 43024; TokenType[TokenType["_export"] = _export] = "_export";
|
99 | const _import = 43536; TokenType[TokenType["_import"] = _import] = "_import";
|
100 | const _yield = 44048; TokenType[TokenType["_yield"] = _yield] = "_yield";
|
101 | const _null = 44560; TokenType[TokenType["_null"] = _null] = "_null";
|
102 | const _true = 45072; TokenType[TokenType["_true"] = _true] = "_true";
|
103 | const _false = 45584; TokenType[TokenType["_false"] = _false] = "_false";
|
104 | const _in = 46104; TokenType[TokenType["_in"] = _in] = "_in";
|
105 | const _instanceof = 46616; TokenType[TokenType["_instanceof"] = _instanceof] = "_instanceof";
|
106 | const _typeof = 47248; TokenType[TokenType["_typeof"] = _typeof] = "_typeof";
|
107 | const _void = 47760; TokenType[TokenType["_void"] = _void] = "_void";
|
108 | const _delete = 48272; TokenType[TokenType["_delete"] = _delete] = "_delete";
|
109 | const _async = 48656; TokenType[TokenType["_async"] = _async] = "_async";
|
110 | const _get = 49168; TokenType[TokenType["_get"] = _get] = "_get";
|
111 | const _set = 49680; TokenType[TokenType["_set"] = _set] = "_set";
|
112 | const _declare = 50192; TokenType[TokenType["_declare"] = _declare] = "_declare";
|
113 | const _readonly = 50704; TokenType[TokenType["_readonly"] = _readonly] = "_readonly";
|
114 | const _abstract = 51216; TokenType[TokenType["_abstract"] = _abstract] = "_abstract";
|
115 | const _static = 51728; TokenType[TokenType["_static"] = _static] = "_static";
|
116 | const _public = 52240; TokenType[TokenType["_public"] = _public] = "_public";
|
117 | const _private = 52752; TokenType[TokenType["_private"] = _private] = "_private";
|
118 | const _protected = 53264; TokenType[TokenType["_protected"] = _protected] = "_protected";
|
119 | const _as = 53776; TokenType[TokenType["_as"] = _as] = "_as";
|
120 | const _enum = 54288; TokenType[TokenType["_enum"] = _enum] = "_enum";
|
121 | const _type = 54800; TokenType[TokenType["_type"] = _type] = "_type";
|
122 | const _implements = 55312; TokenType[TokenType["_implements"] = _implements] = "_implements";
|
123 | })(TokenType || (TokenType = {}));
|
124 | export function formatTokenType(tokenType) {
|
125 | switch (tokenType) {
|
126 | case TokenType.num:
|
127 | return "num";
|
128 | case TokenType.bigint:
|
129 | return "bigint";
|
130 | case TokenType.regexp:
|
131 | return "regexp";
|
132 | case TokenType.string:
|
133 | return "string";
|
134 | case TokenType.name:
|
135 | return "name";
|
136 | case TokenType.eof:
|
137 | return "eof";
|
138 | case TokenType.bracketL:
|
139 | return "[";
|
140 | case TokenType.bracketR:
|
141 | return "]";
|
142 | case TokenType.braceL:
|
143 | return "{";
|
144 | case TokenType.braceBarL:
|
145 | return "{|";
|
146 | case TokenType.braceR:
|
147 | return "}";
|
148 | case TokenType.braceBarR:
|
149 | return "|}";
|
150 | case TokenType.parenL:
|
151 | return "(";
|
152 | case TokenType.parenR:
|
153 | return ")";
|
154 | case TokenType.comma:
|
155 | return ",";
|
156 | case TokenType.semi:
|
157 | return ";";
|
158 | case TokenType.colon:
|
159 | return ":";
|
160 | case TokenType.doubleColon:
|
161 | return "::";
|
162 | case TokenType.dot:
|
163 | return ".";
|
164 | case TokenType.question:
|
165 | return "?";
|
166 | case TokenType.questionDot:
|
167 | return "?.";
|
168 | case TokenType.arrow:
|
169 | return "=>";
|
170 | case TokenType.template:
|
171 | return "template";
|
172 | case TokenType.ellipsis:
|
173 | return "...";
|
174 | case TokenType.backQuote:
|
175 | return "`";
|
176 | case TokenType.dollarBraceL:
|
177 | return "${";
|
178 | case TokenType.at:
|
179 | return "@";
|
180 | case TokenType.hash:
|
181 | return "#";
|
182 | case TokenType.eq:
|
183 | return "=";
|
184 | case TokenType.assign:
|
185 | return "_=";
|
186 | case TokenType.preIncDec:
|
187 | return "++/--";
|
188 | case TokenType.postIncDec:
|
189 | return "++/--";
|
190 | case TokenType.bang:
|
191 | return "!";
|
192 | case TokenType.tilde:
|
193 | return "~";
|
194 | case TokenType.pipeline:
|
195 | return "|>";
|
196 | case TokenType.nullishCoalescing:
|
197 | return "??";
|
198 | case TokenType.logicalOR:
|
199 | return "||";
|
200 | case TokenType.logicalAND:
|
201 | return "&&";
|
202 | case TokenType.bitwiseOR:
|
203 | return "|";
|
204 | case TokenType.bitwiseXOR:
|
205 | return "^";
|
206 | case TokenType.bitwiseAND:
|
207 | return "&";
|
208 | case TokenType.equality:
|
209 | return "==/!=";
|
210 | case TokenType.lessThan:
|
211 | return "<";
|
212 | case TokenType.greaterThan:
|
213 | return ">";
|
214 | case TokenType.relationalOrEqual:
|
215 | return "<=/>=";
|
216 | case TokenType.bitShift:
|
217 | return "<</>>";
|
218 | case TokenType.plus:
|
219 | return "+";
|
220 | case TokenType.minus:
|
221 | return "-";
|
222 | case TokenType.modulo:
|
223 | return "%";
|
224 | case TokenType.star:
|
225 | return "*";
|
226 | case TokenType.slash:
|
227 | return "/";
|
228 | case TokenType.exponent:
|
229 | return "**";
|
230 | case TokenType.jsxName:
|
231 | return "jsxName";
|
232 | case TokenType.jsxText:
|
233 | return "jsxText";
|
234 | case TokenType.jsxTagStart:
|
235 | return "jsxTagStart";
|
236 | case TokenType.jsxTagEnd:
|
237 | return "jsxTagEnd";
|
238 | case TokenType.typeParameterStart:
|
239 | return "typeParameterStart";
|
240 | case TokenType.nonNullAssertion:
|
241 | return "nonNullAssertion";
|
242 | case TokenType._break:
|
243 | return "break";
|
244 | case TokenType._case:
|
245 | return "case";
|
246 | case TokenType._catch:
|
247 | return "catch";
|
248 | case TokenType._continue:
|
249 | return "continue";
|
250 | case TokenType._debugger:
|
251 | return "debugger";
|
252 | case TokenType._default:
|
253 | return "default";
|
254 | case TokenType._do:
|
255 | return "do";
|
256 | case TokenType._else:
|
257 | return "else";
|
258 | case TokenType._finally:
|
259 | return "finally";
|
260 | case TokenType._for:
|
261 | return "for";
|
262 | case TokenType._function:
|
263 | return "function";
|
264 | case TokenType._if:
|
265 | return "if";
|
266 | case TokenType._return:
|
267 | return "return";
|
268 | case TokenType._switch:
|
269 | return "switch";
|
270 | case TokenType._throw:
|
271 | return "throw";
|
272 | case TokenType._try:
|
273 | return "try";
|
274 | case TokenType._var:
|
275 | return "var";
|
276 | case TokenType._let:
|
277 | return "let";
|
278 | case TokenType._const:
|
279 | return "const";
|
280 | case TokenType._while:
|
281 | return "while";
|
282 | case TokenType._with:
|
283 | return "with";
|
284 | case TokenType._new:
|
285 | return "new";
|
286 | case TokenType._this:
|
287 | return "this";
|
288 | case TokenType._super:
|
289 | return "super";
|
290 | case TokenType._class:
|
291 | return "class";
|
292 | case TokenType._extends:
|
293 | return "extends";
|
294 | case TokenType._export:
|
295 | return "export";
|
296 | case TokenType._import:
|
297 | return "import";
|
298 | case TokenType._yield:
|
299 | return "yield";
|
300 | case TokenType._null:
|
301 | return "null";
|
302 | case TokenType._true:
|
303 | return "true";
|
304 | case TokenType._false:
|
305 | return "false";
|
306 | case TokenType._in:
|
307 | return "in";
|
308 | case TokenType._instanceof:
|
309 | return "instanceof";
|
310 | case TokenType._typeof:
|
311 | return "typeof";
|
312 | case TokenType._void:
|
313 | return "void";
|
314 | case TokenType._delete:
|
315 | return "delete";
|
316 | case TokenType._async:
|
317 | return "async";
|
318 | case TokenType._get:
|
319 | return "get";
|
320 | case TokenType._set:
|
321 | return "set";
|
322 | case TokenType._declare:
|
323 | return "declare";
|
324 | case TokenType._readonly:
|
325 | return "readonly";
|
326 | case TokenType._abstract:
|
327 | return "abstract";
|
328 | case TokenType._static:
|
329 | return "static";
|
330 | case TokenType._public:
|
331 | return "public";
|
332 | case TokenType._private:
|
333 | return "private";
|
334 | case TokenType._protected:
|
335 | return "protected";
|
336 | case TokenType._as:
|
337 | return "as";
|
338 | case TokenType._enum:
|
339 | return "enum";
|
340 | case TokenType._type:
|
341 | return "type";
|
342 | case TokenType._implements:
|
343 | return "implements";
|
344 | default:
|
345 | return "";
|
346 | }
|
347 | }
|