preface.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Preface</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 background="theme/bkd.gif" text="#000000">
  9. <table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
  10. <tbody>
  11. <tr>
  12. <td width="21">
  13. <h1></h1>
  14. </td>
  15. <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Preface</font></b></font></td>
  16. <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" align="right" border="0" height="68" width="93"></a></td>
  17. </tr>
  18. </tbody>
  19. </table>
  20. <br>
  21. <table border="0">
  22. <tbody>
  23. <tr>
  24. <td width="10"></td>
  25. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  26. <td width="30"><img src="theme/l_arr_disabled.gif" border="0" height="19" width="20"></td>
  27. <td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td>
  28. </tr>
  29. </tbody>
  30. </table>
  31. <p>During the last time many new features have been developed as additions to the <tt>Spirit</tt>
  32. <a href="references.html#spirit">[4]</a> parser construction framework and we
  33. felt more and more, that it would be very helpful, to have a 'real world' example,
  34. which could be used as a sandbox for testing the usability of certain features.
  35. Additionally&nbsp;a recent discussion on the Boost mailing list showed the widespread
  36. interest of developers to have a modern, open source C++ preprocessor library
  37. to play with.&nbsp; So we had the idea to implement a C++ preprocessor to fit
  38. this needs&nbsp;-&nbsp;<tt>Wave</tt> was born.</p>
  39. <p align="justify">The <tt>Wave</tt> C++ preprocessor library uses the <a href="http://www.boost.org/">
  40. </a> <tt>Spirit<a href="references.html#spirit">[4]</a></tt> parser construction
  41. library to implement a C++ lexer with ISO/ANSI Standards conformant preprocessing
  42. capabilities. It exposes an iterator interface, which returns the current preprocessed
  43. token from the input stream. This preprocessed token is generated on the fly
  44. while iterating over the preprocessor iterator sequence (in the terminology
  45. of the STL these iterators are forward iterators). </p>
  46. <p align="justify"> The C++ preprocessor is a macro processor that under normal
  47. circumstances is used automatically by your C++ compiler to transform your program
  48. before actual compilation. It is called a macro processor because it allows
  49. to define macros, which are brief abbreviations for longer constructs. The
  50. C++ preprocessor provides four separate facilities that you can use as you see
  51. fit: </p>
  52. <blockquote>
  53. <p><b><img src="theme/bullet.gif" id="IMG1" height="13" width="13">&nbsp;</b>Inclusion
  54. of header files<br>
  55. <b><img src="theme/bullet.gif" id="IMG2" height="13" width="13">&nbsp;</b>Macro
  56. expansion<br>
  57. <b><img src="theme/bullet.gif" id="IMG3" height="13" width="13">&nbsp;</b>Conditional
  58. compilation<br>
  59. <b><img src="theme/bullet.gif" id="IMG4" height="13" width="13">&nbsp;</b>Line
  60. control</p>
  61. </blockquote>
  62. <p>These features are greatly underestimated today, even more, the preprocessor
  63. has been frowned on for so long that its usage just hasn't been effectively
  64. pushed until the Boost preprocessor library <a href="references.html#pp_lib">[7]</a>
  65. came into being a few years ago. Only today we begin to understand, that preprocessor
  66. generative metaprogramming combined with template metaprogramming in C++ is
  67. by far one of the most powerful compile-time reflection/metaprogramming facilities
  68. that any language has ever supported.</p>
  69. <p>The C++ Standard <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS%2FISO%2FIEC%2B14882%2D1998">[2] </a>
  70. was adopted back in 1998, but there is still no (known to me)
  71. commercial C++ compiler, which has a bugfree implementation of the
  72. rather simple preprocessor requirements mandated therein. This may be a
  73. result of the mentioned underestimation or even banning of the
  74. preprocessor from good programming style during the last few years or
  75. may stem from the somewhat awkward standardese dialect of English used
  76. to describe it. Two open source projects are exceptions of this: gcc
  77. and Clang (a subproject of LLVM), both providing preprocessors with
  78. very good standards conformance. </p>
  79. <p align="justify">So the main goals for the <tt>Wave</tt> project are:</p>
  80. <blockquote>
  81. <p><b><img src="theme/bullet.gif" id="IMG5" height="13" width="13">&nbsp;</b>full
  82. conformance with the C++ standard (ISO/IEC 14882:1998) <a href="references.html#iso_cpp">[1]</a>
  83. and with the C99 standard (INCITS/ISO/IEC 9899:1999) <a href="references.html#iso_c">[2]</a><br>
  84. <b><img src="theme/bullet.gif" height="13" width="13">&nbsp;</b>usage of <tt>Spirit<a href="references.html#spirit">[4]</a></tt>
  85. for the parsing parts of the game (certainly :-)<br>
  86. <b><img src="theme/bullet.gif" height="13" width="13">&nbsp;</b>maximal usage
  87. of STL and/or <tt>Boost</tt> libraries (for compactness and maintainability)<br>
  88. <b><img src="theme/bullet.gif" height="13" width="13">&nbsp;</b>straightforward
  89. extendability for the implementation of additional features<br>
  90. <b><img src="theme/bullet.gif" height="13" width="13">&nbsp;</b>building a
  91. flexible library for different C++ lexing and preprocessing needs</p>
  92. </blockquote>
  93. <p>At the first steps it is not planned to make a very high performance
  94. or very small C++ preprocessor. If you are looking for these objectives
  95. you probably have to look at other places. Although our C++
  96. preprocessor iterator works as expected and is usable as a reference
  97. implementation, for instance for testing of other preprocessor oriented
  98. libraries as the Boost Preprocessor library <a href="references.html#pp_lib">[7]</a> et.al. Nevertheless recent work has lead to surprising performance enhancements (if compared
  99. with earlier versions). Wave is still somewhat slower as for instance EDG
  100. based preprocessors (Intel, Comeau) on simple input files, however, as
  101. complexity increases, time dilates expontentially on EDG. Preprocessing time
  102. dilates linearly under Wave, which causes it to easily outperform EDG based
  103. preprocessors when complexity increases.</p>
  104. <p>As tests showed, the <tt>Wave</tt> library is very conformant to the C++ Standard,
  105. such that it compiles several strict conformant macro definitions, which are
  106. not even compilable with EDG based preprocessors (i.e. Comeau or Intel). </p>
  107. <table border="0">
  108. <tbody>
  109. <tr>
  110. <td width="10"></td>
  111. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  112. <td width="30"><img src="theme/l_arr_disabled.gif" border="0" height="19" width="20"></td>
  113. <td width="30"><a href="introduction.html"><img src="theme/r_arr.gif" border="0"></a></td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <hr size="1">
  118. <p class="copyright">Copyright &copy; 2003-2011 Hartmut Kaiser<br>
  119. <br>
  120. <font size="2">Distributed under the Boost Software License, Version
  121. 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  122. http://www.boost.org/LICENSE_1_0.txt) </font> </p>
  123. <span class="updated"></span>
  124. <p class="copyright"><span class="updated">Last updated:
  125. <!-- #BeginDate format:fcAm1m -->Sunday, January 9, 2011 16:17<!-- #EndDate -->
  126. </span></p>
  127. </body>
  128. </html>