Skip to content

"Build Your Own Interpreter" Challenge on CodeCrafters in Rust

Notifications You must be signed in to change notification settings

snufkinwa/rustinterpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Interpreter Project - Codecrafters Challenge

This project is a Rust-based interpreter for the "Build Your Own Interpreter" Challenge from Codecrafters, following the structure and concepts presented in the book Crafting Interpreters by Robert Nystrom.

Overview

In this challenge, the goal is to build an interpreter for the Lox language, a simple scripting language. The project helps solidify core concepts of interpreters, including tokenization, abstract syntax trees (ASTs), and tree-walk interpreters.

Key Components

  • Tokenization: Handles the process of breaking down input strings into meaningful symbols (tokens) used by the interpreter.
  • Parsing: Constructs an Abstract Syntax Tree (AST) from the tokens, forming the structure of the code for interpretation.
  • AST Printer: Outputs the structure of parsed expressions for debugging and testing.
  • Tree-Walk Interpreter (Coming Soon): Future work will include a tree-walk interpreter that directly interprets the Abstract Syntax Tree (AST) and executes the code.

How to Run

  1. Install dependencies: This project uses Rust. Ensure that you have Rust installed by following the instructions here.

  2. Tokenize a Lox file: To tokenize your input Lox code:

   ./your_program.sh tokenize tests/test.lox
  1. Parse a Lox file: To parse your input Lox code and generate the AST:
  ./your_program.sh parse tests/test.lox

Development

This project is organized into several core modules:

  • token: Responsible for handling the different types of tokens in Lox.
  • parser: Builds the Abstract Syntax Tree (AST) from tokens.
  • ast_printer: A utility for visualizing the AST.

Future Work

  • A tree-walk interpreter will be added, allowing direct interpretation and execution of the AST.
  • Support for functions, classes, and additional language features may be implemented to extend the Lox interpreter.

References

Crafting Interpreters

Lox Language

The Rust Reference

Progress

You can track my progress on the Codecrafters platform here.

About

"Build Your Own Interpreter" Challenge on CodeCrafters in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published