Skip to content
/ cloxpp Public

Lox bytecode VM written in C++ - Based on Part III of Bob Nystrom's Book "Crafting Interpreters"

License

Notifications You must be signed in to change notification settings

hashemi/cloxpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. Chunks of Bytecode.
  2. A Virtual Machine.
  3. Scanning on Demand.
  4. Compiling Expressions.
  5. Types of Values.
  6. Strings.
  7. Hash Tables. (no code, using std containers)
  8. Globals Variables.
  9. Local Variables.
  10. Jumping Back and Forth.
  11. Calls and Functions.
  12. Closures.
  13. Garbage Collection. (not implemented, using shared_ptr instead for ref counting)
  14. Classes and Instances.
  15. Methods and Initializers.
  16. 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

About

Lox bytecode VM written in C++ - Based on Part III of Bob Nystrom's Book "Crafting Interpreters"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published