fez-lisp 1.4.7 → 1.4.8

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/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { evaluate } from './src/evaluator.js'
2
2
  import { compile } from './src/compiler.js'
3
3
  import { debug, parse } from './src/utils.js'
4
- export { parse, evaluate, compile, debug }
4
+ import { LISP, AST } from './src/parser.js'
5
+ export { parse, evaluate, compile, debug, LISP, AST }
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.4.7",
5
+ "version": "1.4.8",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/macros.js CHANGED
@@ -645,26 +645,6 @@ const iron = (scope) => {
645
645
  for (let i = 0; i < copy.length; ++i) scope[i] = copy[i]
646
646
  }
647
647
  }
648
- const iron2 = (scope, exp) => {
649
- const key = AST.stringify(exp)
650
- const indexes = new Set(
651
- scope
652
- .map((x, i) => (AST.stringify(x) === key ? i : -1))
653
- .filter((x) => x !== -1)
654
- )
655
- console.log(indexes)
656
- if (indexes.size) {
657
- const copy = []
658
- for (let i = 0; i < scope.length; ++i) {
659
- if (indexes.has(i)) {
660
- copy.push(...scope[i][0])
661
- } else {
662
- copy.push(scope[i])
663
- }
664
- }
665
- for (let i = 0; i < copy.length; ++i) scope[i] = copy[i]
666
- }
667
- }
668
648
  export const replaceQuotes = (source) =>
669
649
  source
670
650
  .replaceAll(/\[/g, `(${KEYWORDS.CREATE_ARRAY} `)
package/src/utils.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  WORD
14
14
  } from './keywords.js'
15
15
  import { evaluate } from './evaluator.js'
16
- import { AST, isLeaf, LISP } from './parser.js'
16
+ import { isLeaf, LISP } from './parser.js'
17
17
  import {
18
18
  deSuggarAst,
19
19
  deSuggarSource,
@@ -259,6 +259,7 @@ export const ast = (source, deps) =>
259
259
  )
260
260
 
261
261
  export const astWithStd = (source) => wrapInBlock(shake(prep(source), std))
262
+ export const unwrapped = (source) => shake(prep(source), std)
262
263
  export const parse = (source) =>
263
264
  wrapInBlock(
264
265
  shake(
@@ -284,28 +285,7 @@ const identity = (name) => [
284
285
  [1, 'x']
285
286
  ]
286
287
  ]
287
- // export const result = (ast) => {
288
- // try {
289
- // return { output: evaluate(ast, keywords), error: null }
290
- // } catch (error) {
291
- // const isMaxCallStack =
292
- // error.message.includes('Maximum call stack size exceeded') ||
293
- // error.message.includes('too much recursion')
294
- // return {
295
- // output: null,
296
- // error: {
297
- // stack: [...callStack],
298
- // message: isMaxCallStack
299
- // ? error
300
- // : `${error}\n${callStack
301
- // .reverse()
302
- // .map((x, i) => `${Array(i + 2).join(' ')}(${x} ...)`)
303
- // .join('\n')}`
304
- // }
305
- // }
306
- // }
307
- // }
308
- export const debug = (ast) => {
288
+ export const debug = (ast, onSuccess = compile) => {
309
289
  const debugEnv = {
310
290
  ...keywords,
311
291
  [DEBUG.CALLSTACK]: [KEYWORDS.BLOCK],
@@ -421,7 +401,7 @@ export const debug = (ast) => {
421
401
  block.unshift(temp, identity(DEBUG.LOG), identity(DEBUG.ASSERT))
422
402
  return {
423
403
  evaluated,
424
- compiled: compile(ast),
404
+ compiled: onSuccess(ast),
425
405
  error: null
426
406
  }
427
407
  } catch (error) {