Interpreter Pattern
Summary
Used to implement grammars in language.
How It Works
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design
The implementation of the Interpreter pattern is just the use of the composite pattern applied to represent a grammar.
The Interpreter defines the behavior while the composite defines only the structure.
Overview Tutorials
Uses and example
The Interpreter pattern has a limited area where it can be applied.
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.
This pattern can be applied for parsing light expressions defined in simple grammars and sometimes in simple rule engines.