The Interpreter works best when the grammar is simple. Structure Participants AbstractExpression declares an abstract interpreter operation that is common to all nodes in the abstract syntax tree. TerminalExpression implements an Interpret operation associated with terminal symbols in the grammar. R n in the grammar. Interpret typically calls itself recursively on the variables representing R 1 through R n .
Context contains information that's global to the interpreter.
Code generation We have input the default values in the following form. Users can change any values in their application-specific names for the participants in the pattern. Implementing the grammar is easy, too. Complex grammars are hard to maintain. Adding new ways to interpret expressions.