fez-lisp 1.5.123 → 1.5.125

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.5.123",
5
+ "version": "1.5.125",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/compiler.js CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  TYPE,
7
7
  VALUE,
8
8
  WORD,
9
- STATIC_TYPES
9
+ STATIC_TYPES,
10
+ DEBUG
10
11
  } from './keywords.js'
11
12
  import { leaf, isLeaf, AST } from './parser.js'
12
13
  import { FALSE_WORD, TRUE_WORD } from './types.js'
@@ -274,6 +275,9 @@ const comp = (tree, Drill) => {
274
275
  case STATIC_TYPES.ATOM:
275
276
  case STATIC_TYPES.PREDICATE:
276
277
  case STATIC_TYPES.ANY:
278
+ case DEBUG.ASSERT:
279
+ case DEBUG.LOG:
280
+ case DEBUG.STRING:
277
281
  return compile(tail[0], Drill)
278
282
 
279
283
  default: {
@@ -1,14 +1,6 @@
1
1
  import { AST, isLeaf } from './parser.js'
2
- import {
3
- APPLY,
4
- ATOM,
5
- KEYWORDS,
6
- PREDICATE_SUFFIX,
7
- TYPE,
8
- VALUE,
9
- WORD
10
- } from './keywords.js'
11
- import { getPrefix, getSuffix, shake, wrapInBlock } from './utils.js'
2
+ import { APPLY, ATOM, KEYWORDS, TYPE, VALUE, WORD } from './keywords.js'
3
+ import { getPrefix, shake, wrapInBlock } from './utils.js'
12
4
  import std from '../lib/baked/std.js'
13
5
  export const OPTIMIZATIONS = {
14
6
  RECURSION: 'recursive',
@@ -24,7 +16,7 @@ const deepTransform = (predicate, transform, tree) => {
24
16
  else deepTransform(predicate, transform, leaf)
25
17
  }
26
18
  }
27
- export const enhance = (ast) => {
19
+ const opt = (ast) => {
28
20
  const evaluate = (exp) => {
29
21
  const [first, ...rest] = isLeaf(exp) ? [exp] : exp
30
22
  if (first != undefined) {
@@ -221,11 +213,12 @@ export const enhance = (ast) => {
221
213
  default:
222
214
  break
223
215
  }
224
-
225
216
  for (const r of rest) evaluate(r)
226
217
  }
227
218
  }
228
- evaluate(AST.parse(AST.stringify(ast)))
219
+ evaluate(ast)
229
220
  const shaked = shake(ast[1][1].slice(1), std)
230
221
  return wrapInBlock(shaked)
231
222
  }
223
+
224
+ export const enhance = (ast) => opt(AST.parse(AST.stringify(ast))[0])
package/src/utils.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  deSuggarSource,
16
16
  handleUnbalancedQuotes
17
17
  } from './macros.js'
18
- import { OPTIMIZATIONS } from './enchance.js'
18
+ import { OPTIMIZATIONS } from './enhance.js'
19
19
  export const logError = (error) =>
20
20
  console.log('\x1b[31m', `\n${error}\n`, '\x1b[0m')
21
21
  export const logSuccess = (output) => console.log('\x1b[32m', output, '\x1b[0m')