commit 18

This commit is contained in:
HarakaraSite
2026-02-15 18:30:04 +09:00
parent 836086b358
commit 5ea13dad80
19 changed files with 875 additions and 33 deletions

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env node
/**
* Basic syntax fixer for Strudel code.
* - Replaces ~ with -
* - Ensures setcps exists (adds default if missing)
* - Basic track control check
*/
const fs = require('fs');
function fixStrudelCode(code) {
let fixed = code;
// 1. Replace ~ with -
fixed = fixed.replace(/~/g, '-');
// 2. Ensure setcps exists at the beginning
if (!fixed.includes('setcps')) {
fixed = `setcps(120/60/4)
${fixed}`;
}
// 3. Simple warning/fix for track control (just a heuristic)
if (!fixed.includes('$:') && fixed.includes('s(')) {
// If it's a single line starting with s(, add $:
fixed = fixed.replace(/^s\(/gm, '$: s(');
}
return fixed;
}
// Read from stdin or file
const input = process.argv[2] ? fs.readFileSync(process.argv[2], 'utf8') : '';
if (input) {
process.stdout.write(fixStrudelCode(input));
} else {
// If no input, just exit
process.exit(0);
}