fez-lisp 1.3.3 → 1.3.4

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.3.3",
5
+ "version": "1.3.4",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/compiler.js CHANGED
@@ -233,7 +233,7 @@ const compile = (tree, Drill) => {
233
233
  case KEYWORDS.IS_LAMBDA:
234
234
  Drill.Helpers.add('lambda_predicate')
235
235
  return `lambda_predicate(${compile(Arguments[0], Drill)});`
236
- case KEYWORDS.ARRAY_TYPE:
236
+ case KEYWORDS.CREATE_ARRAY:
237
237
  return `[${parseArgs(Arguments, Drill)}];`
238
238
  case KEYWORDS.ARRAY_LENGTH:
239
239
  Drill.Helpers.add('length')
@@ -1,4 +1,13 @@
1
- import { TYPE, VALUE, WORD, KEYWORDS, FALSE, TRUE, TYPES } from './keywords.js'
1
+ import {
2
+ TYPE,
3
+ VALUE,
4
+ WORD,
5
+ KEYWORDS,
6
+ FALSE,
7
+ TRUE,
8
+ TYPES,
9
+ RUNTIME_TYPES
10
+ } from './keywords.js'
2
11
  import { evaluate } from './evaluator.js'
3
12
  import { isForbiddenVariableName, stringifyArgs } from './utils.js'
4
13
  export const keywords = {
@@ -15,14 +24,14 @@ export const keywords = {
15
24
  if (typeof a !== 'number')
16
25
  throw new TypeError(
17
26
  `First arguments of (${KEYWORDS.ADDITION}) is not a (${
18
- KEYWORDS.NUMBER_TYPE
27
+ RUNTIME_TYPES.NUMBER
19
28
  }) (${KEYWORDS.ADDITION} ${stringifyArgs(args)})`
20
29
  )
21
30
  const b = evaluate(args[1], env)
22
31
  if (typeof b !== 'number')
23
32
  throw new TypeError(
24
33
  `Second arguments of (${KEYWORDS.ADDITION}) is not a (${
25
- KEYWORDS.NUMBER_TYPE
34
+ RUNTIME_TYPES.NUMBER
26
35
  }) (${KEYWORDS.ADDITION} ${stringifyArgs(args)})`
27
36
  )
28
37
  return a + b
@@ -36,14 +45,14 @@ export const keywords = {
36
45
  if (typeof a !== 'number')
37
46
  throw new TypeError(
38
47
  `First arguments of (${KEYWORDS.MULTIPLICATION}) is not a (${
39
- KEYWORDS.NUMBER_TYPE
48
+ RUNTIME_TYPES.NUMBER
40
49
  }) (${KEYWORDS.MULTIPLICATION} ${stringifyArgs(args)})`
41
50
  )
42
51
  const b = evaluate(args[1], env)
43
52
  if (typeof b !== 'number')
44
53
  throw new TypeError(
45
54
  `Second arguments of (${KEYWORDS.MULTIPLICATION}) is not a (${
46
- KEYWORDS.NUMBER_TYPE
55
+ RUNTIME_TYPES.NUMBER
47
56
  }) (${KEYWORDS.MULTIPLICATION} ${stringifyArgs(args)})`
48
57
  )
49
58
  return a * b
@@ -61,7 +70,7 @@ export const keywords = {
61
70
  if (typeof a !== 'number')
62
71
  throw new TypeError(
63
72
  `First argument of (${KEYWORDS.SUBTRACTION}) is not a (${
64
- KEYWORDS.NUMBER_TYPE
73
+ RUNTIME_TYPES.NUMBER
65
74
  }) (${KEYWORDS.SUBTRACTION} ${stringifyArgs(args)})`
66
75
  )
67
76
  if (args.length === 1) return -a
@@ -69,7 +78,7 @@ export const keywords = {
69
78
  if (typeof b !== 'number')
70
79
  throw new TypeError(
71
80
  `Second argument of (${KEYWORDS.SUBTRACTION}) is not a (${
72
- KEYWORDS.NUMBER_TYPE
81
+ RUNTIME_TYPES.NUMBER
73
82
  }) (${KEYWORDS.SUBTRACTION} ${stringifyArgs(args)})`
74
83
  )
75
84
  return a - b
@@ -83,14 +92,14 @@ export const keywords = {
83
92
  if (typeof a !== 'number')
84
93
  throw new TypeError(
85
94
  `First argument of (${KEYWORDS.DIVISION}) is not (${
86
- KEYWORDS.NUMBER_TYPE
95
+ RUNTIME_TYPES.NUMBER
87
96
  }) (${KEYWORDS.DIVISION} ${stringifyArgs(args)})`
88
97
  )
89
98
  const b = evaluate(args[1], env)
90
99
  if (typeof b !== 'number')
91
100
  throw new TypeError(
92
101
  `Second argument of (${KEYWORDS.DIVISION}) is not (${
93
- KEYWORDS.NUMBER_TYPE
102
+ RUNTIME_TYPES.NUMBER
94
103
  }) (${KEYWORDS.DIVISION} ${stringifyArgs(args)})`
95
104
  )
96
105
  if (b === 0)
@@ -116,14 +125,14 @@ export const keywords = {
116
125
  if (typeof a !== 'number')
117
126
  throw new TypeError(
118
127
  `First argument of (${KEYWORDS.REMAINDER_OF_DIVISION}) is not (${
119
- KEYWORDS.NUMBER_TYPE
128
+ RUNTIME_TYPES.NUMBER
120
129
  }) (${KEYWORDS.REMAINDER_OF_DIVISION} ${stringifyArgs(args)})`
121
130
  )
122
131
  const b = evaluate(args[1], env)
123
132
  if (typeof b !== 'number')
124
133
  throw new TypeError(
125
134
  `Second argument of (${KEYWORDS.REMAINDER_OF_DIVISION}) is not (${
126
- KEYWORDS.NUMBER_TYPE
135
+ RUNTIME_TYPES.NUMBER
127
136
  }) (${KEYWORDS.REMAINDER_OF_DIVISION} ${stringifyArgs(args)})`
128
137
  )
129
138
  if (b === 0)
@@ -148,7 +157,7 @@ export const keywords = {
148
157
  if (operands.some((x) => typeof x !== 'number'))
149
158
  throw new TypeError(
150
159
  `Not all arguments of (${KEYWORDS.BITWISE_AND}) are ${
151
- KEYWORDS.NUMBER_TYPE
160
+ RUNTIME_TYPES.NUMBER
152
161
  } (${KEYWORDS.BITWISE_AND} ${stringifyArgs(args)})`
153
162
  )
154
163
  return operands.reduce((acc, x) => acc & x)
@@ -164,7 +173,7 @@ export const keywords = {
164
173
  if (typeof operand !== 'number')
165
174
  throw new TypeError(
166
175
  `Argument of (${KEYWORDS.BITWISE_NOT}) is not a (${
167
- KEYWORDS.NUMBER_TYPE
176
+ RUNTIME_TYPES.NUMBER
168
177
  }) (${KEYWORDS.BITWISE_NOT} ${stringifyArgs(args)})`
169
178
  )
170
179
  return ~operand
@@ -181,7 +190,7 @@ export const keywords = {
181
190
  if (typeof a !== 'number' || typeof b !== 'number')
182
191
  throw new TypeError(
183
192
  `Not all arguments of (${KEYWORDS.BITWISE_OR}) are (${
184
- KEYWORDS.NUMBER_TYPE
193
+ RUNTIME_TYPES.NUMBER
185
194
  }) (${KEYWORDS.BITWISE_OR} ${stringifyArgs(args)})`
186
195
  )
187
196
  return a | b
@@ -198,7 +207,7 @@ export const keywords = {
198
207
  if (typeof a !== 'number' || typeof b !== 'number')
199
208
  throw new TypeError(
200
209
  `Not all arguments of (${KEYWORDS.BITWISE_XOR}) are (${
201
- KEYWORDS.NUMBER_TYPE
210
+ RUNTIME_TYPES.NUMBER
202
211
  }) (${KEYWORDS.BITWISE_XOR} ${stringifyArgs(args)})`
203
212
  )
204
213
  return a ^ b
@@ -217,7 +226,7 @@ export const keywords = {
217
226
  if (typeof a !== 'number' || typeof b !== 'number')
218
227
  throw new TypeError(
219
228
  `Not all arguments of (${KEYWORDS.BITWISE_LEFT_SHIFT}) are (${
220
- KEYWORDS.NUMBER_TYPE
229
+ RUNTIME_TYPES.NUMBER
221
230
  }) (${KEYWORDS.BITWISE_LEFT_SHIFT} ${stringifyArgs(args)})`
222
231
  )
223
232
  return a << b
@@ -236,7 +245,7 @@ export const keywords = {
236
245
  if (typeof a !== 'number' || typeof b !== 'number')
237
246
  throw new TypeError(
238
247
  `Not all arguments of (${KEYWORDS.BITWISE_RIGHT_SHIFT}) are (${
239
- KEYWORDS.NUMBER_TYPE
248
+ RUNTIME_TYPES.NUMBER
240
249
  }) (${KEYWORDS.BITWISE_RIGHT_SHIFT} ${stringifyArgs(args)})`
241
250
  )
242
251
  return a >> b
@@ -255,12 +264,12 @@ export const keywords = {
255
264
  if (typeof a !== 'number' || typeof b !== 'number')
256
265
  throw new TypeError(
257
266
  `Not all arguments of (${KEYWORDS.BITWISE_UNSIGNED_RIGHT_SHIFT}) are (${
258
- KEYWORDS.NUMBER_TYPE
267
+ RUNTIME_TYPES.NUMBER
259
268
  }) (${KEYWORDS.BITWISE_UNSIGNED_RIGHT_SHIFT} ${stringifyArgs(args)})`
260
269
  )
261
270
  return a >>> b
262
271
  },
263
- [KEYWORDS.ARRAY_TYPE]: (args, env) => {
272
+ [KEYWORDS.CREATE_ARRAY]: (args, env) => {
264
273
  return args.length ? args.map((x) => evaluate(x, env)) : []
265
274
  },
266
275
  [KEYWORDS.GET_ARRAY]: (args, env) => {
@@ -274,32 +283,32 @@ export const keywords = {
274
283
  if (!Array.isArray(array))
275
284
  throw new TypeError(
276
285
  `First argument of (${KEYWORDS.GET_ARRAY}) must be an (${
277
- KEYWORDS.ARRAY_TYPE
286
+ RUNTIME_TYPES.ARRAY
278
287
  })) (${KEYWORDS.GET_ARRAY} ${stringifyArgs(args)})`
279
288
  )
280
289
  if (array.length === 0)
281
290
  throw new RangeError(
282
291
  `First argument of (${KEYWORDS.GET_ARRAY}) is an empty (${
283
- KEYWORDS.ARRAY_TYPE
292
+ RUNTIME_TYPES.ARRAY
284
293
  })) (${KEYWORDS.GET_ARRAY} ${stringifyArgs(args)}))`
285
294
  )
286
295
  const index = evaluate(args[1], env)
287
296
  if (!Number.isInteger(index))
288
297
  throw new TypeError(
289
298
  `Second argument of (${KEYWORDS.GET_ARRAY}) must be an (32 bit ${
290
- KEYWORDS.NUMBER_TYPE
299
+ RUNTIME_TYPES.NUMBER
291
300
  }) (${index}) (${KEYWORDS.GET_ARRAY} ${stringifyArgs(args)})`
292
301
  )
293
302
  if (index > array.length - 1 || index * -1 > array.length)
294
303
  throw new RangeError(
295
304
  `Second argument of (${KEYWORDS.GET_ARRAY}) is outside of (${
296
- KEYWORDS.ARRAY_TYPE
305
+ RUNTIME_TYPES.ARRAY
297
306
  }) bounds (${index}) (${KEYWORDS.GET_ARRAY} ${stringifyArgs(args)})`
298
307
  )
299
308
  const value = array.at(index)
300
309
  if (value == undefined)
301
310
  throw new RangeError(
302
- `Trying to get a null value in (${KEYWORDS.ARRAY_TYPE}) at (${
311
+ `Trying to get a null value in (${RUNTIME_TYPES.ARRAY}) at (${
303
312
  KEYWORDS.GET_ARRAY
304
313
  }) (${KEYWORDS.GET_ARRAY} ${stringifyArgs(args)})`
305
314
  )
@@ -316,7 +325,7 @@ export const keywords = {
316
325
  if (!Array.isArray(array))
317
326
  throw new TypeError(
318
327
  `First argument of (${KEYWORDS.SET_ARRAY}) must be an (${
319
- KEYWORDS.ARRAY_TYPE
328
+ RUNTIME_TYPES.ARRAY
320
329
  }) but got (${array}) (${KEYWORDS.SET_ARRAY} ${stringifyArgs(args)})`
321
330
  )
322
331
  if (args.length === 1) {
@@ -326,13 +335,13 @@ export const keywords = {
326
335
  if (!Number.isInteger(index) || index < 0)
327
336
  throw new TypeError(
328
337
  `Second argument of (${KEYWORDS.SET_ARRAY}) must be a positive (${
329
- KEYWORDS.NUMBER_TYPE
338
+ RUNTIME_TYPES.NUMBER
330
339
  } integer) (${index}) (${KEYWORDS.SET_ARRAY} ${stringifyArgs(args)})`
331
340
  )
332
341
  if (index > array.length)
333
342
  throw new RangeError(
334
343
  `Second argument of (${KEYWORDS.SET_ARRAY}) is outside of the (${
335
- KEYWORDS.ARRAY_TYPE
344
+ RUNTIME_TYPES.ARRAY
336
345
  }) bounds (index ${index} bounds ${array.length}) (${
337
346
  KEYWORDS.SET_ARRAY
338
347
  } ${stringifyArgs(args)})`
@@ -340,7 +349,7 @@ export const keywords = {
340
349
  const value = evaluate(args[2], env)
341
350
  if (value == undefined)
342
351
  throw new RangeError(
343
- `Trying to set a null value in (${KEYWORDS.ARRAY_TYPE}) at (${
352
+ `Trying to set a null value in (${RUNTIME_TYPES.ARRAY}) at (${
344
353
  KEYWORDS.SET_ARRAY
345
354
  }). (${KEYWORDS.SET_ARRAY} ${stringifyArgs(args)})`
346
355
  )
@@ -359,7 +368,7 @@ export const keywords = {
359
368
  if (!Array.isArray(array))
360
369
  throw new TypeError(
361
370
  `First argument of (${KEYWORDS.ARRAY_LENGTH}) must be an ${
362
- KEYWORDS.ARRAY_TYPE
371
+ RUNTIME_TYPES.ARRAY
363
372
  } (${KEYWORDS.ARRAY_LENGTH} ${stringifyArgs(args)})`
364
373
  )
365
374
  return array.length
@@ -407,13 +416,13 @@ export const keywords = {
407
416
  if (typeof a !== 'number')
408
417
  throw new TypeError(
409
418
  `Invalid use of (${KEYWORDS.EQUAL}), first argument is not an ${
410
- KEYWORDS.NUMBER_TYPE
419
+ RUNTIME_TYPES.NUMBER
411
420
  } (${KEYWORDS.EQUAL} ${stringifyArgs(args)})`
412
421
  )
413
422
  if (typeof b !== 'number')
414
423
  throw new TypeError(
415
424
  `Invalid use of (${KEYWORDS.EQUAL}), second argument are not an ${
416
- KEYWORDS.NUMBER_TYPE
425
+ RUNTIME_TYPES.NUMBER
417
426
  } (${KEYWORDS.EQUAL} ${stringifyArgs(args)})`
418
427
  )
419
428
  return +(a === b)
@@ -430,13 +439,13 @@ export const keywords = {
430
439
  if (typeof a !== 'number')
431
440
  throw new TypeError(
432
441
  `Invalid use of (${KEYWORDS.LESS_THAN}), first argument is not an ${
433
- KEYWORDS.NUMBER_TYPE
442
+ RUNTIME_TYPES.NUMBER
434
443
  } (${KEYWORDS.LESS_THAN} ${stringifyArgs(args)})`
435
444
  )
436
445
  if (typeof b !== 'number')
437
446
  throw new TypeError(
438
447
  `Invalid use of (${KEYWORDS.LESS_THAN}), second argument are not an ${
439
- KEYWORDS.NUMBER_TYPE
448
+ RUNTIME_TYPES.NUMBER
440
449
  } (${KEYWORDS.LESS_THAN} ${stringifyArgs(args)})`
441
450
  )
442
451
  return +(a < b)
@@ -453,14 +462,14 @@ export const keywords = {
453
462
  if (typeof a !== 'number')
454
463
  throw new TypeError(
455
464
  `Invalid use of (${KEYWORDS.GREATHER_THAN}), first argument is not an ${
456
- KEYWORDS.NUMBER_TYPE
465
+ RUNTIME_TYPES.NUMBER
457
466
  } (${KEYWORDS.GREATHER_THAN} ${stringifyArgs(args)})`
458
467
  )
459
468
  if (typeof b !== 'number')
460
469
  throw new TypeError(
461
470
  `Invalid use of (${
462
471
  KEYWORDS.GREATHER_THAN
463
- }), second argument are not an ${KEYWORDS.NUMBER_TYPE} (${
472
+ }), second argument are not an ${RUNTIME_TYPES.NUMBER} (${
464
473
  KEYWORDS.GREATHER_THAN
465
474
  } ${stringifyArgs(args)})`
466
475
  )
@@ -481,7 +490,7 @@ export const keywords = {
481
490
  throw new TypeError(
482
491
  `Invalid use of (${
483
492
  KEYWORDS.GREATHER_THAN_OR_EQUAL
484
- }), first argument is not an ${KEYWORDS.NUMBER_TYPE} (${
493
+ }), first argument is not an ${RUNTIME_TYPES.NUMBER} (${
485
494
  KEYWORDS.GREATHER_THAN_OR_EQUAL
486
495
  } ${stringifyArgs(args)})`
487
496
  )
@@ -489,7 +498,7 @@ export const keywords = {
489
498
  throw new TypeError(
490
499
  `Invalid use of (${
491
500
  KEYWORDS.GREATHER_THAN_OR_EQUAL
492
- }), second argument are not an ${KEYWORDS.NUMBER_TYPE} (${
501
+ }), second argument are not an ${RUNTIME_TYPES.NUMBER} (${
493
502
  KEYWORDS.GREATHER_THAN_OR_EQUAL
494
503
  } ${stringifyArgs(args)})`
495
504
  )
@@ -510,7 +519,7 @@ export const keywords = {
510
519
  throw new TypeError(
511
520
  `Invalid use of (${
512
521
  KEYWORDS.LESS_THAN_OR_EQUAL
513
- }), first argument is not an ${KEYWORDS.NUMBER_TYPE} (${
522
+ }), first argument is not an ${RUNTIME_TYPES.NUMBER} (${
514
523
  KEYWORDS.LESS_THAN_OR_EQUAL
515
524
  } ${stringifyArgs(args)})`
516
525
  )
@@ -518,7 +527,7 @@ export const keywords = {
518
527
  throw new TypeError(
519
528
  `Invalid use of (${
520
529
  KEYWORDS.LESS_THAN_OR_EQUAL
521
- }), second argument are not an ${KEYWORDS.NUMBER_TYPE} (${
530
+ }), second argument are not an ${RUNTIME_TYPES.NUMBER} (${
522
531
  KEYWORDS.LESS_THAN_OR_EQUAL
523
532
  } ${stringifyArgs(args)})`
524
533
  )
@@ -691,7 +700,7 @@ export const keywords = {
691
700
  if (!Array.isArray(expression))
692
701
  throw new TypeError(
693
702
  `Argument of (${KEYWORDS.THROW}) must be an (${
694
- KEYWORDS.ARRAY_TYPE
703
+ RUNTIME_TYPES.ARRAY
695
704
  }) but got (${expression}) (${KEYWORDS.THROW} ${stringifyArgs(args)})`
696
705
  )
697
706
  throw new Error(expression.map((x) => String.fromCharCode(x)).join(''))
@@ -718,7 +727,7 @@ export const keywords = {
718
727
  if (!Array.isArray(expression))
719
728
  throw new TypeError(
720
729
  `Argument of (${KEYWORDS.LOG_STRING}) must be an (${
721
- KEYWORDS.ARRAY_TYPE
730
+ RUNTIME_TYPES.ARRAY
722
731
  }) but got (${expression}) (${KEYWORDS.LOG_STRING} ${stringifyArgs(
723
732
  args
724
733
  )})`
@@ -737,7 +746,7 @@ export const keywords = {
737
746
  if (typeof expression !== 'number')
738
747
  throw new TypeError(
739
748
  `Argument of (${KEYWORDS.LOG_CHAR}) must be a (${
740
- KEYWORDS.NUMBER_TYPE
749
+ RUNTIME_TYPES.NUMBER
741
750
  }) but got (${expression}) (${KEYWORDS.LOG_CHAR} ${stringifyArgs(
742
751
  args
743
752
  )})`
package/src/keywords.js CHANGED
@@ -7,8 +7,7 @@ export const TRUE = 1
7
7
  export const FALSE = 0
8
8
  export const PLACEHOLDER = '.'
9
9
  export const KEYWORDS = {
10
- NUMBER_TYPE: 'number',
11
- ARRAY_TYPE: 'array',
10
+ CREATE_ARRAY: 'array',
12
11
  IDENTITY: 'identity',
13
12
  ARRAY_LENGTH: 'length',
14
13
  IS_ATOM: 'atom?',
@@ -56,3 +55,7 @@ export const TYPES = {
56
55
  [WORD]: 'WORD',
57
56
  [ATOM]: 'ATOM'
58
57
  }
58
+ export const RUNTIME_TYPES = {
59
+ NUMBER: 'number',
60
+ ARRAY: 'array'
61
+ }
package/src/macros.js CHANGED
@@ -146,10 +146,10 @@ export const deSuggarAst = (ast) => {
146
146
  exp.length = 0
147
147
  let temp = exp
148
148
  for (const item of rest) {
149
- temp.push([APPLY, KEYWORDS.ARRAY_TYPE], item, [])
149
+ temp.push([APPLY, KEYWORDS.CREATE_ARRAY], item, [])
150
150
  temp = temp.at(-1)
151
151
  }
152
- temp.push([APPLY, KEYWORDS.ARRAY_TYPE])
152
+ temp.push([APPLY, KEYWORDS.CREATE_ARRAY])
153
153
  }
154
154
  deSuggarAst(exp)
155
155
  break
@@ -386,7 +386,7 @@ export const replaceStrings = (source) => {
386
386
  for (const q of quotes)
387
387
  source = source.replaceAll(
388
388
  q,
389
- `(${KEYWORDS.ARRAY_TYPE} ${[...q.replaceAll('\r', '')]
389
+ `(${KEYWORDS.CREATE_ARRAY} ${[...q.replaceAll('\r', '')]
390
390
  .slice(1, -1)
391
391
  .map((x) => x.charCodeAt(0))
392
392
  .join(' ')})`
@@ -395,9 +395,9 @@ export const replaceStrings = (source) => {
395
395
  }
396
396
  export const replaceQuotes = (source) =>
397
397
  source
398
- .replaceAll(/\'\(/g, `(${KEYWORDS.ARRAY_TYPE} `)
398
+ .replaceAll(/\'\(/g, `(${KEYWORDS.CREATE_ARRAY} `)
399
399
  .replaceAll(/\`\(/g, `(${SUGGAR.LIST_TYPE} `)
400
- .replaceAll(/\(\)/g, `(${KEYWORDS.ARRAY_TYPE})`)
400
+ .replaceAll(/\(\)/g, `(${KEYWORDS.CREATE_ARRAY})`)
401
401
  export const deSuggarSource = (source) => replaceQuotes(replaceStrings(source))
402
402
  export const handleUnbalancedQuotes = (source) => {
403
403
  const diff = (source.match(/\"/g) ?? []).length % 2
package/src/utils.js CHANGED
@@ -58,7 +58,7 @@ export const stringifyType = (type) => {
58
58
  if (!isLeaf(type)) {
59
59
  const [car] = type
60
60
  if (car == undefined) return '(array)'
61
- else if (car[TYPE] === APPLY && car[VALUE] === KEYWORDS.ARRAY_TYPE)
61
+ else if (car[TYPE] === APPLY && car[VALUE] === KEYWORDS.CREATE_ARRAY)
62
62
  return `(array ${type
63
63
  .map((t) => stringifyType(t))
64
64
  .join(' ')
@@ -83,15 +83,18 @@ export const stringifyArgs = (args) =>
83
83
  .replace(new RegExp(/"/g), '')
84
84
  )
85
85
  .join(' ')
86
+ const KEYWORDS_SET = Object.values(KEYWORDS).reduce((a, b) => {
87
+ a.add(b)
88
+ return a
89
+ }, new Set())
86
90
  export const isForbiddenVariableName = (name) => {
87
91
  switch (name) {
88
92
  case '_':
89
- case KEYWORDS.DEFINE_VARIABLE:
90
93
  case OPTIMIZATIONS.RECURSION:
91
94
  case OPTIMIZATIONS.CACHE:
92
95
  return true
93
96
  default:
94
- return !isNaN(name[0])
97
+ return KEYWORDS_SET.has(name) || !isNaN(name[0])
95
98
  }
96
99
  }
97
100
  export const isEqual = (a, b) =>