How hkey0/lox-interpreter works
Project type and purpose
• This is a small compiler-style project: a Lox language interpreter written in Rust.
• It reads a “.lox” script, lexes it into tokens, builds an AST from the grammar, and then executes (interprets) it.
File structure
• Top-level:
• Cargo.toml – Rust dependencies/metadata
• first_program.lox – sample Lox source file
• src/
– scanner.rs – the lexer module
– generate_ast.rs – code that defines AST node types and visitor interfaces
– main.rs – orchestrates the pipeline (reads input, calls scanner, parser/interpreter)
• No external services or databases—this is a pure in-process compiler/interpreter.
README
• Usage is simply “cargo run -- first_program.lox,” confirming it’s a command-line compiler/interpreter.
Detail
• Break out subcomponents if needed (e.g., separate lexical rules vs. token buffer in Scanner).
• That generate_ast.rs actually generates AST node definitions and the visitor interface.
• Central role of main.rs as the orchestrator that ties modules together.