This is a personal C++ implementation of the Lox interpreter ( from the book "Crafting Interpreters" [ Java ] ). It has C-like syntax and regular programming-language features like variables with dynamic types, control flow constructs like conditionals, loops and functions.
Writing a simple recursive fibonacci function in Lox++ REPL mode.
loxpp.demo.2.mp4
In addition to the core functionalities, Lox++ brings the following capabilities
- Multiline nested comments
- String and number concatenation
- Break statement to exit loops prematurely
Instead of employing templates (STL) which introduced too much complexity that I was still not familiar with yet, I used void pointers and additional variables to store and keep track of values and their types to perform typecasting as needed to access values. Perhaps not the optimal approach in hindsight.
- RAII (smart pointers)
- Structured bindings
- Classes are not yet implemented. Support for it is planned but not anytime soon.
- Only 'false' and 'nil' are considered falsy in Lox, Lox++ also considers the number 0 and empty string as falsy values.
Go to Releases, download the executable and run it if you'd like to give Lox++ a go.
- Ensure you have a compiler for C++17.
- Clone the repository or download the source code.
- Run make clean then make.
- Run the executable in build/bin
Path to a file as an argument will execute it in Lox++, otherwise no arguments will start REPL mode.
- Implement classes (sometime in the future).
- Functions that don't create or delete ptrs should accept regular ptrs instead of unique or shared.
- Resolution and binding