Skip to content

Add WASM compilation and web TUI REPL for slox interpreter#1

Merged
yabalaban merged 43 commits intomainfrom
claude/slox-wasm-web-tui-IkvrU
Jan 6, 2026
Merged

Add WASM compilation and web TUI REPL for slox interpreter#1
yabalaban merged 43 commits intomainfrom
claude/slox-wasm-web-tui-IkvrU

Conversation

@yabalaban
Copy link
Copy Markdown
Owner

  • Restructure project with SloxCore library for shared interpreter code
  • Add slox-wasm target for WebAssembly compilation using SwiftWasm
  • Create web frontend with xterm.js for terminal-style REPL
  • Add GitHub Actions workflow for automatic deployment to GitHub Pages
  • Make interpreter output configurable for WASM environment
  • Update native functions to be WASM-compatible (clock, print)

claude added 7 commits January 5, 2026 23:23
- Restructure project with SloxCore library for shared interpreter code
- Add slox-wasm target for WebAssembly compilation using SwiftWasm
- Create web frontend with xterm.js for terminal-style REPL
- Add GitHub Actions workflow for automatic deployment to GitHub Pages
- Make interpreter output configurable for WASM environment
- Update native functions to be WASM-compatible (clock, print)
- Add .nojekyll to prevent Jekyll processing
- Update workflow to use carton for SwiftWasm builds
- Fix WASI and JavaScriptKit runtime URLs in app.js
- Use SwiftWasm 5.9.2 release (verified working URL)
- Use carton 1.1.3 release
- Add debug output to workflow steps
- Fix tar strip-components for SwiftWasm extraction
Change from esm.sh to unpkg.com CDN which provides direct ES module access
for the WASI shim and JavaScriptKit Swift runtime dependencies.
Instead of relying on CDN imports which were failing, bundle custom
implementations of:
- wasi-loader.js: Browser WASI shim for SwiftWasm
- swift-runtime.js: JavaScriptKit Swift runtime for browser

This avoids dependency on external CDNs and ensures compatibility.
claude added 2 commits January 6, 2026 00:59
…llback

The JavaScript callback passed to initInterpreter is a function, which maps
to JSFunction in JavaScriptKit, not JSObject. Using args[0].object returned
nil causing the guard to fail or force unwrap to crash.

Also store JSClosures globally to prevent garbage collection.
- Add Driver.runRepl() that returns evaluation result
- Add Interpreter.interpretRepl() to capture last expression value
- Update WASM execute to use runRepl and output the result
- Add tests for REPL-style evaluation

Now every REPL input shows its result (nil for declarations/statements)
- Add getGlobals() and reset() methods to Driver
- Expose new methods via WASM to JavaScript
- Handle % prefixed commands in app.js
- Update help/manpage with magic commands section
- Add tests for magic command support methods
- Add getBuildTime() to WASM API, show in startup message
- Remove all debug console.log statements
- Add multiline input support (Python REPL style):
  - Continuation prompt "..." for incomplete input
  - Detects unclosed braces, parens, strings
- Add cursor navigation:
  - Left/Right arrows move by character
  - Ctrl+Left/Right move by word
  - Home/End jump to start/end of line
  - Ctrl+A/E for start/end (readline style)
  - Ctrl+W deletes word backward
  - Delete key support
- Update help page with new keybindings
- Add comprehensive CLAUDE.md project guide for AI assistants
- Add inline comments and JSDoc documentation to app.js
- Add MARK sections and documentation to Swift files
- Improve code organization with section headers
@yabalaban yabalaban merged commit 2299b3a into main Jan 6, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants