Computers are supposed to interpret sentences or evaluate expressions. If we have to write a sequence of code that is supposed to deal with such a requirement, first of all, we need to know the structure; we need to have an internal representation of the expression or the sentence. In many situations, the most appropriate structure to use is a composite one based on the composite pattern. We will further discuss the composite pattern in Chapter 4, Structural Patterns, for now, we can think of composite representation as grouping objects of a similar nature together.
The interpreter pattern
Intent
The interpreter pattern defines the representation of the grammar along with the interpretation.