Interpreter pattern
和它相关的pattern:
wikipedia Interpreter pattern:
The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence for a client.[1]:243 See also Composite pattern.
因为formal language是典型的符合 containing关系的,因此它是可以可以使用tree structure的;
其实它更多的是和 composite pattern 相关,通过Iterator pattern,可以为 tree structure添加多种algorithm/behavior。
三地址码,其实非常类似于一个command;
wikipedia Interpreter pattern
In computer programming, the interpreter pattern is a design pattern that specifies how to evaluate sentences in a language. The basic idea is to have a class for each symbol (terminal or nonterminal) in a specialized computer language. The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence for a client.[1]:243 See also Composite pattern.