Wave 1.0

The Wave C++ preprocessor library is a Standards conformant implementation of the mandated C99/C++ preprocessor functionality packed behind a simple to use interface, which integrates well with the well known idioms of the Standard Template Library (STL).

The Wave C++ preprocessor is not a monolitic application, it's rather a modular library, which exposes mainly a context object and an iterator interface. The context object helps to configure the actual preprocessing process (as search path's, predefined macros, etc.). The exposed iterators are generated by this context object too. Iterating over the sequence defined by the two iterators will return the preprocessed tokens, which are to be built on the fly from the given input stream.

The C++ preprocessor iterator itself is fed by a C++ lexer iterator, which implements an abstract interface. The C++ lexers packaged with the Wave library may be used standalone, too, and are not tied to the C++ preprocessor iterator at all.

To make the C++ preprocessing library modular, the C++ lexer is held completely separate and independent from the preprocessor. To prove this concept, there are two different, but functionally identical C++ lexers were implemented. Additionally there is implemented a IDL lexer, which allows to use the preprocessor library as the lexing component of a IDL oriented tool. All these lexers implement the mentioned abstract interface, so that the C++ preprocessor iterator may be used with all of them. The abstraction of the lexer from the preprocessor iterator library was done to allow to plugging in different lexers without the need to reimplement the preprocessor. This will allow for benchmarking and specific fine tuning of the process of preprocessing itself.

Wave may be used for preprocessing IDL files too, since the token set needed for the IDL language is very similar to the C++ token set. That's the reason, why the Wave preprocessor library contains also an IDL lexer. Naturally, the IDL lexer recognizes a different set of tokens, so it does not recognize any keywords (except true and false, which are needed by the preprocessor itself). This is needed because there exist different IDL language flavours, where identifiers of one flavour may be keywords of others - certainly this implies postponing keyword identification after the preprocessing, but it allows to use Wave for all of the IDL derivatives.

It is possible to build other C++ lexers if needed. Currently there are plans to adapt the Spirit C++ lexer example cpplexer, which is completely based on static Spirit grammars.

Both of the included C++ lexers and the library itself are able to act in a C99 compliant mode. In this mode the lexers reject C++-only tokens ('::', '->*', '.*' and the alternate keywords such as 'and', etc.). The preprocessor additionally handles placemarkers (empty macro arguments) and variadics (macros with variable parameter counts). As an extension to the C++ Standard the library can be enabled to handle placemarkers and variadics in C++ mode too.

If you want to get acquainted with Wave, please consider looking at :

To successfully build Wave you will still need to install at least the Boost 1.30.2 release (download here) and the program_options library from Vladimir Prus (download here).