Architectural Styles - Interpreter

The interpreter pattern is a design pattern that specifies how to evaluate sentences in a language. The basic idea is to have a class for each symbol (terminal or nonterminal) in a specialized computer language. The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence.


Uses for the Interpreter pattern


  1. Specialized database query languages such as SQL.
  2. Specialized computer languages which are often used to describe communication protocols.
  3. Most general-purpose computer languages actually incorporate several specialized languages.
Figure: Example for an interpreter pattern