YannAhlgrim d8691cf178 details
2026-07-12 16:21:32 +02:00
2026-05-07 10:22:48 +02:00
2026-05-07 10:22:48 +02:00
2026-05-07 10:22:48 +02:00
2026-07-12 16:21:32 +02:00

rust-interpreter

This repository follows the book Writing an Interpreter in Go and implements the code in Rust.

Writing an Interpreter in Go

Run

cargo run

Architecture

The interpreter is built in three main stages:

  1. Lexer — tokenizes the input source code.
  2. Pratt parser — builds an AST from the tokens.
  3. Evaluator — walks the AST and executes the program.

Additional tests are in evaluator/tests.rs.

Features

  • Integers, strings, booleans
  • Arrays and hashes with index access
  • let bindings, return statements, and if/else expressions
  • First-class functions and closures

Project structure

Module Purpose
lexer Tokenizes source input
parser Pratt parser that produces an AST
ast AST node definitions
object Runtime values and environment
evaluator Tree-walking evaluator
repl Interactive REPL

Tests

cargo test
S
Description
This repository follows the book Writing an Interpreter in Go and implements the code in Rust.
Readme 82 KiB
Languages
Rust 100%