// debug-interpreter.js - Debug the interpreter JS bridge setup import { createLexer } from './src/core/lexer.js'; import { createParser } from './src/core/parser.js'; import { createInterpreter } from './src/core/interpreter.js'; const code = ` result : io.callJS "Math.abs" [-5]; `; const lexer = createLexer(code); const tokens = lexer.allTokens(); const parser = createParser(tokens); const ast = parser.parse(); const host = { jsBridgeConfig: { allowedFunctions: new Set([ 'JSON.parse', 'JSON.stringify', 'Math.abs', 'Math.floor', 'Math.ceil', 'Math.round', 'Math.min', 'Math.max', 'Math.random', 'console.log', 'console.warn', 'console.error', 'Date.now', 'performance.now' ]) }, io: { out: (...args) => console.log('[OUT]', ...args), debug: (...args) => console.log('[DEBUG]', ...args) } }; console.log('Host config:', host.jsBridgeConfig); const interpreter = createInterpreter(ast, host); console.log('Interpreter created'); // Let's see if we can access the bridge console.log('Interpreter scope has io?', interpreter.scope.has('io')); const ioObj = interpreter.scope.get('io'); console.log('IO object:', ioObj); console.log('IO properties:', Array.from(ioObj.properties.keys())); interpreter.interpret(); const result = interpreter.scope.get('result'); console.log('Final result:', result);