The context is initialized and the Interpret method is invoked. Each Interpret operation maintains the context to make sure that the following Interpret operations only have the remaining context. Consequences Simple grammars are easy to change and extend. All rules are represented by distinct classes in an orderly, segmented manner. Adding another rule means adding another class.
Complex grammars are difficult to implement and maintain.
The more interdependent the rules the more interdependent the classes. The first step in implementing the Interpreter design pattern is the expression of language rules. These rules will each be expressed, one per class. Those that involve Alternations, Repetitions or Sequences are expressed as Nonterminal Expresssions. Those rules that are literal translations are expressed as Terminal Expressions.