Skip to content

Releases: WenzeJin/rlox

rlox completed version v1.0.0

31 May 09:35
Compare
Choose a tag to compare

rlox is a Rust implementation of the Lox programming language, as described in the book Crafting Interpreters. It includes a REPL (Read-Eval-Print Loop) and the ability to execute Lox scripts.

Features v1.0.0

  • A fully functional Lox interpreter written in Rust.
    • Basic expressions and statements
    • Control flows
    • Functions and closure (HOF)
    • Classes and objects
    • BuiltIn functions
  • Support for both interactive REPL and script execution.
  • Implements the Lox language as described in Crafting Interpreters, ported from jlox.
  • Easy to build, run, and test using cargo.

Build & run

git clone https://github.com/WenzeJin/rlox.git
cd rlox
cargo build --release
cargo run [script]

A example lox program:

class Animal {
  init(name) {
    this.name = name;
  }

  speak() {
    print this.name + " makes a sound";
  }
}

class Dog < Animal {
  speak() {
    super.speak();
    print this.name + " barks";
  }
}

var d = Dog("Rex");
d.speak();