Interpreter Definition:
Define the grammar of the language and create an interpreter to interpret the sentences in that language.
Interpreter seems to use the surface is not very wide, it describes how a language interpreter is constituted, in practical applications, we may rarely construct a language grammar. Let's just take a quick look:
The first thing to do is to create an interface to describe the common operation.
Public Interface void interpret (context context);
And look at some of the global information that contains the interpreter.
Public Interface Context {}
The specific implementation of abstractexpression is divided into two types: Terminator expressions and non-terminator expressions:
Public class Implements publicvoid interpret (context context) {}}
For no rule in grammar, non-terminator expressions are required:
public class nonterminalexpression Span style= "COLOR: #0000ff" >implements abstractexpression { private abstractexpression successor; public void Setsuccessor (Abstractexpression successor) { thi S . Successor = successor; public Abstractexpression Getsuccessor ( { return successor; public void interpret (context context) {}}
Transferred from: http://www.jdon.com Banqiao
Interpreter of design patterns (interpreter) (RPM)