This was a follow-up to whatever part one was, so I came in mid-flow.
Clarify the exact syntax and semantics of the IN clause (e.g., IN (value1, value2) or IN subquery) and discuss how it fits into the existing parser architecture. Then outline a step-by-step plan to extend the lexer, parser, and AST, emphasizing testing and edge cases.
Pro tip: Mention that you would first check if the existing parser uses a recursive descent or Pratt approach, as that determines how easily you can add IN as a postfix operator. Also, proactively discuss handling empty IN lists and NULL semantics, which shows depth.
Ask the interviewer to confirm the exact IN syntax (e.g., IN (1,2,3) vs IN subquery) and whether it can appear in WHERE, SELECT, or both. This avoids building the wrong feature.
Explain how the current parser is structured (lexer, parser, AST) and identify where IN fits—likely as a postfix operator after an expression. Discuss whether to extend the grammar or add a new node type.
Describe how to parse the IN keyword, followed by a parenthesized list of expressions or a subquery. Handle comma-separated values and ensure proper precedence relative to other operators.
Add an InExpression node to the AST that holds the left expression and a list of right expressions (or subquery). Explain how it would be evaluated (e.g., checking membership) and any optimizations.
Outline tests for valid and invalid syntax, empty lists, nested IN, and interaction with other clauses. Mention error handling for missing parentheses or trailing commas.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.