How jawad-ch/go-interpreter works
Project type and purpose
• This is a small programming-language implementation written in Go (from Thorsten Ball’s “Writing an Interpreter in Go”).
• It provides both an AST-based interpreter (evaluator) and a compiler that emits bytecode for a stack-based VM, along with a REPL and benchmarks.
File structure
• Top-level Go modules and directories:
• token, lexer, parser – the front-end: tokenization → parsing → AST
• ast – the abstract syntax tree definitions
• evaluator – direct AST interpreter (walks AST, produces objects)
• compiler – bytecode emitter (symbol_table, code)
• vm – virtual machine (frame, stack, instruction execution)
• object – runtime objects and built-in definitions
• repl – interactive shell tying everything together
• benchmark – performance harness
• Config: go.mod
• Main entrypoint: main.go (invokes either REPL or compiles/runs files)
README for additional insights
• The README simply attributes the source to Thorsten Ball; no extra architecture notes
• However, the code layout signals a classic compiler pipeline with an alternate interpreter path
Detail everything without overthinking
• Break each module into as many subcomponents as helpful (e.g., symbol_table vs code in compiler)
• Notable functions (e.g., NextToken in lexer; ParseProgram in parser; Emit in compiler; Run in VM)
• If space permits, add small notes about test coverage for each module