GLaDOS is a tiny Lisp environment written in Haskell: a front-end that parses and compiles Lisp programs and a bytecode virtual machine that runs them. The project started as a student exercise and grew into a complete toolchain capable of handling real-world Lisp snippets.
- A readable compiler pipeline (parser → macros → desugaring → SSA-like lowering → bytecode)
- A stack-based VM with tail-call optimisation, closures, and a small standard library
- Ready-to-run examples plus a Jenkins-backed functional regression suite
- Haskell sources that can be hacked on with
stackor the providedMakefile
# Build the executable (uses stack under the hood)
make
# Run a Lisp file
./glados examples/factorial_test.lisp
# Peek at the generated bytecode
./glados --disasm examples/factorial_test.lisp
# Dump raw bytecode instructions
./glados --bytecode examples/factorial_test.lisp
# Run the Haskell unit tests locally
stack testThe resulting binary reads a .lisp file, compiles it to bytecode, loads the builtins from src/Builtins.hs, and executes the program on the VM. Functional tests now run automatically in Jenkins after every push.
docs/README.md— map of the documentation setdocs/ARCHITECTURE.md— how the compiler and VM are structureddocs/LANGUAGE_GUIDE.md— how to write programs for our Lisp dialectdocs/INSTRUCTIONS.md— bytecode and runtime referencedocs/DEVELOPMENT.md— build, test, and debugging workflows
.
├── app/ Main CLI wiring
├── docs/ Project documentation
├── examples/ Sample Lisp programs
├── scripts/ Helper scripts used by tooling
├── src/ Compiler, runtime, and builtins
├── test/ Haskell unit tests
└── Makefile Shortcuts around stack
Key sources worth opening:
src/Compiler.hs— orchestration of all compilation passessrc/CodeGen.hs— lowers ANF into bytecode instructionssrc/VM.hs— the execution loop and call-stack managementsrc/Builtins.hs— implementation of primitives like+,format,read-line
- Tail-call optimisation is enabled by default (
cfgTCO = True) - Jenkins runs the full functional regression suite on every branch; check the latest build before merging
- Known limitations and TODOs are tracked in
CHANGELOG.md
This repository is released under the MIT licence (see LICENSE).