fez-lisp 1.6.27 → 1.6.30
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/README.md +33 -4
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/debugger.js +1191 -0
- package/src/keywords.js +0 -2
- package/src/parser.js +9 -0
- package/src/types.js +0 -18
- package/src/utils.js +13 -7
package/src/keywords.js
CHANGED
package/src/parser.js
CHANGED
@@ -42,6 +42,15 @@ export const LISP = {
|
|
42
42
|
.join(' ')})`
|
43
43
|
else return array
|
44
44
|
},
|
45
|
+
serialise: (arg) => {
|
46
|
+
if (typeof arg === 'number' || typeof arg === 'string')
|
47
|
+
return arg.toString()
|
48
|
+
else if (Array.isArray(arg))
|
49
|
+
return arg.length
|
50
|
+
? `[${arg.map((a) => LISP.serialise(a)).join(' ')}]`
|
51
|
+
: '[]'
|
52
|
+
else return '(lambda)'
|
53
|
+
},
|
45
54
|
json: (item) => {
|
46
55
|
if (item === null) return 0
|
47
56
|
else if (typeof item === 'boolean') return item
|
package/src/types.js
CHANGED
@@ -464,24 +464,6 @@ export const SPECIAL_FORM_TYPES = {
|
|
464
464
|
[RETURNS]: [UNKNOWN]
|
465
465
|
}
|
466
466
|
},
|
467
|
-
[DEBUG.LIST_THEMES]: {
|
468
|
-
[STATS]: {
|
469
|
-
[TYPE_PROP]: [APPLY],
|
470
|
-
[SIGNATURE]: DEBUG.LIST_THEMES,
|
471
|
-
retried: Infinity,
|
472
|
-
[ARG_COUNT]: VARIADIC,
|
473
|
-
[RETURNS]: [UNKNOWN]
|
474
|
-
}
|
475
|
-
},
|
476
|
-
[DEBUG.SET_THEME]: {
|
477
|
-
[STATS]: {
|
478
|
-
[TYPE_PROP]: [APPLY],
|
479
|
-
[SIGNATURE]: DEBUG.SET_THEME,
|
480
|
-
retried: Infinity,
|
481
|
-
[ARG_COUNT]: VARIADIC,
|
482
|
-
[RETURNS]: [UNKNOWN]
|
483
|
-
}
|
484
|
-
},
|
485
467
|
[KEYWORDS.BLOCK]: {
|
486
468
|
[STATS]: {
|
487
469
|
[TYPE_PROP]: [APPLY],
|
package/src/utils.js
CHANGED
@@ -26,6 +26,7 @@ import {
|
|
26
26
|
withCtxTypes
|
27
27
|
} from './types.js'
|
28
28
|
import { compile } from './compiler.js'
|
29
|
+
import { debugStackToString, startDebug, debug } from './debugger.js'
|
29
30
|
export const logError = (error) =>
|
30
31
|
console.log('\x1b[31m', `\n${error}\n`, '\x1b[0m')
|
31
32
|
export const logSuccess = (output) => console.log('\x1b[32m', output, '\x1b[0m')
|
@@ -365,6 +366,9 @@ export const isInputVariable = (x) =>
|
|
365
366
|
x[1][VALUE] === 'INPUT'
|
366
367
|
|
367
368
|
export const UTILS = {
|
369
|
+
debug,
|
370
|
+
startDebug,
|
371
|
+
debugStackToString,
|
368
372
|
handleUnbalancedQuotes,
|
369
373
|
handleUnbalancedParens,
|
370
374
|
logError,
|
@@ -529,6 +533,13 @@ export const fez = (ast, c = false) => {
|
|
529
533
|
|
530
534
|
export const toTypedAst = (ast, userDefinedTypes) => {
|
531
535
|
try {
|
536
|
+
const typeSet = (Types, name, env, exp) => {
|
537
|
+
Types.set(withScope(name, env), () => {
|
538
|
+
if (exp.at(-1)[TYPE] !== FLAG) exp.push(formatAstTypes(name, env))
|
539
|
+
else exp[exp.length - 1] = formatAstTypes(name, env)
|
540
|
+
return ''
|
541
|
+
})
|
542
|
+
}
|
532
543
|
const types = typeCheck(
|
533
544
|
ast,
|
534
545
|
withCtxTypes(
|
@@ -539,19 +550,14 @@ export const toTypedAst = (ast, userDefinedTypes) => {
|
|
539
550
|
}
|
540
551
|
: definedTypes(filteredDefinedTypes(ast, std, stdT))
|
541
552
|
),
|
542
|
-
|
543
|
-
Types.set(withScope(name, env), () => {
|
544
|
-
if (exp.at(-1)[TYPE] !== FLAG) exp.push(formatAstTypes(name, env))
|
545
|
-
else exp[exp.length - 1] = formatAstTypes(name, env)
|
546
|
-
return ''
|
547
|
-
})
|
548
|
-
}
|
553
|
+
typeSet
|
549
554
|
)
|
550
555
|
for (const v of types[1].values()) v()
|
551
556
|
// types[0][1][1].slice(1)
|
552
557
|
return types
|
553
558
|
} catch (error) {
|
554
559
|
logError(error.message)
|
560
|
+
return []
|
555
561
|
}
|
556
562
|
}
|
557
563
|
export const atst = (ast, ctx) => toTypedAst(ast, ctx)[0]
|