Skip to content
/ rlox Public

A Rust implementation of an interpreter for the Lox language.

Notifications You must be signed in to change notification settings

jtfmumm/rlox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rlox

A Rust implementation of an interpreter for the Lox language.

Overview

Lox is a language designed by Bob Nystrom for his entertaining book Crafting Interpreters.

This Rust-based Lox interpreter is currently a simple tree-walking interpreter. If for some strange reason you work at a Lox shop, don't use this interpreter in production!

Implemented

Tree-walking interpreter

  • scanning/lexing
  • parsing
  • evaluating
  • statements
  • control flow
  • functions
  • scope resolution
  • classes
  • inheritance

Future: implement the much faster bytecode version.

Usage

Clone and change to rlox directory:

git clone https://github.com/jtfmumm/rlox
cd rlox

Build:

cargo build --release

Enter the repl:

target/release/rlox

Run a Lox file:

target/release/rlox examples/guessing_game.lox

Tests

I've included Bob Nystrom's Lox interpreter test suite.

To run, you need to have Dart v2.12. On MacOS you can install with:

brew install dart@2.12

Then install deps with:

cd lox-test-suite/tool
dart pub get
cd -

Then run the test suite (up to the point I've implemented):

make test

About

A Rust implementation of an interpreter for the Lox language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages