This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Implement compiler for custom language states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
##### Question
Design and implement a compiler/interpreter for a simple bespoke programming language in your preferred language. Describe your object-oriented design, the compilation pipeline, and how you would detect and fix bugs.
Quick Answer: This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Implement compiler for custom language states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Design and implement a simple compiler/interpreter
Goal
Design and implement a small compiler/interpreter for a bespoke toy language in your preferred programming language. Explain:
Your object-oriented design (key classes and their responsibilities).
The compilation pipeline (from source to execution and/or code generation).
How you would systematically detect and fix bugs.
Assumptions and scope (you may adapt as needed)
Target language: a small, expression-oriented language (call it MiniLang) with integers, booleans, variables, arithmetic, comparisons, if/else, while, let bindings, functions, and print.
Implementation language: your choice (example below uses Python, but any OO language is fine).
MiniLang sketch
Types: int, bool.
Statements: let, assignment, print, if/else, while, block, function def, return.