This project follows Bob Nystrom's excellent book, Crafting Interpreters which takes you through the process of writing an interpreter for a language called Lox. The interpreter is ported from the original C interprter to C++.
The interpreter is now fully implemented in terms of functionality. It implements code from the following chapters of section III of the book:
- Chunks of Bytecode.
- A Virtual Machine.
- Scanning on Demand.
- Compiling Expressions.
- Types of Values.
- Strings.
- Hash Tables. (no code, using
std
containers) - Globals Variables.
- Local Variables.
- Jumping Back and Forth.
- Calls and Functions.
- Closures.
- Garbage Collection. (not implemented, using
shared_ptr
instead for ref counting) - Classes and Instances.
- Methods and Initializers.
- Superclasses.
Next I'll be working on refactoring the code and improving its performance.
The test suite is from the reference C implementation. To run the tests:
dart tool/bin/test.dart clox --interpreter build/Release/cloxpp
The command specifies build/Release/cloxpp
as the binary, which is where it ends up after running xcodebuild
from the command line.
For the test suite to run, you need to have the Dart programming language SDK installed. After that, you need to get the test runners dependencies by going to the tool
directory and running:
pub get
My goal in this project is to become more proficient in C++.
MIT