fez-lisp 1.5.41 → 1.5.42
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/check.js +637 -651
- package/src/compiler.js +0 -2
- package/src/evaluator.js +0 -1
- package/src/parser.js +2 -8
package/src/compiler.js
CHANGED
package/src/evaluator.js
CHANGED
package/src/parser.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { APPLY, ATOM, TYPE, WORD, VALUE } from './keywords.js'
|
2
2
|
export const leaf = (type, value) => [type, value]
|
3
3
|
export const isLeaf = ([car]) => car === APPLY || car === ATOM || car === WORD
|
4
|
-
export const toPair = (exp) => []
|
5
4
|
export const LISP = {
|
6
5
|
parse: (source) => {
|
7
6
|
const tree = []
|
@@ -30,14 +29,13 @@ export const LISP = {
|
|
30
29
|
return tree
|
31
30
|
},
|
32
31
|
stringify: (array) => {
|
33
|
-
if (array
|
34
|
-
else if (typeof array === 'function') return '(lambda)'
|
32
|
+
if (typeof array === 'function') return '(lambda)'
|
35
33
|
else if (typeof array === 'boolean') return +array
|
36
34
|
else if (typeof array === 'object')
|
37
35
|
if (Array.isArray(array))
|
38
36
|
return array.length
|
39
37
|
? `(array ${array.map(LISP.stringify).join(' ')})`
|
40
|
-
: '()'
|
38
|
+
: '(array)'
|
41
39
|
else
|
42
40
|
return `(array ${array
|
43
41
|
.map(([key, value]) => `("${key}" ${LISP.stringify(value)})`)
|
@@ -48,7 +46,6 @@ export const LISP = {
|
|
48
46
|
const dfs = (exp) => {
|
49
47
|
let out = ''
|
50
48
|
const [head, ...tail] = isLeaf(exp) ? [exp] : exp
|
51
|
-
if (head == undefined) return (out += '(array)')
|
52
49
|
switch (head[TYPE]) {
|
53
50
|
case WORD:
|
54
51
|
out += head[VALUE]
|
@@ -110,9 +107,6 @@ export const AST = {
|
|
110
107
|
const dfs = (exp) => {
|
111
108
|
let out = ''
|
112
109
|
const [head, ...tail] = isLeaf(exp) ? [exp] : exp
|
113
|
-
if (head == undefined)
|
114
|
-
return (out +=
|
115
|
-
'(Expression::Apply(vec![Expression::Word("array".to_string())]))')
|
116
110
|
switch (head[TYPE]) {
|
117
111
|
case WORD:
|
118
112
|
out += `Expression::Word("${head[VALUE]}".to_string())`
|