rulox 0.7.2

A lightweight scripting language embedded in Rust.
Documentation

rulox

crates.io github docs.rs

rulox is a lightweight scripting language embedded in Rust. It is based on the Lox language from Crafting Interpreters.

Examples

use rulox::*;

fn main() {
    lox! {
        var a = 5;

        print a + 2;
    }

    let b: f64 = a.try_into().unwrap();

    println!("{}", b);
}
use rulox::*;

fn main() {
    lox! {
        for (var i = 5; i > 0; i = i - 1) print i;
    }
}
use rulox::*;

fn main() {
    lox! {
        fun hello(name) {
            print "Hello " + name + "! :)"
        }

        fun add_one(num) {
            return num + 1;
        }
    }

    hello(LoxValue::from("Alice"));

    assert_eq!(add_one(LoxValue::from(3)), LoxValue::from(4));
}
use rulox::*;

fn main() {
    lox! {
        var people = ["Bob", "Alice", "John"];

        for (person in people) {
            print "Hello " + person + "!";
        }
    }
}

Features

  • Variable declarations
  • Print statements
  • Control flow statements
  • Loops
  • for ... in ... loops
  • Indefinite loops and break
  • Functions as first-class objects

Possible future features

  • Closures
  • Object orientation
  • Macros