Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: auto-fix KidLisp source format by wrapping unparenthesized commands

+76
+23
oven/kidlisp-mini/bundle.mjs
··· 40 40 } 41 41 } 42 42 43 + // Fix KidLisp source format: wrap unparenthesized commands in parentheses 44 + function fixKidLispSourceFormat(source) { 45 + const lines = source.split('\n'); 46 + const fixed = lines.map(line => { 47 + line = line.trim(); 48 + if (!line) return ''; 49 + 50 + // Skip lines that already have parens or special prefixes 51 + if (line.startsWith('(') || line.startsWith('fade:')) { 52 + return line; 53 + } 54 + 55 + // Wrap atoms followed by other expressions in parens 56 + // This handles: "ink (? rainbow white 0) (1s... 24 64)" → "(ink (? rainbow white 0) (1s... 24 64))" 57 + return '(' + line + ')'; 58 + }); 59 + 60 + return fixed.join('\n'); 61 + } 62 + 43 63 async function bundleMini(source, seed = null) { 64 + // Fix source format: wrap unparenthesized commands in parentheses 65 + source = fixKidLispSourceFormat(source); 66 + 44 67 // Read all module files 45 68 const evalCode = await fs.readFile(path.join(__dirname, 'eval.mjs'), 'utf-8'); 46 69 const renderCode = await fs.readFile(path.join(__dirname, 'render.mjs'), 'utf-8');
+53
oven/test_fixed_source.mjs
··· 1 + // Test fixed source with explicit parentheses 2 + import { KidLispMini, parse } from './kidlisp-mini/eval.mjs'; 3 + 4 + const originalSource = `fade:red-blue-black-blue-red 5 + ink (? rainbow white 0) (1s... 24 64) 6 + line 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)) 10 + ink (? cyan yellow magenta) 8 11 + circle w/2 h/2 (? 2 4 8)`; 12 + 13 + const 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 + 23 + console.log('=== ORIGINAL SOURCE ==='); 24 + try { 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 + 39 + console.log('\n=== FIXED SOURCE ==='); 40 + try { 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 + }