How bfierz/lox-rs works
Project type and purpose
• This repository is a command-line tool (“loxrun”) written in Rust that interprets Lox scripts. It follows the structure of a language interpreter: source code scanner (lexer), parser (AST builder), and an interpreter that walks the AST.
• The primary purpose is to provide a runnable Lox interpreter (see examples/*.lox) and to demonstrate Rust development using DevContainers and CI.
File structure
• Top-level configuration:
• .devcontainer/, .vscode/: Development environment (VS Code DevContainer)
• .github/workflows/verify.yml: CI job for building/testing
• scripts/post_setup.sh: Container setup steps
• Core application (“loxrun” folder):
• Cargo.toml/Cargo.lock: Rust project metadata and dependencies
• src/main.rs: CLI entrypoint
• src/scanner.rs: Tokenizes Lox source
• src/parser.rs: Builds AST of expressions/statements
• src/expression.rs & src/stmt.rs: AST node definitions
• src/tokens.rs: Token type definitions
• src/interpreter.rs: AST walker that executes code
• src/printer.rs: (Optional) AST pretty-printer
• src/callable.rs: Function/callable abstractions
• Examples directory: sample .lox scripts to test/run
• verification/: patch files for testing language conformance
README for additional insights
• README focuses on providing a Rust DevContainer setup; it does not describe system architecture, so we infer architecture purely from the file layout and naming.
• Central pipeline:
[Examples (input)] → [Scanner] → [Parser] → [AST Nodes] → [Interpreter] → [Console Output]
Optionally branch from AST Nodes → [Printer] for debugging
• Development/config (blue)
• CI (green)
• Runtime pipeline (orange)
• Build system (gray)
Final advice
• Be detailed: include every module as a separate component in the pipeline.