Conclusion
Grammar is set to become a key element of computing. The technology for implementing grammars is very well established—such technology is a standard part of compilers and more recently AOP toolkits. One compelling reason for gaining more insight into grammars is the fact that simple grammars can be used to great effect in IT management. Just as nature tends to favor simplicity, grammars can provide for very powerful emergent behavior in IT systems. This underlines the move away from technology-based solutions toward business facilitation.
In this article, we’ve discussed how to create a simple grammar that can be extended with relative ease. While the grammar developed here was simple, it can be combined with complex back-end logic (as in the rule processor of Figure 1) to achieve very powerful features.
The interpreter pattern can be incorporated into your programming efforts effectively with a small investment in time. The source code for this article consists of eight C++ header files and eight accompanying C++ implementation files. To build this code and try it for yourself, just create a Visual C++ console project, drop the files in, switch off precompiled headers, and you’re all set!