Apologies for the raw HTML in the previous message.
Here is the readable version:
---
Hi everyone,
For the past year, I have been working on The Tiny Lua Compiler, an educational project that implements Lua 5.1 entirely in Lua. It features a fully functioning lexer, parser, code generator, and virtual machine, all contained in a single file of roughly 4000 lines of heavily commented code.
https://github.com/bytexenon/The-Tiny-Lua-Compiler
The motivation came from studying the official C implementation. While efficient, I found it difficult for a beginner to fully grasp. I wanted to build a "clean room" implementation that prioritizes readability over performance, essentially treating the code as executable documentation.
To that end, the project has zero dependencies; I avoided LPeg to ensure it runs on a stock interpreter. It is also fully self-hosting: the compiler can compile its own source code and execute the result within its own VM.
There are a few intentional omissions, most notably the `CLOSE` instruction (and by extension, full upvalue closing semantics on scope exit). I decided that the added complexity in the Code Generator outweighed the educational value for this specific project.
I am specifically looking for feedback on simplification. My goal is to keep the project as small and approachable as possible. If you see areas where the implementation could be made cleaner without sacrificing readability, I would love to hear your thoughts.
-Daniel