fez-lisp 1.3.13 → 1.3.14

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.
@@ -132,7 +132,6 @@ export const SLICE = [
132
132
  [0, 'lambda'],
133
133
  [1, 'arr'],
134
134
  [1, 'start'],
135
- [1, 'end'],
136
135
  [
137
136
  [0, 'do'],
138
137
  [
@@ -140,7 +139,10 @@ export const SLICE = [
140
139
  [1, 'bounds'],
141
140
  [
142
141
  [0, '-'],
143
- [1, 'end'],
142
+ [
143
+ [0, 'length'],
144
+ [1, 'arr']
145
+ ],
144
146
  [1, 'start']
145
147
  ]
146
148
  ],
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.13",
5
+ "version": "1.3.14",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/macros.js CHANGED
@@ -385,52 +385,51 @@ export const deSuggarAst = (ast, scope) => {
385
385
  let newScope
386
386
  exp.length = 0
387
387
  switch (left[0][VALUE]) {
388
- case KEYWORDS.CREATE_ARRAY:
389
- {
390
- if (
391
- !isLeaf(right) &&
392
- right[0][TYPE] === APPLY &&
393
- right[0][VALUE] === KEYWORDS.CREATE_ARRAY
394
- ) {
395
- const values = right.slice(1)
396
- newScope = indexes.map((i) => [
397
- [APPLY, KEYWORDS.DEFINE_VARIABLE],
398
- vars[i],
399
- values[i]
400
- ])
401
- if (isSlicing)
402
- newScope.push([
388
+ case KEYWORDS.CREATE_ARRAY:
389
+ {
390
+ if (
391
+ !isLeaf(right) &&
392
+ right[0][TYPE] === APPLY &&
393
+ right[0][VALUE] === KEYWORDS.CREATE_ARRAY
394
+ ) {
395
+ const values = right.slice(1)
396
+ newScope = indexes.map((i) => [
403
397
  [APPLY, KEYWORDS.DEFINE_VARIABLE],
404
- lastLeft,
405
- [
406
- [APPLY, KEYWORDS.CREATE_ARRAY],
407
- ...values.slice(indexes.at(-1) + 1)
408
- ]
398
+ vars[i],
399
+ values[i]
409
400
  ])
410
- } else {
411
- newScope = indexes.map((i) => [
412
- [APPLY, KEYWORDS.DEFINE_VARIABLE],
413
- vars[i],
414
- [[APPLY, KEYWORDS.GET_ARRAY], right, [ATOM, i]]
415
- ])
416
- if (isSlicing)
417
- newScope.push([
401
+ if (isSlicing)
402
+ newScope.push([
403
+ [APPLY, KEYWORDS.DEFINE_VARIABLE],
404
+ lastLeft,
405
+ [
406
+ [APPLY, KEYWORDS.CREATE_ARRAY],
407
+ ...values.slice(indexes.at(-1) + 1)
408
+ ]
409
+ ])
410
+ } else {
411
+ newScope = indexes.map((i) => [
418
412
  [APPLY, KEYWORDS.DEFINE_VARIABLE],
419
- lastLeft,
420
- [
421
- [APPLY, KEYWORDS.CALL_FUNCTION],
422
- SLICE,
423
- right,
424
- [ATOM, indexes.at(-1) + 1],
425
- [[APPLY, KEYWORDS.ARRAY_LENGTH], right]
426
- ]
427
- ])
413
+ vars[i],
414
+ [[APPLY, KEYWORDS.GET_ARRAY], right, [ATOM, i]]
415
+ ])
416
+ if (isSlicing)
417
+ newScope.push([
418
+ [APPLY, KEYWORDS.DEFINE_VARIABLE],
419
+ lastLeft,
420
+ [
421
+ [APPLY, KEYWORDS.CALL_FUNCTION],
422
+ SLICE,
423
+ right,
424
+ [ATOM, indexes.at(-1) + 1]
425
+ ]
426
+ ])
427
+ }
428
+ exp.iron = true
429
+ exp.push(newScope)
430
+ deSuggarAst(exp)
428
431
  }
429
- exp.iron = true
430
- exp.push(newScope)
431
- deSuggarAst(exp)
432
- }
433
- break
432
+ break
434
433
  }
435
434
  }
436
435
  }
@@ -439,9 +438,10 @@ export const deSuggarAst = (ast, scope) => {
439
438
  prev = first
440
439
  }
441
440
  break
442
- default: {
443
- iron(scope)
444
- for (const e of exp) evaluate(e)
441
+ default:
442
+ {
443
+ iron(scope)
444
+ for (const e of exp) evaluate(e)
445
445
  }
446
446
  break
447
447
  }
@@ -469,23 +469,23 @@ export const replaceStrings = (source) => {
469
469
  }
470
470
  const iron = (scope) => {
471
471
  const indecies = scope
472
- .map((x, i) => {
473
- return x.iron ? i : -1
474
- })
475
- .filter((x) => x !== -1)
476
- if (indecies.length) {
477
- const set = new Set(indecies)
478
- const copy = []
479
- for (let i = 0; i < scope.length; ++i) {
480
- if (set.has(i)) {
481
- delete scope[i].iron
482
- copy.push(...scope[i][0])
483
- } else {
484
- copy.push(scope[i])
472
+ .map((x, i) => {
473
+ return x.iron ? i : -1
474
+ })
475
+ .filter((x) => x !== -1)
476
+ if (indecies.length) {
477
+ const set = new Set(indecies)
478
+ const copy = []
479
+ for (let i = 0; i < scope.length; ++i) {
480
+ if (set.has(i)) {
481
+ delete scope[i].iron
482
+ copy.push(...scope[i][0])
483
+ } else {
484
+ copy.push(scope[i])
485
+ }
485
486
  }
487
+ for (let i = 0; i < copy.length; ++i) scope[i] = copy[i]
486
488
  }
487
- for (let i = 0; i < copy.length; ++i) scope[i] = copy[i]
488
- }
489
489
  }
490
490
  export const replaceQuotes = (source) =>
491
491
  source