What is the Interpreter design pattern?

Answer

The Interpreter pattern defines a grammar for a language and provides an interpreter to process sentences in that language. Each grammar rule is represented as a class, and parsing a sentence means building a composite expression tree and calling interpret() on it. Classic examples include: regular expression engines, SQL query parsers, mathematical expression evaluators, and template engines. While conceptually important, it is rarely implemented from scratch today because parser-generator tools (ANTLR, Lark, PEG) are far more practical for real languages. The Interpreter pattern is most appropriate for simple, domain-specific languages with a small grammar.