fez-lisp 1.6.33 → 1.6.34

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/debugger.js +25 -17
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.6.33",
5
+ "version": "1.6.34",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/debugger.js CHANGED
@@ -17,7 +17,11 @@ import {
17
17
  } from './keywords.js'
18
18
  import { isLeaf, LISP } from './parser.js'
19
19
  import { definedTypes, filteredDefinedTypes, withCtxTypes } from './types.js'
20
- import { isForbiddenVariableName, removeNoCode } from './utils.js'
20
+ import {
21
+ isForbiddenVariableName,
22
+ removeNoCode,
23
+ stringifyArgs
24
+ } from './utils.js'
21
25
  const keywords = {
22
26
  [KEYWORDS.LOOP]: (args, env) => {
23
27
  if (args.length != 2)
@@ -886,24 +890,28 @@ export const debugStackToString = (stack) =>
886
890
  stack.map(({ source, result }) => `${source}\n${result}`).join('\n')
887
891
  export const startDebug = (ast, speed = 250, start, end) => {
888
892
  debugStack.length = 0
889
- evaluate(ast)
890
- start = start ? debugStack.findIndex(start) : 0
891
- end = end ? debugStack.findIndex(end) + 1 : debugStack.length
892
- const stack = debugStack.slice(start, end)
893
- if (speed !== 0) {
894
- stack.reverse()
895
- const rec = () => {
896
- setTimeout(() => {
897
- if (stack.length) {
898
- const { source, result } = stack.pop()
899
- console.log(`\x1b[31m${source}\x1b[32m\n${result}\x1b[0m`)
900
- rec()
901
- }
902
- }, speed)
893
+ try {
894
+ evaluate(enhance(ast))
895
+ start = start ? debugStack.findIndex(start) : 0
896
+ end = end ? debugStack.findIndex(end) + 1 : debugStack.length
897
+ const stack = debugStack.slice(start, end)
898
+ if (speed !== 0) {
899
+ stack.reverse()
900
+ const rec = () => {
901
+ setTimeout(() => {
902
+ if (stack.length) {
903
+ const { source, result } = stack.pop()
904
+ console.log(`\x1b[31m${source}\x1b[32m\n${result}\x1b[0m`)
905
+ rec()
906
+ }
907
+ }, speed)
908
+ }
909
+ rec()
903
910
  }
904
- rec()
911
+ return [stack, null]
912
+ } catch (error) {
913
+ return [null, error]
905
914
  }
906
- return stack
907
915
  }
908
916
 
909
917
  // const types = typeCheck(std[0], withCtxTypes(definedTypes(stdT)))[1]