Skip to content

Commit d49e71a

Browse files
committed
Full JS compatibility
1 parent 0f7931b commit d49e71a

File tree

7 files changed

+96
-88
lines changed

7 files changed

+96
-88
lines changed

LANGUAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Or defining functions:
5959
returnExpression3
6060
)
6161
```
62-
`->` a lambda define an anonimous function:
62+
`->` a lambda define an anonimous function without capture:
6363
```lisp
6464
(-> [param1 param2 ... paramN] expression)
6565
(-> param expression)

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ console.log(result)
3434

3535
- Port pausable interpreter to TypeScript
3636
- Implement a pausable interpreter
37-
- Make the build env with FuseBox :fire:
3837
- Improve README and docs
3938
- Support for comments (`;`) as a special form
4039
- Implement code generation
@@ -50,3 +49,7 @@ console.log(result)
5049
## Docs
5150

5251
- Language is described in LANGUAGE.md
52+
53+
## TODOs
54+
55+
- Tests lambdas to capture values

interpreter.spec.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ test('interpreter', async t => {
66

77
t.deepEqual(
88
await evalAst(makeAPI({}))(['+', '1', '2', '3']),
9-
['atom', 6],
9+
6,
1010
'Simple expression'
1111
)
1212

1313
t.deepEqual(
1414
await evalAst(makeAPI({}))(['*', '2', '3', ['-', '3', '4'], '2', ['/', '1', '2']]),
15-
['atom', -6],
15+
-6,
1616
'Composed expression'
1717
)
1818

1919
t.deepEqual(
20-
await evalAst(makeAPI({ x: ['atom', 5], y: ['atom', 3] }))(['*', 'x', 'y', ['-', '3', '4'], '2', ['/', '1', '2']]),
21-
['atom', -15],
20+
await evalAst(makeAPI({ x: 5, y: 3 }))(['*', 'x', 'y', ['-', '3', '4'], '2', ['/', '1', '2']]),
21+
-15,
2222
'Composed expression with env constants'
2323
)
2424

@@ -29,20 +29,20 @@ test('interpreter', async t => {
2929
[['cat', '"a"', '"1"'], 11],
3030
],
3131
),
32-
['atom', 11],
32+
11,
3333
'Computed operation name'
3434
)
3535

3636
t.deepEqual(
37-
await evalAst(makeAPI({ x: ['atom', 5], y: ['atom', 3] }))(
37+
await evalAst(makeAPI({ x: 5, y: 3 }))(
3838
['process',
3939
['def', 'a', '2'],
4040
['def', 'b', '3'],
4141
['def', 'x', ['+', 'a', '3', 'b', ['*', 'b', 'a']]],
4242
['+', 'y', 'x'],
4343
]
4444
),
45-
['atom', 17],
45+
17,
4646
'Process expression with env constants'
4747
)
4848

@@ -53,7 +53,7 @@ test('interpreter', async t => {
5353
['identity', 7],
5454
]
5555
),
56-
['atom', 7],
56+
7,
5757
'Identity procedure definition / application'
5858
)
5959

@@ -67,7 +67,7 @@ test('interpreter', async t => {
6767
['inc', 7],
6868
]
6969
),
70-
['atom', 8],
70+
8,
7171
'Procedure declaration / application'
7272
)
7373

@@ -81,7 +81,7 @@ test('interpreter', async t => {
8181
['sum', 7, 8],
8282
]
8383
),
84-
['atom', 15],
84+
15,
8585
'Multiparameter procedure declaration / application'
8686
)
8787

@@ -103,19 +103,19 @@ test('interpreter', async t => {
103103
['sqrt', 9],
104104
]
105105
),
106-
['atom', 3],
106+
3,
107107
'Procedure recursion'
108108
)
109109

110110
t.deepEqual(
111111
await evalAst(makeAPI({}))(['+', ['*', '1', '2', '3'], '2', ['/', '27', '3', '3']]),
112-
['atom', 11],
112+
11,
113113
'Mathematical operators'
114114
)
115115

116116
t.deepEqual(
117117
await evalAst(makeAPI({}))(['or', ['and', 'true', ['>', '3', '4']], 'false', ['<', '27', '3'], ['or', 'true', 'false', 'false']]),
118-
['atom', true],
118+
true,
119119
'Logical operators'
120120
)
121121

@@ -127,7 +127,7 @@ test('interpreter', async t => {
127127
['Math', 'a', ['Math', 'b']],
128128
]
129129
),
130-
['atom', 1],
130+
1,
131131
'Math operators with evaluated name'
132132
)
133133

@@ -137,7 +137,7 @@ test('interpreter', async t => {
137137
['Math', '.log', ['Math', '.E']],
138138
]
139139
),
140-
['atom', 1],
140+
1,
141141
'Math operators with known name'
142142
)
143143

@@ -153,7 +153,7 @@ test('interpreter', async t => {
153153
['+', 'x', 8],
154154
]
155155
),
156-
['atom', 20],
156+
20,
157157
'Process application / definition'
158158
)
159159

@@ -166,7 +166,7 @@ test('interpreter', async t => {
166166
['else', ['+', 12, 3]],
167167
]
168168
),
169-
['atom', 10],
169+
10,
170170
'Case analysis'
171171
)
172172

@@ -180,7 +180,7 @@ test('interpreter', async t => {
180180
['else', ['+', 12, 3]],
181181
]
182182
),
183-
['atom', 15],
183+
15,
184184
'Case analysis - else'
185185
)
186186

@@ -192,7 +192,7 @@ test('interpreter', async t => {
192192
['+', 12, 3],
193193
]
194194
),
195-
['atom', 10],
195+
10,
196196
'Conditional'
197197
)
198198

@@ -204,23 +204,23 @@ test('interpreter', async t => {
204204
['+', 12, 3],
205205
]
206206
),
207-
['atom', 15],
207+
15,
208208
'Conditional - else'
209209
)
210210

211211
t.deepEqual(
212212
await evalAst(makeAPI({}))(
213213
[['->', ['x', 'y'], ['+', 'x', 'y']], 23, 34],
214214
),
215-
['atom', 57],
215+
57,
216216
'Lambda definition and application'
217217
)
218218

219219
t.deepEqual(
220220
await evalAst(makeAPI({}))(
221221
[['->', 'param', ['+', 'param', '10']], 23],
222222
),
223-
['atom', 33],
223+
33,
224224
'Lambda definition and application (one parameter)'
225225
)
226226

@@ -234,7 +234,7 @@ test('interpreter', async t => {
234234
3
235235
],
236236
),
237-
['atom', 10],
237+
10,
238238
'Function composition operator'
239239
)
240240

@@ -248,7 +248,7 @@ test('interpreter', async t => {
248248
3
249249
],
250250
),
251-
['atom', 12],
251+
12,
252252
'Inverse function composition operator'
253253
)
254254

@@ -260,7 +260,7 @@ test('interpreter', async t => {
260260
'key3', '"value3"',
261261
],
262262
),
263-
['atom', { key1: 'value1', key2: 2, key3: 'value3' }],
263+
{ key1: 'value1', key2: 2, key3: 'value3' },
264264
'Key-Value (kv) constructor operator'
265265
)
266266

@@ -273,7 +273,7 @@ test('interpreter', async t => {
273273
'key4', ['cat', '"value"', ['+', '2', '2']],
274274
],
275275
),
276-
['atom', { key1: 'value1', key2: 2, key3: 3, key4: 'value4' }],
276+
{ key1: 'value1', key2: 2, key3: 3, key4: 'value4' },
277277
'Key-Value Object (kv) constructor operator with evaluated arguments'
278278
)
279279

@@ -287,7 +287,7 @@ test('interpreter', async t => {
287287
['-', '10', '5'],
288288
],
289289
),
290-
['atom', [1, 5, 3, 4, 5]],
290+
[1, 5, 3, 4, 5],
291291
'List (ls) constructor operator with evaluated arguments'
292292
)
293293

@@ -298,7 +298,7 @@ test('interpreter', async t => {
298298
'"key"', '"a"', '"b"',
299299
],
300300
),
301-
['atom', 12],
301+
12,
302302
'Get (get) general getter for objects and lists'
303303
)
304304

@@ -313,7 +313,7 @@ test('interpreter', async t => {
313313
['get', 'a', '"key"', '"a"', '"b"'],
314314
],
315315
),
316-
['atom', 21],
316+
21,
317317
'Set (set) general setter for objects and lists'
318318
)
319319

0 commit comments

Comments
 (0)