Interpreter definition: Define the textual method of the language and establish an interpreter to explain the sentence in the 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-based law. We still come to a simple understanding:
First create a interface, used to describe a common operation.
Public interface AbstractExpression {void interpret (context context);
Take a look at some global information other than the interpreter.
Public interface context {}
Part of ABSTRACTEXPRESSION is divided into two types: end conforming operations and non-ending operations:
Public Class TerminalExpression Implements AbstractExpression {Public Void Interpret (CONTEXT CONTEXT) {}
For not a grammar rule nonterminal expressions are necessary: public class NonterminalExpression implements AbstractExpression {private AbstractExpression successor; public void setSuccessor (AbstractExpression successor) {this.successor = successor;} public AbstractExpression getSuccessor () {return successor; } Public void interpret (context context) {}}