Design Patterns Interpreter Pattern - Design Patterns

What is Design Pattern Interpreter Pattern?

Interpreter pattern provides a way to evaluate language grammar or expression. This type of pattern comes below behavioural pattern. This pattern involves implementing an expression interface which tells to understand an exacting context. This pattern is used in SQL parsing, symbol giving out device etc.


We are going to produce an interface Expression and concrete classes implementing the Expression interface. A class Terminal Expression is define which acts as a main interpreter of context in question. Other classes Or Expression, And Expression are used to make combinational language.

InterpreterPatternDemo, our demo class, will use Expression class to create rules and display parsing of terms.

Step 1

Create an expression interface.

Step 2

Create concrete classes implementing the above interface.

Step 3

InterpreterPatternDemo uses Expression class to produce rules and then parse them.

Step 4

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics