about summary refs log tree commit diff stats
path: root/js/baba-yaga/web/editor/debug-modules.html
diff options
context:
space:
mode:
Diffstat (limited to 'js/baba-yaga/web/editor/debug-modules.html')
-rw-r--r--js/baba-yaga/web/editor/debug-modules.html107
1 files changed, 107 insertions, 0 deletions
diff --git a/js/baba-yaga/web/editor/debug-modules.html b/js/baba-yaga/web/editor/debug-modules.html
new file mode 100644
index 0000000..549b984
--- /dev/null
+++ b/js/baba-yaga/web/editor/debug-modules.html
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Module Loading Debug</title>
+</head>
+<body>
+    <h1>Module Loading Debug</h1>
+    
+    <div id="status">Loading...</div>
+    
+    <div id="results"></div>
+    
+    <!-- Baba Yaga Language Components -->
+    <script src="../../lexer.js" type="module"></script>
+    <script src="../../parser.js" type="module"></script>
+    <script src="../../interpreter.js" type="module"></script>
+    
+    <script type="module">
+        const statusDiv = document.getElementById('status');
+        const resultsDiv = document.getElementById('results');
+        
+        function log(message, type = 'info') {
+            const color = type === 'error' ? 'red' : type === 'success' ? 'green' : 'black';
+            resultsDiv.innerHTML += `<p style="color: ${color}">${message}</p>`;
+        }
+        
+        async function debugModules() {
+            try {
+                statusDiv.textContent = 'Checking module loading...';
+                
+                // Wait a bit for modules to load
+                await new Promise(resolve => setTimeout(resolve, 100));
+                
+                log('=== Module Loading Debug ===');
+                
+                // Check global scope
+                log('Global scope check:');
+                log(`- window.createLexer: ${typeof window.createLexer}`);
+                log(`- window.createParser: ${typeof window.createParser}`);
+                log(`- window.createInterpreter: ${typeof window.createInterpreter}`);
+                
+                // Check if functions are available
+                log('Function availability check:');
+                log(`- createLexer: ${typeof createLexer}`);
+                log(`- createParser: ${typeof createParser}`);
+                log(`- createInterpreter: ${typeof createInterpreter}`);
+                
+                if (typeof createLexer === 'undefined') {
+                    log('❌ createLexer is not defined', 'error');
+                } else {
+                    log('✅ createLexer is available', 'success');
+                }
+                
+                if (typeof createParser === 'undefined') {
+                    log('❌ createParser is not defined', 'error');
+                } else {
+                    log('✅ createParser is available', 'success');
+                }
+                
+                if (typeof createInterpreter === 'undefined') {
+                    log('❌ createInterpreter is not defined', 'error');
+                } else {
+                    log('✅ createInterpreter is available', 'success');
+                }
+                
+                // Try to use them if available
+                if (typeof createLexer !== 'undefined' && typeof createParser !== 'undefined') {
+                    log('Testing basic functionality...');
+                    
+                    try {
+                        const testCode = 'add : x y -> x + y;';
+                        const lexer = createLexer(testCode);
+                        const tokens = lexer.allTokens();
+                        log(`✅ Lexer test passed: ${tokens.length} tokens`);
+                        
+                        const parser = createParser(tokens);
+                        const ast = parser.parse();
+                        log(`✅ Parser test passed: AST type = ${ast.type}`);
+                        
+                        statusDiv.textContent = 'All tests passed! 🎉';
+                        statusDiv.style.color = 'green';
+                        
+                    } catch (error) {
+                        log(`❌ Functionality test failed: ${error.message}`, 'error');
+                        statusDiv.textContent = 'Tests failed! ❌';
+                        statusDiv.style.color = 'red';
+                    }
+                } else {
+                    log('❌ Cannot test functionality - modules not loaded', 'error');
+                    statusDiv.textContent = 'Modules not loaded! ❌';
+                    statusDiv.style.color = 'red';
+                }
+                
+            } catch (error) {
+                log(`❌ Debug failed: ${error.message}`, 'error');
+                statusDiv.textContent = 'Debug failed! ❌';
+                statusDiv.style.color = 'red';
+            }
+        }
+        
+        // Run debug when page loads
+        document.addEventListener('DOMContentLoaded', debugModules);
+    </script>
+</body>
+</html>