Skip to content

calebkoy/cplox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cplox

A scripting language built in C++

What is this?

cplox is a C++17 port of Bob Nystrom's programming language Lox, from the book Crafting Interpreters.

The aim of this project is to learn how programming languages are built from the ground up.

How does it work?

cplox consists of a handwritten compiler and virtual machine. The compiler compiles Lox source code to bytecode and the virtual machine interprets the bytecode instructions in order to run the Lox program.

To build the interpreter, you'll need make. Once you have that set up, run:

$ make cplox

This will copy the built interpreter into the root of the repository. You can run the (single-line command) REPL with this command:

$ ./cplox

And you can run a program with this command:

$ ./cplox [program-name].lox

To run the tests, you'll need Dart. Once you've installed it, run the following command to get the dependencies:

$ make get

If you develop on a non-Windows OS, you might need to change the command in the Makefile to use pub instead of pub.bat.

Run this command to compile a debug build of cplox and run all tests against it:

$ make test

How can I contribute?

Contributions are welcome! To contribute to Lox, see the repo. To contribute to cplox, please follow the process below:

  • Create a personal fork of this GitHub repo.
  • In your fork, create a branch off the master branch.
  • Make your changes on your branch, keeping the following in mind:
    • Follow the current coding style.
    • Include tests when adding a new feature.
  • Build the repo with your changes, and ensure that all tests pass.
  • Commit your changes to your branch.
  • Create a pull request (PR) against the repo's master branch:
    • Add a title that summarises the changes.
    • In the description, list the main changes.
  • Wait for feedback or approval of your changes.
  • When your changes have been approved, the PR will be merged.

License

The project is licensed under the MIT license.