Skip to content

gbubemismith/interpreter-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpreter-rs

A Rust implementation of the interpreter described in the book Crafting Interpreters by Bob Nystrom.

This project aims to follow the book's structure and philosophy, building a Lox(using the .smith extension for source files) interpreter in Rust. It is a learning project, focusing on clarity, idiomatic Rust, and testability.

Features

  • Lexical analysis (scanner) with support for single-line and block comments, string and number literals, identifiers, and keywords.
  • Tokenization and error reporting.
  • Modular code structure for easy extension as more chapters are implemented.
  • Unit tests for core components.

Usage

Prerequisites

  • Rust (latest stable recommended). Install from rustup.rs.

Running the Interpreter

Currently, the main focus is on the scanner (lexer). You can run the tests to see the scanner in action:

cd interpreter-rs
cargo test

To run the interpreter (when implemented):

cargo run -- path/to/source.smith

Testing

Unit tests are included for the scanner and tokenization logic. Run all tests with:

cargo test

Progress

  • Scanner (lexer)
  • Parser
  • Interpreter
  • REPL
  • Error handling improvements

References

Contributing

This project is primarily for educational purposes, but contributions and suggestions are welcome! If you see a better or more idiomatic way to implement something, suggestions are especially encouraged.


Happy interpreting!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages