Accompanying the framework are a couple of test programs that follow up what we have started. There are a some sample and test programs that demonstrate the use and capabilities of the Spirit framework.
calc1.cpp A simple calculator (expression parser only) test (note) calc2.cpp A simple working calculator calc3.cpp Compiler to byte-code and interpreted by a virtual machine calc4.cpp Calculator with variables (using the symbol table) char_actions.cpp Extracting characters demo char_param.cpp Character parametric parser demo chset.cpp Character sets demo (note) calc_debug.cpp The calculator in debugging mode exception_test.cpp Exceptions demo iter_param.cpp Iteration parametric parser demo micro.cpp Numeric parser demo numeric_actions.cpp Numeric semantic actions demo string_extract.cpp Extracting strings demo string_param.cpp String parametric parser demo symbols.cpp Symbol table demo and test Pascal
sg_pascal.cpp A Pascal parser Pascal test files Pascal programs (some have explicit syntax errors) C
c_grammar.cpp An ANSI C parser C test files C programs XML
simplexml.cpp A simple XML parser test (note) filexml.cpp XML parser demonstrating the multi_pass iterator xml.cpp A full Unicode capable XML parser XML test files Various (good) XML test files regres1.cpp For stress testing the framework (note) note: these test files include a corresponding *.txt output file. The outputs of the compiled program may be checked against these to ensure that the framework is working as expected.
The framework itself is small, comprising only header files. There are no external libraries to link to. The <spirit.hpp> file is the master header file that includes all the necessary headers in the framework. The framework does not rely on any code or library except the standard C++ libraries.
The complete package including the framework, documentation and sample files is available for free download from http://spirit.sourceforge.net/. Spirit is continually being developed. The latest source code and documentation can be found in this site. There is also a mailing list for those who want to ask questions, report bugs, contribute to the project or simply communicate with other Spirit users on parsing or C++ related topics.
There are a couple of new innovations introduced in the Spirit framework worth looking into. The modeling of parsers as hierarchical composite objects coupled with the notion of composition of simple objects to create more complex objects as applied to parsers is one of the first of its kind. Another innovation is the application of template meta-programming techniques, expression templates in particular, to parsing. The abundance of oparators such as parser intersection &, difference -, and xor ^ proves to be quite powerful. Now, we have seen in this version of Spirit the power of dynamic parsing. This is a powerful concept that opens up unique solutions to otherwise difficult parsing problems.
So far we have just scratched the surface of what we can do with the Spirit parser compiler. The framework is continually evolving as more experience is gained and more research is done. We shall see more dynamic parsers. We shall also see more deterministic static parsers. There are still avenues to explore that ultimately lead towards this new frontier. I invite you now to trek this exciting journey with me. We will push C++ to its limits. Have fun!