123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Introduction</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link href="theme/style.css" rel="stylesheet" type="text/css">
- </head>
- <body text="#000000" background="theme/bkd.gif">
- <table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
- <tr>
- <td width="21"> <h1></h1></td>
- <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Introduction</font></b></font></td>
- <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
- </tr>
- </table>
- <br>
- <table border="0">
- <tr>
- <td width="10"></td>
- <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
- <td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
- <td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
- </tr>
- </table>
- <P dir="ltr">The <tt>Wave</tt> 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).</P>
- <P dir="ltr">The <tt>Wave</tt> C++ preprocessor is not a monolithic 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 built
- on the fly from the given input stream. </P>
- <P dir="ltr"> The C++ preprocessor iterator itself is fed by a C++ lexer iterator,
- which implements an abstract interface. The C++ lexers packaged with the
- <tt>Wave</tt> library may be used standalone, too, and are not tied to the C++
- preprocessor iterator at all. </P>
- <P dir="ltr">To make the C++ preprocessing library modular, the C++ lexer is held
- completely separate and independent from the preprocessor. To prove this concept,
- 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
- 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.</P>
- <P dir="ltr">The first of these C++ lexers is implemented with the help of the
- well known <tt>Re2C</tt> <a href="references.html#re2c">[3]</a> tool, which generates
- C code from given regular expressions. The lexers generated with <tt>Re2C</tt>
- are known to be very fast, because they are not table driven but directly code the token building logic
- (very similar to hand coded lexers).
- </P>
- <P dir="ltr">The second of these C++ lexers is built around a table driven lexer,
- where the DFA tables (discrete finite automaton tables) are generated from regular expressions with the help of
- a Spirit-based lexer generating framework named <tt>Slex</tt> <a href="references.html#slex">[5]</a>.
- The <tt>Slex</tt> is fed during runtime with the token definitions (regular
- expressions) and generates the resulting DFA table. This table is used to combine
- the input characters into corresponding lexemes (tokens). The generated DFA table
- can be saved to disk to avoid the generation process at program startup.</P>
- <P dir="ltr">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 <tt>Wave</tt> preprocessor library contains also an IDL lexer. The IDL lexer is also based on the <tt>Re2C</tt> tool, but recognizes a different set of tokens. So this lexer does not recognize any keywords (except <tt>true</tt> and <tt>false</tt>, 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 - Ok, this requires postponement of keyword identification until after the
- preprocessing, but allows to use Wave for all of the IDL derivatives. </P>
- <P dir="ltr">It is possible to build other C++ lexers if needed. Currently there
- are plans to adapt the <tt>Spirit</tt> C++ lexer example <tt>cpplexer</tt> <a href="references.html#cpplexer">[6]</a>,
- which is completely based on static <tt>Spirit<a href="references.html#spirit">[4]</a></tt>
- grammars.</P>
- <P dir="ltr">Both of the included lexers and the library itself are able
- to act in a C99 compliant mode. In this mode the lexers reject C++-only tokens
- (<tt>'::'</tt>, <tt>'->*'</tt>, <tt>'.*'</tt> and the alternate keywords
- such as <tt>'and'</tt>, 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.</P>
- <table border="0">
- <tr>
- <td width="10"></td>
- <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
- <td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
- <td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
- </tr>
- </table>
- <hr size="1">
- <p class="copyright">Copyright © 2003-2011 Hartmut Kaiser<br>
- <br>
- <font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
- <span class="updated"></span>
- <p class="copyright"><span class="updated">Last updated:
- <!-- #BeginDate format:fcAm1m -->Sunday, December 2, 2007 19:03<!-- #EndDate -->
- </span> </p>
- </body>
- </html>
|