This is the whole round, not just one question.
Start by clarifying the language's grammar and semantics, then implement a clean pipeline: tokenizer, parser (e.g., recursive descent), and evaluator with an environment for variables. Keep the design modular and extensible so you can quickly add features like new operators or control flow when the interviewer asks.
Pro tip: Before coding, write down a few example programs and their expected outputs to validate your implementation and catch edge cases early. Also, mention that you'll use a symbol table (environment) to handle variable scoping and assignments.
Ask the interviewer about the exact syntax and semantics: what operators, data types, and statements are needed? Confirm whether variables are dynamically typed and how print works.
Outline the components: tokenizer, parser (AST), evaluator, and environment. Choose a parsing strategy (e.g., recursive descent) and decide on error handling.
Write a tokenizer that converts source into tokens, then a parser that builds an AST. Start with assignments, arithmetic, and print, ensuring correct operator precedence.
Traverse the AST to evaluate expressions and execute statements, using an environment to store variable values. Handle errors like undefined variables.
When the interviewer adds features (e.g., if statements, loops), extend the tokenizer, parser, and evaluator accordingly. Test with sample programs and edge cases.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.