February 12, 2008 at 10:33 PM
Couple of weeks ago, I needed to parse a set of XML files. As always, my first thought was to search the web for free XML parsers. But then I remembered that I found a solution in the past: Xerces XML parser. Even though, xerces was originally written in Java, there is an excellent port to c/c++. Xerces was developed by Apachi Software Foundation, and it supports wide range of compilers. To use it with Visual Studio 2005 C++ compiler, following steps are required:
- Download compiler in binary form from here;
- Unpack into any folder; This step will create subfolders include and lib;
- Add path include and lib folders to VC++ directories;
- To statically link to a project, link with xerces-c_static_2.lib or (xerces-c_static_2D.lib for debug version);
- Set to ignore libcmt.lib
Steps 4 and 5 are shown in the screen shot below:
May 8, 2007 at 5:43 PM
The compiler design is a well researched area of computer science. Typically, compiler designers use a parser generator framework like YACC or PCCTS to construct lexer, scanner, parser, and abstract syntax tree. With the arrival of expression templates and template meta-programming, it is possible to construct a parser by simply using the template meta-programming technique. The Spirit library is object-oriented recursive-decent parser implemented in C++ using expression templates and meta-programming. In Spirit the parser is constructed during the compile time using a combination of primitive parsers and fusing them through template meta-programming. TinyPascal is a practical application of Spirit framework.
March 25, 2007 at 5:31 PM
According to one of expression templates inventors, Todd Veldhuizen, expression templates are “new C++ technique for passing expressions as functions arguments” . The purpose of expression template is to inline expressions during compilation, which produces faster and arguably more readable code. Most of expression template articles focus on numeric array classes and operations on those using expression template techniques. For instance, expression templates could be utilized for matrix multiplication without using temporaries. For such article and code examples, please refer to articles referenced under  and .
As probably suspected, this article will not focus on expression templates as applied on numeric array classes. In this article, the focus will be on parsing and language recognition using expression template techniques. Furthermore the article will focus on Spirit library , a parser framework implemented completely using expression templates and template meta-programming. At this point the reader is encouraged to refer to introductory part of Spirit documentation as found here http://www.boost.org/libs/spirit/doc/introduction.html.
In addition it is important to note that this article will not focus on all parts of Spirit framework. This article is rather attempt to explain fundamentals behind expression templates as applied in Spirit framework.