标签:
public interface AbstractExpression { void interpret( Context context ); }
再看看包含解释器之外的一些全局信息
public interface Context { } AbstractExpression的具体实现分两种:终结符表达式和非终结符表达式。 public class TerminalExpression implements AbstractExpression { public void interpret( Context context ) { } } 对于文法中没一条规则,非终结符表达式都必须的: 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 ) { } }
标签:
原文地址:http://www.cnblogs.com/Coda/p/4307893.html