Mini Lox Interpreter

RustInterpreterCompilersClap

Mini Lox Interpreter

A small, educational Lox interpreter implemented in Rust. It contains a lexer, a parser, and a tiny runtime, built for learning and experimentation with language implementation.

Overview

The project is structured as both a binary CLI and a library crate (mini_lox_interpreter), so the lexer and parser can be reused from other Rust programs rather than being locked inside the executable.

CLI Subcommands

The binary exposes three subcommands via Clap:

  • tokenize <filename> — run the lexer over a file and print tokens (or lexer errors)
  • parse <filename> — parse a single expression and print its representation (or parse errors)
  • run <filename> — parse the whole input and print the resulting value, acting as a minimal program runner

Structure

  • src/lex.rs — lexer / tokenizer
  • src/parse.rs — parser for Lox expressions and statements
  • src/lib.rs — library exports and core types
  • src/main.rs — CLI entrypoint

Tech Stack

  • Language: Rust (edition targeting 1.80+)
  • CLI: Clap

Build

cargo build --release