A toy Python interpreter written in C++26.
- Ensure you have CMake 3.20+ and a C++26 supporting compiler.
- Enable
helper.sh. - Do
./helper.sh helpfor usage info. Use./helper.sh build debug-build <your build tool>to create the binary.
This is based off typical compiler stages:
- Lexer: Tokenizes Python source code.
- Parser: Builds an AST via recursive descent with Pratt's parsing
- Bytecode Compiler: Compiles the AST into bytecode with constant/name pooling, scope-aware variable access, and jump patching
- Stack-Based VM: Executes bytecode with a global/local variable env with its own stack and instruction pointer.
- Basic variable store/load, comparisons, arithmetic.
- print??

Special thanks to DrkWithT for helping refactor the match and consume functions in the Parser namespace to use metaprogramming, eliminating verbose consume(T) || consume(T) chains for larger conditionals.
- VM Refactor 1
- New stack representation supporting arbitrary peeking (presized vector with SP, BP)
- Stack of call frames for recursion support
- Get Fibonacci working as microbenchmark 1
- Support nested functions
- For loops
- Ternary expressions?
- Support lists
- Support dictionaries