Compiler & VM
LANGUAGE / VIRTUAL MACHINE
Luna Compiler & Gravity VM
From source text to a language of its own. A compiler and sandboxed VM in C++.

THE IDEA
Luna follows a program all the way from characters to execution. A handwritten scanner and parser build an arena-allocated syntax tree, then a bytecode compiler hands the result to Gravity VM.
HOW IT WORKS
- 01Scan source text
- 02Parse expressions
- 03Allocate the syntax tree
- 04Emit bytecode
- 05Execute in Gravity VM
INSIDE THE BUILD
A zero-copy scanner reads source without allocating a string for every token.
A Pratt parser resolves operator precedence in expressions.
Arena allocation groups syntax nodes into a shared lifetime.
A stack-based VM executes bytecode with instruction limits.
Owning the whole toolchain makes memory, dispatch and language design decisions visible.
THE TRADE-OFFS
The documented implementation does not yet provide lexical closures or a C foreign-function interface. Dispatch and value representation leave room for further optimisation.
BUILT WITH
- C++20
- CMake
- Ninja
- Clang