Start by clarifying the language features and then outline a classic pipeline: tokenizer, parser (to AST), and interpreter. Emphasize modular design, error handling, and testing, and be ready to discuss trade-offs between AST interpretation and direct evaluation.
Pro tip: Mention that you would use a recursive descent parser for simplicity and extendability, and that you'd write unit tests for each component to ensure correctness.
Ask about the specific syntax and semantics: what arithmetic operators, control flow constructs (if/while), variable scoping, and print format are expected. Confirm whether the language is statically or dynamically typed.
Propose a modular pipeline: tokenizer -> parser -> AST -> interpreter. Discuss whether to evaluate directly from the AST or compile to bytecode, and justify your choice based on simplicity and performance.
Describe tokenizing with regular expressions or a hand-written lexer. For parsing, suggest recursive descent or Pratt parsing for expressions, and explain how to handle operator precedence and associativity.
Explain how to traverse the AST, maintain an environment (symbol table) for variables, and execute control flow using conditional jumps or recursive evaluation. Mention handling runtime errors like undefined variables.
Outline a testing strategy: unit tests for each component, integration tests with sample programs, and edge cases (e.g., division by zero, nested loops). Discuss how to extend the language later.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.