1.Topics‎ > ‎Architecture‎ > ‎Patterns‎ > ‎a.Design Patterns‎ > ‎D.Behavioral Patterns‎ > ‎

Interpreter Pattern

  1. Summary 
    1. Used to implement grammars in language.
  2. How It Works
    1. Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
    2. Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design
    3. The implementation of the Interpreter pattern is just the use of the composite pattern applied to represent a grammar.
    4. The Interpreter defines the behavior while the composite defines only the structure.
  3. Overview Tutorials
    1. http://www.oodesign.com/command-pattern.html
  4. Uses and example
    1. The Interpreter pattern has a limited area where it can be applied. 
    2. We can discuss the Interpreter pattern only in terms of formal grammars but in this area there are better solutions and this is the reason why this pattern is not so frequently used.
    3. This pattern can be applied for parsing light expressions defined in simple grammars and sometimes in simple rule engines.