How binxly/monkey-interpreter works
Main Components
• Entry Point (main.go) – This is where the interpreter is launched.
• REPL (repl/repl.go) – Acts as the interactive command-line interface where users input Monkey code.
• Lexer (lexer/lexer.go & lexer/lexer_test.go) – Responsible for tokenizing the input string into a sequence of tokens.
• Token Definitions (token/token.go) – Contains the Token structure and constants used by the lexer.
• Parser (parser/parser.go & parser/parser_test.go) – Converts tokens into an Abstract Syntax Tree (AST) structure.
• AST (ast/ast.go & ast/ast_test.go) – Represents the syntactic structure of Monkey code, forming the basis for evaluation.
Relationships and Data Flow
• User inputs code into the REPL.
• The REPL directs this input to the Lexer.
• The Lexer processes the input and emits tokens, using the definitions in token/token.go.
• These tokens are passed to the Parser to construct an AST.
• The AST (as defined in ast/ast.go) is then used for interpretation and evaluation.
• The evaluated result is presented back to the user via the REPL.
• The main.go file ties these components together, initializing the REPL and bootstrapping the interpreter's workflow.
Additional Guidance
• Since this is an interpreter project based on concepts from “Writing an Interpreter in Go”, you might note that iterative development (e.g., adding language features like if statements, grouped expressions, function literals) is a key design consideration, though not all may be fully implemented yet.