@angular-wave/angular.ts 0.4.0 → 0.4.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/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-queue.js +5 -4
- package/src/animations/shared.js +3 -3
- package/src/core/compile/compile.js +1 -1
- package/src/core/interpolate/interpolate.js +35 -28
- package/src/core/{parser/lexer.html → parse/ast/ast.html} +1 -1
- package/src/core/{parser → parse/ast}/ast.js +43 -29
- package/src/core/parse/ast/ast.spec.js +1462 -0
- package/src/core/parse/ast/ast.test.js +10 -0
- package/src/core/{parser → parse}/interpreter.js +10 -10
- package/src/core/parse/lexer/lexer.html +18 -0
- package/src/core/{parser → parse/lexer}/lexer.js +1 -1
- package/src/core/{parser → parse/lexer}/lexer.spec.js +2 -2
- package/src/core/parse/lexer/lexer.test.js +10 -0
- package/src/core/{parser → parse}/parse.html +1 -1
- package/src/core/{parser → parse}/parse.js +5 -5
- package/src/core/{parser → parse}/parse.spec.js +6 -1725
- package/src/core/parse/parse.test.js +10 -0
- package/src/core/parse/parser/parser.html +18 -0
- package/src/core/{parser → parse/parser}/parser.js +6 -6
- package/src/core/parse/parser/parser.spec.js +8 -0
- package/src/core/parse/parser/parser.test.js +10 -0
- package/src/core/scope/scope.js +5 -6
- package/src/directive/class/class.js +1 -1
- package/src/directive/model/model.js +2 -2
- package/src/directive/validators/validators.js +3 -3
- package/src/public.js +1 -1
- package/types/animations/shared.d.ts +1 -1
- package/types/core/compile/compile.d.ts +1 -1
- package/types/core/interpolate/interpolate.d.ts +7 -4
- package/types/core/{parser → parse/ast}/ast.d.ts +17 -17
- package/types/core/{parser → parse}/interpreter.d.ts +7 -7
- package/types/core/{parser → parse/parser}/parser.d.ts +8 -8
- package/types/core/scope/scope.d.ts +3 -3
- package/types/directive/class/class.d.ts +3 -3
- package/types/directive/model/model.d.ts +6 -6
- package/types/directive/validators/validators.d.ts +3 -3
- package/src/core/parser/parser.test.js +0 -19
- /package/src/core/{parser → parse}/ast-type.js +0 -0
- /package/src/core/{parser → parse}/parse.md +0 -0
- /package/types/core/{parser → parse}/ast-type.d.ts +0 -0
- /package/types/core/{parser → parse/lexer}/lexer.d.ts +0 -0
- /package/types/core/{parser → parse}/parse.d.ts +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
|
@@ -195,12 +195,13 @@ export function AnimateQueueProvider($animateProvider) {
|
|
|
195
195
|
// compiled. The $templateRequest.totalPendingRequests variable keeps track of
|
|
196
196
|
// all of the remote templates being currently downloaded. If there are no
|
|
197
197
|
// templates currently downloading then the watcher will still fire anyway.
|
|
198
|
+
$rootScope["$templateRequest"] = $templateRequest;
|
|
198
199
|
const deregisterWatch = $rootScope.$watch(
|
|
199
|
-
|
|
200
|
-
(
|
|
201
|
-
if (
|
|
200
|
+
"$templateRequest.totalPendingRequests",
|
|
201
|
+
(val) => {
|
|
202
|
+
if (val !== 0) return;
|
|
202
203
|
deregisterWatch();
|
|
203
|
-
|
|
204
|
+
$rootScope["$templateRequest"] = undefined;
|
|
204
205
|
// Now that all templates have been downloaded, $animate will wait until
|
|
205
206
|
// the post digest queue is empty before enabling animations. By having two
|
|
206
207
|
// calls to $postDigest calls we can ensure that the flag is enabled at the
|
package/src/animations/shared.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { forEach, isString, minErr, extend } from "../shared/utils";
|
|
2
|
-
import { JQLite } from "../shared/jqlite/jqlite";
|
|
3
|
-
import { ASTType } from "../core/
|
|
1
|
+
import { forEach, isString, minErr, extend } from "../shared/utils.js";
|
|
2
|
+
import { JQLite } from "../shared/jqlite/jqlite.js";
|
|
3
|
+
import { ASTType } from "../core/parse/ast-type.js";
|
|
4
4
|
|
|
5
5
|
export const ADD_CLASS_SUFFIX = "-add";
|
|
6
6
|
export const REMOVE_CLASS_SUFFIX = "-remove";
|
|
@@ -528,7 +528,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
528
528
|
* @param {*} $interpolate
|
|
529
529
|
* @param {import("../exception-handler").ErrorHandler} $exceptionHandler
|
|
530
530
|
* @param {*} $templateRequest
|
|
531
|
-
* @param {import("../
|
|
531
|
+
* @param {import("../parse/parse").ParseService} $parse
|
|
532
532
|
* @param {*} $controller
|
|
533
533
|
* @param {import('../scope/scope').Scope} $rootScope
|
|
534
534
|
* @param {*} $sce
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
valueFn,
|
|
7
7
|
extend,
|
|
8
8
|
} from "../../shared/utils";
|
|
9
|
-
import { constantWatchDelegate } from "../
|
|
9
|
+
import { constantWatchDelegate } from "../parse/parse.js";
|
|
10
10
|
|
|
11
11
|
const $interpolateMinErr = minErr("$interpolate");
|
|
12
12
|
function throwNoconcat(text) {
|
|
@@ -40,9 +40,13 @@ function interr(text, err) {
|
|
|
40
40
|
* security bugs!
|
|
41
41
|
* </div>
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
export class InterpolateProvider {
|
|
44
|
+
constructor() {
|
|
45
|
+
/** @type {string} */
|
|
46
|
+
this.start = "{{";
|
|
47
|
+
/** @type {string} */
|
|
48
|
+
this.end = "}}";
|
|
49
|
+
}
|
|
46
50
|
|
|
47
51
|
/**
|
|
48
52
|
* Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
|
|
@@ -50,13 +54,13 @@ export function InterpolateProvider() {
|
|
|
50
54
|
* @param {string=} value new value to set the starting symbol to.
|
|
51
55
|
* @returns {string|InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
startSymbol(value) {
|
|
54
58
|
if (value) {
|
|
55
|
-
|
|
59
|
+
this.start = value;
|
|
56
60
|
return this;
|
|
57
61
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
62
|
+
return this.start;
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
66
|
* Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
|
|
@@ -64,33 +68,36 @@ export function InterpolateProvider() {
|
|
|
64
68
|
* @param {string=} value new value to set the ending symbol to.
|
|
65
69
|
* @returns {string|InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
66
70
|
*/
|
|
67
|
-
|
|
71
|
+
endSymbol(value) {
|
|
68
72
|
if (value) {
|
|
69
|
-
|
|
73
|
+
this.end = value;
|
|
70
74
|
return this;
|
|
71
75
|
}
|
|
72
|
-
return
|
|
73
|
-
}
|
|
76
|
+
return this.end;
|
|
77
|
+
}
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
$get = [
|
|
76
80
|
"$parse",
|
|
77
|
-
"$exceptionHandler",
|
|
78
81
|
"$sce",
|
|
79
82
|
/**
|
|
80
83
|
*
|
|
81
|
-
* @param {import("../
|
|
82
|
-
* @param {import('../exception-handler').ErrorHandler} $exceptionHandler
|
|
84
|
+
* @param {import("../parse/parse").ParseService} $parse
|
|
83
85
|
* @param {*} $sce
|
|
84
86
|
* @returns
|
|
85
87
|
*/
|
|
86
|
-
function ($parse, $
|
|
87
|
-
|
|
88
|
-
const
|
|
88
|
+
function ($parse, $sce) {
|
|
89
|
+
/** @type {InterpolateProvider} */
|
|
90
|
+
const provider = this;
|
|
91
|
+
const startSymbolLength = provider.start.length;
|
|
92
|
+
const endSymbolLength = provider.end.length;
|
|
89
93
|
const escapedStartRegexp = new RegExp(
|
|
90
|
-
|
|
94
|
+
this.start.replace(/./g, escape),
|
|
95
|
+
"g",
|
|
96
|
+
);
|
|
97
|
+
const escapedEndRegexp = new RegExp(
|
|
98
|
+
provider.end.replace(/./g, escape),
|
|
91
99
|
"g",
|
|
92
100
|
);
|
|
93
|
-
const escapedEndRegexp = new RegExp(endSymbol.replace(/./g, escape), "g");
|
|
94
101
|
|
|
95
102
|
function escape(ch) {
|
|
96
103
|
return `\\\\\\${ch}`;
|
|
@@ -98,8 +105,8 @@ export function InterpolateProvider() {
|
|
|
98
105
|
|
|
99
106
|
function unescapeText(text) {
|
|
100
107
|
return text
|
|
101
|
-
.replace(escapedStartRegexp,
|
|
102
|
-
.replace(escapedEndRegexp,
|
|
108
|
+
.replace(escapedStartRegexp, provider.start)
|
|
109
|
+
.replace(escapedEndRegexp, provider.end);
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
/**
|
|
@@ -222,7 +229,7 @@ export function InterpolateProvider() {
|
|
|
222
229
|
trustedContext === $sce.URL || trustedContext === $sce.MEDIA_URL;
|
|
223
230
|
|
|
224
231
|
// Provide a quick exit and simplified result function for text with no interpolation
|
|
225
|
-
if (!text.length || text.indexOf(
|
|
232
|
+
if (!text.length || text.indexOf(provider.start) === -1) {
|
|
226
233
|
if (mustHaveExpression) return;
|
|
227
234
|
|
|
228
235
|
let unescapedText = unescapeText(text);
|
|
@@ -255,9 +262,9 @@ export function InterpolateProvider() {
|
|
|
255
262
|
|
|
256
263
|
while (index < textLength) {
|
|
257
264
|
if (
|
|
258
|
-
(startIndex = text.indexOf(
|
|
265
|
+
(startIndex = text.indexOf(provider.start, index)) !== -1 &&
|
|
259
266
|
(endIndex = text.indexOf(
|
|
260
|
-
|
|
267
|
+
provider.end,
|
|
261
268
|
startIndex + startSymbolLength,
|
|
262
269
|
)) !== -1
|
|
263
270
|
) {
|
|
@@ -390,7 +397,7 @@ export function InterpolateProvider() {
|
|
|
390
397
|
* @returns {string} start symbol.
|
|
391
398
|
*/
|
|
392
399
|
$interpolate.startSymbol = function () {
|
|
393
|
-
return
|
|
400
|
+
return provider.start;
|
|
394
401
|
};
|
|
395
402
|
|
|
396
403
|
/**
|
|
@@ -402,7 +409,7 @@ export function InterpolateProvider() {
|
|
|
402
409
|
* @returns {string} end symbol.
|
|
403
410
|
*/
|
|
404
411
|
$interpolate.endSymbol = function () {
|
|
405
|
-
return
|
|
412
|
+
return provider.end;
|
|
406
413
|
};
|
|
407
414
|
|
|
408
415
|
return $interpolate;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
|
|
11
11
|
<script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
|
|
12
12
|
<script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
|
|
13
|
-
<script type="module" src="/src/core/
|
|
13
|
+
<script type="module" src="/src/core/parse/ast/ast.spec.js"></script>
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="dummy"></div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isAssignable } from "
|
|
2
|
-
import { ASTType } from "
|
|
3
|
-
import { minErr } from "
|
|
1
|
+
import { isAssignable } from "../interpreter.js";
|
|
2
|
+
import { ASTType } from "../ast-type.js";
|
|
3
|
+
import { minErr } from "../../../shared/utils.js";
|
|
4
4
|
|
|
5
5
|
const $parseMinErr = minErr("$parse");
|
|
6
6
|
|
|
@@ -48,10 +48,10 @@ export const literals = new Map(
|
|
|
48
48
|
*/
|
|
49
49
|
export class AST {
|
|
50
50
|
/**
|
|
51
|
-
* @param {import('
|
|
51
|
+
* @param {import('../lexer/lexer.js').Lexer} lexer - The lexer instance for tokenizing input
|
|
52
52
|
*/
|
|
53
53
|
constructor(lexer) {
|
|
54
|
-
/** @type {import('
|
|
54
|
+
/** @type {import('../lexer/lexer.js').Lexer} */
|
|
55
55
|
this.lexer = lexer;
|
|
56
56
|
this.selfReferential = {
|
|
57
57
|
this: { type: ASTType.ThisExpression },
|
|
@@ -202,7 +202,7 @@ export class AST {
|
|
|
202
202
|
while ((token = this.expect("==", "!=", "===", "!=="))) {
|
|
203
203
|
left = {
|
|
204
204
|
type: ASTType.BinaryExpression,
|
|
205
|
-
operator: /** @type {import("
|
|
205
|
+
operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
|
|
206
206
|
left,
|
|
207
207
|
right: this.relational(),
|
|
208
208
|
};
|
|
@@ -220,7 +220,7 @@ export class AST {
|
|
|
220
220
|
while ((token = this.expect("<", ">", "<=", ">="))) {
|
|
221
221
|
left = {
|
|
222
222
|
type: ASTType.BinaryExpression,
|
|
223
|
-
operator: /** @type {import("
|
|
223
|
+
operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
|
|
224
224
|
left,
|
|
225
225
|
right: this.additive(),
|
|
226
226
|
};
|
|
@@ -238,7 +238,7 @@ export class AST {
|
|
|
238
238
|
while ((token = this.expect("+", "-"))) {
|
|
239
239
|
left = {
|
|
240
240
|
type: ASTType.BinaryExpression,
|
|
241
|
-
operator: /** @type {import("
|
|
241
|
+
operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
|
|
242
242
|
left,
|
|
243
243
|
right: this.multiplicative(),
|
|
244
244
|
};
|
|
@@ -256,7 +256,7 @@ export class AST {
|
|
|
256
256
|
while ((token = this.expect("*", "/", "%"))) {
|
|
257
257
|
left = {
|
|
258
258
|
type: ASTType.BinaryExpression,
|
|
259
|
-
operator: /** @type {import("
|
|
259
|
+
operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
|
|
260
260
|
left,
|
|
261
261
|
right: this.unary(),
|
|
262
262
|
};
|
|
@@ -273,7 +273,7 @@ export class AST {
|
|
|
273
273
|
if ((token = this.expect("+", "-", "!"))) {
|
|
274
274
|
return {
|
|
275
275
|
type: ASTType.UnaryExpression,
|
|
276
|
-
operator: /** @type {import("
|
|
276
|
+
operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
|
|
277
277
|
prefix: true,
|
|
278
278
|
argument: this.unary(),
|
|
279
279
|
};
|
|
@@ -297,40 +297,48 @@ export class AST {
|
|
|
297
297
|
} else if (
|
|
298
298
|
Object.prototype.hasOwnProperty.call(
|
|
299
299
|
this.selfReferential,
|
|
300
|
-
/** @type {import("
|
|
300
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()).text,
|
|
301
301
|
)
|
|
302
302
|
) {
|
|
303
303
|
primary = structuredClone(this.selfReferential[this.consume().text]);
|
|
304
304
|
} else if (
|
|
305
|
-
literals.has(
|
|
305
|
+
literals.has(
|
|
306
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()).text,
|
|
307
|
+
)
|
|
306
308
|
) {
|
|
307
309
|
primary = {
|
|
308
310
|
type: ASTType.Literal,
|
|
309
311
|
value: literals.get(this.consume().text),
|
|
310
312
|
};
|
|
311
313
|
} else if (
|
|
312
|
-
/** @type {import("
|
|
314
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()).identifier
|
|
313
315
|
) {
|
|
314
316
|
primary = this.identifier();
|
|
315
|
-
} else if (
|
|
317
|
+
} else if (
|
|
318
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()).constant
|
|
319
|
+
) {
|
|
316
320
|
primary = this.constant();
|
|
317
321
|
} else {
|
|
318
322
|
this.throwError(
|
|
319
323
|
"not a primary expression",
|
|
320
|
-
/** @type {import("
|
|
324
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
|
|
321
325
|
);
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
let next;
|
|
325
329
|
while ((next = this.expect("(", "[", "."))) {
|
|
326
|
-
if (
|
|
330
|
+
if (
|
|
331
|
+
/** @type {import("../lexer/lexer.js").Token} */ (next).text === "("
|
|
332
|
+
) {
|
|
327
333
|
primary = {
|
|
328
334
|
type: ASTType.CallExpression,
|
|
329
335
|
callee: primary,
|
|
330
336
|
arguments: this.parseArguments(),
|
|
331
337
|
};
|
|
332
338
|
this.consume(")");
|
|
333
|
-
} else if (
|
|
339
|
+
} else if (
|
|
340
|
+
/** @type {import("../lexer/lexer.js").Token} */ (next).text === "["
|
|
341
|
+
) {
|
|
334
342
|
primary = {
|
|
335
343
|
type: ASTType.MemberExpression,
|
|
336
344
|
object: primary,
|
|
@@ -338,7 +346,9 @@ export class AST {
|
|
|
338
346
|
computed: true,
|
|
339
347
|
};
|
|
340
348
|
this.consume("]");
|
|
341
|
-
} else if (
|
|
349
|
+
} else if (
|
|
350
|
+
/** @type {import("../lexer/lexer.js").Token} */ (next).text === "."
|
|
351
|
+
) {
|
|
342
352
|
primary = {
|
|
343
353
|
type: ASTType.MemberExpression,
|
|
344
354
|
object: primary,
|
|
@@ -447,13 +457,17 @@ export class AST {
|
|
|
447
457
|
break;
|
|
448
458
|
}
|
|
449
459
|
property = { type: ASTType.Property, kind: "init" };
|
|
450
|
-
if (
|
|
460
|
+
if (
|
|
461
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek())
|
|
462
|
+
.constant
|
|
463
|
+
) {
|
|
451
464
|
property.key = this.constant();
|
|
452
465
|
property.computed = false;
|
|
453
466
|
this.consume(":");
|
|
454
467
|
property.value = this.assignment();
|
|
455
468
|
} else if (
|
|
456
|
-
/** @type {import("
|
|
469
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek())
|
|
470
|
+
.identifier
|
|
457
471
|
) {
|
|
458
472
|
property.key = this.identifier();
|
|
459
473
|
property.computed = false;
|
|
@@ -473,7 +487,7 @@ export class AST {
|
|
|
473
487
|
} else {
|
|
474
488
|
this.throwError(
|
|
475
489
|
"invalid key",
|
|
476
|
-
/** @type {import("
|
|
490
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
|
|
477
491
|
);
|
|
478
492
|
}
|
|
479
493
|
properties.push(property);
|
|
@@ -487,7 +501,7 @@ export class AST {
|
|
|
487
501
|
/**
|
|
488
502
|
* Throws a syntax error.
|
|
489
503
|
* @param {string} msg - The error message.
|
|
490
|
-
* @param {import("
|
|
504
|
+
* @param {import("../lexer/lexer.js").Token} [token] - The token that caused the error.
|
|
491
505
|
*/
|
|
492
506
|
throwError(msg, token) {
|
|
493
507
|
throw $parseMinErr(
|
|
@@ -504,7 +518,7 @@ export class AST {
|
|
|
504
518
|
/**
|
|
505
519
|
* Consumes a token if it matches the expected type.
|
|
506
520
|
* @param {string} [e1] - The expected token type.
|
|
507
|
-
* @returns {import("
|
|
521
|
+
* @returns {import("../lexer/lexer.js").Token} The consumed token.
|
|
508
522
|
*/
|
|
509
523
|
consume(e1) {
|
|
510
524
|
if (this.tokens.length === 0) {
|
|
@@ -519,16 +533,16 @@ export class AST {
|
|
|
519
533
|
if (!token) {
|
|
520
534
|
this.throwError(
|
|
521
535
|
`is unexpected, expecting [${e1}]`,
|
|
522
|
-
/** @type {import("
|
|
536
|
+
/** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
|
|
523
537
|
);
|
|
524
538
|
} else {
|
|
525
|
-
return /** @type {import("
|
|
539
|
+
return /** @type {import("../lexer/lexer.js").Token} */ (token);
|
|
526
540
|
}
|
|
527
541
|
}
|
|
528
542
|
|
|
529
543
|
/**
|
|
530
544
|
* Returns the next token without consuming it.
|
|
531
|
-
* @returns {import("
|
|
545
|
+
* @returns {import("../lexer/lexer.js").Token} The next token.
|
|
532
546
|
*/
|
|
533
547
|
peekToken() {
|
|
534
548
|
if (this.tokens.length === 0) {
|
|
@@ -544,7 +558,7 @@ export class AST {
|
|
|
544
558
|
/**
|
|
545
559
|
* Checks if the next token matches any of the expected types.
|
|
546
560
|
* @param {...string} [expected] - The expected token types.
|
|
547
|
-
* @returns {import('
|
|
561
|
+
* @returns {import('../lexer/lexer.js').Token|boolean} The next token if it matches, otherwise false.
|
|
548
562
|
*/
|
|
549
563
|
peek(...expected) {
|
|
550
564
|
return this.peekAhead(0, ...expected);
|
|
@@ -554,7 +568,7 @@ export class AST {
|
|
|
554
568
|
* Checks if the token at the specified index matches any of the expected types.
|
|
555
569
|
* @param {number} i - The index to check.
|
|
556
570
|
* @param {...string} [expected] - The expected token types.
|
|
557
|
-
* @returns {import("
|
|
571
|
+
* @returns {import("../lexer/lexer.js").Token|boolean} The token at the specified index if it matches, otherwise false.
|
|
558
572
|
*/
|
|
559
573
|
peekAhead(i, ...expected) {
|
|
560
574
|
if (this.tokens.length > i) {
|
|
@@ -573,7 +587,7 @@ export class AST {
|
|
|
573
587
|
/**
|
|
574
588
|
* Consumes the next token if it matches any of the expected types.
|
|
575
589
|
* @param {...string} [expected] - The expected token types.
|
|
576
|
-
* @returns {import("
|
|
590
|
+
* @returns {import("../lexer/lexer.js").Token|boolean} The consumed token if it matches, otherwise false.
|
|
577
591
|
*/
|
|
578
592
|
expect(...expected) {
|
|
579
593
|
const token = this.peek(...expected);
|