introduction.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Introduction</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="theme/style.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body text="#000000" background="theme/bkd.gif">
  9. <table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
  10. <tr>
  11. <td width="21"> <h1></h1></td>
  12. <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Introduction</font></b></font></td>
  13. <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
  14. </tr>
  15. </table>
  16. <br>
  17. <table border="0">
  18. <tr>
  19. <td width="10"></td>
  20. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  21. <td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  22. <td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
  23. </tr>
  24. </table>
  25. <P dir="ltr">The <tt>Wave</tt> C++ preprocessor library is a Standards conformant
  26. implementation of the mandated C99/C++ preprocessor functionality packed behind
  27. a simple to use interface, which integrates well with the well known idioms
  28. of the Standard Template Library (STL).</P>
  29. <P dir="ltr">The <tt>Wave</tt> C++ preprocessor is not a monolithic application,
  30. it's rather a modular library, which exposes mainly a context object and an
  31. iterator interface. The context object helps to configure the actual preprocessing
  32. process (as search path's, predefined macros, etc.). The exposed iterators are
  33. generated by this context object too. Iterating over the sequence defined by
  34. the two iterators will return the preprocessed tokens, which are built
  35. on the fly from the given input stream. </P>
  36. <P dir="ltr"> The C++ preprocessor iterator itself is fed by a C++ lexer iterator,
  37. which implements an abstract interface. The C++ lexers packaged with the
  38. <tt>Wave</tt> library may be used standalone, too, and are not tied to the C++
  39. preprocessor iterator at all. </P>
  40. <P dir="ltr">To make the C++ preprocessing library modular, the C++ lexer is held
  41. completely separate and independent from the preprocessor. To prove this concept,
  42. two different, but functionally identical C++ lexers were
  43. 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,
  44. so that the C++ preprocessor iterator may be used with all of them. The abstraction
  45. of the lexer from the preprocessor iterator library was done to allow
  46. plugging in different lexers without the need to reimplement the preprocessor.
  47. This will allow for benchmarking and specific fine tuning of the process of preprocessing
  48. itself.</P>
  49. <P dir="ltr">The first of these C++ lexers is implemented with the help of the
  50. well known <tt>Re2C</tt> <a href="references.html#re2c">[3]</a> tool, which generates
  51. C code from given regular expressions. The lexers generated with <tt>Re2C</tt>
  52. are known to be very fast, because they are not table driven but directly code the token building logic
  53. (very similar to hand coded lexers).
  54. </P>
  55. <P dir="ltr">The second of these C++ lexers is built around a table driven lexer,
  56. where the DFA tables (discrete finite automaton tables) are generated from regular expressions with the help of
  57. a Spirit-based lexer generating framework named <tt>Slex</tt> <a href="references.html#slex">[5]</a>.
  58. The <tt>Slex</tt> is fed during runtime with the token definitions (regular
  59. expressions) and generates the resulting DFA table. This table is used to combine
  60. the input characters into corresponding lexemes (tokens). The generated DFA table
  61. can be saved to disk to avoid the generation process at program startup.</P>
  62. <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
  63. preprocessing, but allows to use Wave for all of the IDL derivatives. </P>
  64. <P dir="ltr">It is possible to build other C++ lexers if needed. Currently there
  65. are plans to adapt the <tt>Spirit</tt> C++ lexer example <tt>cpplexer</tt> <a href="references.html#cpplexer">[6]</a>,
  66. which is completely based on static <tt>Spirit<a href="references.html#spirit">[4]</a></tt>
  67. grammars.</P>
  68. <P dir="ltr">Both of the included lexers and the library itself are able
  69. to act in a C99 compliant mode. In this mode the lexers reject C++-only tokens
  70. (<tt>'::'</tt>, <tt>'-&gt;*'</tt>, <tt>'.*'</tt> and the alternate keywords
  71. such as <tt>'and'</tt>, etc.). The preprocessor additionally handles placemarkers
  72. (empty macro arguments) and variadics (macros with variable parameter counts).
  73. As an extension to the C++ Standard, the library can be enabled to handle placemarkers
  74. and variadics in C++ mode too.</P>
  75. <table border="0">
  76. <tr>
  77. <td width="10"></td>
  78. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  79. <td width="30"><a href="preface.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
  80. <td width="30"><a href="quickstart.html"><img src="theme/r_arr.gif" border="0"></a></td>
  81. </tr>
  82. </table>
  83. <hr size="1">
  84. <p class="copyright">Copyright &copy; 2003-2011 Hartmut Kaiser<br>
  85. <br>
  86. <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>
  87. <span class="updated"></span>
  88. <p class="copyright"><span class="updated">Last updated:
  89. <!-- #BeginDate format:fcAm1m -->Sunday, December 2, 2007 19:03<!-- #EndDate -->
  90. </span> </p>
  91. </body>
  92. </html>