Cloxpp
Lox bytecode VM written in C++ - Based on Part III of Bob Nystrom's Book "Crafting Interpreters"
Install / Use
/learn @hashemi/CloxppREADME
cloxpp
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++.
Progress
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
stdcontainers) - Globals Variables.
- Local Variables.
- Jumping Back and Forth.
- Calls and Functions.
- Closures.
- Garbage Collection. (not implemented, using
shared_ptrinstead for ref counting) - Classes and Instances.
- Methods and Initializers.
- Superclasses.
Next I'll be working on refactoring the code and improving its performance.
Tests
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
Goals & Design
My goal in this project is to become more proficient in C++.
License
MIT
Related Skills
node-connect
339.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
