fez-lisp 1.2.0 → 1.2.1
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 +9 -8
- package/src/keywords.js +7 -0
package/package.json
CHANGED
package/src/interpreter.js
CHANGED
@@ -6,7 +6,8 @@ import {
|
|
6
6
|
APPLY,
|
7
7
|
ATOM,
|
8
8
|
FALSE,
|
9
|
-
TRUE
|
9
|
+
TRUE,
|
10
|
+
TYPES,
|
10
11
|
} from './keywords.js'
|
11
12
|
import { evaluate } from './evaluator.js'
|
12
13
|
import { isLeaf } from './parser.js'
|
@@ -165,7 +166,7 @@ const keywords = {
|
|
165
166
|
const condition = evaluate(args[0], env)
|
166
167
|
if (condition !== FALSE && condition !== TRUE)
|
167
168
|
throw new TypeError(
|
168
|
-
`Condition of (${KEYWORDS.IF}) must be
|
169
|
+
`Condition of (${KEYWORDS.IF}) must be ${TRUE} or ${FALSE} but got ${condition}`
|
169
170
|
)
|
170
171
|
return condition
|
171
172
|
? evaluate(args[1], env)
|
@@ -186,7 +187,7 @@ const keywords = {
|
|
186
187
|
const condition = evaluate(args[i], env)
|
187
188
|
if (condition !== FALSE && condition !== TRUE)
|
188
189
|
throw new TypeError(
|
189
|
-
`Condition of (${KEYWORDS.CONDITION}) must be
|
190
|
+
`Condition of (${KEYWORDS.CONDITION}) must be ${TRUE} or ${FALSE} but got ${condition}`
|
190
191
|
)
|
191
192
|
if (condition) return evaluate(args[i + 1], env)
|
192
193
|
}
|
@@ -422,7 +423,7 @@ const keywords = {
|
|
422
423
|
circuit = evaluate(args[i], env)
|
423
424
|
if (circuit !== FALSE && circuit !== TRUE)
|
424
425
|
throw new TypeError(
|
425
|
-
`Condition of (${KEYWORDS.AND}) must be
|
426
|
+
`Condition of (${KEYWORDS.AND}) must be ${TRUE} or ${FALSE} but got ${circuit}`
|
426
427
|
)
|
427
428
|
if (circuit) continue
|
428
429
|
else return 0
|
@@ -430,7 +431,7 @@ const keywords = {
|
|
430
431
|
const end = evaluate(args.at(-1), env)
|
431
432
|
if (end !== FALSE && end !== TRUE)
|
432
433
|
throw new TypeError(
|
433
|
-
`Condition of (${KEYWORDS.AND}) must be
|
434
|
+
`Condition of (${KEYWORDS.AND}) must be ${TRUE} or ${FALSE} but got ${end}`
|
434
435
|
)
|
435
436
|
return end
|
436
437
|
},
|
@@ -446,7 +447,7 @@ const keywords = {
|
|
446
447
|
circuit = evaluate(args[i], env)
|
447
448
|
if (circuit !== FALSE && circuit !== TRUE)
|
448
449
|
throw new TypeError(
|
449
|
-
`Condition of (${KEYWORDS.OR}) must be
|
450
|
+
`Condition of (${KEYWORDS.OR}) must be ${TRUE} or ${FALSE} but got ${circuit}`
|
450
451
|
)
|
451
452
|
if (circuit) return 1
|
452
453
|
else continue
|
@@ -454,7 +455,7 @@ const keywords = {
|
|
454
455
|
const end = evaluate(args.at(-1), env)
|
455
456
|
if (end !== FALSE && end !== TRUE)
|
456
457
|
throw new TypeError(
|
457
|
-
`Condition of (${KEYWORDS.OR}) must be
|
458
|
+
`Condition of (${KEYWORDS.OR}) must be ${TRUE} or ${FALSE} but got ${end}`
|
458
459
|
)
|
459
460
|
return end
|
460
461
|
},
|
@@ -498,7 +499,7 @@ const keywords = {
|
|
498
499
|
throw new SyntaxError(
|
499
500
|
`First argument of (${
|
500
501
|
KEYWORDS.DEFINE_VARIABLE
|
501
|
-
}) must be word but got ${type} (${
|
502
|
+
}) must be word but got ${TYPES[type]} (${
|
502
503
|
KEYWORDS.DEFINE_VARIABLE
|
503
504
|
} ${stringifyArgs(args)})`
|
504
505
|
)
|