How andrealaforgia/magic-lisp works
MagicLisp is a Rust implementation of a Scheme-family Lisp, exposed as a single CLI. Its principal workflow is source input → reading → compilation to bytecode → VM execution and output; the CLI also supports saving/loading bytecode, disassembly, and an interactive REPL. The VM uses runtime values for language data and execution. The README documents closures, macros, tail calls, cycle-safe cleanup, and rich data types, but the excerpts do not expose their internal wiring, so those capabilities are represented within the compiler/VM rather than as speculative components.
Main entry points: cli.rs CLI dispatch · repl.rs Interactive REPL · bytecode.rs Bytecode format · compiler.rs Compiler
Components 10
User interfaces
- CLI dispatch
src/cli.rs - Interactive REPL
src/repl.rs - Exit codes
src/exitcode.rs
Language processing
- Source reader
src/reader.rs - Compiler
src/compiler.rs
Execution runtime
- Virtual machine
src/vm.rs - Runtime values
src/value.rs
Bytecode tools
- Bytecode format
src/bytecode.rs - Disassembler
src/disasm.rs
Other components
- Programmer
Connections 18
- Programmer → CLI dispatch: selects command
README.md - CLI dispatch → Source reader: reads source
src/cli.rs - CLI dispatch → Compiler: compiles source
src/cli.rs - Compiler → Source reader: consumes forms
src/compiler.rs - Compiler → Bytecode format: emits instructions
src/compiler.rs - CLI dispatch → Virtual machine: runs program
src/cli.rs - Virtual machine → Bytecode format: executes instructions
src/vm.rs - Virtual machine → Runtime values: manipulates values
src/vm.rs - CLI dispatch → Bytecode format: encodes artifact
src/cli.rs - CLI dispatch → Bytecode format: decodes artifact
src/cli.rs - CLI dispatch → Disassembler: disassembles artifact
src/cli.rs - Disassembler → Bytecode format: inspects instructions
src/disasm.rs - Programmer → Interactive REPL: enters session
README.md - CLI dispatch → Interactive REPL: starts REPL
src/cli.rs - Interactive REPL → Source reader: reads entries
src/repl.rs - Interactive REPL → Compiler: compiles entries
src/repl.rs - Interactive REPL → Virtual machine: executes entries
src/repl.rs - CLI dispatch → Exit codes: reports status
src/cli.rs