Monorepo for Aesthetic.Computer
aesthetic.computer
1// Test fixed source with explicit parentheses
2import { KidLispMini, parse } from './kidlisp-mini/eval.mjs';
3
4const originalSource = `fade:red-blue-black-blue-red
5ink (? rainbow white 0) (1s... 24 64)
6line w/2 0 w/2 h
7(spin (2s... -1.125 1.125)) (zoom 1.1)
8(0.5s (contrast 1.05))
9(scroll (? -0.1 0 0.1) (? -0.1 0 0.1))
10ink (? cyan yellow magenta) 8
11circle w/2 h/2 (? 2 4 8)`;
12
13const fixedSource = `fade:red-blue-black-blue-red
14(ink (? rainbow white 0) (1s... 24 64))
15(line w/2 0 w/2 h)
16(spin (2s... -1.125 1.125))
17(zoom 1.1)
18(0.5s (contrast 1.05))
19(scroll (? -0.1 0 0.1) (? -0.1 0 0.1))
20(ink (? cyan yellow magenta) 8)
21(circle w/2 h/2 (? 2 4 8))`;
22
23console.log('=== ORIGINAL SOURCE ===');
24try {
25 const ast1 = parse(originalSource);
26 console.log('AST length:', ast1.length);
27 console.log('Top-level items (first 5):');
28 ast1.slice(0, 5).forEach((item, i) => {
29 if (Array.isArray(item)) {
30 console.log(` [${i}]: [${item[0]} ...]`);
31 } else {
32 console.log(` [${i}]: ${typeof item === 'object' ? JSON.stringify(item) : item}`);
33 }
34 });
35} catch (e) {
36 console.error('Parse error:', e.message);
37}
38
39console.log('\n=== FIXED SOURCE ===');
40try {
41 const ast2 = parse(fixedSource);
42 console.log('AST length:', ast2.length);
43 console.log('Top-level items (first 5):');
44 ast2.slice(0, 5).forEach((item, i) => {
45 if (Array.isArray(item)) {
46 console.log(` [${i}]: [${item[0]} ...]`);
47 } else {
48 console.log(` [${i}]: ${typeof item === 'object' ? JSON.stringify(item) : item}`);
49 }
50 });
51} catch (e) {
52 console.error('Parse error:', e.message);
53}