xmlui 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{apiInterceptorWorker-230V_-Ds.mjs → apiInterceptorWorker-DJ_oGB-F.mjs} +1 -1
- package/dist/{index-DUwwx3L4.mjs → index-2qtmUAFJ.mjs} +11 -11
- package/dist/index.css +12 -14
- package/dist/scripts/bin/vite-xmlui-plugin.js +1 -1
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +48 -0
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +2 -2
- package/dist/scripts/src/components-core/RestApiProxy.js +2 -2
- package/dist/scripts/src/components-core/rendering/Container.js +3 -3
- package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -3
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +37 -37
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +8 -8
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +37 -37
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +29 -29
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +5 -5
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +29 -29
- package/dist/scripts/src/components-core/script-runner/visitors.js +47 -47
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +2 -2
- package/dist/scripts/src/components-core/theming/themes/root.js +1 -1
- package/dist/scripts/src/components-core/utils/statementUtils.js +32 -32
- package/dist/scripts/src/parsers/scripting/Lexer.js +166 -178
- package/dist/scripts/src/parsers/scripting/Parser.js +555 -701
- package/dist/scripts/src/parsers/scripting/ParserError.js +3 -3
- package/dist/scripts/src/parsers/scripting/TokenTrait.js +103 -105
- package/dist/scripts/src/parsers/{scripting-exp → scripting}/code-behind-collect.js +4 -4
- package/dist/scripts/src/parsers/{scripting-exp → scripting}/modules.js +2 -2
- package/dist/scripts/src/parsers/{scripting-exp → scripting}/tree-visitor.js +45 -45
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +2 -2
- package/dist/style.css +12 -14
- package/dist/xmlui-metadata.mjs +1 -1
- package/dist/xmlui-metadata.umd.js +1 -1
- package/dist/xmlui-parser.d.ts +1 -11
- package/dist/xmlui-standalone.umd.js +25 -27
- package/dist/xmlui.d.ts +2 -75
- package/dist/xmlui.mjs +1 -1
- package/package.json +3 -3
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +0 -50
- package/dist/scripts/src/abstractions/scripting/Token.js +0 -112
- package/dist/scripts/src/components-core/theming/abstractions.js +0 -11
- package/dist/scripts/src/parsers/scripting-exp/Lexer.js +0 -1092
- package/dist/scripts/src/parsers/scripting-exp/Parser.js +0 -2635
- package/dist/scripts/src/parsers/scripting-exp/ParserError.js +0 -47
- package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +0 -109
- /package/dist/scripts/src/abstractions/scripting/{LogicalThreadExp.js → LogicalThread.js} +0 -0
- /package/dist/scripts/src/parsers/{scripting-exp → scripting}/TokenType.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Lexer = void 0;
|
|
4
4
|
const regexpp_1 = require("@eslint-community/regexpp");
|
|
5
|
-
const
|
|
5
|
+
const TokenType_1 = require("./TokenType");
|
|
6
6
|
/**
|
|
7
7
|
* This enum indicates the current lexer phase
|
|
8
8
|
*/
|
|
@@ -45,8 +45,8 @@ var LexerPhase;
|
|
|
45
45
|
LexerPhase[LexerPhase["RealExponent"] = 30] = "RealExponent";
|
|
46
46
|
LexerPhase[LexerPhase["RealExponentSign"] = 31] = "RealExponentSign";
|
|
47
47
|
LexerPhase[LexerPhase["RealExponentTail"] = 32] = "RealExponentTail";
|
|
48
|
-
LexerPhase[LexerPhase["
|
|
49
|
-
LexerPhase[LexerPhase["
|
|
48
|
+
LexerPhase[LexerPhase["StringTemplateLiteralBackSlash"] = 33] = "StringTemplateLiteralBackSlash";
|
|
49
|
+
LexerPhase[LexerPhase["StringTemplateLiteral"] = 34] = "StringTemplateLiteral";
|
|
50
50
|
LexerPhase[LexerPhase["String"] = 35] = "String";
|
|
51
51
|
LexerPhase[LexerPhase["StringBackSlash"] = 36] = "StringBackSlash";
|
|
52
52
|
LexerPhase[LexerPhase["StringHexa1"] = 37] = "StringHexa1";
|
|
@@ -157,11 +157,10 @@ class Lexer {
|
|
|
157
157
|
*/
|
|
158
158
|
getTail() {
|
|
159
159
|
return this._ahead.length > 0
|
|
160
|
-
? this.input.getTail(this._ahead[0].
|
|
160
|
+
? this.input.getTail(this._ahead[0].startPosition)
|
|
161
161
|
: this.input.getTail(this._lastFetchPosition);
|
|
162
162
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Parsing template literals requires a context sensitive lexer.
|
|
163
|
+
/** Parsing template literals requires a context sensitive lexer.
|
|
165
164
|
* This method has to be called by the parser when the lexer needs to scan a string inside a template literal.
|
|
166
165
|
* Call this after the first opening backing and after the parser is done with parsing a placeholder, after the right brace.
|
|
167
166
|
*/
|
|
@@ -193,7 +192,7 @@ class Lexer {
|
|
|
193
192
|
// --- State variables
|
|
194
193
|
let stringState = null;
|
|
195
194
|
let text = "";
|
|
196
|
-
let tokenType =
|
|
195
|
+
let tokenType = TokenType_1.TokenType.Eof;
|
|
197
196
|
let lastEndPos = input.position;
|
|
198
197
|
let lastEndColumn = input.column;
|
|
199
198
|
let ch = null;
|
|
@@ -209,8 +208,8 @@ class Lexer {
|
|
|
209
208
|
return makeToken();
|
|
210
209
|
}
|
|
211
210
|
// --- Set the initial token type to unknown for the other characters
|
|
212
|
-
if (tokenType ===
|
|
213
|
-
tokenType =
|
|
211
|
+
if (tokenType === TokenType_1.TokenType.Eof) {
|
|
212
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
214
213
|
}
|
|
215
214
|
// --- Follow the lexer state machine
|
|
216
215
|
phaseSwitch: switch (phase) {
|
|
@@ -224,105 +223,105 @@ class Lexer {
|
|
|
224
223
|
case "\n":
|
|
225
224
|
case "\r":
|
|
226
225
|
phase = LexerPhase.InWhiteSpace;
|
|
227
|
-
tokenType =
|
|
226
|
+
tokenType = TokenType_1.TokenType.Ws;
|
|
228
227
|
break;
|
|
229
228
|
// --- Divide, BlockComment, or EolComment
|
|
230
229
|
case "/":
|
|
231
230
|
phase = LexerPhase.Slash;
|
|
232
|
-
tokenType =
|
|
231
|
+
tokenType = TokenType_1.TokenType.Divide;
|
|
233
232
|
break;
|
|
234
233
|
case "$":
|
|
235
234
|
phase = LexerPhase.Dollar;
|
|
236
|
-
tokenType =
|
|
235
|
+
tokenType = TokenType_1.TokenType.Identifier;
|
|
237
236
|
break;
|
|
238
237
|
case "*":
|
|
239
238
|
phase = LexerPhase.Asterisk;
|
|
240
|
-
tokenType =
|
|
239
|
+
tokenType = TokenType_1.TokenType.Multiply;
|
|
241
240
|
break;
|
|
242
241
|
case "%":
|
|
243
242
|
phase = LexerPhase.Remainder;
|
|
244
|
-
tokenType =
|
|
243
|
+
tokenType = TokenType_1.TokenType.Remainder;
|
|
245
244
|
break;
|
|
246
245
|
case "+":
|
|
247
246
|
phase = LexerPhase.Plus;
|
|
248
|
-
tokenType =
|
|
247
|
+
tokenType = TokenType_1.TokenType.Plus;
|
|
249
248
|
break;
|
|
250
249
|
case "-":
|
|
251
250
|
phase = LexerPhase.Minus;
|
|
252
|
-
tokenType =
|
|
251
|
+
tokenType = TokenType_1.TokenType.Minus;
|
|
253
252
|
break;
|
|
254
253
|
case "^":
|
|
255
254
|
phase = LexerPhase.BitwiseXor;
|
|
256
|
-
tokenType =
|
|
255
|
+
tokenType = TokenType_1.TokenType.BitwiseXor;
|
|
257
256
|
break;
|
|
258
257
|
// --- BitwiseOr, LogicalOr
|
|
259
258
|
case "|":
|
|
260
259
|
phase = LexerPhase.Or;
|
|
261
|
-
tokenType =
|
|
260
|
+
tokenType = TokenType_1.TokenType.BitwiseOr;
|
|
262
261
|
break;
|
|
263
262
|
// --- BitwiseAnd, LogicalAnd
|
|
264
263
|
case "&":
|
|
265
264
|
phase = LexerPhase.Ampersand;
|
|
266
|
-
tokenType =
|
|
265
|
+
tokenType = TokenType_1.TokenType.BitwiseAnd;
|
|
267
266
|
break;
|
|
268
267
|
// --- "?", "?", or "?."
|
|
269
268
|
case "?":
|
|
270
269
|
phase = LexerPhase.QuestionMark;
|
|
271
|
-
tokenType =
|
|
270
|
+
tokenType = TokenType_1.TokenType.QuestionMark;
|
|
272
271
|
break;
|
|
273
272
|
case ";":
|
|
274
|
-
return completeToken(
|
|
273
|
+
return completeToken(TokenType_1.TokenType.Semicolon);
|
|
275
274
|
case ",":
|
|
276
|
-
return completeToken(
|
|
275
|
+
return completeToken(TokenType_1.TokenType.Comma);
|
|
277
276
|
case "(":
|
|
278
|
-
return completeToken(
|
|
277
|
+
return completeToken(TokenType_1.TokenType.LParent);
|
|
279
278
|
case ")":
|
|
280
|
-
return completeToken(
|
|
279
|
+
return completeToken(TokenType_1.TokenType.RParent);
|
|
281
280
|
// --- ":" or "::"
|
|
282
281
|
case ":":
|
|
283
282
|
phase = LexerPhase.Colon;
|
|
284
|
-
tokenType =
|
|
283
|
+
tokenType = TokenType_1.TokenType.Colon;
|
|
285
284
|
break;
|
|
286
285
|
case "`":
|
|
287
|
-
return completeToken(
|
|
286
|
+
return completeToken(TokenType_1.TokenType.Backtick);
|
|
288
287
|
case "[":
|
|
289
|
-
return completeToken(
|
|
288
|
+
return completeToken(TokenType_1.TokenType.LSquare);
|
|
290
289
|
case "]":
|
|
291
|
-
return completeToken(
|
|
290
|
+
return completeToken(TokenType_1.TokenType.RSquare);
|
|
292
291
|
case "~":
|
|
293
|
-
return completeToken(
|
|
292
|
+
return completeToken(TokenType_1.TokenType.BinaryNot);
|
|
294
293
|
case "{":
|
|
295
|
-
return completeToken(
|
|
294
|
+
return completeToken(TokenType_1.TokenType.LBrace);
|
|
296
295
|
case "}":
|
|
297
|
-
return completeToken(
|
|
296
|
+
return completeToken(TokenType_1.TokenType.RBrace);
|
|
298
297
|
// --- "=","==", "===", or "=>"
|
|
299
298
|
case "=":
|
|
300
299
|
phase = LexerPhase.Equal;
|
|
301
|
-
tokenType =
|
|
300
|
+
tokenType = TokenType_1.TokenType.Assignment;
|
|
302
301
|
break;
|
|
303
302
|
// --- "!", "!=", or "!=="
|
|
304
303
|
case "!":
|
|
305
304
|
phase = LexerPhase.Exclamation;
|
|
306
|
-
tokenType =
|
|
305
|
+
tokenType = TokenType_1.TokenType.LogicalNot;
|
|
307
306
|
break;
|
|
308
307
|
// --- "<", "<=", or "<<"
|
|
309
308
|
case "<":
|
|
310
309
|
phase = LexerPhase.AngleLeft;
|
|
311
|
-
tokenType =
|
|
310
|
+
tokenType = TokenType_1.TokenType.LessThan;
|
|
312
311
|
break;
|
|
313
312
|
// --- ">", ">=", ">>", or ">>>"
|
|
314
313
|
case ">":
|
|
315
314
|
phase = LexerPhase.AngleRight;
|
|
316
|
-
tokenType =
|
|
315
|
+
tokenType = TokenType_1.TokenType.GreaterThan;
|
|
317
316
|
break;
|
|
318
317
|
// --- Decimal or Real literal
|
|
319
318
|
case "0":
|
|
320
319
|
phase = LexerPhase.Zero;
|
|
321
|
-
tokenType =
|
|
320
|
+
tokenType = TokenType_1.TokenType.DecimalLiteral;
|
|
322
321
|
break;
|
|
323
322
|
case ".":
|
|
324
323
|
phase = LexerPhase.Dot;
|
|
325
|
-
tokenType =
|
|
324
|
+
tokenType = TokenType_1.TokenType.Dot;
|
|
326
325
|
break;
|
|
327
326
|
// --- String (both " and ' are accepted as string wrappers
|
|
328
327
|
case '"':
|
|
@@ -334,32 +333,20 @@ class Lexer {
|
|
|
334
333
|
if (isIdStart(ch)) {
|
|
335
334
|
useResolver = true;
|
|
336
335
|
phase = LexerPhase.IdTail;
|
|
337
|
-
tokenType =
|
|
336
|
+
tokenType = TokenType_1.TokenType.Identifier;
|
|
338
337
|
}
|
|
339
338
|
else if (isDecimalDigit(ch)) {
|
|
340
339
|
phase = LexerPhase.DecimalOrReal;
|
|
341
|
-
tokenType =
|
|
340
|
+
tokenType = TokenType_1.TokenType.DecimalLiteral;
|
|
342
341
|
}
|
|
343
342
|
else {
|
|
344
|
-
completeToken(
|
|
343
|
+
completeToken(TokenType_1.TokenType.Unknown);
|
|
345
344
|
}
|
|
346
345
|
break;
|
|
347
346
|
}
|
|
348
347
|
break;
|
|
349
348
|
// ====================================================================
|
|
350
349
|
// Process comments
|
|
351
|
-
// A dollar sign is also a valid variable name. When it isn't a dollar left brace, we continue as if it was an identifier
|
|
352
|
-
case LexerPhase.Dollar:
|
|
353
|
-
if (ch === "{") {
|
|
354
|
-
return completeToken(Token_1.TokenType.DollarLBrace);
|
|
355
|
-
}
|
|
356
|
-
phase = LexerPhase.IdTail;
|
|
357
|
-
useResolver = true;
|
|
358
|
-
tokenType = Token_1.TokenType.Identifier;
|
|
359
|
-
if (!isIdContinuation(ch)) {
|
|
360
|
-
makeToken();
|
|
361
|
-
}
|
|
362
|
-
break;
|
|
363
350
|
// --- Looking for the end of whitespace
|
|
364
351
|
case LexerPhase.InWhiteSpace:
|
|
365
352
|
if (ch !== " " && ch !== "\t" && ch !== "\r" && ch !== "\n") {
|
|
@@ -375,7 +362,7 @@ class Lexer {
|
|
|
375
362
|
// --- Wait for a "/" that may complete a block comment
|
|
376
363
|
case LexerPhase.BlockCommentTrail2:
|
|
377
364
|
if (ch === "/") {
|
|
378
|
-
return completeToken(
|
|
365
|
+
return completeToken(TokenType_1.TokenType.BlockComment);
|
|
379
366
|
}
|
|
380
367
|
break;
|
|
381
368
|
case LexerPhase.InlineCommentTrail:
|
|
@@ -393,17 +380,17 @@ class Lexer {
|
|
|
393
380
|
// ====================================================================
|
|
394
381
|
// Process miscellaneous tokens
|
|
395
382
|
case LexerPhase.Colon:
|
|
396
|
-
return ch === ":" ? completeToken(
|
|
383
|
+
return ch === ":" ? completeToken(TokenType_1.TokenType.Global) : makeToken();
|
|
397
384
|
case LexerPhase.Slash:
|
|
398
385
|
if (ch === "*") {
|
|
399
386
|
phase = LexerPhase.BlockCommentTrail1;
|
|
400
387
|
}
|
|
401
388
|
else if (ch === "/") {
|
|
402
389
|
phase = LexerPhase.InlineCommentTrail;
|
|
403
|
-
tokenType =
|
|
390
|
+
tokenType = TokenType_1.TokenType.EolComment;
|
|
404
391
|
}
|
|
405
392
|
else if (ch === "=") {
|
|
406
|
-
return completeToken(
|
|
393
|
+
return completeToken(TokenType_1.TokenType.DivideAssignment);
|
|
407
394
|
}
|
|
408
395
|
else {
|
|
409
396
|
return makeToken();
|
|
@@ -411,142 +398,142 @@ class Lexer {
|
|
|
411
398
|
break;
|
|
412
399
|
case LexerPhase.Plus:
|
|
413
400
|
if (ch === "+") {
|
|
414
|
-
return completeToken(
|
|
401
|
+
return completeToken(TokenType_1.TokenType.IncOp);
|
|
415
402
|
}
|
|
416
|
-
return ch === "=" ? completeToken(
|
|
403
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.AddAssignment) : makeToken();
|
|
417
404
|
case LexerPhase.Minus:
|
|
418
405
|
if (ch === "-") {
|
|
419
|
-
return completeToken(
|
|
406
|
+
return completeToken(TokenType_1.TokenType.DecOp);
|
|
420
407
|
}
|
|
421
|
-
return ch === "=" ? completeToken(
|
|
408
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.SubtractAssignment) : makeToken();
|
|
422
409
|
case LexerPhase.Remainder:
|
|
423
|
-
return ch === "=" ? completeToken(
|
|
410
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.RemainderAssignment) : makeToken();
|
|
424
411
|
case LexerPhase.BitwiseXor:
|
|
425
|
-
return ch === "=" ? completeToken(
|
|
412
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.BitwiseXorAssignment) : makeToken();
|
|
426
413
|
case LexerPhase.Or:
|
|
427
414
|
if (ch === "=") {
|
|
428
|
-
return completeToken(
|
|
415
|
+
return completeToken(TokenType_1.TokenType.BitwiseOrAssignment);
|
|
429
416
|
}
|
|
430
417
|
if (ch === "|") {
|
|
431
418
|
phase = LexerPhase.LogicalOr;
|
|
432
|
-
tokenType =
|
|
419
|
+
tokenType = TokenType_1.TokenType.LogicalOr;
|
|
433
420
|
break;
|
|
434
421
|
}
|
|
435
422
|
return makeToken();
|
|
436
423
|
case LexerPhase.LogicalOr:
|
|
437
|
-
return ch === "=" ? completeToken(
|
|
424
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.LogicalOrAssignment) : makeToken();
|
|
438
425
|
case LexerPhase.Ampersand:
|
|
439
426
|
if (ch === "=") {
|
|
440
|
-
return completeToken(
|
|
427
|
+
return completeToken(TokenType_1.TokenType.BitwiseAndAssignment);
|
|
441
428
|
}
|
|
442
429
|
if (ch === "&") {
|
|
443
430
|
phase = LexerPhase.LogicalAnd;
|
|
444
|
-
tokenType =
|
|
431
|
+
tokenType = TokenType_1.TokenType.LogicalAnd;
|
|
445
432
|
break;
|
|
446
433
|
}
|
|
447
434
|
return makeToken();
|
|
448
435
|
case LexerPhase.LogicalAnd:
|
|
449
|
-
return ch === "=" ? completeToken(
|
|
436
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.LogicalAndAssignment) : makeToken();
|
|
450
437
|
case LexerPhase.Asterisk:
|
|
451
438
|
if (ch === "*") {
|
|
452
439
|
phase = LexerPhase.Exponent;
|
|
453
|
-
tokenType =
|
|
440
|
+
tokenType = TokenType_1.TokenType.Exponent;
|
|
454
441
|
break;
|
|
455
442
|
}
|
|
456
443
|
else if (ch === "=") {
|
|
457
|
-
return completeToken(
|
|
444
|
+
return completeToken(TokenType_1.TokenType.MultiplyAssignment);
|
|
458
445
|
}
|
|
459
446
|
return makeToken();
|
|
460
447
|
case LexerPhase.Exponent:
|
|
461
|
-
return ch === "=" ? completeToken(
|
|
448
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.ExponentAssignment) : makeToken();
|
|
462
449
|
case LexerPhase.QuestionMark:
|
|
463
450
|
if (ch === "?") {
|
|
464
451
|
phase = LexerPhase.NullCoalesce;
|
|
465
|
-
tokenType =
|
|
452
|
+
tokenType = TokenType_1.TokenType.NullCoalesce;
|
|
466
453
|
break;
|
|
467
454
|
}
|
|
468
455
|
if (ch === ".") {
|
|
469
|
-
return completeToken(
|
|
456
|
+
return completeToken(TokenType_1.TokenType.OptionalChaining);
|
|
470
457
|
}
|
|
471
458
|
return makeToken();
|
|
472
459
|
case LexerPhase.NullCoalesce:
|
|
473
|
-
return ch === "=" ? completeToken(
|
|
460
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.NullCoalesceAssignment) : makeToken();
|
|
474
461
|
case LexerPhase.Equal:
|
|
475
462
|
if (ch === ">") {
|
|
476
|
-
return completeToken(
|
|
463
|
+
return completeToken(TokenType_1.TokenType.Arrow);
|
|
477
464
|
}
|
|
478
465
|
if (ch === "=") {
|
|
479
466
|
phase = LexerPhase.DoubleEqual;
|
|
480
|
-
tokenType =
|
|
467
|
+
tokenType = TokenType_1.TokenType.Equal;
|
|
481
468
|
break;
|
|
482
469
|
}
|
|
483
470
|
return makeToken();
|
|
484
471
|
case LexerPhase.DoubleEqual:
|
|
485
|
-
return ch === "=" ? completeToken(
|
|
472
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.StrictEqual) : makeToken();
|
|
486
473
|
case LexerPhase.Exclamation:
|
|
487
474
|
if (ch === "=") {
|
|
488
475
|
phase = LexerPhase.NotEqual;
|
|
489
|
-
tokenType =
|
|
476
|
+
tokenType = TokenType_1.TokenType.NotEqual;
|
|
490
477
|
break;
|
|
491
478
|
}
|
|
492
479
|
return makeToken();
|
|
493
480
|
case LexerPhase.NotEqual:
|
|
494
|
-
return ch === "=" ? completeToken(
|
|
481
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.StrictNotEqual) : makeToken();
|
|
495
482
|
case LexerPhase.AngleLeft:
|
|
496
483
|
if (ch === "=") {
|
|
497
|
-
return completeToken(
|
|
484
|
+
return completeToken(TokenType_1.TokenType.LessThanOrEqual);
|
|
498
485
|
}
|
|
499
486
|
if (ch === "<") {
|
|
500
487
|
phase = LexerPhase.ShiftLeft;
|
|
501
|
-
tokenType =
|
|
488
|
+
tokenType = TokenType_1.TokenType.ShiftLeft;
|
|
502
489
|
break;
|
|
503
490
|
}
|
|
504
491
|
return makeToken();
|
|
505
492
|
case LexerPhase.ShiftLeft:
|
|
506
|
-
return ch === "=" ? completeToken(
|
|
493
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.ShiftLeftAssignment) : makeToken();
|
|
507
494
|
case LexerPhase.AngleRight:
|
|
508
495
|
if (ch === "=") {
|
|
509
|
-
return completeToken(
|
|
496
|
+
return completeToken(TokenType_1.TokenType.GreaterThanOrEqual);
|
|
510
497
|
}
|
|
511
498
|
if (ch === ">") {
|
|
512
499
|
phase = LexerPhase.SignedShiftRight;
|
|
513
|
-
tokenType =
|
|
500
|
+
tokenType = TokenType_1.TokenType.SignedShiftRight;
|
|
514
501
|
break;
|
|
515
502
|
}
|
|
516
503
|
return makeToken();
|
|
517
504
|
case LexerPhase.SignedShiftRight:
|
|
518
505
|
if (ch === ">") {
|
|
519
506
|
phase = LexerPhase.ShiftRight;
|
|
520
|
-
tokenType =
|
|
507
|
+
tokenType = TokenType_1.TokenType.ShiftRight;
|
|
521
508
|
break;
|
|
522
509
|
}
|
|
523
510
|
if (ch === "=") {
|
|
524
|
-
return completeToken(
|
|
511
|
+
return completeToken(TokenType_1.TokenType.SignedShiftRightAssignment);
|
|
525
512
|
}
|
|
526
513
|
return makeToken();
|
|
527
514
|
case LexerPhase.ShiftRight:
|
|
528
|
-
return ch === "=" ? completeToken(
|
|
515
|
+
return ch === "=" ? completeToken(TokenType_1.TokenType.ShiftRightAssignment) : makeToken();
|
|
529
516
|
// ====================================================================
|
|
530
517
|
// --- Literals
|
|
531
518
|
case LexerPhase.Zero:
|
|
532
519
|
if (ch === "x") {
|
|
533
520
|
phase = LexerPhase.HexaFirst;
|
|
534
|
-
tokenType =
|
|
521
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
535
522
|
}
|
|
536
523
|
else if (ch === "b") {
|
|
537
524
|
phase = LexerPhase.BinaryFirst;
|
|
538
|
-
tokenType =
|
|
525
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
539
526
|
}
|
|
540
527
|
else if (isDecimalDigit(ch) || ch === "_") {
|
|
541
528
|
phase = LexerPhase.DecimalOrReal;
|
|
542
529
|
}
|
|
543
530
|
else if (ch === ".") {
|
|
544
531
|
phase = LexerPhase.RealFractionalFirst;
|
|
545
|
-
tokenType =
|
|
532
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
546
533
|
}
|
|
547
534
|
else if (ch === "e" || ch === "E") {
|
|
548
535
|
phase = LexerPhase.RealExponent;
|
|
549
|
-
tokenType =
|
|
536
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
550
537
|
}
|
|
551
538
|
else {
|
|
552
539
|
return makeToken();
|
|
@@ -555,17 +542,17 @@ class Lexer {
|
|
|
555
542
|
case LexerPhase.Dot:
|
|
556
543
|
if (ch === ".") {
|
|
557
544
|
phase = LexerPhase.DotDot;
|
|
558
|
-
tokenType =
|
|
545
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
559
546
|
break;
|
|
560
547
|
}
|
|
561
548
|
if (!isDecimalDigit(ch)) {
|
|
562
549
|
return makeToken();
|
|
563
550
|
}
|
|
564
551
|
phase = LexerPhase.RealFractionalTail;
|
|
565
|
-
tokenType =
|
|
552
|
+
tokenType = TokenType_1.TokenType.RealLiteral;
|
|
566
553
|
break;
|
|
567
554
|
case LexerPhase.DotDot:
|
|
568
|
-
return ch === "." ? completeToken(
|
|
555
|
+
return ch === "." ? completeToken(TokenType_1.TokenType.Spread) : makeToken();
|
|
569
556
|
case LexerPhase.HexaFirst:
|
|
570
557
|
if (ch === "_") {
|
|
571
558
|
break;
|
|
@@ -574,7 +561,7 @@ class Lexer {
|
|
|
574
561
|
return makeToken();
|
|
575
562
|
}
|
|
576
563
|
phase = LexerPhase.HexaTail;
|
|
577
|
-
tokenType =
|
|
564
|
+
tokenType = TokenType_1.TokenType.HexadecimalLiteral;
|
|
578
565
|
break;
|
|
579
566
|
case LexerPhase.HexaTail:
|
|
580
567
|
if (!isHexadecimalDigit(ch) && ch !== "_") {
|
|
@@ -589,26 +576,25 @@ class Lexer {
|
|
|
589
576
|
return makeToken();
|
|
590
577
|
}
|
|
591
578
|
phase = LexerPhase.BinaryTail;
|
|
592
|
-
tokenType =
|
|
579
|
+
tokenType = TokenType_1.TokenType.BinaryLiteral;
|
|
593
580
|
break;
|
|
594
581
|
case LexerPhase.BinaryTail:
|
|
595
582
|
if (!isBinaryDigit(ch) && ch !== "_") {
|
|
596
583
|
return makeToken();
|
|
597
584
|
}
|
|
598
|
-
tokenType =
|
|
585
|
+
tokenType = TokenType_1.TokenType.BinaryLiteral;
|
|
599
586
|
break;
|
|
600
587
|
case LexerPhase.DecimalOrReal:
|
|
601
588
|
if (isDecimalDigit(ch) || ch === "_") {
|
|
602
589
|
break;
|
|
603
590
|
}
|
|
604
|
-
else if (ch === "." &&
|
|
605
|
-
(this.input.peek() === null || isDecimalDigit(this.input.peek()))) {
|
|
591
|
+
else if (ch === "." && (this.input.peek() === null || isDecimalDigit(this.input.peek()))) {
|
|
606
592
|
phase = LexerPhase.RealFractionalFirst;
|
|
607
|
-
tokenType =
|
|
593
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
608
594
|
}
|
|
609
595
|
else if (ch === "e" || ch === "E") {
|
|
610
596
|
phase = LexerPhase.RealExponent;
|
|
611
|
-
tokenType =
|
|
597
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
612
598
|
}
|
|
613
599
|
else {
|
|
614
600
|
return makeToken();
|
|
@@ -617,7 +603,7 @@ class Lexer {
|
|
|
617
603
|
case LexerPhase.RealFractionalFirst:
|
|
618
604
|
if (isDecimalDigit(ch)) {
|
|
619
605
|
phase = LexerPhase.RealFractionalTail;
|
|
620
|
-
tokenType =
|
|
606
|
+
tokenType = TokenType_1.TokenType.RealLiteral;
|
|
621
607
|
}
|
|
622
608
|
else if (ch === "e" || ch === "E") {
|
|
623
609
|
phase = LexerPhase.RealExponent;
|
|
@@ -629,7 +615,7 @@ class Lexer {
|
|
|
629
615
|
case LexerPhase.RealFractionalTail:
|
|
630
616
|
if (ch === "e" || ch === "E") {
|
|
631
617
|
phase = LexerPhase.RealExponent;
|
|
632
|
-
tokenType =
|
|
618
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
633
619
|
}
|
|
634
620
|
else if (!isDecimalDigit(ch) && ch !== "_") {
|
|
635
621
|
return makeToken();
|
|
@@ -641,7 +627,7 @@ class Lexer {
|
|
|
641
627
|
}
|
|
642
628
|
else if (isDecimalDigit(ch)) {
|
|
643
629
|
phase = LexerPhase.RealExponentTail;
|
|
644
|
-
tokenType =
|
|
630
|
+
tokenType = TokenType_1.TokenType.RealLiteral;
|
|
645
631
|
}
|
|
646
632
|
else {
|
|
647
633
|
return makeToken();
|
|
@@ -650,7 +636,7 @@ class Lexer {
|
|
|
650
636
|
case LexerPhase.RealExponentSign:
|
|
651
637
|
if (isDecimalDigit(ch)) {
|
|
652
638
|
phase = LexerPhase.RealExponentTail;
|
|
653
|
-
tokenType =
|
|
639
|
+
tokenType = TokenType_1.TokenType.RealLiteral;
|
|
654
640
|
}
|
|
655
641
|
else {
|
|
656
642
|
return makeToken();
|
|
@@ -661,12 +647,24 @@ class Lexer {
|
|
|
661
647
|
return makeToken();
|
|
662
648
|
}
|
|
663
649
|
break;
|
|
650
|
+
// A dollar sign is also a valid variable name. When it isn't a dollar left brace, we continue as if it was an identifier
|
|
651
|
+
case LexerPhase.Dollar:
|
|
652
|
+
if (ch === "{") {
|
|
653
|
+
return completeToken(TokenType_1.TokenType.DollarLBrace);
|
|
654
|
+
}
|
|
655
|
+
phase = LexerPhase.IdTail;
|
|
656
|
+
useResolver = true;
|
|
657
|
+
tokenType = TokenType_1.TokenType.Identifier;
|
|
658
|
+
if (!isIdContinuation(ch)) {
|
|
659
|
+
makeToken();
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
664
662
|
case LexerPhase.StringTemplateLiteralBackSlash: {
|
|
665
663
|
phase = LexerPhase.StringTemplateLiteral;
|
|
666
664
|
const charAhead1 = this.input.ahead(0);
|
|
667
665
|
const charAhead2 = this.input.ahead(1);
|
|
668
666
|
if (charAhead1 === "`" || (charAhead1 === "$" && charAhead2 === "{")) {
|
|
669
|
-
return completeToken(
|
|
667
|
+
return completeToken(TokenType_1.TokenType.StringLiteral);
|
|
670
668
|
}
|
|
671
669
|
break;
|
|
672
670
|
}
|
|
@@ -674,34 +672,34 @@ class Lexer {
|
|
|
674
672
|
switch (ch) {
|
|
675
673
|
case "\\":
|
|
676
674
|
phase = LexerPhase.StringTemplateLiteralBackSlash;
|
|
677
|
-
tokenType =
|
|
675
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
678
676
|
break phaseSwitch;
|
|
679
677
|
case "`":
|
|
680
|
-
return completeToken(
|
|
678
|
+
return completeToken(TokenType_1.TokenType.Backtick);
|
|
681
679
|
case "$":
|
|
682
680
|
const charAhead = this.input.ahead(0);
|
|
683
681
|
if (charAhead === "{") {
|
|
684
682
|
appendTokenChar();
|
|
685
683
|
this.fetchNextChar();
|
|
686
|
-
return completeToken(
|
|
684
|
+
return completeToken(TokenType_1.TokenType.DollarLBrace);
|
|
687
685
|
}
|
|
688
686
|
}
|
|
689
687
|
const charAhead1 = this.input.ahead(0);
|
|
690
688
|
const charAhead2 = this.input.ahead(1);
|
|
691
689
|
if (charAhead1 === "`" || (charAhead1 === "$" && charAhead2 === "{")) {
|
|
692
|
-
return completeToken(
|
|
690
|
+
return completeToken(TokenType_1.TokenType.StringLiteral);
|
|
693
691
|
}
|
|
694
692
|
break;
|
|
695
693
|
case LexerPhase.String:
|
|
696
694
|
if (ch === stringState) {
|
|
697
|
-
return completeToken(
|
|
695
|
+
return completeToken(TokenType_1.TokenType.StringLiteral);
|
|
698
696
|
}
|
|
699
697
|
else if (isRestrictedInString(ch)) {
|
|
700
|
-
return completeToken(
|
|
698
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
701
699
|
}
|
|
702
700
|
else if (ch === "\\") {
|
|
703
701
|
phase = LexerPhase.StringBackSlash;
|
|
704
|
-
tokenType =
|
|
702
|
+
tokenType = TokenType_1.TokenType.Unknown;
|
|
705
703
|
}
|
|
706
704
|
break;
|
|
707
705
|
// Start of string character escape
|
|
@@ -738,7 +736,7 @@ class Lexer {
|
|
|
738
736
|
phase = LexerPhase.StringHexa2;
|
|
739
737
|
}
|
|
740
738
|
else {
|
|
741
|
-
return completeToken(
|
|
739
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
742
740
|
}
|
|
743
741
|
break;
|
|
744
742
|
// --- Second hexadecimal digit of character escape
|
|
@@ -747,7 +745,7 @@ class Lexer {
|
|
|
747
745
|
phase = LexerPhase.String;
|
|
748
746
|
}
|
|
749
747
|
else {
|
|
750
|
-
return completeToken(
|
|
748
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
751
749
|
}
|
|
752
750
|
break;
|
|
753
751
|
// --- First hexadecimal digit of Unicode string character escape
|
|
@@ -760,7 +758,7 @@ class Lexer {
|
|
|
760
758
|
phase = LexerPhase.StringUHexa2;
|
|
761
759
|
}
|
|
762
760
|
else {
|
|
763
|
-
return completeToken(
|
|
761
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
764
762
|
}
|
|
765
763
|
break;
|
|
766
764
|
// --- Second hexadecimal digit of Unicode string character escape
|
|
@@ -769,7 +767,7 @@ class Lexer {
|
|
|
769
767
|
phase = LexerPhase.StringUHexa3;
|
|
770
768
|
}
|
|
771
769
|
else {
|
|
772
|
-
return completeToken(
|
|
770
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
773
771
|
}
|
|
774
772
|
break;
|
|
775
773
|
// --- Third hexadecimal digit of Unicode string character escape
|
|
@@ -778,7 +776,7 @@ class Lexer {
|
|
|
778
776
|
phase = LexerPhase.StringUHexa4;
|
|
779
777
|
}
|
|
780
778
|
else {
|
|
781
|
-
return completeToken(
|
|
779
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
782
780
|
}
|
|
783
781
|
break;
|
|
784
782
|
// --- Fourth hexadecimal digit of Unicode string character escape
|
|
@@ -787,7 +785,7 @@ class Lexer {
|
|
|
787
785
|
phase = LexerPhase.String;
|
|
788
786
|
}
|
|
789
787
|
else {
|
|
790
|
-
return completeToken(
|
|
788
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
791
789
|
}
|
|
792
790
|
break;
|
|
793
791
|
// --- First hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -796,7 +794,7 @@ class Lexer {
|
|
|
796
794
|
phase = LexerPhase.StringUcp2;
|
|
797
795
|
}
|
|
798
796
|
else {
|
|
799
|
-
return completeToken(
|
|
797
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
800
798
|
}
|
|
801
799
|
break;
|
|
802
800
|
// --- Second hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -808,7 +806,7 @@ class Lexer {
|
|
|
808
806
|
phase = LexerPhase.StringUcp3;
|
|
809
807
|
}
|
|
810
808
|
else {
|
|
811
|
-
return completeToken(
|
|
809
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
812
810
|
}
|
|
813
811
|
break;
|
|
814
812
|
// --- Third hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -820,7 +818,7 @@ class Lexer {
|
|
|
820
818
|
phase = LexerPhase.StringUcp4;
|
|
821
819
|
}
|
|
822
820
|
else {
|
|
823
|
-
return completeToken(
|
|
821
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
824
822
|
}
|
|
825
823
|
break;
|
|
826
824
|
// --- Fourth hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -832,7 +830,7 @@ class Lexer {
|
|
|
832
830
|
phase = LexerPhase.StringUcp5;
|
|
833
831
|
}
|
|
834
832
|
else {
|
|
835
|
-
return completeToken(
|
|
833
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
836
834
|
}
|
|
837
835
|
break;
|
|
838
836
|
// --- Fifth hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -844,7 +842,7 @@ class Lexer {
|
|
|
844
842
|
phase = LexerPhase.StringUcp6;
|
|
845
843
|
}
|
|
846
844
|
else {
|
|
847
|
-
return completeToken(
|
|
845
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
848
846
|
}
|
|
849
847
|
break;
|
|
850
848
|
// --- Sixth hexadecimal digit of Unicode codepoint string character escape
|
|
@@ -856,7 +854,7 @@ class Lexer {
|
|
|
856
854
|
phase = LexerPhase.StringUcpTail;
|
|
857
855
|
}
|
|
858
856
|
else {
|
|
859
|
-
return completeToken(
|
|
857
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
860
858
|
}
|
|
861
859
|
break;
|
|
862
860
|
// --- Closing bracket of Unicode codepoint string character escape
|
|
@@ -865,7 +863,7 @@ class Lexer {
|
|
|
865
863
|
phase = LexerPhase.String;
|
|
866
864
|
}
|
|
867
865
|
else {
|
|
868
|
-
return completeToken(
|
|
866
|
+
return completeToken(TokenType_1.TokenType.Unknown);
|
|
869
867
|
}
|
|
870
868
|
break;
|
|
871
869
|
// ====================================================================
|
|
@@ -895,21 +893,17 @@ class Lexer {
|
|
|
895
893
|
var _a;
|
|
896
894
|
if (useResolver) {
|
|
897
895
|
tokenType =
|
|
898
|
-
(_a = resolverHash.get(text)) !== null && _a !== void 0 ? _a : (isIdStart(text[0]) && text[text.length - 1] !== "'"
|
|
899
|
-
? Token_1.TokenType.Identifier
|
|
900
|
-
: Token_1.TokenType.Unknown);
|
|
896
|
+
(_a = resolverHash.get(text)) !== null && _a !== void 0 ? _a : (isIdStart(text[0]) && text[text.length - 1] !== "'" ? TokenType_1.TokenType.Identifier : TokenType_1.TokenType.Unknown);
|
|
901
897
|
}
|
|
902
898
|
return {
|
|
903
899
|
text,
|
|
904
900
|
type: tokenType,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
endColumn: lastEndColumn,
|
|
912
|
-
},
|
|
901
|
+
startPosition: startPos,
|
|
902
|
+
endPosition: lastEndPos,
|
|
903
|
+
startLine: line,
|
|
904
|
+
endLine: line,
|
|
905
|
+
startColumn,
|
|
906
|
+
endColumn: lastEndColumn,
|
|
913
907
|
};
|
|
914
908
|
}
|
|
915
909
|
/**
|
|
@@ -937,7 +931,7 @@ class Lexer {
|
|
|
937
931
|
*/
|
|
938
932
|
fetchRegEx() {
|
|
939
933
|
// --- Get the tail
|
|
940
|
-
const tailPosition = this._ahead.length > 0 ? this._ahead[0].
|
|
934
|
+
const tailPosition = this._ahead.length > 0 ? this._ahead[0].startPosition : this._lastFetchPosition;
|
|
941
935
|
const tail = this.input.getTail(tailPosition);
|
|
942
936
|
// --- Parse the tail. If no error, the entire tail is the RegExp
|
|
943
937
|
try {
|
|
@@ -1009,52 +1003,50 @@ exports.Lexer = Lexer;
|
|
|
1009
1003
|
* Reserved ID-like tokens
|
|
1010
1004
|
*/
|
|
1011
1005
|
const resolverHash = new Map();
|
|
1012
|
-
resolverHash.set("typeof",
|
|
1013
|
-
resolverHash.set("Infinity",
|
|
1014
|
-
resolverHash.set("NaN",
|
|
1015
|
-
resolverHash.set("true",
|
|
1016
|
-
resolverHash.set("false",
|
|
1017
|
-
resolverHash.set("undefined",
|
|
1018
|
-
resolverHash.set("null",
|
|
1019
|
-
resolverHash.set("in",
|
|
1020
|
-
resolverHash.set("let",
|
|
1021
|
-
resolverHash.set("const",
|
|
1022
|
-
resolverHash.set("var",
|
|
1023
|
-
resolverHash.set("if",
|
|
1024
|
-
resolverHash.set("else",
|
|
1025
|
-
resolverHash.set("return",
|
|
1026
|
-
resolverHash.set("break",
|
|
1027
|
-
resolverHash.set("continue",
|
|
1028
|
-
resolverHash.set("do",
|
|
1029
|
-
resolverHash.set("while",
|
|
1030
|
-
resolverHash.set("for",
|
|
1031
|
-
resolverHash.set("of",
|
|
1032
|
-
resolverHash.set("try",
|
|
1033
|
-
resolverHash.set("catch",
|
|
1034
|
-
resolverHash.set("finally",
|
|
1035
|
-
resolverHash.set("throw",
|
|
1036
|
-
resolverHash.set("switch",
|
|
1037
|
-
resolverHash.set("case",
|
|
1038
|
-
resolverHash.set("default",
|
|
1039
|
-
resolverHash.set("delete",
|
|
1040
|
-
resolverHash.set("function",
|
|
1041
|
-
resolverHash.set("
|
|
1042
|
-
resolverHash.set("
|
|
1043
|
-
resolverHash.set("as", Token_1.TokenType.As);
|
|
1044
|
-
resolverHash.set("from", Token_1.TokenType.From);
|
|
1006
|
+
resolverHash.set("typeof", TokenType_1.TokenType.Typeof);
|
|
1007
|
+
resolverHash.set("Infinity", TokenType_1.TokenType.Infinity);
|
|
1008
|
+
resolverHash.set("NaN", TokenType_1.TokenType.NaN);
|
|
1009
|
+
resolverHash.set("true", TokenType_1.TokenType.True);
|
|
1010
|
+
resolverHash.set("false", TokenType_1.TokenType.False);
|
|
1011
|
+
resolverHash.set("undefined", TokenType_1.TokenType.Undefined);
|
|
1012
|
+
resolverHash.set("null", TokenType_1.TokenType.Null);
|
|
1013
|
+
resolverHash.set("in", TokenType_1.TokenType.In);
|
|
1014
|
+
resolverHash.set("let", TokenType_1.TokenType.Let);
|
|
1015
|
+
resolverHash.set("const", TokenType_1.TokenType.Const);
|
|
1016
|
+
resolverHash.set("var", TokenType_1.TokenType.Var);
|
|
1017
|
+
resolverHash.set("if", TokenType_1.TokenType.If);
|
|
1018
|
+
resolverHash.set("else", TokenType_1.TokenType.Else);
|
|
1019
|
+
resolverHash.set("return", TokenType_1.TokenType.Return);
|
|
1020
|
+
resolverHash.set("break", TokenType_1.TokenType.Break);
|
|
1021
|
+
resolverHash.set("continue", TokenType_1.TokenType.Continue);
|
|
1022
|
+
resolverHash.set("do", TokenType_1.TokenType.Do);
|
|
1023
|
+
resolverHash.set("while", TokenType_1.TokenType.While);
|
|
1024
|
+
resolverHash.set("for", TokenType_1.TokenType.For);
|
|
1025
|
+
resolverHash.set("of", TokenType_1.TokenType.Of);
|
|
1026
|
+
resolverHash.set("try", TokenType_1.TokenType.Try);
|
|
1027
|
+
resolverHash.set("catch", TokenType_1.TokenType.Catch);
|
|
1028
|
+
resolverHash.set("finally", TokenType_1.TokenType.Finally);
|
|
1029
|
+
resolverHash.set("throw", TokenType_1.TokenType.Throw);
|
|
1030
|
+
resolverHash.set("switch", TokenType_1.TokenType.Switch);
|
|
1031
|
+
resolverHash.set("case", TokenType_1.TokenType.Case);
|
|
1032
|
+
resolverHash.set("default", TokenType_1.TokenType.Default);
|
|
1033
|
+
resolverHash.set("delete", TokenType_1.TokenType.Delete);
|
|
1034
|
+
resolverHash.set("function", TokenType_1.TokenType.Function);
|
|
1035
|
+
resolverHash.set("as", TokenType_1.TokenType.As);
|
|
1036
|
+
resolverHash.set("from", TokenType_1.TokenType.From);
|
|
1045
1037
|
/**
|
|
1046
1038
|
* Tests if a token id EOF
|
|
1047
1039
|
* @param t Token instance
|
|
1048
1040
|
*/
|
|
1049
1041
|
function isEof(t) {
|
|
1050
|
-
return t.type ===
|
|
1042
|
+
return t.type === TokenType_1.TokenType.Eof;
|
|
1051
1043
|
}
|
|
1052
1044
|
/**
|
|
1053
1045
|
* Tests if a token is whitespace
|
|
1054
1046
|
* @param t Token instance
|
|
1055
1047
|
*/
|
|
1056
1048
|
function isWs(t) {
|
|
1057
|
-
return t.type <=
|
|
1049
|
+
return t.type <= TokenType_1.TokenType.Ws;
|
|
1058
1050
|
}
|
|
1059
1051
|
/**
|
|
1060
1052
|
* Tests if a character is an identifier start character
|
|
@@ -1068,11 +1060,7 @@ function isIdStart(ch) {
|
|
|
1068
1060
|
* @param ch Character to test
|
|
1069
1061
|
*/
|
|
1070
1062
|
function isIdContinuation(ch) {
|
|
1071
|
-
return (
|
|
1072
|
-
(ch >= "A" && ch <= "Z") ||
|
|
1073
|
-
(ch >= "0" && ch <= "9") ||
|
|
1074
|
-
ch === "_" ||
|
|
1075
|
-
ch === "$");
|
|
1063
|
+
return (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || (ch >= "0" && ch <= "9") || ch === "_" || ch === "$";
|
|
1076
1064
|
}
|
|
1077
1065
|
/**
|
|
1078
1066
|
* Tests if a character is a binary digit
|