fez-lisp 1.4.5 → 1.4.6
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 +1 -1
- package/src/interpreter.js +5 -1
- package/src/utils.js +0 -33
package/package.json
CHANGED
package/src/interpreter.js
CHANGED
@@ -774,7 +774,11 @@ export const keywords = {
|
|
774
774
|
writable: true
|
775
775
|
})
|
776
776
|
}
|
777
|
-
if (
|
777
|
+
if (
|
778
|
+
name &&
|
779
|
+
Array.isArray(env[DEBUG.CALLSTACK]) &&
|
780
|
+
name !== env[DEBUG.CALLSTACK].at(-1)
|
781
|
+
)
|
778
782
|
env[DEBUG.CALLSTACK].push(name)
|
779
783
|
return evaluate(body, localEnv)
|
780
784
|
}
|
package/src/utils.js
CHANGED
@@ -232,39 +232,6 @@ export const wrapInBlock = (ast) => [
|
|
232
232
|
]
|
233
233
|
export const interpret = (ast, keywords) =>
|
234
234
|
ast.reduce((_, x) => evaluate(x, keywords), 0)
|
235
|
-
export const fez = (source, options = {}) => {
|
236
|
-
const env = { ...keywords }
|
237
|
-
try {
|
238
|
-
if (typeof source === 'string') {
|
239
|
-
source = deSuggarSource(source)
|
240
|
-
const valid = handleUnbalancedQuotes(
|
241
|
-
handleUnbalancedParens(removeNoCode(source))
|
242
|
-
)
|
243
|
-
const code = !options.mutation ? removeMutation(valid) : valid
|
244
|
-
if (!code.length && options.throw) throw new Error('Nothing to parse!')
|
245
|
-
const parsed = LISP.parse(code)
|
246
|
-
const scope = deSuggarAst(parsed)
|
247
|
-
const ast = wrapInBlock(shake(scope, std))
|
248
|
-
// if (options.check) typeCheck(ast)
|
249
|
-
if (options.compile) return compile(ast)
|
250
|
-
return evaluate(ast, env)
|
251
|
-
} else if (Array.isArray(source)) {
|
252
|
-
const ast = !options.mutation
|
253
|
-
? AST.parse(AST.stringify(source).replace(new RegExp(/!/g), 'ǃ'))
|
254
|
-
: source
|
255
|
-
if (options.compile) return compile(ast)
|
256
|
-
return evaluate(ast, env)
|
257
|
-
} else {
|
258
|
-
throw new Error('Source has to be either a lisp source code or an AST')
|
259
|
-
}
|
260
|
-
} catch (error) {
|
261
|
-
const err = error.message.replace("'[object Array]'", '(array)')
|
262
|
-
// .replace('object', '(array)')
|
263
|
-
logError(err)
|
264
|
-
if (options.throw) throw err
|
265
|
-
return err
|
266
|
-
}
|
267
|
-
}
|
268
235
|
export const shake = (parsed, std) => treeShake(parsed, std).concat(parsed)
|
269
236
|
export const tree = (source, std) =>
|
270
237
|
std
|