Extend a Rule Parser with New Operators Safely

Quick Overview

Review and extend an AI-assisted rule parser using clear grammar, AST, operator semantics, validation, backward compatibility, and independently specified tests.

Extend a Rule Parser with New Operators Safely

Company: Stripe

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

A rule parser has been implemented with AI assistance. How would you review the generated code and extend it to support a new operator without scattering special cases throughout parsing and evaluation? ### Constraints & Assumptions The source does not provide the grammar or existing operators. Describe the boundaries and extension mechanism, and identify the language-specific details that must be established before writing the new operator. ### Clarifying Questions to Ask - Does the operator introduce new syntax, precedence, arity, or operand types? - Are rules parsed into an AST before evaluation? - What error behavior and backward compatibility are required? ```hint Separate syntax from meaning Recognizing an operator token and executing its behavior need not be implemented in the same place. ``` ### What a Strong Answer Covers - Inspecting the generated parser's actual grammar, AST, and evaluation path. - Central operator metadata and type/arity validation where appropriate. - Tests for precedence, malformed inputs, old rules, and new semantics. ### Follow-up Questions - When is adding a registry entry insufficient because grammar changes are required? - How would you prevent untrusted rules from executing arbitrary host-language code?

Overview: Review and extend an AI-assisted rule parser using clear grammar, AST, operator semantics, validation, backward compatibility, and independently specified tests.

Read the full Stripe Software Engineer interview experience this question came from

Stripe logo
Stripe
Nov 3, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

A rule parser has been implemented with AI assistance. How would you review the generated code and extend it to support a new operator without scattering special cases throughout parsing and evaluation?

Constraints & Assumptions

The source does not provide the grammar or existing operators. Describe the boundaries and extension mechanism, and identify the language-specific details that must be established before writing the new operator.

Clarifying Questions to Ask Guidance

  • Does the operator introduce new syntax, precedence, arity, or operand types?
  • Are rules parsed into an AST before evaluation?
  • What error behavior and backward compatibility are required?

What a Strong Answer Covers Guidance

  • Inspecting the generated parser's actual grammar, AST, and evaluation path.
  • Central operator metadata and type/arity validation where appropriate.
  • Tests for precedence, malformed inputs, old rules, and new semantics.

Follow-up Questions Guidance

  • When is adding a registry entry insufficient because grammar changes are required?
  • How would you prevent untrusted rules from executing arbitrary host-language code?