Home

Awesome

cloxrs

An interpreter for Lox. Written in Rust. It follows the 3rd part of the book, and is similar in structure to clox. It also replaces some parts of clox by leveraging Rust's features.

It is a fully-featured Lox VM, and all features are implemented, however it's about 4-7x slower (depending on the benchmark) than clox due to different design decisions as well as a few limitations of Rust's memory model.

Notable user-facing differences to clox

Additional native functions

Implementation differences

Build/Run

As of 2021-03-11, cloxrs requires a nightly version of Rust due to use of const_mut_refs and const_fn_fn_ptr_basics features (they might be stablized by the time you read this). If you use rustup, rustup default nightly will automatically install the newest nightly version.

# Build release, output in ./target/release/cloxrs
cargo build --release

# Run as REPL
./target/release/cloxrs 

# Execute $file
./target/release/cloxrs $file

Code style

Follow the style used by rustfmt.