Powerful Interpreter

The PowerfulInterpreter pattern adds some power and reuse to http://wiki.cs.uiuc.edu/patternStories/InterpreterPattern.

There are two main improvements. First, it turns out that you can create new production rules as objects (instead of as classes). This means that in five programming statements you can define a language that has five grammar rules. Powerful!

The second improvement is the use of application-specific Stackers instead of visitors. Stackers are helpers that get plugged into production rules. When you write a production rule, you can hand it a Stacker that does whatever you want to have happen when the rule fires. For example, if you're parsing an HTML file, when you see some <BOLD> stuff, you can have a stacker set the text style to be bold.

[If you want more information on this Prolog interpreter, implemented in Java, go bug SteveMetsker. ;-> ]


I'd like more specifics on this pattern, as I am working on a hybrid involving Interpreter and a few other patterns. But so far I have been unable to get in touch with this author. Can anyone else offer some pointers? -DavidOtoole


EditText of this page (last edited October 15, 2004) or FindPage with title or text search